Klaas-Jan Stol schrieb:
I wonder in what case it's useful to have a "normal" .local directive in a
macro (with its normal semantics).
Every time the macro is expanded, the same local var. would be declared,
which can't be good.
As far as I understand it, PIR macros a simple text replacements with some magic,
like for '.label'. So it could be used to add  boilerplate code to subs.

E.g:

.macro init_log()
.local string my_debug
.endm

.macro log(MSG)
concat my_debug, .MSG
.endm

.macro print_log
print my_debug
.endm

.sub my_sub

.init_log()
.log( 'my log message')
.print_log()

.end


In this case a regular '.local' is more or less sensible.

So, it'd make sense to have '.local' generate a unique var within a macro,
but it does break consistency a bit (because the same directive does
different things, but arguably it does the *right* thing in different
contexts).
I would prefer to be more consistent and less magic.

Regards,
 Bernhard

Reply via email to