On 1/5/06, Netocrat <[EMAIL PROTECTED]> wrote:
> Philip Ganchev wrote:
[...]
> > Anyway, there seems to be another approach, if search efficiency is
> > not a big issue:
[...]
> 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).

A thousand apologies.  I was just searching for the original thread
when I actually thought about Netocrat's first post on this thread,
realizing that's what he meant.  The original thread is where I must
have got the idea in the first place.

> 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".

I was assuming that order will be maintained, which might make lookup
expensive, as pointed out earlier.  The order has to be simple and
predictable.  I think it should be the insertion order rather than
alphabetic order of the keys, since it is easy to sort the keys
anytime.


> > 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.

Yes - d'oh again.

> > 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".

The advantage of aliasing keys as indeces is that you can retain array
semantics like shift-on-delete. But you may be right that it is
conceptually simpler to have associative arrays with string keys, and
the keys are implicitly assigned to 1 2 3 when writing "set arr a b
c".


-------------------------------------------------------
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_idv37&alloc_id865&op=click
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to