noSuchMethod: "funargs" + "invoke-only-phantoms"

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Sat Dec 17 07:12:42 PST 2011


On 17.12.2011 17:21, Herby Vojčík wrote:
> Hello,
>
> from my point the scenario that:
>
>    delete lib.toRussianName;
>
>    then it still:
>
>    typeof lib.toRussianName; // "function", Trollface ;D
>
> is much more acceptable (it happens everyday - there are non-writable 
> properties everywhere),

Yes, good point on non-configurable properties. So, we may justify this 
broken invariant with `delete' which becomes not so broken. it's good. 
Agreed.


> than the scenario where I cannot transform
>
>    lib.toRussianName("Andrea"); // Андрей
>
> into
>
>    var toRussianName = lib.toRussianName;
>    toRussianName.apply(null, ["Andrea", "Alex"]); // error, 
> "toRussianName" is undefined
>
> That's why I proposed first-class phantoms in gist: beasts that typeof 
> to "phantom", ToBoolean to false, ToNumber to 0, are wrapping a 
> function, [[Call]] calls that function, [[Get]] and [[Prototype]] 
> delegates to that function ([[Class]] is questionable) and rest does 
> not work ([[Set]] silently fails etc.). And the ability to return them 
> from any code, not just proxies.
>

This is by the way, may also be an interesting idea. You mean "phantom" 
is the function returned from `get' or it for "non-existing" method in 
case of noSuchMethod is used?

Dmitry.


More information about the es-discuss mailing list