On Aug 24, 2008, at 7:57 PM, Mark S. Miller wrote:
> On Sun, Aug 24, 2008 at 7:44 PM, Brendan Eich <[EMAIL PROTECTED]>
> wrote:
>> [...] But
>> really, I'm wondering why it is important to have Object.eq if
>> 1.0m ===
>> 1.00m. Without Object.hashcode.
>
> I would hope Harmony would either have some kind of identity hashcode
> or some kind of built-in identity hashtable abstraction.
Absolutely.
> Given a
> function F that one knows is functional, it should be possible to
> write memoize such that memoize(F) acts like F, trading space for
> time. Without Object.eq or the equivalent, how does memoize tell
> whether its got a cache hit or miss?
We had this in the ES4 RI, implemented in ES4 (builtins/Map.es). The
Map class takes type parameters K and V and has a constructor:
function Map(equals = (function (x,y) x === y),
hashcode = intrinsic::hashcode)
NaNs all hash to code 0 (any constant would do, 0 was picked for
simplicity and interoperation). You have to avoid mapping NaN or else
provide a non-default equals function that tests isNaN() or x !== x.
Ignoring the ES4 details (type parameters, default arguments),
there's nothing here that adds a new equality operator to the
language as a whole. Anything like Map in Harmony, sans distinct type
parameters (any such would be value parameters), could do likewise.
No need for an Object.eq analogue.
/be
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss