Does pharo support runtime trait composition or does it only work on class definition time. I mean something like
anObject addTrait: MySpecialCapability anObject removeTrait: MySpecialCapability Norbert |
Hi Norbert, It sounds like you want something like talents Talents http://scg.unibe.ch/research/bifrost/talents. However, there is no running version on pharo 3.0 yet.
I am not aware of work on object-specific traits, I could be wrong though. Cheers, On Thu, Aug 22, 2013 at 3:23 PM, Norbert Hartl <[hidden email]> wrote: Does pharo support runtime trait composition or does it only work on class definition time. I mean something like Jorge Ressia www.jorgeressia.com |
Hi Norbert, You can do anObject setTraitComposition: aTraitComposition but only works for behavior objects 2013/8/22 Jorge Ressia <[hidden email]>
|
In reply to this post by NorbertHartl
On Aug 22, 2013, at 3:23 PM, Norbert Hartl <[hidden email]> wrote: > Does pharo support runtime trait composition or does it only work on class definition time. I mean something like > > anObject addTrait: MySpecialCapability > anObject removeTrait: MySpecialCapability Nope :) traits are static :) > > Norbert > > |
Am 22.08.2013 um 16:25 schrieb Stéphane Ducasse <[hidden email]>: > > On Aug 22, 2013, at 3:23 PM, Norbert Hartl <[hidden email]> wrote: > >> Does pharo support runtime trait composition or does it only work on class definition time. I mean something like >> >> anObject addTrait: MySpecialCapability >> anObject removeTrait: MySpecialCapability > > Nope :) > traits are static :) Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) Norbert >> >> Norbert > > |
>>
>>> Does pharo support runtime trait composition or does it only work on class definition time. I mean something like >>> >>> anObject addTrait: MySpecialCapability >>> anObject removeTrait: MySpecialCapability >> >> Nope :) >> traits are static :) > > Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) :) What I think is that traits are cool but not powerful enough but even the ones that we have right now makes the system more complex and this is what makes me sad :) I would prefer something more powerful and simpler: the graal :) Stef |
In reply to this post by NorbertHartl
Norbert, do you want to be able to programmatically add and remove traits at runtime? I wrote a small utility for that a while ago that still works OK (All tests are still green in 2.0). See http://www.squeaksource.com/TraitsApplication.html Hope this helps. On Aug 22, 2013, at 1:19 PM, Norbert Hartl <[hidden email]> wrote: > > Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) ---> Save our in-boxes! http://emailcharter.org <--- Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile |
In reply to this post by Stéphane Ducasse
CONTENTS DELETED
The author has deleted this message.
|
I think that indeed you touch on 2 important cultural issues, first the entire "Worse is Better" discussion (started by Richard Gabriel), and second that IDE support is key for getting more advanced forms of modularity in use. In my experience, sadly, Traits support in Pharo has been less than ideal. In 2.0 it has improved though, so I am happy about that. On Aug 22, 2013, at 4:03 PM, Juraj Kubelka <[hidden email]> wrote: > Interesting. Is it only problem of system complexity? I have the impression the problem is that people do not changed his mind in order to think in traits. (or generally speaking in any other system like mixins, aspects, etc.) It looks like objects with single-inheritance are simple and powerful enough. > > Or maybe any system like traits have not come with efficient enough IDE? ---> Save our in-boxes! http://emailcharter.org <--- Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile |
CONTENTS DELETED
The author has deleted this message.
|
Define 'widely used' and 'is it necessary' ;-) I would say, from the point of view of an Aspects guy (me), that a noticeable influence in the acceptance of the language AspectJ is that they have an acceptable level of IDE support. And there is no escaping the fact that sometimes the decomposition of the system will lead to code that is scattered around different places. Single inheritance with objects is not a silver bullet. But it can be 'good enough' … worse is better ... On Aug 22, 2013, at 4:25 PM, Juraj Kubelka <[hidden email]> wrote: > Is there any "more complex" system which is widely used? I am interested if it has a sense to spend time on researching something better than single-inheritance OOP, traits, etc. Because "Worse is Better" is maybe the point. > > For example I found easier to improve (optimize) an existing application structure by using traits/aspects/etc. But for a new parts of system it looks easier to think in single-inheritance-objects. About optimisation developers think when it is necessary. Is it? > > Cheers, > Jura > > El 22-08-2013, a las 16:11, Johan Fabry <[hidden email]> escribió: > >> >> I think that indeed you touch on 2 important cultural issues, first the entire "Worse is Better" discussion (started by Richard Gabriel), and second that IDE support is key for getting more advanced forms of modularity in use. In my experience, sadly, Traits support in Pharo has been less than ideal. In 2.0 it has improved though, so I am happy about that. >> >> On Aug 22, 2013, at 4:03 PM, Juraj Kubelka <[hidden email]> wrote: >> >>> Interesting. Is it only problem of system complexity? I have the impression the problem is that people do not changed his mind in order to think in traits. (or generally speaking in any other system like mixins, aspects, etc.) It looks like objects with single-inheritance are simple and powerful enough. >>> >>> Or maybe any system like traits have not come with efficient enough IDE? >> >> >> >> ---> Save our in-boxes! http://emailcharter.org <--- >> >> Johan Fabry - http://pleiad.cl/~jfabry >> PLEIAD lab - Computer Science Department (DCC) - University of Chile >> >> > ---> Save our in-boxes! http://emailcharter.org <--- Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile |
In reply to this post by Jorge Ressia
Jorge,
Am 22.08.2013 um 15:28 schrieb Jorge Ressia <[hidden email]>: you might be right. The way talents work is basically what I am asking for. I never got into depth with talents and thought it is much more than adjustment of behavior on per object base. I was hoping there are some easy things available to use in order to modify behavior lookup. I should have a look at talents. Thanks for the tip. Norbert
|
In reply to this post by jfabry
Am 22.08.2013 um 20:29 schrieb Johan Fabry <[hidden email]>: > > Norbert, do you want to be able to programmatically add and remove traits at runtime? I wrote a small utility for that a while ago that still works OK (All tests are still green in 2.0). See http://www.squeaksource.com/TraitsApplication.html > > Hope this helps. > Thanks. My high hopes were to get something to tweak behavior composition on an object base. I did not have a look at TraitsApplication, yet. But it sounds like it operates on behavior. The background of my inquiry is just a thought experiment. Thinking about it I might get away with a hacked version of cloning classes, adjust the trait composition and reassign the class of the objects I need to work on. Norbert > On Aug 22, 2013, at 1:19 PM, Norbert Hartl <[hidden email]> wrote: > >> >> Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) > > > > ---> Save our in-boxes! http://emailcharter.org <--- > > Johan Fabry - http://pleiad.cl/~jfabry > PLEIAD lab - Computer Science Department (DCC) - University of Chile > > |
In reply to this post by Stéphane Ducasse
Am 22.08.2013 um 20:12 schrieb Stéphane Ducasse <[hidden email]>: >>> >>>> Does pharo support runtime trait composition or does it only work on class definition time. I mean something like >>>> >>>> anObject addTrait: MySpecialCapability >>>> anObject removeTrait: MySpecialCapability >>> >>> Nope :) >>> traits are static :) >> >> Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) > > :) > > What I think is that traits are cool but not powerful enough but even the ones that we have right now > makes the system more complex and this is what makes me sad :) I would prefer something more powerful > and simpler: the graal :) > Norbert |
In reply to this post by Juraj Kubelka-5
Am 22.08.2013 um 22:03 schrieb Juraj Kubelka <[hidden email]>: > > El 22-08-2013, a las 14:12, Stéphane Ducasse <[hidden email]> escribió: > >>>> >>>>> Does pharo support runtime trait composition or does it only work on class definition time. I mean something like >>>>> >>>>> anObject addTrait: MySpecialCapability >>>>> anObject removeTrait: MySpecialCapability >>>> >>>> Nope :) >>>> traits are static :) >>> >>> Sad. You know I was not asking about trait but about runtime composable behavior. I'm not sure what you mean with "traits are static". If traits are static in pharo that's fine. If you think traits are static by design then I was looking for something that has a different name :) >> >> :) >> >> What I think is that traits are cool but not powerful enough but even the ones that we have right now >> makes the system more complex and this is what makes me sad :) I would prefer something more powerful >> and simpler: the graal :) >> >> Stef > > Interesting. Is it only problem of system complexity? I have the impression the problem is that people do not changed his mind in order to think in traits. (or generally speaking in any other system like mixins, aspects, etc.) It looks like objects with single-inheritance are simple and powerful enough. > I found traits an interesting approach in the beginning but I don't really like them how they are. I'm not sure if this is dependent on traits or the fact that I have doubts that classes are a good approach. At least I would like to have a looser/lighter approach to compose some behavior at runtime. Just like we do not only have compiled methods but also blocks. To me behavior composition is less about defining types like we do with static traits. It is more about adjusting behavior at runtime depending on the execution context. We have a single inheritance system that is good. And we use a lot of delegations to escape the limits of this approach. Bringing this spirit closer to the language enables IMHO more expressive programs and could enable a lot more things. my 2 cents, Norbert > Or maybe any system like traits have not come with efficient enough IDE? > > Cheers, > Jura |
In reply to this post by NorbertHartl
would strategy not solve your problem? Stef |
In reply to this post by Juraj Kubelka-5
IDE is support key as Johan mentioned.
Then the question is what is the correct granularity that will suit future users of a trait. Stef |
In reply to this post by Stéphane Ducasse
Am 23.08.2013 um 09:34 schrieb Stéphane Ducasse <[hidden email]>: Sure if I would have an actual problem I would use strategy to mitigate the problem. With strategy you can extend the single dimensionality of single inheritance but you cannot acquire new behavior. Or better it is even more cumbersome if you use it to make it acquire new things. Or different said: If there is something like a design pattern that is used really often it could be a good idea if the language would support this out of the box, right? Somewhere in between is the reason why I was asking :) Norbert |
On Aug 23, 2013, at 3:48 AM, Norbert Hartl <[hidden email]> wrote: >> would strategy not solve your problem? >> > Sure if I would have an actual problem I would use strategy to mitigate the problem. With strategy you can extend the single dimensionality of single inheritance but you cannot acquire new behavior. Or better it is even more cumbersome if you use it to make it acquire new things. > Or different said: If there is something like a design pattern that is used really often it could be a good idea if the language would support this out of the box, right? Somewhere in between is the reason why I was asking :) Metaprogramming is your friend :-P Actually this is only half jokingly … one of the ideas of metaprogramming is that the programmer can mold the semantics of the language to his/her liking depending on the task at hand. This (amongst others) is why we can do so many cool things in Smalltalk. For example, when you have a more concrete case of what you are looking for you can build something with method wrappers, or override DNU :-) to do your thing ... ---> Save our in-boxes! http://emailcharter.org <--- Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile |
Am 23.08.2013 um 15:44 schrieb Johan Fabry <[hidden email]>: > > On Aug 23, 2013, at 3:48 AM, Norbert Hartl <[hidden email]> wrote: > >>> would strategy not solve your problem? >>> >> Sure if I would have an actual problem I would use strategy to mitigate the problem. With strategy you can extend the single dimensionality of single inheritance but you cannot acquire new behavior. Or better it is even more cumbersome if you use it to make it acquire new things. >> Or different said: If there is something like a design pattern that is used really often it could be a good idea if the language would support this out of the box, right? Somewhere in between is the reason why I was asking :) > > Metaprogramming is your friend :-P > > Actually this is only half jokingly … one of the ideas of metaprogramming is that the programmer can mold the semantics of the language to his/her liking depending on the task at hand. This (amongst others) is why we can do so many cool things in Smalltalk. For example, when you have a more concrete case of what you are looking for you can build something with method wrappers, or override DNU :-) to do your thing … > thanks, Norbert |
Free forum by Nabble | Edit this page |