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

Fw: Fw: Beyond Java?




----- Original Message ----- 
From: Maxim Kizub <M.Kizub@post.skynet.lt>
To: Jason Trenouth <Jason.Trenouth@bigfoot.com>
Sent: Sunday, March 18, 2001 12:10 PM
Subject: Re: Fw: Beyond Java?


> Hello Jason,
> 
> I investigated multiple inheritance in Dylan, and
> have found, that it's not as efficient as can be.
> 
> Let me demostrate why. First, if you remember, in
> my kiev comopler I added two forms of multiple
> inherotance - via interfaces and via delegation.
> 
> For interfaces I added ability to have "virtual"
> fields, i.e. ability to define a getter and setter
> pair of methods, and syntax sugar to use them
> as fields. For example
> 
> interface I {
>   virtual int i;
>   int mul(int j) { return i*j; }
> }
> 
> which will be translated as
> 
> interface I {
>   int get$i();
>   void set$i(int val);
>   static mul(I this, int j) { return this.get$i() * j; }
> }
> 
> I noticed, that Dylan has two forms of clases.
> Those that called "primary" - can access own fields
> like java classes (i.e. fast direct access), and
> others - only via getter/setter methods, exactly like
> in my interfaces with virtual fields.
> 
> But I have defined another way - delegation.
> For example
> 
> class C {
>   forward Named name;
> }
> 
> will delegate all calls to 'Named' methods to
> field 'name'. Sometimes you do not need that
> implementation of Named will call any methods
> of class that extends it - in this case instance
> of Named will be able to access it's fields
> in the same direct and efficient way as "primary"
> classes.
> 
> So, whenever developer will need 'delegation' kind
> of inheritance - dylan will be slower, then
> it's possible.
> 
> And a few words about optimization of libraries.
> To be able optimize method dispatching you need
> to declare Dylan's classes and functions to be closed
> (not allowed to be extended). The same issue is
> solved in java by having 'final' classes and methods.
> And optimized compiler may inline small methods
> of final classes or final and private methods,
> plus JIT compiler can (and do) dispatch calls
> to those methods as direct calls, not via
> virtual table.
> 
> So, I think that there is no magic in Dylan about
> ability to optimize multimethod calls in libraries,
> except library designer will makes most of classes
> 'final' :-(
> 
> 
> -- 
> Best regards,
>  Maxim                            mailto:M.Kizub@post.skynet.lt
> 
> 
> 



Follow-Ups: