Re: WeakMap API questions?

2010-09-07 Thread Sam Tobin-Hochstadt
[replying to the two issues separately] On Thu, Sep 2, 2010 at 12:47 PM, Mark S. Miller erig...@google.com wrote: Syntax aside, is the observable semantics of Names different from http://wiki.ecmascript.org/doku.php?id=strawman:inherited_explicit_soft_fields? How? If the only semantic

Re: WeakMap API questions?

2010-09-07 Thread Sam Tobin-Hochstadt
On Thu, Sep 2, 2010 at 12:47 PM, Mark S. Miller erig...@google.com wrote: In the names proposal, it seems that once in scope of a private draw declaration, all apparent uses of draw as a property name are amplifying. Even if the object being accessed has a normally named draw property,

Re: WeakMap API questions?

2010-09-03 Thread Erik Corry
2010/9/2 Mike Shaver mike.sha...@gmail.com: On Thu, Sep 2, 2010 at 11:32 AM, Erik Corry erik.co...@gmail.com wrote: Surely that is the case with WeakMap?  At least unless you lost the key and don't have any other references to the value.  In which case you can't reach the value any more, so

Re: WeakMap API questions?

2010-09-03 Thread David Herman
But HashMaps and WeakMaps both map objects to values. The difference is just that, with WeakMaps, the mapping is weak. The name is excellent, short, and clear. Perhaps ObjectMap would be better? That wouldn't distinguish them from HashMaps, since they are both object maps. WeakMap is a

Re: WeakMap API questions?

2010-09-03 Thread Mike Shaver
On Fri, Sep 3, 2010 at 8:22 AM, David Herman dher...@mozilla.com wrote: Mike momentarily forgot what they mean Yes, it was a lapse from a casual observer reading the conversations quickly; please don't let my brain-blip harm the sweet naming. Mike ___

Re: WeakMap API questions?

2010-09-03 Thread Mark S. Miller
From email on this thread and from private email I've received, I'm a bit worried that my earlier message was misunderstood. I agree that we're not going to secure JavaScript well enough to solve the covert channel problem. I stated so: On Tue, Aug 31, 2010 at 9:32 PM, Mark S. Miller

Re: WeakMap API questions?

2010-09-03 Thread Brendan Eich
On Sep 3, 2010, at 10:31 AM, Mark S. Miller wrote: From email on this thread and from private email I've received, I'm a bit worried that my earlier message was misunderstood. I wrote covert channel too, when inviiting you to reply -- sorry about that, you're right that the side channel is

Re: WeakMap API questions?

2010-09-03 Thread Mark S. Miller
On Fri, Sep 3, 2010 at 11:32 AM, Brendan Eich bren...@mozilla.com wrote: On Sep 3, 2010, at 10:31 AM, Mark S. Miller wrote: From email on this thread and from private email I've received, I'm a bit worried that my earlier message was misunderstood. I wrote covert channel too, when

Re: WeakMap API questions?

2010-09-02 Thread Erik Corry
2010/8/14 Mark S. Miller erig...@google.com: On Sat, Aug 14, 2010 at 1:01 PM, Ash Berlin ash...@firemirror.com wrote: On 14 Aug 2010, at 07:22, Erik Arvidsson wrote: I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key (using

Re: WeakMap API questions?

2010-09-02 Thread Bradley Meck
I would like to agree that .keys would expose some of the internal workings of the GC. This is true, but the solution to that could be to remove .keys() off the individual WeakMap for secure operations, however in some situations where a WeakMap is sandboxed within a closure or such, having .keys

Re: WeakMap API questions?

2010-09-02 Thread Mark S. Miller
On Thu, Sep 2, 2010 at 8:05 AM, Bradley Meck bradley.m...@gmail.com wrote: I would like to agree that .keys would expose some of the internal workings of the GC. This is true, but the solution to that could be to remove .keys() off the individual WeakMap for secure operations, Remove off of

Re: WeakMap API questions?

2010-09-02 Thread Mike Shaver
On Thu, Sep 2, 2010 at 12:46 AM, Erik Corry erik.co...@gmail.com wrote: And this is as it should be.  As it stands the weak map can be used as an object with private members.  The object key acts as a capability that controls whether or not you have access to the private member. If I were to

Re: WeakMap API questions?

2010-09-02 Thread Mark S. Miller
That page currently has TBD semantics. Two questions: Syntax aside, is the observable semantics of Names different from http://wiki.ecmascript.org/doku.php?id=strawman:inherited_explicit_soft_fields? How? If the only semantic difference is (not normally observable) less aggressive GC

Re: WeakMap API questions?

2010-09-02 Thread Mark S. Miller
On Thu, Sep 2, 2010 at 9:47 AM, Mark S. Miller erig...@google.com wrote: That page currently has TBD semantics. Two questions: Syntax aside, is the observable semantics of Names different from http://wiki.ecmascript.org/doku.php?id=strawman:inherited_explicit_soft_fields? How? If the only

Re: WeakMap API questions?

2010-09-02 Thread David Herman
That page currently has TBD semantics. Yeah, that's part of the work that needs to be done. Intuitively, it's a simple idea: ToName essentially generalizes the current semantics of property lookup; instead of trying to convert the property to a string, you try to convert it to a

Re: WeakMap API questions?

2010-09-02 Thread Erik Corry
2010/9/2 Mike Shaver mike.sha...@gmail.com: On Thu, Sep 2, 2010 at 12:46 AM, Erik Corry erik.co...@gmail.com wrote: And this is as it should be.  As it stands the weak map can be used as an object with private members.  The object key acts as a capability that controls whether or not you have

Re: WeakMap API questions?

2010-09-02 Thread Mike Shaver
On Thu, Sep 2, 2010 at 11:32 AM, Erik Corry erik.co...@gmail.com wrote: Surely that is the case with WeakMap?  At least unless you lost the key and don't have any other references to the value.  In which case you can't reach the value any more, so why would you care whether it is kept alive?

Re: WeakMap API questions?

2010-09-02 Thread Brendan Eich
On Sep 2, 2010, at 9:14 AM, Mark S. Miller wrote: (Btw, *please* don't call non-strict mode normal.) To emphasize Mark's point, ES-Harmony is based on strict mode. It's the new normal :-P. /be___ es-discuss mailing list es-discuss@mozilla.org

Re: WeakMap API questions?

2010-08-31 Thread Mark S. Miller
On Thu, Aug 26, 2010 at 9:03 PM, Brendan Eich bren...@mozilla.com wrote: On Aug 26, 2010, at 8:19 PM, Bradley Meck wrote: I am not sure that would make it a regular map. Having the keys available does not ensure that the keys will not be collected. That's the crux of the matter. Mark

Re: WeakMap API questions?

2010-08-27 Thread Bradley Meck
It is native code, all ECMAScript based solutions would leak as of right now. I am also unsure you could tell what has been collected since you would need to maintains a reference to that object, you could however tell how many objects are left for possible collection. You could do a complex

Re: WeakMap API questions?

2010-08-26 Thread Waldemar Horwat
Erik Arvidsson wrote: 3. Why isn't there a way to iterate over the keys? Because then it would be a regular map, not a weak map. This is something that only a debugger should be able to do. Waldemar ___ es-discuss mailing list

WeakMap API questions?

2010-08-14 Thread Erik Arvidsson
I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key (using has/contains)? Given that undefined is a valid value it is not sufficient to just return undefined for get 2. Why isn't there a way to remove a key-value-pair? Setting the value to

Re: WeakMap API questions?

2010-08-14 Thread Ash Berlin
On 14 Aug 2010, at 07:22, Erik Arvidsson wrote: I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key (using has/contains)? Given that undefined is a valid value it is not sufficient to just return undefined for get Does the standard

Re: WeakMap API questions?

2010-08-14 Thread Mark S. Miller
On Fri, Aug 13, 2010 at 11:22 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key (using has/contains)? Given that undefined is a valid value it is not sufficient to just return

Re: WeakMap API questions?

2010-08-14 Thread Mark S. Miller
On Sat, Aug 14, 2010 at 1:01 PM, Ash Berlin ash...@firemirror.com wrote: On 14 Aug 2010, at 07:22, Erik Arvidsson wrote: I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key (using has/contains)? Given that undefined is a valid

Re: WeakMap API questions?

2010-08-14 Thread Erik Arvidsson
Thanks for the answers Mark. On Sat, Aug 14, 2010 at 14:01, Mark S. Miller erig...@google.com wrote: On Fri, Aug 13, 2010 at 11:22 PM, Erik Arvidsson erik.arvids...@gmail.com wrote: I have a few questions regarding the WeakMap API. 1. Why isn't there a way to check for presence of a key

Re: WeakMap API questions?

2010-08-14 Thread Erik Arvidsson
I think Ash brings up a valid point here. From a usability point it is a clear win to use [], delete and in for WeakMaps and Maps. On Sat, Aug 14, 2010 at 14:02, Mark S. Miller erig...@google.com wrote: On Sat, Aug 14, 2010 at 1:01 PM, Ash Berlin ash...@firemirror.com wrote: On 14 Aug 2010, at

Re: WeakMap API questions?

2010-08-14 Thread Mark S. Miller
[+openstrat, +istvan] On Sat, Aug 14, 2010 at 3:12 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: Thanks for the answers Mark. On Sat, Aug 14, 2010 at 14:01, Mark S. Miller erig...@google.com wrote: On Fri, Aug 13, 2010 at 11:22 PM, Erik Arvidsson erik.arvids...@gmail.com wrote:

Re: WeakMap API questions?

2010-08-14 Thread Mark S. Miller
On Sat, Aug 14, 2010 at 3:16 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: I think Ash brings up a valid point here. From a usability point it is a clear win to use [], delete and in for WeakMaps and Maps. We've been over this territory before. How would you reconcile this (quite

Re: WeakMap API questions?

2010-08-14 Thread Ash Berlin
On 14 Aug 2010, at 23:58, Mark S. Miller wrote: On Sat, Aug 14, 2010 at 3:16 PM, Erik Arvidsson erik.arvids...@gmail.com wrote: I think Ash brings up a valid point here. From a usability point it is a clear win to use [], delete and in for WeakMaps and Maps. We've been over this territory