Nested macroses
Feature request Implement feature that allow define macros inside macros.
It can be cool for meta-programming and implementing DSLs inside sjasmplus(it really can be useful).
For example:
macro def_proc name
macro name
dw name_proc
endm
name_proc:
endm
and later
def_proc cls
xor a
ld hl, #4000, de, #4001, bc, 6911, (hl), a
ldir
next ; some macros to change to next instruction
and in part where interpreter work
call kernal.run
cls
loop 10
someproc_1
vsync
end_loop
cls
Cause I'm making some interpreter engine it will be very useful for me.
In your example case (work-around proposal), you could do this:
macro def_proc name
define do_name dw name_proc
name_proc:
endm
def_proc cls
xor a
ld hl, #4000, de, #4001, bc, 6911, (hl), a
ldir
do_cls
; must have the "do_" or some other prefix
; can't define just "cls" without recursion accident
(it's actually kinda funny you can define do_cls inside the macro, outside of macro you would define do_name as the substitution would not touch the define identifier, but because it's inside macro and macro argument, it gets substituted even there, producing final line define do_cls dw cls_proc, I didn't expect it to work like this, just tried it blindly if it does anything)
This issue is still valid enhancement proposal, even if the workaround is good enough for your project, as the workaround can cover only very limited cases, so leaving it open.
I was also trying to produce some more clever lua workaround, but actually you can't define macros from lua either, not even outside of macro, because there is no way to parse multi-line piece of source from lua, and macro can't be defined by single statement (the colons are treated like end-of-line internally, so that can't be used to avoid the limitation).