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
May 31, 2016 17:25
[perl #128301] [PATCH] Test to see if hash values are eagerlycreated
Message ID:
# New Ticket Created by  "B O" 
# Please include the string:  [perl #128301]
# in the subject line of all future correspondence about this issue. 
# <URL: >

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 :)


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