[General] Multiple Inheritance in Lively Kernel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[General] Multiple Inheritance in Lively Kernel

Haowei Ruan
Hi, does anyone know if Lively Kernel provide any support to
facilitate multiple inheritance ?

cheers,
Haowei


Reply | Threaded
Open this post in threaded view
|

[General] Multiple Inheritance in Lively Kernel

Robert Krahn
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@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,@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
> [hidden email]
> 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