On Thu, May 21, 2009 at 11:25 PM, John M. Dlugosz
<2nb81l...@sneakemail.com> wrote:
> Larry Wall larry-at-wall.org |Perl 6| wrote:
>>
>> And since the "when" modifier counts as a conditional, you can rewrite
>>
>>    grep Dog, @mammals
>>
>> as
>>
>>    $_ when Dog for @mammals;
>>
>> So perhaps will see a lot of subtypes used this way:
>>    subset Odd if Int where { $_ % 2 };
>>   �...@evens = ($_ * 2 when Odd for 0..*);
>>
>>
>
>
>   @primes = do $_ if prime($_) for 1..100;
>
> becomes
>
>   @primes = $_ when prime($_) for 1..100;
>
> ?
>
> Not sure that is any better.

subset Prime of Int where { prime($_) }
@primes = do $_ when Prime for 1..100;

But yes, something does get lost when you have to explicitly pass $_
into a function; its topical nature gets degraded.  Back when ".prime"
was shorthand for "prime $_", this wasn't a big deal; now, with the
fact that you'd somehow have to add a prime method to Int before you
could reliably say ".prime", it's a bit more of a problem.

-- 
Jonathan "Dataweaver" Lang

Reply via email to