Es4-discuss Digest, Vol 3, Issue 2
Andrew Dupont
andrew at andrewdupont.net
Wed May 2 13:10:11 PDT 2007
On May 2, 2007, at 2:37 PM, Kris Zyp wrote:
> Also, having function/methods as slots that can be swapped with
> values seems like a fundamental concept of ES and its simplicity
> and consistency. It would seem bizarre to me to set toString to a
> primitive and expect anything but an error when coercion tried to
> convert the object to string. ES3 throws an error, and it seems
> totally logical that it should.
I agree with this. My example is willfully boneheaded for the sake of
brevity. Key safety is an issue when *arbitrary* keys are set -- for
instance, the situation described here [1].
Peter's point is illuminating, I think -- we're really just looking
for a better UI for Hash.set and Hash.get. ES3's object/hash duality
is convenient, but I'm willing to store my keys and values some other
way if it means that I can get key safety. Introducing a new
operator (like "#.") instead of Hash.set/Hash.get would minimize the
pain of giving up this duality, especially if said operator can be
overridden.
[1] http://www.andrewdupont.net/2006/05/18/javascript-associative-
arrays-considered-harmful/#comment-543
Cheers,
Andrew
More information about the Es4-discuss
mailing list