On Tue, Sep 06, 2005 at 13:28:24 +0000, Luke Palmer wrote:

This should still work:

>     sub map (&code, [EMAIL PROTECTED]) {
>         gather {
>             my @args = @list.splice(0, &code.arity);
>             take &code([EMAIL PROTECTED]);
>         }
>     }

                multi sub foo ( ... ) { ... } 
                multi sub foo ( ... ) { ... }

                my @mapped = map &foo ...;

I think this is inconsistent.

There is another option though:

        sub map (&code, [EMAIL PROTECTED]) {
                gather {
                        take &code.mutably_bind_some(@list); # removes stuff
                        # from @list
                }
        }

The code object can then look for suitable multimethod alternatives
for the arguments in question, avoid that alltogether, dispatch
based on the arity of the first alternative, dispatch based on the
arity of the most general alternative, or whatever.

I would be careful though, and only pass singly bindable, non slurpy
code refs into map in my code, in which case i'd expect
'mutably_bind_some(@list)' to be along these lines:

        method mutably_bind_some ([EMAIL PROTECTED] is rw) {
                my @bound_params = map { pop @params } 1 .. $?SELF.arity;
                $?SELF.bind_params(@bound_params);
        }

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me supports the ASCII Ribbon Campaign: neeyah!!!

Attachment: pgpZ6GyiTREuw.pgp
Description: PGP signature

Reply via email to