1. Nested Multiline Comment
- Posted by eumini Jul 02, 2009
- 1109 views
- Last edited Jul 03, 2009
Dear Developers,
The new multi-line commenting feature has proven to be quite useful. I have a question as to how it was designed to behave when nested.
I recently did something like the following (basically from a C header file) expecting the whole thing to be ignored, but EU complains about the last item which is right after a nested c-type comment. I could put a "" before the nested comment (infact this happens to be one of those I forgot to treat that way), but wondered if this is possibly a bug or as intended.
Thanks.
'Debo
/* enum --gretl_opt_flags OPT_NONE = 0, OPT_A = 1 << 0, OPT_B = 1 << 1, OPT_C = 1 << 2, OPT_D = 1 << 3, OPT_E = 1 << 4, OPT_F = 1 << 5, OPT_G = 1 << 6, OPT_H = 1 << 7, OPT_I = 1 << 8, OPT_J = 1 << 9, OPT_K = 1 << 10, OPT_L = 1 << 11, OPT_M = 1 << 12, OPT_N = 1 << 13, OPT_O = 1 << 14, OPT_P = 1 << 15, OPT_Q = 1 << 16, OPT_R = 1 << 17, OPT_S = 1 << 18, OPT_T = 1 << 19, OPT_U = 1 << 20, OPT_V = 1 << 21, OPT_W = 1 << 22, OPT_X = 1 << 23, OPT_Z = 1 << 24, OPT_Y = 1 << 25, /* added 2009-03-15 */ OPT_UNSET = 1 << 30 */
2. Re: Nested Multiline Comment
- Posted by eumini Jul 02, 2009
- 1102 views
- Last edited Jul 03, 2009
I could put a "" before the nested comment (infact this happens to be one of those I forgot to treat that way), but wondered if this is possibly a bug or as intended. ACTUALLY THIS DID NOT WORK EITHER
JUST IN CASE THIS IS ALREADY RESOLVED I AM USING r1847M
Dear Developers,
The new multi-line commenting feature has proven to be quite useful. I have a question as to how it was designed to behave when nested.
I recently did something like the following (basically from a C header file) expecting the whole thing to be ignored, but EU complains about the last item which is right after a nested c-type comment. I could put a "" before the nested comment (infact this happens to be one of those I forgot to treat that way), but wondered if this is possibly a bug or as intended.
Thanks.
'Debo
/* enum --gretl_opt_flags OPT_NONE = 0, OPT_A = 1 << 0, OPT_B = 1 << 1, OPT_C = 1 << 2, OPT_D = 1 << 3, OPT_E = 1 << 4, OPT_F = 1 << 5, OPT_G = 1 << 6, OPT_H = 1 << 7, OPT_I = 1 << 8, OPT_J = 1 << 9, OPT_K = 1 << 10, OPT_L = 1 << 11, OPT_M = 1 << 12, OPT_N = 1 << 13, OPT_O = 1 << 14, OPT_P = 1 << 15, OPT_Q = 1 << 16, OPT_R = 1 << 17, OPT_S = 1 << 18, OPT_T = 1 << 19, OPT_U = 1 << 20, OPT_V = 1 << 21, OPT_W = 1 << 22, OPT_X = 1 << 23, OPT_Z = 1 << 24, OPT_Y = 1 << 25, /* added 2009-03-15 */ OPT_UNSET = 1 << 30 */
3. Re: Nested Multiline Comment
- Posted by DerekParnell (admin) Jul 03, 2009
- 1111 views
Dear Developers,
The new multi-line commenting feature has proven to be quite useful. I have a question as to how it was designed to behave when nested.
The /* ... */ is intended not to be nested. The comment starts with /* and ends at the very next */ that it comes across.
The comment idea is intended to to help coders add comments to their code, and not explicitly intended to comment out valid code.
One way that you can do to comment out a large block of code is to use the ifdef facility.
For example:
ifdef COMMENT_OUT then enum --gretl_opt_flags OPT_NONE = 0, OPT_A = 1 << 0, OPT_B = 1 << 1, OPT_C = 1 << 2, OPT_D = 1 << 3, OPT_E = 1 << 4, OPT_F = 1 << 5, OPT_G = 1 << 6, OPT_H = 1 << 7, OPT_I = 1 << 8, OPT_J = 1 << 9, OPT_K = 1 << 10, OPT_L = 1 << 11, OPT_M = 1 << 12, OPT_N = 1 << 13, OPT_O = 1 << 14, OPT_P = 1 << 15, OPT_Q = 1 << 16, OPT_R = 1 << 17, OPT_S = 1 << 18, OPT_T = 1 << 19, OPT_U = 1 << 20, OPT_V = 1 << 21, OPT_W = 1 << 22, OPT_X = 1 << 23, OPT_Z = 1 << 24, OPT_Y = 1 << 25, /* added 2009-03-15 */ OPT_UNSET = 1 << 30 end ifdef
[/quote] By the way, probably coming in 4.1 we will have shift operators << and >> and enums that do binary increments, something like
enum by *2 OPT_NONE = 0, OPT_A = 1, -- #00000001 OPT_B, -- #00000002 OPT_C, -- #00000004 OPT_D, -- #00000008 OPT_E, -- #00000010 . . . etc ... OPT_UNSET = 1 << 30
4. Re: Nested Multiline Comment
- Posted by ChrisB (moderator) Jul 03, 2009
- 1112 views
Hi
Oh b***er- did I miss eu 4 stable!
Chris
( )
5. Re: Nested Multiline Comment
- Posted by DerekParnell (admin) Jul 03, 2009
- 1155 views
Hi
Oh b***er- did I miss eu 4 stable!
Chris
( )
LOL ... not exactly. A number of enhancements have been suggested that we have decided not to put into 4.0. Instead we will wait until after that big bang has settled down a bit.
Have a look at Sourceforge to see the recorded suggestions so far. Of course, you can always add to this list.
6. Re: Nested Multiline Comment
- Posted by jeremy (admin) Jul 03, 2009
- 1096 views
Is there any reason why we shouldn't make this valid?
/* sequence name = "John" /* testing */ integer age = 133 */
I personally am in favor of the above working. I'd like to know the reasoning against it? I understand that multi-line comments were not designed to comment out working blocks of code and that an ifdef could be used, but is that the best way? Why not allow it to be commented out by multi-line comments?
Jeremy
7. Re: Nested Multiline Comment
- Posted by jimcbrown (admin) Jul 03, 2009
- 1095 views
Is there any reason why we shouldn't make this valid?
/* sequence name = "John" /* testing */ integer age = 133 */
I personally am in favor of the above working. I'd like to know the reasoning against it? I understand that multi-line comments were not designed to comment out working blocks of code and that an ifdef could be used, but is that the best way? Why not allow it to be commented out by multi-line comments?
Jeremy
It would be very convinient to have. I can't tell you how many times I've used those in C or Java files, only to have the compile fail because the code I was commenting out, had a multiline comment that was one line long. I would be for this unless someone gave a compelling reason why it was a bad idea.
And Java doesn't have even have ifdefs.....
8. Re: Nested Multiline Comment
- Posted by DerekParnell (admin) Jul 03, 2009
- 1085 views
Is there any reason why we shouldn't make this valid?
/* sequence name = "John" /* testing */ integer age = 133 */
I personally am in favor of the above working. I'd like to know the reasoning against it? I understand that multi-line comments were not designed to comment out working blocks of code and that an ifdef could be used, but is that the best way? Why not allow it to be commented out by multi-line comments?
I don't know the reasons against making work like that.
However, the D programming language has a special comment type for nested comments. It has
- //
- for single line comments
- /* ... */
- for non-nesting multi-line comments
- /+ ... +/
- for nesting multi-line comments
But on the other hand, the other language that I use frequently (Progress) has /* ... */ as nesting comments and I have never really been troubled by it.
Well we could try it but it would be hard to revert to non-nesting if we change our minds.