Thank you for the explanation.
If that's what PB is doing it explains what's happening.
But I don't see why it has to be that way.
Based on what you wrote:
wrote:no more code is compiled, even not other macros, until an explicit written CompilerEndIf is reached.
this is my understanding of what's happening, correct me if I'm wrong.
1) The compiler encounters the invokation of BLOCK_START, it expands it to
CompilerIf (#PBCONST= 1)
and evaluates it at compile time deciding it is False.
At this point starts to ignore everything until it encounters a CompilerElse or CompilerEndIf
2) The compiler encounters and ignores
;Debug "some code"
3) The compiler encounters and ignores
;BLOCK_END
4) and goes on ignoring everything else, until it reaches the end of the source and raise the error because it didn't found a CompilerEndIf.
What is macro as PB seems to intend it ?
Helpfile wrote:A macro is a placeholder for some code which will be directly inserted in the source code at the place where a macro is used
So a macro is a fragment of code which has been given a name and whenever the name is invoked it is replaced by the contents of the macro.
Based on the above the compiler should compile the source resulting from the plain code in the source plus any macro expansion.
In my view this is what should happen with the source I posted in the first post:
1) The compiler encounters the constant definition.
2) The compiler encounters two macros definitions.
3) The compiler encounters the invokation of BLOCK_START, it's a macro so it must be expanded, and this results in
CompilerIf (#PBCONST= 1)
then it evaluates it at compile time deciding it is False.
4) The compiler encounters something which is not a macro, it's inside the block of code it shouldn't be compiled and so ignores it
;Debug "some code"
5) The compiler encounters the invokation of BLOCK_END, it's a macro so it must be expanded, and this results in
CompilerEndIf
this is closing the CompilerIf - CompilerEndIf block and all it's fine.
Considering these two different outcomes, is there any good reason why macro expansion shouldn't be treated like in the second example ?
A simple parameter-less macro should simply be a substitute for typing.
Instead of typing some code I write "A" in the source.
If the original code was valid, replacing A with that same code by expanding the macro should still be valid and yield the same results.