My ECMAScript 7 wishlist

Brendan Eich brendan at mozilla.org
Fri Sep 26 15:45:55 PDT 2014


Tab Atkins Jr. wrote:
>> Any nSP of the kind we seem to be discussing would need to fail fast, on evaluation of the dot expression. That is a fast path.
>
> I, personally, have only ever used Python and PHP's nSP functionality
> to implement methods.  Most of the fancy uses I see for it in, say,
> Ruby (like the cool dynamic query methods on ORMs), are also methods.
> There are certainly uses for this kind of functionality for non-method
> properties, but I suspect just going with noSuchMethod would satisfy
> most use-cases.  I'd certainly be happier with that. ^_^

__noSuchMethod__ is not what Nicholas sketched on his wishlist, though.

There are two valid use-cases/proposals:

1. Smalltalk doesNotUnderstand (but Smalltalk makes everything a method 
selected by a message, no get vs. invoke [get+call] distinction), which 
led to SpiderMonkey's __noSuchMethod__. This is an unstratified trap to 
handle obj.foo() but not obj.foo -- in JS, whether it handles `do { let 
f = obj.foo; f(); }` is a good question.

2. Nicholas's request for a way to make obj.typo an error. I wish I had 
a nickel for every time someone new to JS asked me for this since 1995 
(or perhaps 1998 when try-catch was done). This is all about failing 
fast on typo'ed or otherwise missing property references, gets as well 
as get+calls.

These are two distinct things. You should start a new thread if you want 
(1). But we've been over it several times already:

https://www.google.com/search?q=site%3Aesdiscuss.org+noSuchMethod

What new helium do you have this time to get __noSuchMethod__ airborne? 
The Proxy-based library solution from Tom Van Cutsem at

http://esdiscuss.org/topic/nosuchmethod-and-direct-proxies

is sucking heavier gasses out of the air around you :-P.

/be


More information about the es-discuss mailing list