PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > nested comments
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
nested comments

Réponse
 
LinkBack Outils de la discussion
Vieux 26/12/2007, 08h06   #1
Rahul
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut nested comments

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!!!
  Réponse avec citation
Vieux 26/12/2007, 11h03   #2
yanlinlin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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.
  Réponse avec citation
Vieux 26/12/2007, 11h11   #3
simplyamit2
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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
  Réponse avec citation
Vieux 26/12/2007, 11h43   #4
Rolf Magnus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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.

  Réponse avec citation
Vieux 26/12/2007, 11h57   #5
Rahul
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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...
  Réponse avec citation
Vieux 26/12/2007, 13h19   #6
Kira Yamato
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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

  Réponse avec citation
Vieux 26/12/2007, 15h07   #7
Dave Rahardja
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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


  Réponse avec citation
Vieux 26/12/2007, 17h02   #8
Rahul
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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...
  Réponse avec citation
Vieux 26/12/2007, 17h20   #9
Erik Wikström
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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
  Réponse avec citation
Vieux 26/12/2007, 21h32   #10
Jack Klein
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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
  Réponse avec citation
Vieux 26/12/2007, 23h01   #11
Juha Nieminen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: nested comments

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";
*/
}
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h40.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19264 seconds with 19 queries