in reply to •Re: Re: %h->{foo} vs. $h{foo}..
in thread %h->{foo} vs. $h{foo}..
Sorry.. Not trying to beat a dead horse here.. But I don't think it's fair to call it a bug either.. not if something similar is being implemented in Perl6. %foo.{key} is different from %foo->{key}? Both let you access a hash as a hashref, rather than as a hash. (I'm assuming this is the source of my confusion. something I don't know about the Perl6 implementation, perhaps?)
Un-Intentional, perhaps.. but a bug? Of course, I've never looked at more than a few lines of the source.. so I'm no-one to argue. 8) and please don't take it as such.. I really am just trying to see the big picture here.
I love Perl and being bashed for something stupid I've done only makes me better.. right? ;D (provided I learn from it, of course) But.. Just to clear my point of view a little further: (Bare with me, this is long, I apologize)
For instance, take a 1000 new Perl coders.. Explain that $ represents a scalar, and % represents a hash structure.. (Incomplete, I will not disagree.. but still a true statement) Now give them the code:
1> $foo='bar'; 2> $foo{'bar'}='baz!'; 3> %foo=('calvin','hobbes');
Ask them what foo represents on each line. (a hash or scalar) For the experienced perl coder, no problem. For the unexperienced, I'll bet the number of wrong answers isn't zero. (Line 2 being the one likely confused of course) Now give them the code:
1> $foo='bar'; 2> %foo->{'bar'}='baz!'; 3> %foo=('calvin','hobbes');
Ask again.. I'll bet their accuracy is a bit better.. My opinion is, the unexperienced perl coder could probably go their whole life w/o knowing about, or at least understanding refs and still write code that worked for them. Perfect example... back in the Perl 4 days.. A collegue of mine showed ME what a hash was.. Some 7-8 years later, I find myself trying to explain a hashref to them because they're trying to copy a hash (HOH) with $a{1}=$b{1} and they can't figure out why they can't modify $b{1} w/o affecting $a{1}.. But yet.. It's taken them almost 8 years to discover it. 8) (And I know they're still confused by them) I know they've used modules before and have had to instantiate them, so, indirectly they knew about 'em.. They were just unaware of them.
As for the experienced, it may not look right, but I'll bet the number of wrong answers is closer to 0.. or at least much closer than the newb people with the initial code.
Heck, Exegesis 2 is the reason I even tried %foo->{blah} to begin with.. I thought, Hmmm, what if that was available now, in 5.6.1? Let's try it.. Get used to using it.. and, Wow.. whataya know. it worked!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: •Re: Re: %h->{foo} vs. $h{foo}..
by merlyn (Sage) on May 30, 2003 at 21:02 UTC | |
by smferris (Beadle) on Jun 02, 2003 at 13:45 UTC |