in reply to Re^2: Representing all data as Lists
in thread Representing all data as Lists (Perl7?)
It's kind of funny, because my feelings are the opposite of what blokhead describes in the last paragraph of Re^3: Representing all data as Lists; I'd actually be more inclined to support unifying the internals than changing the interface, though I don't really think either is a very good idea.
Like I said (or maybe I should have said more clearly) in my original reply, I think different things should look different. You may say the corollary is that alike things should like similar -- and I'd agree -- but in this case I dont' think a string and a list are things that are really all that alike. I can understand why someone would say they are, but I think it's a contrived likeness.
I strongly agree with Perl's current notion that a string is an individual thing (i.e. a scalar). I don't often have the need to break that thing apart and operate on its individual characters (Update: a clarification of what I meant). Perhaps that's a learned trait, but I tend to think it's more likely that instinctively seeing a string as a list is less natural.
In the case of hashes, I don't feel as strongly as I do about strings. Hashes are very list-like already, and as you pointed out, you can already coerce a list into a hash. That's a pretty natural-feeling thing, in my eyes. I still think a hash is different enough from a plain list that it deserves its own syntax and sigil, though. And Perl 6 will make it pretty easy to get a list of pairs, or a list of interwoven keys/values:
my %hash = <one 1 two 2 three 3>; say $_.join(" ") for %hash.pairs; # output: # one 1 # three 3 # two 2 say for %hash.kv; # output: # one # 1 # three # 3 # two # 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Representing all data as Lists
by Anonymous Monk on Sep 20, 2005 at 20:29 UTC | |
by revdiablo (Prior) on Sep 20, 2005 at 20:55 UTC |