mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Implement Mixins #29

Closed mfichman closed 11 years ago

mfichman commented 13 years ago

Implement mixins, for interfaces and regular types. Mixins will basically just "paste" the mixin code into the body of the class. Debatable: Should mixins inherit from "Mixin?" I think yes, to make the compiler simpler and to distinguish between usable objects and Mixins, which are not standalone.

Conflict rules: victory goes to the method defined in the Object, or to the Mixin listed first in the mixin list.

Self: self-types should be usable in Mixins, and they should be bound to the type of the Object they are mixed into.

Implementation: just copy, or perform some kind of lookup? Should multiple functions be generated, or should the vtable forward to the mixin implementation? (need to worry about instance variables -- should they even be allowed in Mixins?)

mfichman commented 12 years ago

Instance variables in Mixins can only be accessed by virtual function calls. This will simplify the implementation, since no data inheritance is required (only code inheritance, which is the important part anyway).

mfichman commented 12 years ago

Mixins are implemented, except for the following rules:

Possibility: Combine Interfaces and Mixins?

Also, code-gen for mixin functions must treat "this" as an interface.