in reply to Perl is more intuitive
A cow-orker and I were just ruminating over this, and I made the point that I wish that Ruby references were typed differently for hashes and arrays, as in a{x}[y]. One could sort of argue that arrays are just a special case of hashes, but that leaves out the ordinality and indexability of arrays which is not possible for hashes. They only overlap in some ways.
Perl's typing does help here, but I have to say that the rest of Perl's reference syntax is abominable, at least for multi-level references to structures, and Ruby's clarity here far outweighs Perl's typing by first character indicator. When you reference an array or hash element, you're going to make it clear enough by using either a numeric symbol or a string as the key / index which you're accessing. It's more problematic when it's a variable in the brackets, but if you don't know what your variables are doing at night, you're already really in the dark. :D
Re^2: Perl is more intuitive
by Fletch (Bishop) on Aug 19, 2005 at 14:07 UTC
|
Ah, but the overlap is a feature. Not to mention that by adding a few methods ([], []=, etc.) you can make objects look Array- or Hash-like. As with tie in Perl there's places it makes sense and places it doesn't, of course. See the chapter on "Duck Typing" in the second edition Pickaxe for more discussion.
--
We're looking for people in ATL
| [reply] [d/l] [select] |
|
Haven't even gotten to PA#2 yet, 1.6 and PA#1 are so @ss-kicking that I'm grokking hard. Helps that I used to be a heavy Smalltalk user. Subclassing Arrays and Hashes and Strings comes naturally, though I miss the groovy IDE.
| [reply] |
|