Versatile Macros

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Addict
Addict
Posts: 4968
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Versatile Macros

Post by Psychophanta »

No doubt lots of us realized about the inmense posibilities of macros, specially if these are improved with more capabilities.

In order for conversion from other languages to PB there should be more than interesting to improve versatile macros.

Allow names for macros with spaces:

Code: Select all

Macro aaa
  Debug "aaa"
EndMacro

Macro  aaa
  Debug " aaa"
EndMacro

Macro  aaa bb 
  Debug " aaa bb "
EndMacro

aaa

 aaa

 aaa bb 
Allow the macro to read the complete line when called and work with it:

Code: Select all

Macro Then [ ] ;<- parameters separation are spaces
  :
  [last:EndIf] ; [last] is the last parameter read in line
EndMacro
If a=9 Then bbb=ccc

Macro Drawimage [,]    ; <- compiler calls these macros (with preserved native names) only if the syntax is not correct . Parameters separation are commas.
  DisplayTransparentSprite([1](4),[2],[3])
EndMacro
Drawimage imag, cox, coy, num

Macro Drawimage [ ]    ; <- compiler calls these macros (with preserved native names) only if the syntax is not correct . Parameters separation are spaces.
  DisplayTransparentSprite([1](4),[2],[3])
EndMacro
Drawimage imag cox coy num
In few words:
A powerful versatile Macro shoulds allow the programmer to stablish and to implement the desired rules in order to automatically transform, in complitalion time, any parts of the original source (an unique line of code, or several lines of code) into other code, in our case into PB code.
Macros like that would be the chamaleonic heart of the compiler. Should not?
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen: