[General] Multiple Inheritance in Lively Kernel

Robert Krahn robert.krahn at student.hpi.uni-potsdam.de
Sun Apr 26 19:52:39 CEST 2009


No, LK has nor real support for multiple inheritance, however, you can  
simply copy functions and properties from one class to another (note  
that $super, instanceof, etc. will not work correctly). LK uses this  
for Trait-like constructs. E.g. look at NetRequestReporterTrait in  
Network.js and it where it is used.

Object.subclass('ClassA', {
	m1: function() { return 1},
	m2: function() { return 2},
});
Object.subclass('ClassB', {
	m2: function() { return 22 },
	m3: function() { return 3 }
});
ClassA.subclass('ClassC', ClassB.prototype);

x = new ClassC();
x.m1() // 1
x.m2() // 22
x.m3() // 3
x instanceof ClassA // true
x instanceof ClassB // false


Robert



On Apr 26, 2009, at 1:58 PM, Haowei Ruan wrote:

> Hi, does anyone know if Lively Kernel provide any support to
> facilitate multiple inheritance ?
>
> cheers,
> Haowei
> _______________________________________________
> General mailing list
> General at livelykernel.sunlabs.com
> http://livelykernel.sunlabs.com/mailman/listinfo/general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://livelykernel.sunlabs.com/pipermail/general/attachments/20090426/9b5a3598/attachment.html 




More information about the lively-kernel mailing list