[ZPT] Some Macros Questions/Suggestions

Chris Withers chrisw@nipltd.com
Tue, 05 Mar 2002 13:34:15 +0000


Evan Simpson wrote:
> 
> Chris Withers wrote:
> > 2. In macro templates, where does here bind to?
> 
> All use-macro-ed code operates in exactly the same context as the code
> it is expanded into.  So, not only are 'here' and 'template' the same as
>   in surrounding (and fill-slot) code, so are tal:define-d variables.
> This allows loose "parameterization" of macros, as Dieter has pointed out.

Cool :-)

> > 3. Is there any reason why define-macro and fill-slot aren't allowed on the same tag? It
> > would be cool for recursive definey things...
> 
> Simplicity of implementation, and nobody has really worked out in detail
> how all the metal statements should really interact on the same tag.

Where and how would be good to kick off a discussion about this?

> > 4. How hard would it be to implement a fill-attribute thing so that the following would
> > work:
> >
> > <body metal:define-attribute="bgcolor" bgcolor="#FFFFFF">
> > <body metal:fill-attribute="bgcolor string:#FEFEFE">
> Looks simple to a human, but potentially tricky for code.  Consider the
> following:
> 
> [Macro]
> <a href="foo" metal:define-attribute="href">Foo!</a>
> ...
> <a href="bar" metal:define-attribute="href">Bar!</a>
> 
> [Use Macro]
> <a href="foo">Foo!</a>
> ...
> <a href="bar" metal:fill-attribute="href string:notbar">Bar!</a>
> 
> We see an "obvious" interpretation, and it might even be able to be
> rigorously defined, but I'm not up for it.

Hmmm, how about this:

[macro]
<a href="foo" metal:define-attribute="href one">Foo!</a>
...
<a href="bar" metal:define-attribute="href two">Bar!</a>

[Use Macro]
<a href="foo">Foo!</a>
...
<a href="bar" metal:fill-attribute="one string:notbar">Bar!</a>

cheers,

Chris