Thread overview | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 22, 2002 {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
I've followed all the nested/not nested comment discussions with interest. I am reluctant to change the meaning of /* */ from C and C++. How about a new comment style, {{ nested comment }} to indicate nested comments? Is it just too lame to have three (3) different commenting methods in D? |
January 22, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a2kr5h$r70$2@digitaldaemon.com... > I've followed all the nested/not nested comment discussions with interest. I > am reluctant to change the meaning of /* */ from C and C++. > > How about a new comment style, > > {{ nested comment }} > > to indicate nested comments? Is it just too lame to have three (3) different > commenting methods in D? I wouldn't mind if you didn't, really. But if you're going to do it, try some combination of symbols that would be illegal otherwise, just in case. For example: (< ... >) [[ ... ]] (= ... =) <=| ... |=> >=> ... <=< |> ... <| Personally, besides the beauty-looking ones, I like this one best, clearly: [[ ... ]] Salutaciones, JCAB |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> I've followed all the nested/not nested comment discussions with interest. I
> am reluctant to change the meaning of /* */ from C and C++.
>
> How about a new comment style,
>
> {{ nested comment }}
>
> to indicate nested comments? Is it just too lame to have three (3) different
> commenting methods in D?
*sob*
<broken_record_mode>
I can nest comments in C++ or D, as currently implemented,
all day long:
//brokencode// if (a == b)
//brokencode// {
//brokencode// DoTheThing(); // this does the thing
//brokencode////oldcode// DoTheOldThing(); // we useta do this
//brokencode// }
Look, three layers of nested comments.
</broken_record_mode>
-RB
|
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Have you considered looking for <HTML> at the begining of every source file in fact < appears as the first non white space char, then the chances are that its D inside HTML. so a program can begin <code> if you then removed <SPAN> (nested) areas from within the <code> sections you get have nestable comments without changing the syntax of D or use <span> </span> always as nestable comment always or to veiw comments with a bit of logic ... /* */ original c comments // one line c++ comments why not continue the trend /{ }/ nestable D comments /<symbol> is comment { we all know is block/scope "Walter" <walter@digitalmars.com> wrote in message news:a2kr5h$r70$2@digitaldaemon.com... > I've followed all the nested/not nested comment discussions with interest. I > am reluctant to change the meaning of /* */ from C and C++. > > How about a new comment style, > > {{ nested comment }} > > to indicate nested comments? Is it just too lame to have three (3) different > commenting methods in D? > Mike. |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | Russell Borogove wrote:
> Walter wrote:
>
> > I've followed all the nested/not nested comment discussions with interest. I am reluctant to change the meaning of /* */ from C and C++.
> >
> > How about a new comment style,
> >
> > {{ nested comment }}
> >
> > to indicate nested comments? Is it just too lame to have three (3) different
> > commenting methods in D?
>
> *sob*
>
> <broken_record_mode>
>
> I can nest comments in C++ or D, as currently implemented, all day long:
>
> //brokencode// if (a == b)
> //brokencode// {
> //brokencode// DoTheThing(); // this does the thing
> //brokencode////oldcode// DoTheOldThing(); // we useta do this
> //brokencode// }
>
> Look, three layers of nested comments.
>
> </broken_record_mode>
>
> -RB
*gasp!*
Struck by the obvious.
You know, I do per-line commenting all the time in assembler. But we tend to use semicolons and octothorps ("#") there.
Why my brain resists doing it in block-structured languages is a mystery to me. Seriously, I just hadn't considered it. Especially when all program editors allow you to create a trivial macro to easily insert whatever you want at the start of each line (often used to rejustify a relocated block of code).
Suddenly, block-structured comments, especially nested comments, make no sense to me. Why treat comments as code, or code as comments? Code is code, and comments are comments! Just because you are commenting-out some code does NOT mean your comment *is* code! It's just another comment...
Think of comments as an "escape from" the language, not as "part of" the language. Now, what syntax should they have? While we're at it, I think it is high time comments had a reasonable syntax as well. They should parse! Well?
Wait... Now I remember: My first programming language, FORTRAN (on punched cards, no less), reserved the first column for comment characters. Placing a "C" there would cause the compiler to drop the entire line. I think trailing comments (with an octothorp) didn't appear until FORTRAN '77 or so.
And BASIC actually made comments part of the language, with the "REMARK" keyword (implemented, of course, as a PRINT to the bit-bucket). Did any other languages dedicate a keyword for comments?
(Clearly, English uses parentheses for commenting.)
-BobC
|
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | I have seen the //brokencode// style comments further in this thread, even then, inserting a smaller 'commenter' just at the start and at the end feels better. Similar to clip/clipprep style, I suggest, /a{ ........ /a} Where 'a' could be any single digit or number. This will allow true nesting of comments, say like: /a{ part1 of the code /b{ part2 of the code /b} part3 of the code /a} Of course, you can adopt "//a{" to deviate little from the usual // style comments. - Rajiv "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:a2kvgk$tka$1@digitaldaemon.com... > Have you considered looking for <HTML> at the begining of every source file > in fact < appears as the first non white space char, then the chances are > that its D inside HTML. so a program can begin <code> > if you then removed <SPAN> (nested) areas from within the <code> sections > you get have nestable comments without changing the syntax of D > > or use <span> </span> > always as nestable comment always > > or to veiw comments with a bit of logic ... > /* */ original c comments > // one line c++ comments > why not continue the trend > /{ }/ nestable D comments > > /<symbol> is comment { we all know is block/scope > > > "Walter" <walter@digitalmars.com> wrote in message news:a2kr5h$r70$2@digitaldaemon.com... > > I've followed all the nested/not nested comment discussions with interest. > I > > am reluctant to change the meaning of /* */ from C and C++. > > > > How about a new comment style, > > > > {{ nested comment }} > > > > to indicate nested comments? Is it just too lame to have three (3) > different > > commenting methods in D? > > > > > Mike. > > |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | I actually really like this idea... /{ }/ sends a clear message that a comment "scope" is being introduced and then closed. It's not legal anywhere else. And it fits well with the other comments, similar, but just different enough to not be confusing. I don't know that the matching identifiers the other replier suggested are necessary, but I think some rules about whether something like this is legal should be devised: /{ /* /} */ does the /} even get parsed, since it's inside some other comment? My guess is that the above would have to be flagged as an error. Sean "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:a2kvgk$tka$1@digitaldaemon.com... > Have you considered looking for <HTML> at the begining of every source file > in fact < appears as the first non white space char, then the chances are > that its D inside HTML. so a program can begin <code> > if you then removed <SPAN> (nested) areas from within the <code> sections > you get have nestable comments without changing the syntax of D > > or use <span> </span> > always as nestable comment always > > or to veiw comments with a bit of logic ... > /* */ original c comments > // one line c++ comments > why not continue the trend > /{ }/ nestable D comments > > /<symbol> is comment { we all know is block/scope > > > "Walter" <walter@digitalmars.com> wrote in message news:a2kr5h$r70$2@digitaldaemon.com... > > I've followed all the nested/not nested comment discussions with interest. > I > > am reluctant to change the meaning of /* */ from C and C++. > > > > How about a new comment style, > > > > {{ nested comment }} > > > > to indicate nested comments? Is it just too lame to have three (3) > different > > commenting methods in D? > > > > > Mike. > > |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:a2kvgk$tka$1@digitaldaemon.com... <SNIP> > > or to veiw comments with a bit of logic ... > /* */ original c comments > // one line c++ comments > why not continue the trend > /{ }/ nestable D comments > > /<symbol> is comment { we all know is block/scope > <SNIP> > > Mike. YES! Agreed! I think this is definitely a good soulution! / Signals a comment, { Signals a nestable block, so /{ Signals a nestable comment. I would be very happy with this solution. -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rajiv Bhagwat | "Rajiv Bhagwat" <dataflow@vsnl.com> wrote in message news:a2lls2$1chf$1@digitaldaemon.com... > I have seen the file://brokencode// style comments further in this thread, even > then, inserting a smaller 'commenter' just at the start and at the end feels > better. > > Similar to clip/clipprep style, I suggest, > /a{ ........ /a} > Where 'a' could be any single digit or number. This will allow true nesting > of comments, say like: > > /a{ > part1 of the code > /b{ > part2 of the code > /b} > part3 of the code > /a} > > Of course, you can adopt "//a{" to deviate little from the usual // style > comments. > - Rajiv > No, I don't like it. Matching up the correct characters is just a drag and totally unnecesary. "//a" doesn't seem logical to me because // signals a single line comment, not a block. -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail |
January 23, 2002 Re: {{ nested comment }} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert W. Cunningham | "Robert W. Cunningham" <rwc_2001@yahoo.com> wrote in message news:3C4E366D.5AEEFECC@yahoo.com... > Russell Borogove wrote: > > > Walter wrote: > > > > > I've followed all the nested/not nested comment discussions with interest. I > > > am reluctant to change the meaning of /* */ from C and C++. > > > > > > How about a new comment style, > > > > > > {{ nested comment }} > > > > > > to indicate nested comments? Is it just too lame to have three (3) different > > > commenting methods in D? > > > > *sob* > > > > <broken_record_mode> > > > > I can nest comments in C++ or D, as currently implemented, all day long: > > > > file://brokencode// if (a == b) > > file://brokencode// { > > file://brokencode// DoTheThing(); // this does the thing > > file://brokencode////oldcode// DoTheOldThing(); // we useta do this > > file://brokencode// } > > > > Look, three layers of nested comments. > > > > </broken_record_mode> > > > > -RB > > *gasp!* > > Struck by the obvious. > > You know, I do per-line commenting all the time in assembler. But we tend to use > semicolons and octothorps ("#") there. > > Why my brain resists doing it in block-structured languages is a mystery to me. > Seriously, I just hadn't considered it. Especially when all program editors > allow you to create a trivial macro to easily insert whatever you want at the > start of each line (often used to rejustify a relocated block of code). > > Suddenly, block-structured comments, especially nested comments, make no sense to > me. Why treat comments as code, or code as comments? Code is code, and comments > are comments! Just because you are commenting-out some code does NOT mean your > comment *is* code! It's just another comment... > > Think of comments as an "escape from" the language, not as "part of" the language. Now, what syntax should they have? While we're at it, I think it is > high time comments had a reasonable syntax as well. They should parse! Well? > > Wait... Now I remember: My first programming language, FORTRAN (on punched > cards, no less), reserved the first column for comment characters. Placing a "C" > there would cause the compiler to drop the entire line. I think trailing comments (with an octothorp) didn't appear until FORTRAN '77 or so. > > And BASIC actually made comments part of the language, with the "REMARK" keyword > (implemented, of course, as a PRINT to the bit-bucket). Did any other languages > dedicate a keyword for comments? > > (Clearly, English uses parentheses for commenting.) > > > -BobC > What I don't understand is that some of you defend non-nesting comments so fiercefully. When discussing nesting comments, the reasons for not having them usually boil down to two things: 1) You don't need them 2) It is not standard As to 1), If I really wouldn't need them, why am I asking for them? At school I learned that as a software developer I shouldn't tell users of a program just "You don't need that", without explaining very carefully why you don't need it and why it would be a problem to include the feature. Just because *you* think a certain feature is unnecessary, doesn't mean they share your opinion. If this holds true for programs, why shouldn't it hold true for languages? As to 2), you're right, but there are a *lot* of non-standard features in D, so adding (a very usable) one more to it wouldn't hurt that much :) I just don't see what the big problem with nested comments is. Please explain that to me. Would some things go terribly wrong, or be very diffcult? -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail giving some damn good reasons as why including the features of |
Copyright © 1999-2021 by the D Language Foundation