Useful classical inheritance example?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top