lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Feb 02, 2005, at 03:06, Mark Hamburg wrote:

Unless you do really grotesque things with proxies and potentially incur complexities at a number of other places, this doesn't work or becomes very inefficient. Super is a property of the method in which it is being called
as much or more than it is a property of the target of the method.
Hmmm... either I don't understand what you mean or we are not talking  
about the same thing. Or perhaps both :)
For example, in LU, a so called object is merely a packaged table of  
functions. 'super' is a method as well, as anything else worth  
mentioning. It could be argued that an object is entirely defined by  
its set of public methods.
Beside providing the raw mechanisms for OOP (inheritance,  
encapsulation, etc) an object oriented system should take great care in  
specifying its root class. That root class will effectively define the  
behavior of your system. Or, as John Skaller put it, "the semantics of  
a programming language are often best understood in terms of what is  
not allowed". The base class, much more than any other supporting cast,  
will spell out what is practically possible in your system.
It's perhaps worthwhile to take a look at existing root class in other  
languages and see what functionalities they deemed was critical to  
define at the base of their class hierarchy.
java.lang.Object defines 11 methods. Roughly half of them deal with  
multithreading. Things like 'this' and 'super' are not method, but  
rather language constructs. There is no class method in Java. Only  
statics.
Perhaps a more interesting base class is Cocoa's NSObject:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Protocols/NSObject.html
It defines around 20 methods. 5 of them solely to deal with memory  
management (Cocoa uses reference counting). One notable aspect of  
NSObject is that class methods are symmetric to instance methods. In  
other words, as far as the root of the hierarchy goes, both the class  
and its instance provides the same set of methods. This is a very  
useful property in practice.
LU's base class defines 7 core methods with mostly deal with  
introspection: class(), equals(), hashCode(), isKindOf(), self(),  
super() and toString().
http://dev.alt.textdrive.com/file/lu/LUObject.lua

Like in NSObject, those methods are available both at the class and instance level: a class is an object, an object has a class.
But enough ramblings :P

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/