Why doesn't this produce a syntax error? I added the "dd" bit on purpose so the IDE would take me back there when I tried to compile after being somewhere else in the source, but no error occurred. The "dd" isn't part of the macro?
Macro KeyIsDown(key)
GetAsyncKeyState_(key) & $8000
EndMacro
If KeyIsDown(#VK_SHIFT)dd ; Added "dd" to force a syntax error, but doesn't?
Debug "down"
EndIf
Last edited by BarryG on Wed Oct 09, 2024 1:21 pm, edited 1 time in total.
Macro KeyIsDown(key)
GetAsyncKeyState_(key) & $8000
EndMacro
If KeyIsDown(#VK_SHIFT) dd ; Added " dd" to force a syntax error, but doesn't?
Debug "down"
EndIf
While PureBasic's Macro() function is quite versatile, and quite different from macros in other languages, it does leave some syntactical rules to be desired.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!Please visit my YouTube Channel
TI-994A wrote: Fri Oct 11, 2024 5:10 pm
While PureBasic's Macro() function is quite versatile, and quite different from macros in other languages, it does leave some syntactical rules to be desired.
I see no reason to disallow it. The C preprocessor would allow for many, if not all of, the same things. Plus I'm uncertain how this would even be fixed in the compiler, the macros are replaced at compile-time and there would really be no good way of telling the compiler where a macro ends and other tokens start without breaking functionality.
Quin wrote: Fri Oct 11, 2024 5:30 pmThe C preprocessor would allow for many, if not all of, the same things.
I'm pretty sure that such expression-concatenation is not possible in C. PureBasic implements its own text-substitution function for its macros.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!Please visit my YouTube Channel