On Mon, Apr 19, 2004 at 08:57:47AM -0700, Trey Harris wrote: : > : > It's easy to just say "don't nest placeholder-using closures," but that : > : > doesn't seem workable in practice since every block is a closure, unless : > : > placeholders are forbidden from all but the most trivial cases. Absurdly : > : > trivial, it seems. How about : > : > : > : > $sub = { if $^a { $^b = $^a } }; : > : : > : I want this to work. It could look at C<if>'s signature and see that : > : the closure it is expecting wants arguments, and since it doesn't, it : > : knows that they belong outside. But that doesn't generalize. : > : > I don't think I want that to work. : : Alright, you're the boss. But it does make placeholders nearly useless, : does it not, by essentially limiting them to subs containing single : expressions?
Placeholders are by nature useless in anything complex if nobody can figure out their scope. The intent is to keep the rule simple enough that you use placeholders for simple things, but -> $a,$b {...} for more complex things. Strictly speaking, they're not limited to single expressions. You just can't put them into a subordinate closure. You could have any number of statements in your block. But yes, the strong intent is to discourage their use beyond simple expressions. You may think that anything that can't be completely generalized is "nearly useless", but natural language is full of non-generalizable but nevertheless useful idioms. Linguists like to distinguish productive from non-productive affixes, for instance. A new productive suffix in English is -gate, which means "the scandal associated with..." On the other hand, the bi- prefix is on the verge of dying in English, which is partly why we found "bicoastal" funny when it was coined, I suspect. By contrast, the -ant suffix meaning "person who does..." is pretty much completely non-productive anymore. That doesn't mean we stop using words like "attendant", however. : > : I think a better solution would be to associate all placeholders with : > : the outermost closure that introduced a placeholder. For example: : > : : > : $sub = { { $^a + $^b } }; : > : : > : Would bind them both to the inner one, while: : > : : > : $sub = { $^a; { $^a + $^b } }; : > : : > : Would bind them both to the outer one. : > : > This is the sort of twisty thinking that some people can keep straight : > and some people can't. That's why we simplified the list of rules : > from the original placeholder RFC, after all. : : What is the list of rules? That's why I asked, and I'm still not clear : exactly what happens in the example I gave. Saying that my example : shouldn't work only eliminates one of the possibilities, the one where it : works, while leaving all the ways it might not work open. It being : guaranteed to do what I don't mean is a step towards making what I mean be : something closer to what it does, but it would be helpful if I knew what : it does so that I can more finely adjust what I mean. :-) There is no list of rules. There is only one rule: Placeholders bind to the most closely surrounding closure. If you want a list of rules, go see RFC 23. :-) Larry