473,227 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,227 software developers and data experts.

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 help
of recursive grammar rule and ignore them...
does anyone have any idea about the reason why this is not allowed?
Thanks in advance!!!
Dec 26 '07 #1
10 5293
On Dec 26, 4:06 pm, Rahul <sam_...@yahoo.co.inwrote:
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 help
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.
Dec 26 '07 #2
On Dec 26, 1:06 pm, Rahul <sam_...@yahoo.co.inwrote:
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 help
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
Dec 26 '07 #3
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 help
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.

Dec 26 '07 #4
On Dec 26, 4:43 pm, Rolf Magnus <ramag...@t-online.dewrote:
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 help
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...
Dec 26 '07 #5
On 2007-12-26 06:57:14 -0500, Rahul <sa*****@yahoo.co.insaid:
On Dec 26, 4:43 pm, Rolf Magnus <ramag...@t-online.dewrote:
>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 help
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

Dec 26 '07 #6
On 2007-12-26 02:06:00 -0600, Rahul <sa*****@yahoo.co.insaid:
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
Dec 26 '07 #7
On Dec 26, 8:07 pm, Dave Rahardja
<drahardja.place...@sign.here.pobox.comwrote:
On 2007-12-26 02:06:00 -0600, Rahul <sam_...@yahoo.co.insaid:
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...
Dec 26 '07 #8
On 2007-12-26 18:02, Rahul wrote:
On Dec 26, 8:07 pm, Dave Rahardja
<drahardja.place...@sign.here.pobox.comwrote:
>On 2007-12-26 02:06:00 -0600, Rahul <sam_...@yahoo.co.insaid:
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
Dec 26 '07 #9
On Wed, 26 Dec 2007 00:06:00 -0800 (PST), Rahul <sa*****@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 help
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
Dec 26 '07 #10
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";
*/
}
Dec 26 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Wilson | last post by:
Hello, I have the following code which populates as table data from a SQL Server 2000 stored proc (RSByDemoID2). Below that is the view and stored procedure which takes @DemoID as input to match...
4
by: KInd | last post by:
Hello All, When is nested class more preferable that Inheritance ? I think with proper inheritance and friend class concept we can get the same flexibility as nested classes Any comments .. Best...
7
by: Alfonso Morra | last post by:
I have a class that contains a nested class. The outer class is called outer, and the nested class is called inner. When I try to compile the following code, I get a number of errors. It is not...
10
by: Philip Ronan | last post by:
Hi, I'm having problems embedding alternative content with nested OBJECT tags. Take a look at <http://www.japanesetranslator.co.uk/chihiro/map.html> The map on this page is available in SVG,...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
2
by: Bob Day | last post by:
Using VS2003, VB.NET, MSDE... I am looking at a demo program that, to my surprise, has nested classes, such as the example below. I guess it surprised me becuase you cannot have nested subs,...
25
by: GY2 | last post by:
I writing some documentation and I want to describe a common code structure which is used to step through all the items in a collection (e.g. each file in a subdirectory) while applying more and...
3
by: Amit_Basnak | last post by:
Dear Friends I have the follwoing function "tss_fe_get_own_info" which has the arguments as shows below tss_fe_get_own_info(char *user_id, tss_user_profile_t **p_buf_UserSecInfo, error_status_t...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.