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

Re: Referencing a caller's slurpy array.

Thread Previous | Thread Next
From:
Luke Palmer
Date:
March 16, 2005 15:53
Subject:
Re: Referencing a caller's slurpy array.
Message ID:
20050316235505.GA1806@navi.cx
Rod Adams writes:
> >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;
>     }
>   }
> }

That's the listop form.  I was referring to the method form:

    multi sub grep (@array: *&code) returns List {
        ...
    }

The fact that there is a conflict in context in the argument points out
one of the weaknesses of the current multi declaraition semantics.
Currently, it would just default to list context.

I think the *compiler* should be able to tell the difference between the
two forms without having to go to runtime method dispatch (perhaps it
still does dispatch, but if you're in the latter form, you don't even
try to dispatch to the former routine).  But that's a big brainstorm
that needs to happen, and I'm not prepared to do that right now.

Luke

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