|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi Everyone,
I was wondering about the nested comments and the reason why it is not acceptable... /* first /* second */ */ I guess it is easy for any lexer to recognize such text with the of recursive grammar rule and ignore them... does anyone have any idea about the reason why this is not allowed? Thanks in advance!!! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 4:06 pm, Rahul <sam_...@yahoo.co.in> wrote:
> Hi Everyone, > > I was wondering about the nested comments and the reason why it is > not acceptable... > > /* > first > /* > second > */ > */ > > I guess it is easy for any lexer to recognize such text with the > of recursive grammar rule and ignore them... > does anyone have any idea about the reason why this is not allowed? > > Thanks in advance!!! I think comment is used to write something about the code. If you want to disable some code temporarily, "#if 0" is better. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 1:06 pm, Rahul <sam_...@yahoo.co.in> wrote:
> Hi Everyone, > > I was wondering about the nested comments and the reason why it is > not acceptable... > > /* > first > /* > second > */ > */ > > I guess it is easy for any lexer to recognize such text with the > of recursive grammar rule and ignore them... > does anyone have any idea about the reason why this is not allowed? > > Thanks in advance!!! Hi, the implementation of the comments are like that, once the comments is started it will search for the counterpart. You can try nestin like that, /* first \/* second *\/ */ -aims |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Rahul wrote:
> Hi Everyone, > > I was wondering about the nested comments and the reason why it is > not acceptable... Mostly because the language definition says so, I guess. > > /* > first > /* > second > */ > */ > > I guess it is easy for any lexer to recognize such text with the > of recursive grammar rule and ignore them... > does anyone have any idea about the reason why this is not allowed? Maybe because there is no need for it. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 4:43 pm, Rolf Magnus <ramag...@t-online.de> wrote:
> Rahul wrote: > > Hi Everyone, > > > I was wondering about the nested comments and the reason why it is > > not acceptable... > > Mostly because the language definition says so, I guess. > > > > > /* > > first > > /* > > second > > */ > > */ > > > I guess it is easy for any lexer to recognize such text with the > > of recursive grammar rule and ignore them... > > does anyone have any idea about the reason why this is not allowed? > > Maybe because there is no need for it. well, sometimes i does make sense to properly align the comments... |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2007-12-26 06:57:14 -0500, Rahul <sam_cit@yahoo.co.in> said:
> On Dec 26, 4:43 pm, Rolf Magnus <ramag...@t-online.de> wrote: >> Rahul wrote: >>> Hi Everyone, >> >>> I was wondering about the nested comments and the reason why it is >>> not acceptable... >> >> Mostly because the language definition says so, I guess. >> >> >> >>> /* >>> first >>> /* >>> second >>> */ >>> */ >> >>> I guess it is easy for any lexer to recognize such text with the >>> of recursive grammar rule and ignore them... >>> does anyone have any idea about the reason why this is not allowed? >> >> Maybe because there is no need for it. > > well, sometimes i does make sense to properly align the comments... Why would you comment on comments? -- -kira |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 2007-12-26 02:06:00 -0600, Rahul <sam_cit@yahoo.co.in> said:
> Hi Everyone, > > I was wondering about the nested comments and the reason why it is > not acceptable... It is prohibited by the standard, Section 2.7. -dr |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 8:07 pm, Dave Rahardja
<drahardja.place...@sign.here.pobox.com> wrote: > On 2007-12-26 02:06:00 -0600, Rahul <sam_...@yahoo.co.in> said: > > > Hi Everyone, > > > I was wondering about the nested comments and the reason why it is > > not acceptable... > > It is prohibited by the standard, Section 2.7. > > -dr I understand that it is not allowed, but its not a big deal for a compiler to ignore nested comments... (compilers can detect nested ifs, nested blocks... etc) i was just wondering if there was any specific reason of not allowing nested comments... |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
On 2007-12-26 18:02, Rahul wrote:
> On Dec 26, 8:07 pm, Dave Rahardja > <drahardja.place...@sign.here.pobox.com> wrote: >> On 2007-12-26 02:06:00 -0600, Rahul <sam_...@yahoo.co.in> said: >> >> > Hi Everyone, >> >> > I was wondering about the nested comments and the reason why it is >> > not acceptable... >> >> It is prohibited by the standard, Section 2.7. >> >> -dr > > I understand that it is not allowed, but its not a big deal for a > compiler to ignore nested comments... (compilers can detect nested > ifs, nested blocks... etc) i was just wondering if there was any > specific reason of not allowing nested comments... Originally it was probably to make life easier for the compiler developers. -- Erik Wikström |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Wed, 26 Dec 2007 00:06:00 -0800 (PST), Rahul <sam_cit@yahoo.co.in>
wrote in comp.lang.c++: > Hi Everyone, > > I was wondering about the nested comments and the reason why it is > not acceptable... > > /* > first > /* > second > */ > */ > > I guess it is easy for any lexer to recognize such text with the > of recursive grammar rule and ignore them... > does anyone have any idea about the reason why this is not allowed? What is the reason that you think it should be allowed? -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://c-faq.com/ comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
There are other quirks too. For example, assume you have this:
#include <iostream> int main() { std::cout << "Write */ to close a comment block\n"; } And then you comment it out like this: #include <iostream> int main() { /* std::cout << "Write */ to close a comment block\n"; */ } |
|
![]() |
| Outils de la discussion | |
|
|