Re:DuckDuckGo Donates $25,000 to The Perl and Raku Foundatio...
by kstrauser on Thursday October 02, 2025 @11:14AM
(#45450809)
Why is there an arrow between $a and [2], but not between [2] and {“bar”}, in this?
$a->[2]{"bar"}
The highest rated SO answer here explains a little, and it’s the kind of situational nitpickiness that let to me dropping Perl like a hot potato when something better matching my mental model came across my radar: https://stackoverflow.com/questions/1817394/whats-the-differ...
Re:DuckDuckGo Donates $25,000 to The Perl and Raku Foundatio...
by Enk1du on Monday October 06, 2025 @06:33AM
(#45489838)
I suppose it's because very soon people got tired of writing
$a->[2]->{"bar"}
which is equivalent and also works, but suffers from the explosion of punctuation that Perl often gets criticised for. There's an element of Do What I Mean where the first arrow says this is a reference and work the rest out for me.
Re:DuckDuckGo Donates $25,000 to The Perl and Raku Foundatio...
by odc on Monday October 06, 2025 @08:45AM
(#45490767)
In Perl -> is the dereference operator, similar to C.
So when you see
$a->[2]{"bar"}
then $a is an array reference where each item is a hashmap. But with $a->[2]->{"bar"}
then $a is an array reference where each item is a reference to a hashmap.
To do this in Python is truly grim:
and thats doing it the unpythonic way, if you were to do this like the typical Python dev would accept in an MR for a large corp you would have written: They would still hate you for defaultdict(datastructure) though. Because absolutely no one in Python realises its got that level of expressionism one of the few places it does.