[Laszlo-dev] Some questions about mixins (LPP-5266)

P T Withington ptw at openlaszlo.org
Fri Feb 1 13:03:22 PST 2008


On 2008-02-01, at 15:40 EST, Donald Anderson wrote:

> 1) Do we allow forward references:
>
>  class X with M1 { .... }
>  mixin M1 { .... }

We haven't in the past, but it is a common request, so IWBN.

> I expect yes - this wouldn't be hard since we get the whole source
> tree at one time.
>
> 2) When compiling an app, do we allow references to traitsXXXXXX

mixins

> in included libraries/LFC?
> I want to say yes, but this would certainly make things tougher.
> Right now, the LFC is compiled into a .swc, so there isn't
> any readily accessible source information about
> the mixins it contains.  I could think of some hacks to accomplish
> that, but I'd rather not go there.

In and ideal world, but not for now -- there is no need at present.   
(It would mean saving the compiler database of mixins out on the side  
as 'linkage' information.)

> 3) Is there any real work here that needs to be done for JS/SWF8?
> Is it just deprecating keyword 'trait' to prefer 'mixin'?

You don't _have_ to do anything for swf8 (or DHTML).  OTOH, swf8/DHTML  
(i.e., JS1) would make a good testbed, since it is known to be  
working.  Essentially you would be moving to compile-time what is  
currently done at run-time by lfc/compiler/Class.lzs#Trait (in  
particular Trait.makeInterstitial).  This might be beneficial for JS1  
because it will remove some runtime overhead, but we can make the  
decision to take the change or not based on measurement.  (N.B.: There  
is one tricky bit you will have to worry about since there are no  
interfaces in JS1, you will have to provide an implementation of Trait. 
$lzsc$isa, the runtime support for `is` on a mixin.)

> 4) Is this work in devildog only?

I would prototype it in devildog, in the common path for JS1/2.  You  
can test/debug in JS1 (swf8 and/or DHTML, where you have Firebug to  
help you) if that is helpful.  If JS1 benchmarks equal or better with  
the change, let's take it to trunk, on the theory it is better to have  
fewer different paths through the compiler.  If for some unforseen  
reason JS1 benchmarks worse, we can push the code down into the JS2- 
only path.



More information about the Laszlo-dev mailing list