Login  Register

Re: [General] Redefining the Class of Instantiated Morphs, Subclassing Instantiated Morphs on the Fly

Posted by Sean P. DeNigris on Feb 19, 2014; 7:49pm
URL: https://forum.world.st/Re-General-Redefining-the-Class-of-Instantiated-Morphs-Subclassing-Instantiated-Morphs-on-the-Fly-tp4744953p4744959.html

Tim Felgentreff-2 wrote
The lively devs have struggled with various attempts to solve this
problem
In Self, one can share behavior among copies quite easily by defining a new parent before making the copies of the morph. By default, a Morph has "traits Morph" as its parent. What you do is make a new object to be the parent and inject between your morph and "traits Morph" (it is your morph's parent and "traits Morph" is its parent). Then you add shared behavior to the shared (between copies of your morph, but not all morphs) parent.

I don't know much about js, but could one be able to inject a new prototype between the morph and the Morph class and add (or be able to promote) behavior to it?
Cheers,
Sean