...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.
...and for understandable (if not good) reasons: the closure inside
the string expects a parameter ($^name), which it isn't getting.
I just want to make sure that I got the problem right. Would
my $cl = { "$^name upcased becomes {$^OUTER::name.uc}" };
say $cl("larry")
work? The idea is that the embedded closure refers to the strings
$^name. And now the dwimmyness shall make that implicit, right?
That seems a bit odd to me, but if $^name merely causes a signature to be generated that declares $name as a (lexically scope) parameter, then it's just:
my $cl = { "$^name upcased becomes {$name.uc}" };
But perhaps for clarity you would just write:
my $cl = { "$^name upcased becomes $^name.uc()" };
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .