On 8/3/05, Aankhen <[EMAIL PROTECTED]> wrote:
> On 8/3/05, Piers Cawley <[EMAIL PROTECTED]> wrote:
> > So how *do* I pass an unflattened array to a function with a slurpy 
> > parameter?
> 
> Good question.  I would have thought that one of the major gains from
> turning arrays and hashes into references in scalar context is the
> ability to specify an unflattened array or a hash in a sub call
> without any special syntax...

Well, you can, usually.  This is particularly in the flattening
context.  In most cases, for instance:

    sub foo ($a, $b) { say $a }
    my @a = (1,2,3);
    foo(@a, "3");

Passes the array into $a.  If nothing flattened by default, then you'd
have to say, for example:

    map {...} [EMAIL PROTECTED];

And even:

    for [EMAIL PROTECTED] -> $x {...}

Which I'm not sure people want.  

And the way you pass an array in slurpy context as a single reference
is to backwhack it.  What it comes down to is that either you're
backwhacking things a lot or you're flattening things a lot.  Perl
currently solves it by making the common case the default in each
"zone" of parameters.

I would be interested to hear arguments to the contrary, however. 

Luke

Reply via email to