Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 ( #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.

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

Replies are listed 'Best First'.
Re^6: unexpected modify hash in a distance with grep { $_ } (inconsistent behaviour of aliasing)
by LanX (Cardinal) 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
Node Status?
node history
Node Type: note [id://11110462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2020-10-24 18:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?