On Jul 18, 2011, at 6:50 PM, Allen Wirfs-Brock wrote:

>> Even in Harmony, many of the new methods being adding are "static": 
>> Proxy.create(), Proxy.createFunction(), Proxy.isTrapping(), 
>> Object.getPropertyDescriptor(), Object.getPropertyNames(), Object.is(), 
>> Number.isFinite(), Number.isNan()... If anything non-instance methods are 
>> becoming more important in JS as time goes on (though modules might change 
>> that).
> 
> Brendan and I recently had a discussion about some of these and it isn't 
> clear that they are all in the correct places.  Of the ones you mentioned, 
> I'm not so sure I would call Proxy a constructor.  (you never say, new 
> Proxy() right?) it is really a factory object which means the methods you 
> name are instance side.

No, rather Proxy is a module name. We could even spec it for ES.next as 
something users must import from a standard library MRL:

  module Proxy from "@proxy";

and avoid polluting the global scope with 'Proxy' -- users get to name the 
module. With ES.next modules, one can even selectively import:

  import createFunction from "@proxy";


> The Object refection methods were put on object because it was a convenient  
> "namespace" object. But that's not a style I would want to encourage for 
> complex user applications.

It depends on whether we have set a precedent, and also on the domain type (see 
below).


> isFinite and isNaN probably should go on the instance side.

No, that requires an extra test, as we discussed re: isGenerator. These are 
intentional any -> boolean non-coercing functions, not methods. They must be 
callable on any type of argument without testing that the argument is a number 
and then using it to call a method.

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to