develooper Front page | perl.perl6.language | Postings from March 2005

Re: Referencing a caller's slurpy array.

Thread Previous | Thread Next
From:
Rod Adams
Date:
March 16, 2005 11:22
Subject:
Re: Referencing a caller's slurpy array.
Message ID:
4238875A.60905@rodadams.net
Luke Palmer wrote:

>Larry Wall writes:
>  
>
>>Certainly.  The zone markers are as orthogonal to sigils as we can
>>make 'em.  Though I'm not sure we've given a meaning to *&foo yet.
>>I suppose that would have to mean that the next slurpy parameter has
>>to be a sub ref.
>>    
>>
>
>Uhmm... isn't *&foo the adverbial block?  That is, isn't it where grep
>gets its code block in:
>
>    @list.grep:{ $_ % 2 }
>
>  
>
In S29, I currently have C<grep> as:

 multi sub grep (Any|Junction $test : *@values) returns List {
   gather {
     for @values -> $x {
       take $x if $x ~~ $test;
     }
   }
 }


If you wish to supply a closure for C<$test>, you're free to do so.


If I were building it to accept just a closure, I would think:

   multi sub grep (Code &test : *@values)

or

   multi sub grep (: Code +&test = &defaulttest ,  *@values)


would make more sense than:

   multi sub grep (: Code *&test, *@values)


At least to me it does. If you see some advantage to that way, please 
inform me of it. It might change C<map> away from:

 multi sub map (Code $expression : *@values) returns List {
   gather {
     while @values {
       take $expression
          .( splice(@values, 0, $expression.arity) );
     }
   }
 }


-- Rod Adams




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About