develooper Front page | perl.perl5.porters | Postings from May 2016

[perl #128301] [PATCH] Test to see if hash values are eagerlycreated

Thread Previous | Thread Next
From:
B O
Date:
May 31, 2016 17:25
Subject:
[perl #128301] [PATCH] Test to see if hash values are eagerlycreated
Message ID:
rt-4.0.18-27953-1464697743-863.128301-75-0@perl.org
# New Ticket Created by  "B O" 
# Please include the string:  [perl #128301]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128301 >


Hi everyone,

I have spoken to Zefram and TonyC on #p5p, and apparently it's not well
documented in perl which operations will eagerly create hash elements. In
foo(\$x{bla}), for example, the \ is treating its operand as an lvalue,
same as if it were on the lhs of an assignment like that. Now, foo($x{bla})
*also* treats $x{bla} as an lvalue, but doesn't eagerly create it. Instead,
it passes a PVLV to foo(), which can then create the hash element by
assigning to $_[0].

Function arguments are usually taken by value but there's no type
information to say which arguments specifically are taken by reference and
so need the lvalue treatment. This patch adds two extra tests for that
behaviour, so at least we can check whether they remain consistent.

Hope it helps :)
Thanks!

garu

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