I tried some unquote quote as an attempt preserve something past the first
quasi. The unquote should cause the quote to be evaluated which removes the
quote and leaves things as they were

<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<quasi|<with|<unquote*|<quote-arg|w>>|<unquote|<quote|<compound|<unquote*|<quote-arg|x>>>>>>>>>>>

Using compound (above) I got a segfault, using eval (below) instead (which
seemed to work when substituted in the simpler incomplete) cases emits: bad
eval bridge
<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<quasi|<with|<unquote*|<quote-arg|w>>|<unquote|<quote|<eval|<unquote*|<quote-arg|x>>>>>>>>>>>


On Thu, May 24, 2012 at 8:25 AM, Sam Liddicott <s...@liddicott.com> wrote:

> I thought I'd try implementing closures in texmacs macros instead.
>
> I want a macro that can be provided a list of variables and produce a new
> macro that is a "with" block of those variables, and then evaluates the
> parameters.
>
> The produced macro would be of this form (although possibly I would use
> eval instead of compound):
> <xmacro|x|<with|...|...|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>
>
> It seems it would work as this example shows:
> <xmacro|x|<with|a|AHA|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>
>
> The producing macro must fill in ... according to the arguments it is
> passed, indicating the variables and their values to be preserved.
>
> My first attempt at the constructing macro is:
>
> <assign|enclose|<xmacro|w|<quasi|<xmacro|x|<quasi|<with|<unquote*|<quote-arg|w>>|<compound|<unquote*|<quote-arg|x>>>>>>>>>
>
> Note the nested quasi. I need the first unquote* to be expanded by the
> first quasi, and the second quasi to be preserved along with the second
> unquote*, but nesting makes this hard, because the first quasi encloses the
> second quasi which encloses both unquote*
>
>
> <assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|<quote|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>>>>>
>
> otherwise the idea works as this hard-wired version shows:
> <assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|Hello
>  <value|a>
> there>>>>>
>
> That hard wired version fixes the body, and can be executed with:
> <assign|tc|<enclose|a|HEE HEE>>
> <tc>
>
> I tried deferring the body execution into an xcompound macro, like this:
> <assign|xcompound|<xmacro|x|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>
>
>
> <assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|<xcompound|<arg|x>>>>>>>
>
> But then texmacs just segfaults. I guess to call xcompound still needs to
> be using quasi unquote* quote-arg
>
> Can anyone help me preserve SECOND quasi and unquote* in the emitted macro
> while still allowing the FIRST unquote* in the with block to be expanded?
>
> Sam
>
_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/texmacs-dev

Reply via email to