Bug with comment...

Archives Forums/BlitzMax Bug Reports/Bug with comment...

Alberto-Diablo(Posted 2012) [#1]
Hi

This code :

SuperStrict

Local words:String[] =[ ..
'"One",  ..
"Two",  ..
"Three"]

For Local i:Int = 0 Until words.Length
	DebugLog words[i]
Next


Do not work ( end-of-line error ) - "One" literal commented


GfK(Posted 2012) [#2]
That code would throw an error if it was all on line anyway, would it not? You've got an open brace with a comment immediately after it. On ipad so can't test anything but for me, this is expected behaviour.


Alberto-Diablo(Posted 2012) [#3]
I thought the comment line retracts preprocessor, it would be convenient. Of course, it may complicate the task of tracking error, but you can put in your comments, sign a new line (".."), which would make this easy freedom. =)

Last edited 2012


GfK(Posted 2012) [#4]
I would say not. You're telling the preprocessor that all of the code is to be considered as the same line, then sticking a comment in the middle of it. I understand why you think it maybe shouldn't be like that but to me, it makes perfect sense. I think that changing the behaviour would simply be down to user preference.


Alberto-Diablo(Posted 2012) [#5]
Thanks for the clarification!


TomToad(Posted 2012) [#6]
I would think that '..' would be telling the preprocessor that the expression continues on the next line, not that the lines are being combined into one. If so, then there is an inconsistency on how the '..' behaves. For example:
Print "Hello "
'A nice comment ..
Print "World"

Should only print Hello if the '..' preempts the comment and combines the two lines, making Print "World" part of the comment; however it prints both Hello and World showing that the '..' has become part of the comment.

Last edited 2012


TomToad(Posted 2012) [#7]
Ah, wait, I see what's happening now. The newline after the comment is not considered part of the comment. So the preprocessor is changing the code to
SuperStrict

Local words:String[] =[ ..

"Two",  ..
"Three"]

For Local i:Int = 0 Until words.Length
	DebugLog words[i]
Next

Causing the error, since "Two", .. is not on the next immediate line.


Floyd(Posted 2012) [#8]
If the goal is to put comments in the multiple lines you can do this:
SuperStrict

Local words:String[] =[ ..		' Comments can go here, after the .. line continuation.
"One",  ..				' The comment extends to the end of the line.
"Two",  ..
"Three"]

For Local i:Int = 0 Until words.Length
	DebugLog words[i]
Next