Philip Ganchev wrote:
On 1/4/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
I think both syntaxes have merit, and I'd be very happy to see more replys
about which syntax other people prefer.
I'm not sure if hashes (maps) would be useful enough to be implemented.
Anyway, there seems to be another approach, if search efficiency is
not a big issue:
fish> set arr x y z
fish> echo $array
x y z
fish> set arr[foo] bar
fish> echo $arr[foo]
bar
fish> echo $arr
x y z bar
fish> indeces arr
1 2 3 foo
That's what was suggested in the original thread, and what I've been
advocating (except that I've used @arr where you've used "indeces arr" -
the original thread didn't consider how keys would be obtained).
According to the Wikipedia article, the most generic term seems to be
"associative array": "hash" is a synonym that also implies the use of a
hash table, so you seem to have good reason to link search efficiency to
that term but in this thread so far it seems to have been used to mean
simply: "an indexable datatype that accepts string as well as integral
indices".
You might even like to refer to an element by two names:
fish> echo $arr[4]
foo
I think you mean "bar" rather than "foo" here.
fish> # is shorthand for
fish> # echo $arr[(indeces arr)[4]]
Then again, in a hash-style variable, keys are meant to be unique - I
don't think there's an advantage to aliasing them. It's not unlikely
that a user would want to store "bar" at index "foo" and "baz" at index "4".
--
http://members.dodo.com.au/~netocrat
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users