I think I see the confusion here…

 

When you have a line comment symbol “//” in go, “c” in FORTRAN, “;” in 
assembler, etc. you are safe. There is never confusion.

 

When you have a block comment symbol though, “/*” and “*/” in C/C++/…/Go, “{“ 
and “}” in PASCAL, etc., then you have the problem of nested and overlapping 
comment blocks.

 

One issue is that the body of comments is generally considered free text rather 
than code, text without rules and regulations…which is generally necessary for 
the comment writer to get their job done. However, this freedom comes at the 
price of potential confusion when the end of comment symbol appears somewhere 
miscellaneous in the comment block.

 

It might seem that the end symbol should only be recognized on a line by 
itself. (immediately after a newline)

 

It might seem that nesting should happen, where a begin symbol does a 
“comment++” and the end symbol means “comment—“ and text is a comment when the 
count > 0.

 

It might seem that “innocent end symbols” like the one in the string literal of 
the initial post should be ignored. If you want this then the parser needs to 
know “is this innocent?” which means that the text in the block is no longer 
unstructured.

 

There are other out of bound ways…generally not explored…but imagine if 
comments were always in green and there was a way to mark text in the editor as 
being green. Then in it would just work. Same if the magic orthogonal property 
was “italic” or “serif font” or “underlined” or any otherness from regular 
text. As it is though, with regular and comment text interwoven, the ability to 
embed end of comment symbols in free form comment text is an inherent problem, 
which is why you find that every language you consult has the same truth.

 

From: <golang-nuts@googlegroups.com> on behalf of Marvin Stenger 
<marvin.stenge...@gmail.com>
Date: Sunday, November 13, 2016 at 12:05 PM
To: golang-nuts <golang-nuts@googlegroups.com>
Cc: <vvv.poc...@gmail.com>
Subject: [go-nuts] Re: Is it a compiler bug?

 

What should be wrong? It is as intuitive as it can be. Did you ever wrote a 
lexer/tokenizer?

Am Sonntag, 13. November 2016 08:38:03 UTC+1 schrieb imd3c:

OK, I get it. It's in the spec,  I had to check it. But still, isn't it wrong? 
What's the point, is it tradition or something? I checked C, Java, Rust, they 
all do the same.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to