I'm trying to define a macro which takes a macro as an argument and
decomposes it into arguments and a body and constructs a new macro
with the same arguments but enclosing the body inside a <with>
block. <assign|noop|<macro|x|<arg|x>>> The purpose of the macro bt is to take all of the arguments and assemble them under the label "macro" <assign|bt|<xmacro|d|<map-args|noop|macro|d>>> It appears to work as this shows Looks like Macro Definition=<bt|a|b|<compound|arg|a>> But when I save and run it I find the literal <arg|d|2> instead of the body <assign|dobt|<bt|a|b|<compound|arg|a>>> Saved Macro Definition=<value|dobt> Executed Macro Definition=<dobt|ONE|TWO> I've been using a macro like the one below to show the decomposed macro - look-up works, but range doesn't work on a macro body and so in order to fully decompose the function visually I have to "know" the arity at the point I write the function. <assign|juggles|<macro|m|<tree|<arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<look-up|<value|<arg|m>>|0>|<look-up|<value|<arg|m>>|1>|<look-up|<value|<arg|m>>|2>|<look-up|<value|<arg|m>>|3>|<look-up|<value|<arg|m>>|4>|<look-up|<value|<arg|m>>|5>>>> This attempt gathers them but the tree shown has one value - which is a tuple <assign|collect-look-up|<macro|from|data|<case|<lesseq|<get-arity|<arg|data>>|<arg|from>>|<tuple|>|<equal|<get-arity|<arg|data>>|<plus|<arg|from>|1>>|<tuple|<look-up|<arg|data>|<arg|from>>>|<merge|<tuple|<look-up|<arg|data>|<arg|from>>>|<collect-look-up|<plus|<arg|from>|1>|<arg|data>>>>>> <assign|jiggles|<macro|m|<tree|Jiggles <arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<collect-look-up|0|<value|<arg|m>>>>>> I've tried to expand the tuple into arguments with unquote*: <assign|jiggles|<macro|m|<tree|Jiggles <arg|m>=<get-label|<value|<arg|m>>>(<get-arity|<value|<arg|m>>>)|<unquote*|<quote|<collect-look-up|0|<value|<arg|m>>>>>>>> I really need something like map-tuple which works the same way map-args does; or a clear way to call a macro with a tuple that becomes arguments. Sam --
Sam's signature |
Archive powered by MHonArc 2.6.19.