On Fri, Nov 21, 2008 at 09:42:41AM +0100, TSa wrote:
> HaloO,
>
> Carl Mäsak wrote:
>> 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 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()" };

Larry

Reply via email to