Matthew Walton <[EMAIL PROTECTED]> writes:

> Rod Adams wrote:
>> Does
>> ($k, $v) <== pop %hash;
>> or
>> ($k, $v) <== %hash.pop;
>> make sense to anyone except me?
>
> Makes sense to me. Although I would be more inclined to think of pop
> as returning a pair - but does a pair in list context turn into a list
> of key, value? If so then the above makes lots of sense.

  Seeing the above, I first thought up a "pair context":

($k => $v) = %hash.pop;

  However ... IIRC, in list assignment, lvalue pairs are treated as
name/value pairs, so there would be a list assignment of just one
element here.  And this is still list assignment ...

  Better to be explicit, I suppose:

($k, $v) = %hash.pop.kv;


>> If we do that, I'd also want to be able to
>> push %x, %y;
>> which would mean something like:
>> %x{%y.keys} <== %y{%y.keys};
>> but be much easier to read.
>
> Yes, I'd like that. I find myself wanting to do things like that quite
> a lot in Perl 5.

%x.push(%y);

  If no one else writes it, I will.  ;-)


Eirik
-- 
A free society is one where it is safe to be unpopular.
                -- Adlai Stevenson

Reply via email to