Hi,

Yuval Kogman wrote:
> On Sat, Aug 27, 2005 at 17:38:26 +0200, Ingo Blechschmidt wrote:
>>   ($foo, $bar)[0] =:= $foo;
>>   # False (i.e. no difference to arrays) or true?
> 
> I think this is true, because you can say:
> 
> ($foo, $bar) = (1, 2);
> 
> And more curiously:
> 
> for ($foo, $bar) { $_ = "Value" }; # implcit is rw
> for ($foo, $bar) -> $bah { $bah = "Value" }; # not is rw... is
> # it a different elem? or the same elem with behavior changed
> # for this scope?

I'd say (and this is how it's implemented in PIL2JS currently [1]) it's
the same element, but wrapped in a proxy which dies on STORE requests.
I.e.:

    for ($foo, $bar) -> $bah { $bah = "Value" }  # is really
    for ($foo, $bar) -> $bah is rw {
        (new Proxy:
            FETCH => { $bah },
            STORE => { die "Can't modify readonly..." },
        ) = "Value";
    }

> If flattenning becomes involved, then it gets harder to decide:
> 
> ($foo, @array)[2] =:= @array[1]; # i don't know about this
> ($foo, [EMAIL PROTECTED])[2] =:= @array[1]; # i think this is definately false

Hm, I'd say both are true. Consider:

    my $var;
    sub foo ([EMAIL PROTECTED]) { @args[0] =:= $var };
    foo($var, $other, $stuff);
    # Should definitely be true, I think.


--Ingo

[1] FYI, here's the relevant snippet of PIL2JS's subroutine signature
    handling code ([2], lines 263-265):

        unless($self->{tpParam}{isWritable}) {
             push @js, "$jsname = new PIL2JS.Box.ReadOnly($jsname);";
        }

[2] http://svn.openfoundry.org/pugs/perl5/PIL2JS/lib/PIL/Params.pm

-- 
Linux, the choice of a GNU | The computer revolution is over. The
generation on a dual AMD   | computers won.  -- Eduard Bloch
Athlon!                    | 

Reply via email to