in reply to Re: •Re: Re: %h->{foo} vs. $h{foo}..
in thread %h->{foo} vs. $h{foo}..

But I don't think it's fair to call it a bug either.. not if something similar is being implemented in Perl6.
No, that doesn't fly with me. There are hundreds of new syntax forms in Perl6.

In Perl5, the closest interpretation you could apply to %foo->{$bar} is "treat %foo in a scalar context" (which returns the N-over-M bucket usage string) "then dereference that" (as a string, it'd have to be a soft reference) "as a hash reference, and take the element with the key of $bar".

Sorry, that's just next to useless. And the implementers agreed. The only reason it worked is because %foo left the reference to foo on the stack for things like hash functions (keys, each, etc), and then the dereference arrow couldn't tell whether it was a reference from a real referencing, or from the literal name.

So, it worked only because it wasn't disallowed, as it should have been disallowed.

Please stop bringing irrelevant items into the discussion. Perl6 syntax is Perl6 syntax. Perl5 syntax had a meaning for that syntax, except the implementation was broken, and the meaning was almost always not what people accidentally typed. Hence, it is now just becoming forbidden to deal with all possible mistakes.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: %h->{foo} vs. $h{foo}..
by smferris (Beadle) on Jun 02, 2003 at 13:45 UTC

    Hmmm.. Interesting.. Now I see why it's considered a bug. Glad you could set me straight. 8)

    But.. irrelevant? That's your point of view and I will not stop.. I started the node? I could turn it into a discussion about pink elephants in green tu-tu's! Ok.. that's irrelevant.. and not something I'd do on perlmonks. (Or will I?) ;D

    My point is.. If I make a mistake.. Point out my mistake and move on.. knowing that it's a mistake I'll likely not make again. but please don't ask me not to try and understand a problem or make a comment that may help someone understand my point of view.

    If I don't ask.. I wont learn.. If I don't learn.. what's the point of this forum? It took one node Assining data to an array is slow.. to help me understand context and optimize a 6.5 hour process to under 30 minutes. That question was completely irrelevant to that project.. or was it? Sometimes answers WILL cascade into other answers.. Purely by mistake.

    Ok.. time to put this thread to rest.. Thanks for the discussion.. Believe it or not.. I have walked away with something.. I apologize if I have wasted anyones time. Just add me to your 'to filter' list. ;D

    Regards,
    SMF