On Tue, Oct 25, 2005 at 05:26:32PM +0200, Juerd wrote: : Michele Dondi skribis 2005-10-25 17:17 (+0200): : > Hmmm... maybe you're right that $__ is too huffmanized (and hence : > confusing) but $OUTER::_ is somewhat too few... : : for (1..9) -> $n { # ought to be more than enough : eval qq[ : macro prefix:<\$_$n> { "\${ "OUTER::" x $n }_" } : ]; : }
That can't work as is. A macro's syntactic effect is always limited to a particular lexical scope, which is by default the lexical scope of the declaration. You'll need to find some way of installing it into the currently compiling lexical scope, which is going to resemble something more like: BEGIN { for (1..9) -> $n { # ought to be more than enough COMPILING::{"&term:<\$_$n>"} := macro { "\${ "OUTER::" x $n }_" }; } } Also, $_ has to be a term, not a prefix, or the next thing will be expected to be a term rather than an operator. But probably it shouldn't be a macro anyway, since you could just alias $_1 to $OUTER::_ etc. directly: BEGIN { for (1..9) -> $n { # ought to be more than enough COMPILING::{"\$_$n"} := COMPILING::("OUTER::" x $n)::<$_>; } } maybe with something to catch the case of too many OUTERs. Larry