Sorry for being slow, but I was wondering how to choose between making a mixin vs. an abstract class. I'm really not sure what all (any of?) the implications are, and a skim (sorry just a skim) of the docs didn't help me.
Thanks in advance for help on the matter.
brianFri 22 May 2009
The primary difference is that a mixin can't declare any state (via fields), but an abstract class can. A mixin can declare a contract for fields (via abstract fields), but whoever uses the mixin has to override those fields to actually allocate storage.
So the decision is much like Java with classes versus interfaces. With Java, you can't add anything to the interface with breaking users. With Fan you can methods with an implementation without breaking code. But you can't add a field (or any abstract slot) without breaking users.
tompalmerFri 22 May 2009
The primary difference is that a mixin can't declare any state (via fields), but an abstract class can.
Got it now (and probably at some point in the past, too). Thanks.
tompalmerFri 22 May 2009
Understood on the abstract fields thing, too, by the way.
tompalmer Fri 22 May 2009
Sorry for being slow, but I was wondering how to choose between making a mixin vs. an abstract class. I'm really not sure what all (any of?) the implications are, and a skim (sorry just a skim) of the docs didn't help me.
Thanks in advance for help on the matter.
brian Fri 22 May 2009
The primary difference is that a mixin can't declare any state (via fields), but an abstract class can. A mixin can declare a contract for fields (via abstract fields), but whoever uses the mixin has to override those fields to actually allocate storage.
So the decision is much like Java with classes versus interfaces. With Java, you can't add anything to the interface with breaking users. With Fan you can methods with an implementation without breaking code. But you can't add a field (or any abstract slot) without breaking users.
tompalmer Fri 22 May 2009
Got it now (and probably at some point in the past, too). Thanks.
tompalmer Fri 22 May 2009
Understood on the abstract fields thing, too, by the way.