I expected this to DWIM today:

$ perl6 -e 'my $cl = { "$^name upcased becomes {$^name.uc}" }; say $cl("larry")'

...but it doesn't in Rakudo r32938:

too few arguments passed (0) - 1 params expected

...and for understandable (if not good) reasons: the closure inside
the string expects a parameter ($^name), which it isn't getting.

I'll let the IRC discussion[1] take over from here:

<moritz_> why shouldn't it work?
<masak> moritz_: because the thing inside the string is also a closure.
<moritz_> ah, I see what you mean.
<moritz_> but since you can't pass arguments to closures in strings,
it makes most sense to use the outer closure's self-declared
parameters
<moritz_> I don't know if it's specced, from a dwim'miness POV it should work.
<masak> aye
<jnthn> I could also argue that keeping placeholder parameter
semantics consistent is desirable, and saying that if you want a
closure that takes parameters you can always do a pointy instead.
<jnthn> But yes, I see the other argument too.

[1] slightly redacted for readability. Original here:
<http://irclog.perlgeek.de/perl6/2008-11-20#i_707971>

// Carl

Reply via email to