Page 1 of 1

Comment Codeline by Macro

Posted: Mon Dec 19, 2016 12:44 pm
by Josh
I would like to have a possibility to comment a complete code line by macro:

Code: Select all

MacroMessageRequester
 ;
EndMacro
Even though this example will never work in this way, I believe everyone knows what I mean by that.

Re: Comment Codeline by Macro

Posted: Mon Dec 19, 2016 1:43 pm
by Fred
You can override the macro with an empty one and it should work:

Code: Select all

Macro MessageRequester(a, b, c="")
EndMacro

MessageRequester("Hello", "World")

Re: Comment Codeline by Macro

Posted: Mon Dec 19, 2016 8:48 pm
by Mistrel
This is one of my favorite features; being able to fix bugs in platform structures and add some forwards compatibility to older versions. :)

Re: Comment Codeline by Macro

Posted: Tue Dec 20, 2016 9:29 am
by Dude
Josh wrote:I believe everyone knows what I mean by that.
Sorry, but I don't. What are you trying to request?

Re: Comment Codeline by Macro

Posted: Tue Dec 20, 2016 10:57 am
by Josh
Fred wrote:You can override the macro with an empty one and it should work:

Code: Select all

Macro MessageRequester(a, b, c="")
EndMacro

MessageRequester("Hello", "World")
The version with the semicolon would be a little easier to handle because I do not always have to take the entire line with me. But the one with the empty macro is also good. Thx :D
Dude wrote:
Josh wrote:I believe everyone knows what I mean by that.
Sorry, but I don't. What are you trying to request?
I correct my first posting:
I believe that at least the person who is concerned with this question and many others understand what I mean by this request.

Re: Comment Codeline by Macro

Posted: Wed Dec 21, 2016 12:19 pm
by #NULL
when i tried the code i was surprised the comment gets removed before the macro is resolved. i would have thought the opposite, because it could be possible that its actually not a comment after evaluation. i knew spaces (like the indentation) are handled a bit special, but the semicolon is an actual character.

Re: Comment Codeline by Macro

Posted: Wed Dec 21, 2016 1:10 pm
by Mistrel
PureBasic is a single-pass compiler so I would imagine that the commented line is discarded while checking the syntax of the macro on the first pass. Otherwise it would have to reparse on insertion of every macro. Although I think it already does this since we do get macro errors reported. It would be up to the PB team if they want to change this behavior.

On a side note, I wonder how C and C++ preprocessors behave with macros like this.