Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Allen Wirfs-Brock
On Jun 15, 2015, at 9:21 PM, Bradley Meck wrote: > On the surface `O instanceof C` boxes `C`, but when using `GetMethod` O turns > O into an Object. This means `instanceof` is temporarily turning O into an > Object. Read the spec http://people.mozilla.org/~jorendorff/es6-draft.html#sec-relati

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Bradley Meck
On the surface `O instanceof C` boxes `C`, but when using `GetMethod` O turns O into an Object. This means `instanceof` is temporarily turning O into an Object. For primitives, all the operators in JS have been unable to be altered until this was pointed out. `1 instanceof C` is able to be changed

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Allen Wirfs-Brock
On Jun 15, 2015, at 10:06 AM, Bradley Meck wrote: > Kyle Simpson caused the discovery of this oddity : > > https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator > calls GetMethod on C without checking if it is an Object, this means `1 > instanceof Foo` could be affected

Re: @@isConcatSpreadable

2015-06-15 Thread Brendan Eich
Herby Vojčík wrote: So when one actually _wants_ to concat (as, add elements of the iterable), it should stop using concat for that and must do something like var concatenated = first.slice(); concatenated.push(...second, ...third, ...fourth); Or use concat but wrap the parameter with [].

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Bradley Meck
Would not work since @@hasInstance takes priority over OrdinaryHasInstance and would box it. On Mon, Jun 15, 2015 at 3:19 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > so `Object(unknown) instanceof Number` it is then ¯\_(ツ)_/¯ > > On Mon, Jun 15, 2015 at 9:14 PM, Bradley Meck >

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Andrea Giammarchi
so `Object(unknown) instanceof Number` it is then ¯\_(ツ)_/¯ On Mon, Jun 15, 2015 at 9:14 PM, Bradley Meck wrote: > Well this also has slightly odd behavior since the Object operation will > fail for OrdinaryHastInstance if for primitives > https://people.mozilla.org/~jorendorff/es6-draft.html#se

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Bradley Meck
Well this also has slightly odd behavior since the Object operation will fail for OrdinaryHastInstance if for primitives https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinaryhasinstance On Mon, Jun 15, 2015 at 3:09 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > point o

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Andrea Giammarchi
point of views I guess, you could fix forever the inconsistency via ```js Number.prototype[Symbol.hasInstance] = function () { return typeof this.valueOf() === 'number'; }; ``` and fix String, Boolean, Symbol too (why not) and whatever else. `instanceof` is the new `typeof` ^_^ (naa, just jokin

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Bradley Meck
Yes, with regards to O being an Object. This seems a bit strange to me since things like: ``` Number.prototype.toString = function () {return 'overriden';} (1)+'' // "1" String(1) // "1" (1).toString() // "overriden" ``` Implicit string coercion does not box the object. String constructor do

Re: @@isConcatSpreadable

2015-06-15 Thread Herby Vojčík
Allen Wirfs-Brock wrote: On Jun 3, 2015, at 3:46 AM, Leon Arnott wrote: This reminds me: I feel like the spec should've added Array.prototype[Symbol.isConcatSpreadable] (value:true, configurable:false, writable:false), and eliminated the final IsArray() test from [22.1.3.11](https://people.mo

Re: primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Kevin Smith
> > > https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator > calls GetMethod on C without checking if it is an Object, this means `1 > instanceof Foo` could be affected by mutating > `Number.prototype[Symbol.hasInstance]`. > I assume you mean "without checking if O is an ob

Re: {Spam?} Re: Language design

2015-06-15 Thread Brendan Eich
I think we can stick a fork in this thread, it's done. Let it memorialize some knowledge that seems in danger of being lost over time. Thanks, /be Wes Garland wrote: That root post ignored compatibility constraints that have been discussed to death over the years, and just glibly asserted th

primitive boxing in instanceof due to Symbol.hasInstance

2015-06-15 Thread Bradley Meck
Kyle Simpson caused the discovery of this oddity : https://people.mozilla.org/~jorendorff/es6-draft.html#sec-instanceofoperator calls GetMethod on C without checking if it is an Object, this means `1 instanceof Foo` could be affected by mutating `Number.prototype[Symbol.hasInstance]`. I am assumi

Re: `new Object` vs `Object` difference

2015-06-15 Thread Benjamin Gruenbaum
Pointing out that I'm replying to a message with an empty subject - using the correct original title here -- Forwarded message -- From: Rock Benjamin Gruenaum, Andrea Giammarchi, you are wrong about RegExp: ```js var re = /./; new RegExp(re) === re; // false RegExp(re) === re; //

Re:

2015-06-15 Thread Andrea Giammarchi
You can't accept string or regexp 'cause strings cannot be flags this way so beside split I don't know where this could work. flags like i, or u, are also important, being unable to pass these even in split doesn't look like a good idea, IMO On Mon, Jun 15, 2015 at 1:22 PM, Denis Pushkarev wrote:

Re:

2015-06-15 Thread Denis Pushkarev
This logic is convenient if function accept string or regexp, like `String#split`, for convert it to regexp. Behavior with second argument is changed in ES6 and fixed in latest FF, `core-js` and `es6-shim`. Sorry for reply w/o subject - problem with mail client :) 15.06.2015, 17:36, "Andrea Giammar

Re:

2015-06-15 Thread Andrea Giammarchi
that's no how usually you create RegExp ```js RegExp('yep', 'g'); new RegExp('yep', 'g'); ``` both will produce similar RegExp instances (every time a new one). Using the RegExp constructor as RegExp wrapper is a very unusual pattern I haven't seen before. So yes, in that case we have some sort o

[no subject]

2015-06-15 Thread Rock
Benjamin Gruenaum, Andrea Giammarchi, you are wrong about RegExp: ```js var re = /./; new RegExp(re) === re; // false RegExp(re) === re; // true ``` ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss