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

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

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
July 1, 2013 15:27
Subject:
Re: key/value hash and index/valuse array slices syntax
Message ID:
A435BB38-1883-42AB-89BA-EB948CFD432D@cpan.org

On Jul 1, 2013, at 5:52 AM, Ruslan Zakirov <ruz@bestpractical.com> wrote:

> 
> 
> 
> On Sun, Jun 16, 2013 at 11:31 PM, Father Chrysostomos <sprout@cpan.org> wrote:
> 
> On Jun 16, 2013, at 11:47 AM, Ruslan Zakirov <ruz@bestpractical.com> wrote:
> > 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
> 
> $ ./perl -Ilib -le '$_ = "hello"; (sub : lvalue { %{{"hello" => 2}}{$_} }->()) = 3; print $_'
> 3
> 
> Can I check during compile time that an op is used as return value of a lvalue sub? LVRET is runtime thing. Can not find example in the code. A pointer or a list of flags to look at?

Look for OPpMAYBE_LVSUB in op.c:op_lvalue_flags.  Without that flag, LVRET always returns 0 at run time.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About