flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > forward and reverse with zero arguments |
Author |
|
Tomasz Grysztar 28 Dec 2018, 11:05
It is mainly a matter of consistency across syntax where empty value is still a value. The symmetry becomes especially apparent when you specify a default value for an argument, but also when you have a similar macro that does not use argument grouping.
When macro uses no COMMON/FORWARD/REVERSE keywords, by default its whole body is treated as a FORWARD block. Processing an empty argument the same way as in the case of similar macro without square brackets around argument name was also a consistency point. It was also preferable for a macro to signal an error because of broken expression or missing a value instead of just silently skipping entire body when an argument was missing (likely by mistake). Thus error detection was another use case of this feature in original design. |
|||
28 Dec 2018, 11:05 |
|
Tomasz Grysztar 28 Dec 2018, 11:32
For an actual example, old-style macros that utilized this might have looked like:
Code: macro tag16 [value] { db 1Fh,2 dw value+0 } Of course nowadays you'd be more likely to use (relatively recent) syntax for default value instead: Code: macro tag16 [value:0] { db 1Fh,2 dw value } The other variant was where the base macro (for a single argument) would not work with an empty argument (broken expression, etc.) and where group variant would be also be expected to do the same. But nowadays you'd probably just use * to mark the argument as required to be non-empty there. |
|||
28 Dec 2018, 11:32 |
|
revolution 28 Dec 2018, 12:04
For my usage I often make simple call macros that have optional arguments.
Code: macro mycall function,[argument] { reverse ;or forward push argument common call function } |
|||
28 Dec 2018, 12:04 |
|
ProMiNick 28 Dec 2018, 12:48
revolution, syntax of call macro could be so as thou described. Thou just needed to override push to not causing error on empty value.
|
|||
28 Dec 2018, 12:48 |
|
revolution 28 Dec 2018, 12:55
ProMiNick wrote: revolution, syntax of call macro could be so as thou described. Thou just needed to override push to not causing error on empty value. Code: macro mycall function,[argument] { common match anything,argument \{ reverse ;or forward push argument common \} call function } |
|||
28 Dec 2018, 12:55 |
|
ProMiNick 28 Dec 2018, 13:10
not so match code needed to override push. The main thing is to avoid recursion.
push override for avoiding error on empty value is fast because is one line macro. macro push value { match any,value \{ push value \} } and usualy push most overrideble instruction by macros. so code could be added to existing macros. |
|||
28 Dec 2018, 13:10 |
|
revolution 28 Dec 2018, 13:46
Sure. That is another way. But it assumes the code always uses push. Sometimes I have more complex code in there, so for me it is easier to skip the unwanted blocks.
But my point was about the need for solutions, not the solutions themselves. I haven't found any situation where the blank argument behaviour was helpful to me. Last edited by revolution on 28 Dec 2018, 13:50; edited 1 time in total |
|||
28 Dec 2018, 13:46 |
|
Tomasz Grysztar 28 Dec 2018, 13:47
BTW, the new syntax back-ported from fasmg allows for perhaps a little better structured approach:
Code: macro mycall function,arguments& { match any,arguments \{ irp argument,any \\{ reverse push argument \\} \} call function } |
|||
28 Dec 2018, 13:47 |
|
DimonSoft 14 Aug 2022, 14:03
Tomasz Grysztar wrote: It is mainly a matter of consistency across syntax where empty value is still a value. The symmetry becomes especially apparent when you specify a default value for an argument, but also when you have a similar macro that does not use argument grouping. Doesn’t match break this consistency? Code: match any , value { … } ; This somehow doesn’t catch the empty case match , value { … } ; Still need this one Tomasz Grysztar wrote: It was also preferable for a macro to signal an error because of broken expression or missing a value instead of just silently skipping entire body when an argument was missing (likely by mistake). Thus error detection was another use case of this feature in original design. Well, in fact, this error message from somewhere deep inside nested macro invokations usually doesn’t help a macro user much anyway. |
|||
14 Aug 2022, 14:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.