Open SimonMeskens opened 7 years ago
Comment removed, I realized it's unnecessary, code above edited.
Also, note that to delegate to a type, you need to reference a record of that type. Variable b
would store a reference to a variable of type a
. This is commonly called a prototype
. How to specifically set this up, I didn't address yet in my example, assume for now that the constructor of B takes care of that and that setDelegationTo
changes this reference to a different record. The focus is, for now, on the delegation typing part.
I've been waffling about the expressive power of delegation for a while, so I wonder if we can express delegation as part of type classes (ordinarily, they sorta work like subclassing, or maybe reverse subclassing).
I'll start vague and let you guys correct me to get to a more formal solution. Basically, what I want to do is make it so you can change the traits implemented for a type.
Something like this (sorry for the pseudo-syntax, I haven't quite come to grips yet with proposed syntax):
The reason why such a delegation scheme would be interesting is outlined in this paper: http://www.cs.cmu.edu/~aldrich/papers/rdl04.pdf