Re: Fwd: Fwd: Draft Proposed Standard SES (Secure EcmaScript)
Matt Rice <[email protected]> Sun, 20 Mar 2016 16:02:14 -0700
| Newsgroups | gmane.comp.capabilities.general |
|---|---|
| Message-ID | <CACTLOFpR9BtfxWYr+HcdoxtEJeRO4mXnBykF=GNhVOTLVq7dWg@mail.gmail.com> |
I personally wouldn't, but the point i was trying to make is when makeCounter is untrusted code, and we can eval untrusted code into a confined space, and makeCounter can do such a thing, we can load confined code, but passing objects created by the untrusted code to multiple parties seems delicate that this static state makeCounter() is factory breaking, but reveals non-static state makeCounter is not a factory at all since a factory would inhibit such a thing. which makes me think that the scope limited eval thing must be the factory? On Sun, Mar 20, 2016 at 11:02 AM, David Nicol <[email protected]> wrote: > > Why would you move the declaration into file-scope and completely destroy > the functionality of a counter factory? The it is essential to the factory > pattern that the various instances of the created objects are independent, > having all counters refer to the same count variable instead of a new one > getting allocated at make-time completely ruins it. > > On Sun, Mar 20, 2016 at 2:16 AM, Matt Rice <[email protected]> wrote: >> >> >> var count = 0; >> >> function makeCounter() { >> // Moved var count = 0 from here to above >> // appears to be valid strict javascript afaict >> return def({ >> incr: function() { return ++count;}, >> decr: function () { return --count;} >> }); >> }