Matt said:
And who is to make this definition?
I am inviting Bart Van der Donck to attempt to write the definition. I
am doing so in order that he discovers for himself that any detention
that attempts to discriminate between things that are associative
arrays and things that are not is going to put the javascript object in
the _not_ associative array side.
I have suggested a starting point, but inevitable it puts the
javascript object outside of the categorisation.
Because clearly the common
understanding used by Microsoft,
Microsoft? You are joking?
Netscape, Sun, etc is different than yours.
I have not seen any clear statement from any as to what an associative
array is.
And I would argue that their opinions carry more weight than
yours, even if you are technically more correct.
You probably would.
The difference is, you're looking to define something with absolute
certainty,
No, I am looking to demonstrate that any attempt to pin down what an
associative array is, in such a way as to exclude things that are not
associative arrays, will exclude the javascript object. The final
definition does not have to be complete, absolute or definitive. It is
the exercise of seeking it that will make my point for me.
whereas the term "associative array" is often casually used to
refer to "an object holding key/value pairs".
So that would be a definition that does not exclude the Java Vector
(which is an object that really should not be categorised as an
associative array). Do you see why I am doing this yet? You can have
your casual definition that may include javascript objects, but it will
be so loose as to be useless as things will be included that really
should not be called associative arrays.
The question that remains to be answered is whether there is a
discriminating definition of an associative array that excludes things
that should not be included like the Java Vector but can accommodate
the javascript object. I will not be you who will be proposing such a
discriminating definition.
Even if you disagree with the common use of the
term, you can't just choose to ignore it.
I can point out that it is so loose that it includes things that most
people would never accept as reasonably categorised "associative
arrays".
That's why I put it in quotes. Meaning, similar to but not identical
to Reserved Words. And I knew you would object.
Your attribution of meaning to English is sometimes extremely odd.
Maybe they are your pre-conceptions.
What are my pre-conceptions?
Maybe most people looking for a simple key/value pair
construct and using the term "associative array" don't have
those pre-conceptions.
Maybe most don't (who could say), but the many who do are the ones
being harmed by the inappropriate use of the term in association with
javascript objects. It is, after all, the consequences of their
misconceptions that motivates people to post the questions to the group
that give the impression that "associative array" thinking is a problem
causer when applied to javascript objects.
Instead of just arguing over terminology
So the incoherent sentence is not going to be clarified?
and being anal retentive when you _KNOW_ what the
intent of the question is, try to provide a more helpful
answer instead.
Why don't you? Except maybe given that previous proposed response, its
incoherent nature and your mercenary attitude towards English meaning,
you couldn't be much help in improving anyone's understanding anyway.
When you see someone ask "How can I implement an associative
array in javascript" you shouldn't think "what an idiot, there are no
associative arrays in javascript because that term implies X, Y, and
Z, and there are specific non-arbitrary keys that will cause
problems!".
Is that what I would think? Surly if someone asks how to implement an
associative array in javascript the one assumption that can be made is
that they do not believe that Javascript already has associative
arrays, else the question would be redundant?
Instead, think "what he probably wants is a simple way to
store key/value pairs.
No. If someone asks how to implement an associative array in javascript
I am going to assume that they want to be able to store any value under
an arbitrary string key, retrieve any stored values using that key and
remove the key and its corresponding value form that storage. The
simplicity/complexity of the end result is a product of what it would
have to do, not be pre-supposed by the fact that the question was
asked.
I'll explain how to use a simple Object but also warn of some
behaviors and quirks that might confuse him if he happens to
trip on them."
Right, assume the questioner doesn't really want what they are asking
for and suggest something that will only 'mostly work'.
That would be more helpful. Just MO.
And if they really wanted an associative array, and the ability to use
arbitrary keys safely, you will have wasted your own time, their time,
and possible their development effort as they go off down a dead end
and then work their way back to where they started.
There a no blanket prescription for 'more helpful'. If a question is
asked in a way that informs the reader of the context in which it is
asked it is likely better answered than if not. As soon as we are in
the world of assumptions you cannot tell if a simple quick hack is will
be most appropriate, or a pending disaster.
Richard.