Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: unexpected modify hash in a distance with grep { $_ } (inconsistent behaviour of aliasing)

by dave_the_m (Monsignor)
on Dec 21, 2019 at 00:01 UTC ( [id://11110462]=note: print w/replies, xml ) Need Help??


in reply to Re^4: unexpected modify hash in a distance with grep { $_ } (inconsistent behaviour of aliasing)
in thread unexpected modify hash in a distance with grep { $_ }

To clarify:

I am happy with the fact that 'for', 'grep' etc evaluate their args in lvalue context and thus autovivify, and I don't wish it to change. I find that this behaviour makes the rules for autovivification logically simple(r) and consistent.

I am unhappy with the deferring mechanism in hash lookups when used as an arg to a function call. It's a tricksy special-case behaviour and is hard to explain (above, I had to start talking about PVLVs and showing the output of Devel::Peek). It adds performance + memory overhead for such function calls, and is too clever for its own good. But I'm not proposing that it be be changed, since it was intentional behaviour added over 20 years ago.

Dave.

Replies are listed 'Best First'.
Re^6: unexpected modify hash in a distance with grep { $_ } (inconsistent behaviour of aliasing)
by LanX (Saint) on Dec 21, 2019 at 18:50 UTC
    > I find that this behaviour makes the rules for autovivification logically simple(r) and consistent.

    Maybe... But if it was that easy why can't we find it documented in the perldocs.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2024-03-28 09:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found