D
Dmitry A. Soshnikov
Dmitry said:Dmitry A. Soshnikov wrote:
Thomas 'PointedEars' Lahn wrote: [...]
Thanks. Â I had no doubt that the __noSuchMethod__() method could be written;
but your code avoids the issue by not answering to your premise: how do you
trigger it?__noSuchMethod__ is common office signal (message) which is caught
when object can't answer the message itself (including its prototype
chain). This signal is trigger *automatically* (did you try to run
this example? try e.g. in SpiderMonkey and u'll see how it works).
It's general signal in general theory of dynamic objects and is in
some realizations: e.g.:- #doesNotUnderstand (SmallTalk);
- method_missing (Ruby)
- __getattr__ (Python)
- __call (PHP)
- __noSuchMethod__ (some ECMAScript realizations, e.g. SpiderMonkey)
- and so on.Sure it's not standard method, ECMA-262-3 says nothing about that,
that's why i mentioned that it's just theoretical academical interest
of that imitation
They are considering catch-all's for ES harmony -http://wiki.ecmascript.org/doku.php?id=strawman:catchalls
Yeah, thanks, saw it.
ES5 only had as much time as to add accessors, so we'll need to wait a
bit longer for catch-all/no-such-method/method-missing magic
And that's the problem
Also notice that this document proposes means to intercept not only
[[Get]], [[Set]], but other internal methods as well - [[Construct]],
[[Delete]], etc.
I think such hooks are very useful and would be better if they find
the time to implement that.