Allow Recursive Macros
Allow Recursive Macros
PB4 is does a great job of detecting and rejecting recursive macros.
This is great protection of the programmer who only wants nice simple macros.
However, for those of us who like to do all kinds of perverse things with Macros its a little frustrating.
Could something be added to override the recursion checking, so that those of us who want to get all LISPish can?
This is great protection of the programmer who only wants nice simple macros.
However, for those of us who like to do all kinds of perverse things with Macros its a little frustrating.
Could something be added to override the recursion checking, so that those of us who want to get all LISPish can?
Dare2,
I'd like to try something like this:
I'd like to try something like this:
Code: Select all
Macro RecursiveCountDownToZero(i)
CompilerIf i > 0
RecursiveCountDownToZero(i - 1)
CompilerEndIf
EndMacro
Yes, I had a similar problem with CompilerIf and macros:
The solution is to create two macros:
Edit: oh, it's a other topic, sorry...
Code: Select all
Macro FunctionCall
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
CallFunction
CompilerElse
CallCFunction
CompilerEndIf
EndMacro
FunctionCall(1, "test")
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Macro FunctionCall
CallFunction
EndMacro
CompilerElse
Macro FunctionCall
CallCFunction
EndMacro
CompilerEndIf
FunctionCall(1, "test")
Last edited by Lebostein on Mon Mar 20, 2006 4:50 pm, edited 1 time in total.
There is another problem:GedB wrote:Code: Select all
Macro RecursiveCountDownToZero(i) CompilerIf i > 0 RecursiveCountDownToZero(i - 1) CompilerEndIf EndMacro
Variables are not allowed in CompilerIf statement. Variables are calculated at runtime ... CompilerIf statements are parsed at compile time.
i was just thinking "one way" ... because the possibility to pass a variable is there.freak wrote:Just pass a constant for i, where is the problem ?
And the "i" in the recursive macro is just working like an variable.
I assume that the replacement of all macros is just done right before compile time. So it is not possible to combine the functionality of Macros and CompileIf.
In order to get recursive macros working, there should have to be new macro-keywords ... something like MacroIf, MacroEndIf, MacroElse ...
cu,