Re: Cross-global instanceof

2013-11-02 Thread Allen Wirfs-Brock
On Nov 2, 2013, at 11:25 AM, Mark S. Miller wrote: > On Sat, Nov 2, 2013 at 10:55 AM, Allen Wirfs-Brock > wrote: > [...] If the reasons for removing Proxy.isProxy are valid then we should be > providing such a backdoor. > > not? > shouldn't > > -- > Cheers, > --MarkM

Re: Cross-global instanceof

2013-11-02 Thread Mark S. Miller
On Sat, Nov 2, 2013 at 10:55 AM, Allen Wirfs-Brock wrote: > [...] If the reasons for removing Proxy.isProxy are valid then we should > be providing such a backdoor. > not? -- Cheers, --MarkM ___ es-discuss mailing list es-discuss@mozilla.org

Re: Cross-global instanceof

2013-11-02 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 7:13 PM, Allen Wirfs-Brock wrote: > > On Nov 1, 2013, at 6:05 PM, David Bruant wrote: > >> Le 02/11/2013 01:08, Brandon Benvie a écrit : >>> On 11/1/2013 4:59 PM, Brandon Benvie wrote: On 11/1/2013 4:31 PM, Brandon Benvie wrote: > In the spec for Object.prototype.toS

Re: Cross-global instanceof

2013-11-02 Thread David Bruant
Le 02/11/2013 03:13, Allen Wirfs-Brock a écrit : On Nov 1, 2013, at 6:05 PM, David Bruant wrote: I'm not sure about proxy returning "Proxy" as tag name. Is that a good idea? Brand feels like something that could safely transparently cross proxies. There is a note on in the ES6 draft on that Pr

Re: Cross-global instanceof

2013-11-02 Thread Jake Verbaten
> What are the use cases for things like 'isGenerator'. When and why would you need to know that an object upon which you are going to invoke the Iterator interface was/wasn't implemented by a generator. [`co`][1] is a library similar to Task.js that allows you to use ES6 generators as async / aw

Re: Cross-global instanceof

2013-11-01 Thread Brandon Benvie
On 11/1/2013 8:54 PM, Allen Wirfs-Brock wrote: This just reminds me how cold I still am on the fact that you can't easily one-off Proxy anything that's not a plain Object, Array, or Function because of the lack of an invoke trap and every other type of built-in has private state... but I suppo

Re: Cross-global instanceof

2013-11-01 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 7:27 PM, Brandon Benvie wrote: > On 11/1/2013 7:13 PM, Allen Wirfs-Brock wrote: >> Or we could simply not special case Proxy exotic objects and then Proxies >> would be handled like any other object, the value of the objects >> @@toStringTag property would be accessed and use

Re: Cross-global instanceof

2013-11-01 Thread Brandon Benvie
On 11/1/2013 7:13 PM, Allen Wirfs-Brock wrote: Or we could simply not special case Proxy exotic objects and then Proxies would be handled like any other object, the value of the objects @@toStringTag property would be accessed and used to compose the toString result. Which would result in thi

Re: Cross-global instanceof

2013-11-01 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 6:05 PM, David Bruant wrote: > Le 02/11/2013 01:08, Brandon Benvie a écrit : >> On 11/1/2013 4:59 PM, Brandon Benvie wrote: >>> On 11/1/2013 4:31 PM, Brandon Benvie wrote: In the spec for Object.prototype.toString: 'If tag is any of "Arguments", "Array", "Boolea

Re: Cross-global instanceof

2013-11-01 Thread David Bruant
Le 02/11/2013 01:08, Brandon Benvie a écrit : On 11/1/2013 4:59 PM, Brandon Benvie wrote: On 11/1/2013 4:31 PM, Brandon Benvie wrote: In the spec for Object.prototype.toString: 'If tag is any of "Arguments", "Array", "Boolean", "Date", "Error", "Function", "Number", "RegExp", or "String" and

Re: Cross-global instanceof

2013-11-01 Thread Brandon Benvie
On 11/1/2013 4:59 PM, Brandon Benvie wrote: On 11/1/2013 4:31 PM, Brandon Benvie wrote: In the spec for Object.prototype.toString: 'If tag is any of "Arguments", "Array", "Boolean", "Date", "Error", "Function", "Number", "RegExp", or "String" and SameValue(tag, builtinTag) is false, then let

Re: Cross-global instanceof

2013-11-01 Thread Brandon Benvie
On 11/1/2013 4:31 PM, Brandon Benvie wrote: In the spec for Object.prototype.toString: 'If tag is any of "Arguments", "Array", "Boolean", "Date", "Error", "Function", "Number", "RegExp", or "String" and SameValue(tag, builtinTag) is false, then let tag be the string value "~" concatenated wit

Re: Cross-global instanceof

2013-11-01 Thread Mark S. Miller
I just read https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring and agree that it continues to preserve the brand checks that were reliable in ES5. Cool! Thanks! On Fri, Nov 1, 2013 at 4:31 PM, Brandon Benvie wrote: > On 11/1/2013 4:29 PM, Mark S. Miller wrote:

Re: Cross-global instanceof

2013-11-01 Thread Brandon Benvie
On 11/1/2013 4:29 PM, Mark S. Miller wrote: Hi Allen, perhaps I misunderstood. But I thought that as of ES6, O.p.toString can't be used for reliable brand checking of anything, including legacy ES<=5 built-ins. Not so? How would I do such a check of a legacy built-in in ES6? In the spec for O

Re: Cross-global instanceof

2013-11-01 Thread Mark S. Miller
On Fri, Nov 1, 2013 at 4:03 PM, Allen Wirfs-Brock wrote: > > On Nov 1, 2013, at 12:16 PM, Andrea Giammarchi wrote: > > > Allen I think we all agree duck typing is more flexible, powerful, easy, > etc etc ... but since you mentioned, how would do distinguish between a > `Map` and a `WeakMap` withou

Re: Cross-global instanceof

2013-11-01 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 1:11 PM, Mark S. Miller wrote: > For the ES6 builtin types, I have no idea. > Most branded ES6 built-ins have non-destructive brand-checking methods that call be used to perform brand checks. For example, function isMap(obj) { try {Map.prototype.size.call(obj); retu

Re: Cross-global instanceof

2013-11-01 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 12:16 PM, Andrea Giammarchi wrote: > Allen I think we all agree duck typing is more flexible, powerful, easy, etc > etc ... but since you mentioned, how would do distinguish between a `Map` and > a `WeakMap` without passing through the branding check ? > > That's a very good

Re: Cross-global instanceof

2013-11-01 Thread Mark Miller
http://wiki.ecmascript.org/doku.php?id=strawman:relationships On Fri, Nov 1, 2013 at 1:11 PM, Mark S. Miller wrote: > For the ES6 builtin types, I have no idea. > > For abstractions you define yourself, your abstraction can brand its > objects using an encapsulated WeakSet or WeakMap. This will

Re: Cross-global instanceof

2013-11-01 Thread Mark S. Miller
For the ES6 builtin types, I have no idea. For abstractions you define yourself, your abstraction can brand its objects using an encapsulated WeakSet or WeakMap. This will work, but with two problems: * Awkward syntax until more directly supported by ES7 relationships. * Sucky performance until

Re: Cross-global instanceof

2013-11-01 Thread Andrea Giammarchi
Thanks Mark, so how is anyone supposed to be sure about or check a Brand in ES6 then? On Fri, Nov 1, 2013 at 1:00 PM, Mark S. Miller wrote: > > > > On Fri, Nov 1, 2013 at 12:16 PM, Andrea Giammarchi < > andrea.giammar...@gmail.com> wrote: > >> Allen I think we all agree duck typing is more

Re: Cross-global instanceof

2013-11-01 Thread Mark S. Miller
On Fri, Nov 1, 2013 at 12:16 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Allen I think we all agree duck typing is more flexible, powerful, easy, > etc etc ... but since you mentioned, how would do distinguish between a > `Map` and a `WeakMap` without passing through the branding

Re: Cross-global instanceof

2013-11-01 Thread Andrea Giammarchi
Allen I think we all agree duck typing is more flexible, powerful, easy, etc etc ... but since you mentioned, how would do distinguish between a `Map` and a `WeakMap` without passing through the branding check ? That's a very good example indeed, `'has' in obj` or `'set' in obj` does not grant you

Re: Cross-global instanceof

2013-11-01 Thread Allen Wirfs-Brock
On Nov 1, 2013, at 10:40 AM, Anne van Kesteren wrote: > On Fri, Nov 1, 2013 at 12:50 AM, Allen Wirfs-Brock > wrote: >> [isSpecialString]() {return isSpecialString in this}; > > So this is basically what we have for DOM objects right now. And what > we're asking for is having this elevated to la

Re: Cross-global instanceof

2013-11-01 Thread Anne van Kesteren
On Fri, Nov 1, 2013 at 12:50 AM, Allen Wirfs-Brock wrote: > [isSpecialString]() {return isSpecialString in this}; So this is basically what we have for DOM objects right now. And what we're asking for is having this elevated to language-supported construct. Be it in the form of a method or someth

Re: Cross-global instanceof

2013-11-01 Thread Andrea Giammarchi
I have no idea who is doing that and why but yes, in that case I would never have used instanceof so my example is still valid as use case itself. Cheers On Thu, Oct 31, 2013 at 11:54 PM, Oliver Hunt wrote: > > On Nov 1, 2013, at 7:23 PM, Andrea Giammarchi > wrote: > > also, your reviver woul

Re: Cross-global instanceof

2013-10-31 Thread Oliver Hunt
On Nov 1, 2013, at 7:23 PM, Andrea Giammarchi wrote: > also, your reviver would receive objects from the realm I am checking with > that code ... so your reviver will receive object from the **expected** realm > ... just to clarify, for future readers. > I don’t understand what you’re sayin

Re: Cross-global instanceof

2013-10-31 Thread Andrea Giammarchi
also, your reviver would receive objects from the realm I am checking with that code ... so your reviver will receive object from the **expected** realm ... just to clarify, for future readers. Still all ears listening to that case I've never, honestly, considered! Thanks On Thu, Oct 31, 2013 a

Re: Cross-global instanceof

2013-10-31 Thread Andrea Giammarchi
Sure, so Allen asked me a real case to show, and I've done it. Now you please show me a real case when you pass a revival function to `JSON.parse` that is from another realm, explaining why, as I've done for mine, thanks. Best Regards On Thu, Oct 31, 2013 at 7:41 PM, Oliver Hunt wrote: > > On

Re: Cross-global instanceof

2013-10-31 Thread Oliver Hunt
On Nov 1, 2013, at 2:46 PM, Andrea Giammarchi wrote: > Allen, in which place on current known universe, when you parse a > JSON.string, your reviver function receives objects from another realm, > exactly? Please try to keep the discourse polite. That said this is fairly trivial function r

Re: Cross-global instanceof

2013-10-31 Thread Andrea Giammarchi
Allen, in which place on current known universe, when you parse a JSON.string, your reviver function receives objects from another realm, exactly? That logic is bypassing and full-satisfying JSON.parse revival expectations returning object later on checked as instanceof String in order to differen

Re: Cross-global instanceof

2013-10-31 Thread Allen Wirfs-Brock
On Oct 31, 2013, at 2:56 PM, Andrea Giammarchi wrote: > Sorry, secure was actually "reliable", as being secure about the type, not > about security itself. > > A case where I do use instanceof is, example, with new String to easily > decide later on what to do with such object that should not

Re: Cross-global instanceof

2013-10-31 Thread Andrea Giammarchi
Sorry, secure was actually "reliable", as being secure about the type, not about security itself. A case where I do use instanceof is, example, with new String to easily decide later on what to do with such object that should not be treated as such. The script does resolve circular dependencies b

Re: Cross-global instanceof

2013-10-31 Thread Allen Wirfs-Brock
On Oct 31, 2013, at 1:58 PM, Andrea Giammarchi wrote: > I think the question is legit and this is a weak check > > `'throw' in possibleGenerator` > > specially if you have Dictionary like objects around ... And why would such an object be passed into a context where you expect to have a gener

Re: Cross-global instanceof

2013-10-31 Thread Andrea Giammarchi
I think the question is legit and this is a weak check `'throw' in possibleGenerator` specially if you have Dictionary like objects around ... 'length' in object does not tell you much, does it? `Object.prototype.toString` is abused all over client/server libraries/utilities since ducks sometim

Re: Cross-global instanceof

2013-10-31 Thread Allen Wirfs-Brock
On Oct 31, 2013, at 9:43 AM, Brandon Benvie wrote: > On 10/31/2013 8:50 AM, David Bruant wrote: >> I'm not sure it's worth making it work for jQuery. This is trying to make a >> good use of same-origin multi-global which shouldn't exist in the first >> place. Keeping same-origin access as it is

Re: Cross-global instanceof

2013-10-31 Thread Brandon Benvie
On 10/31/2013 8:50 AM, David Bruant wrote: I'm not sure it's worth making it work for jQuery. This is trying to make a good use of same-origin multi-global which shouldn't exist in the first place. Keeping same-origin access as it is and encouraging people to add @sandbox even on same-origin if

Re: Cross-global instanceof

2013-10-31 Thread David Bruant
Le 31/10/2013 16:38, Anne van Kesteren a écrit : This keeps coming up. Last instance: http://mxr.mozilla.org/mozilla-central/source/dom/base/ObjectWrapper.jsm#16 We have it for Array using Array.isArray(). Array.isArray is not at all equivalent to instanceof. Not even related. Object.create

Cross-global instanceof

2013-10-31 Thread Anne van Kesteren
This keeps coming up. Last instance: http://mxr.mozilla.org/mozilla-central/source/dom/base/ObjectWrapper.jsm#16 We have it for Array using Array.isArray(). It is unclear why the arguments for arrays not apply to other types of objects, such as array buffers, nodes, blobs, files, etc. We could in