Comment Codeline by Macro

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Comment Codeline by Macro

Post 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.
sorry for my bad english
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Comment Codeline by Macro

Post 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")
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Comment Codeline by Macro

Post 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. :)
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Comment Codeline by Macro

Post by Dude »

Josh wrote:I believe everyone knows what I mean by that.
Sorry, but I don't. What are you trying to request?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Comment Codeline by Macro

Post 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.
sorry for my bad english
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Comment Codeline by Macro

Post 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.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Comment Codeline by Macro

Post 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.
Post Reply