Re: Pronouns ["Re: $_ defaulting for mutating ops"]
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
Re: Pronouns ["Re: $_ defaulting for mutating ops"]
On Tue, 25 Oct 2005, Juerd wrote: for (1..9) -> $n { # ought to be more than enough eval qq[ macro prefix:<\$_$n> { "\${ "OUTER::" x $n }_" } ]; } And then you can use $_1 .. $_9. I think $_1 is much clearer than $__, but I think neither is needed in the standard language. Can I beg to differ any more? (Implicit answer: no, I can't!) Michele -- The trouble with engineers is that given the problem of knocking down a stack of 100 bricks, they will start at the top, and work all day removing them one at a time, while the mathematician will, after a momemt's thought, remove the bottom brick and be done with it. The "trouble" part, is having to brook the noise of the engineer boasting about how much harder he worked while one is trying to think about the next problem. - Bart Goddard in sci.math
Re: Pronouns ["Re: $_ defaulting for mutating ops"]
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 }_" } ]; } And then you can use $_1 .. $_9. I think $_1 is much clearer than $__, but I think neither is needed in the standard language. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Pronouns ["Re: $_ defaulting for mutating ops"]
On 2005-10-25 11:17 AM, "Michele Dondi" <[EMAIL PROTECTED]> wrote: >> I find $__ confusing, and prefer $OUTER::_, which already exists. > > Hmmm... maybe you're right that $__ is too huffmanized (and hence > confusing) but $OUTER::_ is somewhat too few... What's confusing about $__ is that it looks too much like $_. In my font, for instance, there's no gap - it's just a longer underline, which is far too subtle a difference...
Re: Pronouns ["Re: $_ defaulting for mutating ops"]
On Tue, 25 Oct 2005, Juerd wrote: Michele Dondi skribis 2005-10-25 17:05 (+0200): Now, one that I've sometimes desired is a "two level" $_, i.e. a variable, say, $__ referring to the _second next_ enclosing lexical scope. I am aware that in this vein one may ask a third analogue and so on, but let's face it: $_ already covers 95% of cases, my hypothetical var would cover I guess a remaining 4.5% of cases, and who cares for the rest? E.g.: for @vert { put_point $_, $__ for @horiz; } I find $__ confusing, and prefer $OUTER::_, which already exists. Hmmm... maybe you're right that $__ is too huffmanized (and hence confusing) but $OUTER::_ is somewhat too few... Michele -- A question out of curiousity: who is this Green of Green's functions? Is he the same person of Green's theorem? :) Yes. He was also an early environmentalist; hence the current phrases "green" this and "green" that... - David C. Ullrich in sci.math, "Re: Who is Green?"
Re: Pronouns ["Re: $_ defaulting for mutating ops"]
Michele Dondi skribis 2005-10-25 17:05 (+0200): > Now, one that I've sometimes desired is a "two level" $_, i.e. a variable, > say, $__ referring to the _second next_ enclosing lexical scope. I am > aware that in this vein one may ask a third analogue and so on, but let's > face it: $_ already covers 95% of cases, my hypothetical var would cover I > guess a remaining 4.5% of cases, and who cares for the rest? E.g.: > for @vert { > put_point $_, $__ for @horiz; > } I find $__ confusing, and prefer $OUTER::_, which already exists. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html