Re:Kay on the Meaning of "Object-Oriented Programming"
by justincormack on Tuesday June 07, 2011 @04:38PM
(#2630756)
Lua has this, with metatables that can set methods to handle undefined stuff. It is actually very useful and you can do a lot with it.
IgorPartola's example code won't intervene in the usual function-call process; rather, it provides a tacked-on means of simulating message sending behavior that ought to be included in the language's syntax under Kay's definition of OO. With this convention, you'd never call bar(), or any other method, directly; you'd call handle to send a 'bar' message to the object instead. Then, if you send a message the object doesn't understand, handle() can route it properly.