Erik Arvidsson (2014-06-12T15:30:47.000Z)
On Thu Jun 12 2014 at 10:59:57 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>
wrote:

> The problem with the undefined test is that it doesn't work if somebody
> tries to attach such functions to a namespace object:
>

It should not work. These are methods that depends on `this`.

var ns = {create: document.createElement};
ns.create('div');  // throws wrong receiver


> let arraybuilder = {of: Array.of, from: array:Array.from};
> arraybuilder.of(1,2,3,4);
>
> or consider, at the global level:
> var of = Array.of;
> of(1,2,3); //works
> this.of(1,2,3) //breaks
>

Why can't we "blindly" call `this[[Construct]]`? It will throw for all of
the above cases which is pretty much what one would expect.

That's essentially why we have the IsConstructor test.  To distinguish
> between this values that are actual constructors that will be used to
> create the new collection and non-constructor objects that are just
> contains for the function.
>
> >
> > Back to the topic, it seems weird to go out of our way to expose
> > @@isRegExp and @@isConcatSpreadable and also go out of our way to hide
> > IsConstructor(). I don't like "does this object conform to this
> > protocol" tests, but they are a fact of life in real JS code.
>
> I think the @@is methods and isConstructor are different kinds of beasts.
>  isConstructor wold be a very general predicate that queries a fundamental
> characteristic of the meta-object protocol.  The @@is methods are local to
> the implementation of a specific abstraction and nobody really needs to
> know about them unless they are trying to extend that abstraction.
>
> I'm not really opposed to an isConstructor predicate, I'm just pushing
> back to see if it is something that really needs to be exposed.  If we have
> it, I think we probably should also have a isCallable predicate and I'd
> hand both of them off of Function.  IE:
>
> Functiuon.isCallable(value)
> Function.isConstructor(value)  //or maybe it should be Function.isNewable ?
>
> Allen
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140612/6bcaf11a/attachment.html>
domenic at domenicdenicola.com (2014-06-20T19:32:44.671Z)
On Thu Jun 12 2014 at 10:59:57 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:

> The problem with the undefined test is that it doesn't work if somebody
> tries to attach such functions to a namespace object:

It should not work. These are methods that depends on `this`.

```js
var ns = {create: document.createElement};
ns.create('div');  // throws wrong receiver
```

> ```js
> let arraybuilder = {of: Array.of, from: array:Array.from};
> arraybuilder.of(1,2,3,4);
> ```
>
> or consider, at the global level:
> ```js
> var of = Array.of;
> of(1,2,3); //works
> this.of(1,2,3) //breaks
> ```

Why can't we "blindly" call `this[[Construct]]`? It will throw for all of
the above cases which is pretty much what one would expect.