develooper Front page | perl.perl5.porters | Postings from June 2013

Re: key/value hash and index/valuse array slices syntax

Thread Previous | Thread Next
Ruslan Zakirov
June 16, 2013 18:47
Re: key/value hash and index/valuse array slices syntax
Message ID:
On Sun, Jun 16, 2013 at 6:13 PM, Father Chrysostomos <>wrote:

> Ruslan Zakirov wrote:
> > A quick review of the code [2] would be helpful too.
> I have not had a chance to build your branch yet.

It's ok. I have to re-surrect summary so people who don't want to build
still can participate.

I tried to make tests as readable as possible, so you can take a look at
those and throw edge cases at me and I will grow the suite.

> I do not think allowing %h{a,b} = ... is a good idea, for the same
> reason that "$a$b" = ... is disallowed.  They both return modifiable
> temporary values, so let people modify them through for (%h{a,b}), but
> disallow %h{a,b}, because it could too easily lead to bugs.  I think you
> have implemented it the way I want it.
> Another thing I notice is the use of LVRET in pp_kvhslice.  LVRET returns
> false unless the operator has the OPpMAYBE_LVSUB flag set, which needs to
> be done in op_lvalue_flags.  That will be necessary for
> +sub:lvalue{%h{a}}->() = (undef,"value") to work.

I want to reject most lvalue operations:

1) %h{a} = ... as well as %h{qw(a b)} = ... should throw an error

2) I think lvalue subs should too as it's assignment

3) delete and local also don't work

the only exception is grep, map, foreach ops as I think the following
should behave similar:

$_++ for %hash;
$_++ for %hash{'a', 'b'};

Best regards, Ruslan.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About