Send super to trait?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Send super to trait?

Christoph Thiede

Hi all,


I just was trying to activate a super method from a trait but got a DNU:


MyTrait >> #foo ^0

Object subclass: MyObject uses: MyTrait.

MyObject >> #foo ^super foo + 1


Is this not how traits are expected to work? Or is there any other way to reuse the default logic specified in the trait? Do I need to return to traditional inheritance in order to achieve this?


Thanks in advance!


Best,

Christoph


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Send super to trait?

marcel.taeumel
Hi Christoph,

traits are woven into the class where you use them. This means that you can actually overwrite the included traits as you did in your example. And Object DNU #foo. That's expecetd. :-)

Best,
Marcel

Am 07.05.2021 18:13:24 schrieb Thiede, Christoph <[hidden email]>:

Hi all,


I just was trying to activate a super method from a trait but got a DNU:


MyTrait >> #foo ^0

Object subclass: MyObject uses: MyTrait.

MyObject >> #foo ^super foo + 1


Is this not how traits are expected to work? Or is there any other way to reuse the default logic specified in the trait? Do I need to return to traditional inheritance in order to achieve this?


Thanks in advance!


Best,

Christoph


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Send super to trait?

Christoph Thiede

Hi Marcel,


thank you for the clarification. In this case, I will have to rethink when traits are actually useful ... But eventually, I will find a convincing usage example someday. :-)


Best,

Christoph


Von: Beginners <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Freitag, 7. Mai 2021 19:21:58
An: [hidden email]
Betreff: Re: [Newbies] Send super to trait?
 
Hi Christoph,

traits are woven into the class where you use them. This means that you can actually overwrite the included traits as you did in your example. And Object DNU #foo. That's expecetd. :-)

Best,
Marcel

Am 07.05.2021 18:13:24 schrieb Thiede, Christoph <[hidden email]>:

Hi all,


I just was trying to activate a super method from a trait but got a DNU:


MyTrait >> #foo ^0

Object subclass: MyObject uses: MyTrait.

MyObject >> #foo ^super foo + 1


Is this not how traits are expected to work? Or is there any other way to reuse the default logic specified in the trait? Do I need to return to traditional inheritance in order to achieve this?


Thanks in advance!


Best,

Christoph


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!