Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Perl is more intuitive

by samizdat (Vicar)
on Aug 18, 2005 at 19:26 UTC ( [id://484945]=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
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

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-18 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found