Topic: Why no nested comments /* /**/ */


Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1999/08/31
Raw View
wmm@fastdial.net wrote:
>
> In article <37C14413.90395F73@physik.tu-muenchen.de>,
>   Christopher Eltschka <celtschk@physik.tu-muenchen.de> wrote:
> > "Siemel B. Naran" wrote:
> > >
> > > On 19 Aug 99 08:27:33 GMT, Christopher Eltschka
> > >
> > > >#include <iostream>
> > > >
> > > >int main()
> > > >{
> > > >  std::cout << 1 /*
> > > >  // Is this a nested comment? */
> > > >                +1
> > > >}
> > >
> > > Since
> > >    "/*" is kind of equivalent to "\n#ifdef 0\n"
> > >    "*/" is kind of equivalent to "\n#endif"
> > > the "// Is this a nested comment?" is indeed a nested comment.
> > >
> > > So egcs prints "2" in the above program.
> >
> > I guess it just ignores the "//", since it's inside a comment.
> > Otherwise there would be a problem: The "//" comment extends
> > to the end of the line - but that's *after* the closing "*/"
> > of the "/*" from the previous line. That is, the "*/" is
> > part of the // comment, and therefore it should either be
> > ignored (since it is commented out, and it doesn't clode a
> > nested comment of the // comment), or it should give an error
> > (since it closes a comment while a nested comment is open).
> > The egcs behavious is consistant only if "//" comments are
> > *not* nested inside "/* */" comments.
>
> I think there's a disagreement here over what the phrase "nested
> comment" means.  The "// Is this a nested comment?" is contained
> inside the /*...*/ without affecting the termination point of the
> containing comment, which is one way of viewing "nesting."  But
> you're right, if "nesting" implies eating the termination of the
> containing comment, this isn't nesting.

The definition of the "//" comment is "extending to the end
of the line".
Of course, you might change it to "extending to the end of the
line, or the end marker of an enclosing comment, whatever comes
first". This would, of course, be an _additional_ change.

However, this again poses the question: Should the following
be legal?

int main()
{
  // */
}

Is this "*/" ignored (because there's no corresponding "/*"),
or is it an error (because an enclosing comment is closed
which never was opened).

>
> > In either case, you'd get an illegal program from the above.
>
> The program above is not illegal.
>
> 2.7p1 makes all this trivially clear in the note:  "The comment
> characters //, /*, and */ have no special meaning within a //
> comment and are treated just like other characters.  Similarly,
> the comment characters // and /* have no special meaning within a
> /* comment."

You are obviously confusing the current state (where there
is _no_ comment nesting at all) with the hypothetical
state of comment nesting allowed.
Currently the following program is legal:

int main()
{
/* /* */
}

With nested comments, there would be an undelimited comment
in here.

My posting was all about the problems of nested comments.
Therefore the rule you quote (effectively saying that comments
don't nest) is irrelevant here (since it's exactly what is
assumed to be changed).
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: zivca@netvision.net.il (Ziv Caspi)
Date: 1999/08/29
Raw View
On 26 Aug 99 21:56:29 GMT, David R Tribble <david@tribble.com> wrote:
[...]
>There are three ways to comment out code, and they can be intermixed
>with each other.  Geez, isn't that enough?
[...]

No, there's only one (to comment large code portions, that is):

#if 0
 ...
#endif

The others are not robust.

(Why don't syntax-highlighting editors recognize this special case
is beyond me, BTW.)
---------------------------------------------
Ziv Caspi
zivca@netvision.net.il


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: David R Tribble <david@tribble.com>
Date: 1999/08/26
Raw View
Jerry Coffin wrote:
>
> In article <37BAD005.D977FECA@eng.sun.com>, ball@eng.sun.com says...
>
> [ ... ]
>
> > Nested comments have never been in either language.  The committee
> > did not remove them, it simply didn't add them.  In my opinion
> > it acted responsibly in this.
>
> That's more or less incorrect -- before the standard came along,
> Lattice C supported nested comments, making it (arguably) part of the
> language as it existed at the time.  Given that there were also quite
> a few compilers that didn't support it, I think the committee _could_
> perfectly reasonably have taken either approach.  I have no argument
> (at all) with making comments not nest, but if they had decided to
> allow nesting of comments, they certainly could have pointed to a body
> of existing practice to justify it.

Except that the reference document for the C language that existed
at that time, the K&R white book, stated quite clearly that comments
don't nest.  Which means that the committee could (and probably did)
point to a body of existing practice that justified not changing the
language.  (Lattice clearly added nested comments and an extension
to C, and IRIC, they had a command line option to enable/disable it.)

There are three ways to comment out code, and they can be intermixed
with each other.  Geez, isn't that enough?

    #if 0
      /*
        // int i = 1;
      */
    #endif

    /*
      #if 0
        // int i = 2;
      #endif
    */

    // #if 0
    //   /*
    //     int i = 3;
    //   */
    // #endif

    Etc.

-- David R. Tribble, david@tribble.com --
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: wmm@fastdial.net
Date: 1999/08/24
Raw View
In article <37C14413.90395F73@physik.tu-muenchen.de>,
  Christopher Eltschka <celtschk@physik.tu-muenchen.de> wrote:
> "Siemel B. Naran" wrote:
> >
> > On 19 Aug 99 08:27:33 GMT, Christopher Eltschka
> >
> > >#include <iostream>
> > >
> > >int main()
> > >{
> > >  std::cout << 1 /*
> > >  // Is this a nested comment? */
> > >                +1
> > >}
> >
> > Since
> >    "/*" is kind of equivalent to "\n#ifdef 0\n"
> >    "*/" is kind of equivalent to "\n#endif"
> > the "// Is this a nested comment?" is indeed a nested comment.
> >
> > So egcs prints "2" in the above program.
>
> I guess it just ignores the "//", since it's inside a comment.
> Otherwise there would be a problem: The "//" comment extends
> to the end of the line - but that's *after* the closing "*/"
> of the "/*" from the previous line. That is, the "*/" is
> part of the // comment, and therefore it should either be
> ignored (since it is commented out, and it doesn't clode a
> nested comment of the // comment), or it should give an error
> (since it closes a comment while a nested comment is open).
> The egcs behavious is consistant only if "//" comments are
> *not* nested inside "/* */" comments.

I think there's a disagreement here over what the phrase "nested
comment" means.  The "// Is this a nested comment?" is contained
inside the /*...*/ without affecting the termination point of the
containing comment, which is one way of viewing "nesting."  But
you're right, if "nesting" implies eating the termination of the
containing comment, this isn't nesting.

> In either case, you'd get an illegal program from the above.

The program above is not illegal.

2.7p1 makes all this trivially clear in the note:  "The comment
characters //, /*, and */ have no special meaning within a //
comment and are treated just like other characters.  Similarly,
the comment characters // and /* have no special meaning within a
/* comment."
--
William M. Miller, wmm@fastdial.net
Software Emancipation Technology (www.setech.com)


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1999/08/23
Raw View
"Siemel B. Naran" wrote:
>
> On 19 Aug 99 08:27:33 GMT, Christopher Eltschka
>
> >#include <iostream>
> >
> >int main()
> >{
> >  std::cout << 1 /*
> >  // Is this a nested comment? */
> >                +1
> >}
>
> Since
>    "/*" is kind of equivalent to "\n#ifdef 0\n"
>    "*/" is kind of equivalent to "\n#endif"
> the "// Is this a nested comment?" is indeed a nested comment.
>
> So egcs prints "2" in the above program.

I guess it just ignores the "//", since it's inside a comment.
Otherwise there would be a problem: The "//" comment extends
to the end of the line - but that's *after* the closing "*/"
of the "/*" from the previous line. That is, the "*/" is
part of the // comment, and therefore it should either be
ignored (since it is commented out, and it doesn't clode a
nested comment of the // comment), or it should give an error
(since it closes a comment while a nested comment is open).
The egcs behavious is consistant only if "//" comments are
*not* nested inside "/* */" comments.
In either case, you'd get an illegal program from the above.

>
> >#include <iostream>
> >
> >int main()
> >{
> >  std::cout << 1 /*
> >  // Is this a nested comment? */
> >                +1
> >  // /* And this?
> >  */
> >            << std::endl;
> >}
>
> But "//" means ignore everything else on this line.

/* ... */ is replaced by a single non-newline whitespace.
Therefore linebreaks inside /* */ comments are ignored, like

#define MACRO /*
The following is part of the macro definition:
*/ hello

This is equivalent to

#define MACRO   hello

Now if nested comments would be allowed, I'd expect the
comment replacement to start with the inner comments and
continue to outside. Therefore, the whole /* and this? \n */
(*including* the \n) would be replaced by a single non-\n
whitespace, resulting in a single comment // line with
only whitespace in the comment.
Note that the "#if theory" you used above to explain
egcs' behaviour would give a similar result: Replacing
"/*" by "\n#if 0\n" and "*/" by "\n#endif\n" would
transform the above into

#include <iostream>

int main()
{
  std::cout << 1
#if 0

  // Is this a nested comment?
#endif
                +1
  //
#if 0
 And this?
#endif
            << std::endl;
}

Which obviously should compile.

Also note that the "ignore everything after //" interpretation
together with nested comments would make the first code
illegal (since the "*/" would be commented out).

> So the above body of main() is equivalent to
>    std::cout << 1 /*
>    // Is this a nested comment? */
>                  +1
>    */
>              << std::endl;

Why should the "*/" after "//" be preserved, but the "/*" not?
I don't see any consistent rule which could result in the body
above.

> which is equivalent to
>    std::cout << 1
>                  +1
>    */
>              << std::endl;
> Egcs gives an error.

The error given by egcs can easily be explaint by non-nesting
of the comments - this gives exactly the reduced body you
give last.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/08/19
Raw View
In article <MPG.1224d9c7f0d60aaa989cf4@news.mindspring.com>, Jerry
Coffin <jcoffin@taeus.com> writes
>That's more or less incorrect -- before the standard came along,
>Lattice C supported nested comments, making it (arguably) part of the
>language as it existed at the time.  Given that there were also quite
>a few compilers that didn't support it, I think the committee _could_
>perfectly reasonably have taken either approach.  I have no argument
>(at all) with making comments not nest, but if they had decided to
>allow nesting of comments, they certainly could have pointed to a body
>of existing practice to justify it.
Actually there is a much bigger case for nested comment in C.  Without
them suppressing a block of code requires such idioms as:

#if 0
<suppressed code>
#endif

In C++ always use // comments, then /* */ is available for suppression
of code.


One advantage of the later is that colour coded syntax makes the
suppressed code immediately visible.  This certainly reduces some kinds
of coding errors.


Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: sbnaran@uiuc.edu (Siemel B. Naran)
Date: 1999/08/20
Raw View
On 19 Aug 99 08:27:33 GMT, Christopher Eltschka


>#include <iostream>
>
>int main()
>{
>  std::cout << 1 /*
>  // Is this a nested comment? */
>                +1
>}

Since
   "/*" is kind of equivalent to "\n#ifdef 0\n"
   "*/" is kind of equivalent to "\n#endif"
the "// Is this a nested comment?" is indeed a nested comment.

So egcs prints "2" in the above program.



>#include <iostream>
>
>int main()
>{
>  std::cout << 1 /*
>  // Is this a nested comment? */
>                +1
>  // /* And this?
>  */
>            << std::endl;
>}

But "//" means ignore everything else on this line.
So the above body of main() is equivalent to
   std::cout << 1 /*
   // Is this a nested comment? */
                 +1
   */
             << std::endl;
which is equivalent to
   std::cout << 1
                 +1
   */
             << std::endl;
Egcs gives an error.

--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1999/08/19
Raw View
Paul Black wrote:
>
> clamage@eng.sun.com (Steve Clamage) wrote:
> >
> > sbnaran@uiuc.edu (Siemel B. Naran) writes:
> >
> > >Why no nested comments  /* /**/ */
> >
> > There is no technical reason why comments cannot nest, and
> > some C compilers used to offer it as an option.
> >
> > But nested comments are a source of programmer confusion and
> > hard-to-find errors. For that reason, comments in standard C and
> > C++ do not nest.
>
> Pointers can be a source of confusion and are definitely a source of
> hard-to-find errors. Should they be removed?

Pointers allow programs which would not have been possible
without (hey, even Pascal cannot do without them).
Nested comments just provide some minor convenience to
the programmer.

BTW, should the following compile? If so, what should it output?
If not, which lines should be errors?

#include <iostream>

int main()
{
  std::cout << 1 /*
  // Is this a nested comment? */
                +1
  // /* And this?
  */
            << std::endl;
}
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Jeff Rife <jrifeSPAM@BEnabsGONE.net>
Date: 1999/08/19
Raw View
Paul Black (paul@canix.co.uk) wrote:

> Pointers can be a source of confusion and are definitely a source of
> hard-to-find errors. Should they be removed?

Sure, if you can guarantee that you never have to write code using
a pointer.

Nested comments never *have* to be used, although, at times, for certain
code, they might be convenient.

Pointers, OTOH, are pretty much the basis of the entire C++ implementation
of polymorphism.  So, if we get rid of pointers, we get rid of
much of the reason for the existence of the language.

Now, I'm sure there are a lot of other constructs that never *have*
to be used, but almost all of them make some task easier.  Temporarily
removing a block of code can be accomplished just as easily with other
mechanisms, and if you have a macro-programmable editor, with the same
number of keystrokes.

--
Jeff Rife                   |
19445 Saint Johnsbury Lane  | http://www.nabs.net/Cartoons/Dilbert/StupidCoWorkers.gif
Germantown, MD  20876-1610  |
Home: 301-916-8131          |
Work: 301-770-5800 Ext 5335 |
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: jcoffin@taeus.com (Jerry Coffin)
Date: 1999/08/19
Raw View
In article <37BAD005.D977FECA@eng.sun.com>, ball@eng.sun.com says...

[ ... ]

> Nested comments have never been in either language.  The committee
> did not remove them, it simply didn't add them.  In my opinion
> it acted responsibly in this.

That's more or less incorrect -- before the standard came along,
Lattice C supported nested comments, making it (arguably) part of the
language as it existed at the time.  Given that there were also quite
a few compilers that didn't support it, I think the committee _could_
perfectly reasonably have taken either approach.  I have no argument
(at all) with making comments not nest, but if they had decided to
allow nesting of comments, they certainly could have pointed to a body
of existing practice to justify it.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Paul Black <paul@canix.co.uk>
Date: 1999/08/18
Raw View
clamage@eng.sun.com (Steve Clamage) wrote:
>
> sbnaran@uiuc.edu (Siemel B. Naran) writes:
>
> >Why no nested comments  /* /**/ */
>
> There is no technical reason why comments cannot nest, and
> some C compilers used to offer it as an option.
>
> But nested comments are a source of programmer confusion and
> hard-to-find errors. For that reason, comments in standard C and
> C++ do not nest.

Pointers can be a source of confusion and are definitely a source of
hard-to-find errors. Should they be removed?

Paul
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Michael Ball <ball@eng.sun.com>
Date: 1999/08/18
Raw View

> Pointers can be a source of confusion and are definitely a source of
> hard-to-find errors. Should they be removed?

Most certainly, at least as they are defined in C and C++!

However, there is no way to do that and maintain even a vestige
of compatibility with C, so there would be no way for a responsible
committee even to consider it.

Nested comments have never been in either language.  The committee
did not remove them, it simply didn't add them.  In my opinion
it acted responsibly in this.

Moral:  Just because you like something doesn't mean it should be
in the language.

Alternate Moral:  Just because you don't like something doesn't mean
it shouldn't be in the language.

-Mike Ball-
Sun Microsystems Inc


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: sbnaran@uiuc.edu (Siemel B. Naran)
Date: 1999/08/16
Raw View
Why no nested comments  /* /**/ */

   // main.cc
   /*
      adshjakjsdfhkj;
      /*
         asjkdhkjlahksjdfh;
         ahjsdhjkhaksdjhkjhaa;
      */
      aksdhkjhaskdjhf;
   */
   int main() { return 0; }

The above program compiles without error!


--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Volker Denneberg <denne@aps.rwth-aachen.de>
Date: 1999/08/16
Raw View
"Siemel B. Naran" wrote:
>
> Why no nested comments  /* /**/ */
>
>    // main.cc
>    /*
>       adshjakjsdfhkj;
>       /*
>          asjkdhkjlahksjdfh;
>          ahjsdhjkhaksdjhkjhaa;
>       */
>       aksdhkjhaskdjhf;
>    */
>    int main() { return 0; }
>
> The above program compiles without error!
>

nested comments MAY be supported by newer compilers, but as far
I know are not Standard. Use #if to workaround this limitiation

#if 0

    bla bla bla

    #if 0
        more bla bla bla
    #endif

     bla bla

#endif

To "uncomment" change "#if 0" to "#if 1"

Volker

Volker
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Jeff Rife <jrifeSPAM@BEnabsGONE.net>
Date: 1999/08/16
Raw View
Siemel B. Naran (sbnaran@uiuc.edu) wrote:
> Why no nested comments  /* /**/ */

Because the standard says so ;=>

Truthfully, it's probably mostly because of the problems that
arise with trying to parse that sort of thing.

>    // main.cc
>    /*
>       adshjakjsdfhkj;
>       /*
>          asjkdhkjlahksjdfh;
>          ahjsdhjkhaksdjhkjhaa;
>       */
>       aksdhkjhaskdjhf;
>    */
>    int main() { return 0; }
>
> The above program compiles without error!

Just because one implementation doesn't generate a diagnostic on
something, that doesn't make it:

a. a part of the standard
b. a good thing to do
c. easy to implement

--
Jeff Rife                   |  Sam: What d'ya say to a beer, Normie?
                            |
                            | Norm: Hi, sailor...new in town?
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: jackklein@att.net (Jack Klein)
Date: 1999/08/16
Raw View
On 16 Aug 99 03:05:47 GMT, sbnaran@uiuc.edu (Siemel B. Naran) wrote in
comp.std.c++:

> Why no nested comments  /* /**/ */
>
>    // main.cc
>    /*
>       adshjakjsdfhkj;
>       /*
>          asjkdhkjlahksjdfh;
>          ahjsdhjkhaksdjhkjhaa;
>       */
>       aksdhkjhaskdjhf;
>    */
>    int main() { return 0; }
>
> The above program compiles without error!

The above program compiles without error on an implementation where
there is an option to allow non-standard nested headers.  This might
be the compiler's default mode unless used with a specific switch for
standard conformance.

Why do you think you need nested comments?  What do they do for you
that:

#if 0
 ...
#endif

does not?

Jack Klein
--
Home: http://home.att.net/~jackklein
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: whbloodworth@usa.net (William H. Bloodworth)
Date: 1999/08/16
Raw View
On 16 Aug 99 03:05:47 GMT, sbnaran@uiuc.edu (Siemel B. Naran) wrote:

I breaks perfectly under Visual C++ 6.0.

William Bloodworth

>Why no nested comments  /* /**/ */
>
>   // main.cc
>   /*
>      adshjakjsdfhkj;
>      /*
>         asjkdhkjlahksjdfh;
>         ahjsdhjkhaksdjhkjhaa;
>      */
>      aksdhkjhaskdjhf;
>   */
>   int main() { return 0; }
>
>The above program compiles without error!



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: icedancer-zamboni@ibm-zamboni.net (Ken Walter)
Date: 1999/08/16
Raw View
On Mon, 16 Aug 1999 03:05:47, sbnaran@uiuc.edu (Siemel B. Naran)
wrote:

>Why no nested comments  /* /**/ */
>
[...]
TThen how do you handle:


/* ... "*/" ... */
/* ... "*/  ... */
/* ... can't parse tokens inside a comment and what do we do with '*/'
*/

>[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
>[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
>[              --- Please see the FAQ before posting. ---               ]
>[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]

Ken Walter

Remove -zamboni to reply
All the above is hearsay and the opinion of no one in particular


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/08/17
Raw View
sbnaran@uiuc.edu (Siemel B. Naran) writes:

>Why no nested comments  /* /**/ */

There is no technical reason why comments cannot nest, and
some C compilers used to offer it as an option.

But nested comments are a source of programmer confusion and
hard-to-find errors. For that reason, comments in standard C and
C++ do not nest.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]