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 (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