Re: Object id, hash, etc?

2015-09-11 Thread Brendan Eich
Tab Atkins Jr. wrote: Using a primitive string as a key can inadvertently leak the value for a long time, as the key might be interned and long-lived, far past the point when your code has dropped the intended references to it. Indeed. Strings do not have observable reference semantics at

Re: Object id, hash, etc?

2015-09-11 Thread Andrea Giammarchi
gt; } >>>>> ); >>>>> ``` >>>>> >>>>> Regards >>>>> >>>>> On Tue, Sep 8, 2015 at 9:57 PM, Michael McGlothlin < >>>>> mike.mcgloth...@gmail.com> wrote: >>>>> >>>>>> I tr

Re: Object id, hash, etc?

2015-09-10 Thread Tab Atkins Jr.
On Thu, Sep 10, 2015 at 11:02 AM, Michael McGlothlin wrote: > One issue I did notice with WeakMaps is that because it can't use primative > values as keys that they'll throw errors unless otherwise handled. Checking > if they are an instanceof Object and if not using

Re: Object id, hash, etc?

2015-09-10 Thread Bradley Meck
s[Symbol.identity]; >>>>> } >>>>> } >>>>> ); >>>>> ``` >>>>> >>>>> Regards >>>>> >>>>> On Tue, Sep 8, 2015 at 9:57 PM, Michael McGlothlin < >>>>> mike.mcgloth..

Re: Object id, hash, etc?

2015-09-10 Thread Michael McGlothlin
>>>> have to define it manually. >>>>> >>>>> Symbol.identity = Symbol( 'Symbol.identity' ); >>>>> const identity = Symbol( 'identity' ); >>>>> var OBJECT_ID = 0; >>>>> Object.defineProperty( Object.prototype, Symb

Re: Object id, hash, etc?

2015-09-09 Thread Andrea Giammarchi
identity = Symbol( 'identity' ); >>>> var OBJECT_ID = 0; >>>> Object.defineProperty( Object.prototype, Symbol.identity, { >>>> get: () => { >>>>if ( !Object.hasOwnProperty.call( this, identity ) ) { >>>> this[ identity ] =

Re: Object id, hash, etc?

2015-09-09 Thread Andrea Giammarchi
t;>> this[ identity ] = ++OBJECT_ID; >>>} >>>return this[ identity ]; >>> } >>> } ); >>> >>> On Tue, Sep 8, 2015 at 1:44 PM, Mark S. Miller <erig...@google.com> >>> wrote: >>> >>>> See L

Re: Object id, hash, etc?

2015-09-09 Thread MichaƂ Wadas
<joe...@gmail.com> wrote: >>> >>>> Didn't send to list, something is wrong with my reply all. Sorry about >>>> that. Stupid mobile gmail. >>>> -- Forwarded message -- >>>> From: "joe" <joe...@gmail.com> &

Re: Object id, hash, etc?

2015-09-09 Thread Michael McGlothlin
0; >>>> Object.defineProperty( Object.prototype, Symbol.identity, { >>>> get: () => { >>>>if ( !Object.hasOwnProperty.call( this, identity ) ) { >>>> this[ identity ] = ++OBJECT_ID; >>>>} >>>>return this[ id

Re: Object id, hash, etc?

2015-09-09 Thread Michael McGlothlin
>> <mike.mcgloth...@gmail.com> wrote: >>>>>> I try to keep it pretty simple. It's not fancy but the times you want >>>>>> fast and dirty information like this are the same times you don't want >>>>>> to have to define it manually. >

Re: Object id, hash, etc?

2015-09-09 Thread Brendan Eich
For posterity: http://wiki.ecmascript.org/doku.php?id=proposals:hashcodes http://wiki.ecmascript.org/doku.php?id=discussion:hashcodes (from ES4 daze, a long time ago.) /be Michael McGlothlin wrote: Is there a reason not to provide an object id and hash value as other languages often do? I

Re: Object id, hash, etc?

2015-09-09 Thread Brendan Eich
Michael McGlothlin wrote: I'm only seeing a couple comments there - was that all or am I missing something? Did you read the note about security? I think hashes as an overwritable method that returns a number is pretty standard and let's you combine member hashes with simple Bitwise ops.

Re: Object id, hash, etc?

2015-09-09 Thread Michael McGlothlin
I'm only seeing a couple comments there - was that all or am I missing something? I think hashes as an overwritable method that returns a number is pretty standard and let's you combine member hashes with simple Bitwise ops. Could have on value types and a default on Object that would combine

Re: Object id, hash, etc?

2015-09-08 Thread Mark S. Miller
rwarded message -- > From: "joe" <joe...@gmail.com> > Date: Sep 8, 2015 11:15 AM > Subject: Re: Object id, hash, etc? > To: "Garrett Smith" <dhtmlkitc...@gmail.com> > Cc: > > I agree with this request. This is the logical complement to valueof, I >

Re: Object id, hash, etc?

2015-09-08 Thread Mark S. Miller
On Tue, Sep 8, 2015 at 1:57 PM, Michael McGlothlin < mike.mcgloth...@gmail.com> wrote: > I try to keep it pretty simple. It's not fancy but the times you want fast > and dirty information like this are the same times you don't want to have > to define it manually. > > Symbol.identity = Symbol(

Re: Object id, hash, etc?

2015-09-08 Thread Tab Atkins Jr.
On Tue, Sep 8, 2015 at 2:07 PM, Mark S. Miller wrote: > On Tue, Sep 8, 2015 at 1:57 PM, Michael McGlothlin > wrote: >> >> I try to keep it pretty simple. It's not fancy but the times you want fast >> and dirty information like this are the same

Re: Object id, hash, etc?

2015-09-08 Thread Mark S. Miller
Hi Tab, then you get the Labeler, which this message is responding to. On Tue, Sep 8, 2015 at 2:12 PM, Tab Atkins Jr. wrote: > On Tue, Sep 8, 2015 at 2:07 PM, Mark S. Miller wrote: > > On Tue, Sep 8, 2015 at 1:57 PM, Michael McGlothlin > >

Re: Object id, hash, etc?

2015-09-08 Thread Andrea Giammarchi
te: >> >>> Didn't send to list, something is wrong with my reply all. Sorry about >>> that. Stupid mobile gmail. >>> -- Forwarded message -- >>> From: "joe" <joe...@gmail.com> >>> Date: Sep 8, 2015 11:15 AM >>> Subject: Re: Obj

Re: Object id, hash, etc?

2015-09-08 Thread Michael McGlothlin
-- Forwarded message -- >> From: "joe" <joe...@gmail.com> >> Date: Sep 8, 2015 11:15 AM >> Subject: Re: Object id, hash, etc? >> To: "Garrett Smith" <dhtmlkitc...@gmail.com> >> Cc: >> >> I agree with this

RE: Object id, hash, etc?

2015-09-08 Thread Gary Guo
Changing toString() is obviously not possible since the semantics are fixed and many existing code depends them (ex. Object.prototype.toString are used for type identifying, String.prototype.toString are used for meta-programming frameworks. I think you can extend Object.prototype to provide a

Object id, hash, etc?

2015-09-08 Thread Michael McGlothlin
Is there a reason not to provide an object id and hash value as other languages often do? I find myself defining an identity symbol on objects with a value from a simple global counter. It makes it easier to debug if I can just look at a log and see what objects and functions were active.

Re: Object id, hash, etc?

2015-09-08 Thread joe
Didn't send to list, something is wrong with my reply all. Sorry about that. Stupid mobile gmail. -- Forwarded message -- From: "joe" <joe...@gmail.com> Date: Sep 8, 2015 11:15 AM Subject: Re: Object id, hash, etc? To: "Garrett Smith" <dhtmlki