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:
Ruslan Zakirov
Date:
July 3, 2013 20:12
Subject:
Re: key/value hash and index/valuse array slices syntax
Message ID:
CAMOxC8vshRoddbFxUuL40RizvEOobjp1QWaKXbe=-LH4pBEONA@mail.gmail.com
On Mon, Jul 1, 2013 at 7:27 PM, Father Chrysostomos <sprout@cpan.org> wrote:

>
> 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.
>
> Yep, that part I figured and know how to check it during runtime. However,
in this case I think error should be thrown during compile time. Flag only
suspects lvalue sub and LVRET does additional job to confirm situation. As
far as I can see LVRET only works during runtime (may be I'm wrong). I
should dig more and try a few things, it's possible that I just don't see
obvious thing at the moment.


-- 
Best regards, Ruslan.

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