Trait method override

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

Trait method override

Vitor Medina Cruz
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor
Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

Vitor Medina Cruz
Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor

Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

Julien Delplanque-2
Hello Vitor,

Yeah, I was talking about that with Pablo (who implemented stateful traits) some times ago.

He told me that aliasing was he way to go.

There is no other option to override a trait method without aliasing it.

Cheers,

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
Bâtiment B 40, Avenue Halley 59650 Villeneuve d'Ascq
Numéro de téléphone: +333 59 35 86 40

Le 16 août 2018 à 19:32, Vitor Medina Cruz <[hidden email]> a écrit :

Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor


Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

Vitor Medina Cruz
Thanks Julian!

On Thu, Aug 16, 2018 at 5:38 PM, Julien <[hidden email]> wrote:
Hello Vitor,

Yeah, I was talking about that with Pablo (who implemented stateful traits) some times ago.

He told me that aliasing was he way to go.

There is no other option to override a trait method without aliasing it.

Cheers,

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
Numéro de téléphone: +333 59 35 86 40

Le 16 août 2018 à 19:32, Vitor Medina Cruz <[hidden email]> a écrit :

Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor



Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

tesonep@gmail.com
Hi Vitor, 
   as Julien correctly said there is no super call in traits. Currently the solution, maybe is a bit ugly, it is to use aliasing. 
Cheers,
Pablo

On Fri, Aug 17, 2018 at 12:10 AM Vitor Medina Cruz <[hidden email]> wrote:
Thanks Julian!

On Thu, Aug 16, 2018 at 5:38 PM, Julien <[hidden email]> wrote:
Hello Vitor,

Yeah, I was talking about that with Pablo (who implemented stateful traits) some times ago.

He told me that aliasing was he way to go.

There is no other option to override a trait method without aliasing it.

Cheers,

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
Numéro de téléphone: +333 59 35 86 40

Le 16 août 2018 à 19:32, Vitor Medina Cruz <[hidden email]> a écrit :

Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor





--
Pablo Tesone.
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

Vitor Medina Cruz
Hello Pablo,

Don't think it is ugly, I personally think it is wonderfull how those extensions to the language can be done with normal messaging passing code! But the information about this seems scattered a bit, I found in google and was not certain if the information was official or correct.

Also, there could be some default aliases in hand, in a way similar to groovy: http://docs.groovy-lang.org/latest/html/documentation/#_user_conflict_resolution

So, if I use TraitA with a methodX, this method could be aliased by default with something like TraitA_methodX. Don't know if this have some problem, just an idea (maybe I will explore this here :) )

regards,
Vitor

On Fri, Aug 17, 2018 at 4:37 AM, [hidden email] <[hidden email]> wrote:
Hi Vitor, 
   as Julien correctly said there is no super call in traits. Currently the solution, maybe is a bit ugly, it is to use aliasing. 
Cheers,
Pablo

On Fri, Aug 17, 2018 at 12:10 AM Vitor Medina Cruz <[hidden email]> wrote:
Thanks Julian!

On Thu, Aug 16, 2018 at 5:38 PM, Julien <[hidden email]> wrote:
Hello Vitor,

Yeah, I was talking about that with Pablo (who implemented stateful traits) some times ago.

He told me that aliasing was he way to go.

There is no other option to override a trait method without aliasing it.

Cheers,

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
Numéro de téléphone: +333 59 35 86 40

Le 16 août 2018 à 19:32, Vitor Medina Cruz <[hidden email]> a écrit :

Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor





--
Pablo Tesone.
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Trait method override

tesonep@gmail.com
Jajajja, 
 yes I like the power that there is in the language. It opens a lot of doors and possibilities. 
You can check the implementation of deep alias that rewrites the users of the aliased method. 

There is also the ability to implement new operations to traits algebra. You can check how they are implemented and implement new operations.

Cheers 

On Fri, Aug 17, 2018 at 1:23 PM Vitor Medina Cruz <[hidden email]> wrote:
Hello Pablo,

Don't think it is ugly, I personally think it is wonderfull how those extensions to the language can be done with normal messaging passing code! But the information about this seems scattered a bit, I found in google and was not certain if the information was official or correct.

Also, there could be some default aliases in hand, in a way similar to groovy: http://docs.groovy-lang.org/latest/html/documentation/#_user_conflict_resolution

So, if I use TraitA with a methodX, this method could be aliased by default with something like TraitA_methodX. Don't know if this have some problem, just an idea (maybe I will explore this here :) )

regards,
Vitor

On Fri, Aug 17, 2018 at 4:37 AM, [hidden email] <[hidden email]> wrote:
Hi Vitor, 
   as Julien correctly said there is no super call in traits. Currently the solution, maybe is a bit ugly, it is to use aliasing. 
Cheers,
Pablo

On Fri, Aug 17, 2018 at 12:10 AM Vitor Medina Cruz <[hidden email]> wrote:
Thanks Julian!

On Thu, Aug 16, 2018 at 5:38 PM, Julien <[hidden email]> wrote:
Hello Vitor,

Yeah, I was talking about that with Pablo (who implemented stateful traits) some times ago.

He told me that aliasing was he way to go.

There is no other option to override a trait method without aliasing it.

Cheers,

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
Numéro de téléphone: +333 59 35 86 40

Le 16 août 2018 à 19:32, Vitor Medina Cruz <[hidden email]> a écrit :

Well, found out about aliasing in http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/, is that the correct way of doint it?

On Thu, Aug 16, 2018 at 11:30 AM, Vitor Medina Cruz <[hidden email]> wrote:
Hello,

In a class that uses a Trait, how can I override one of it's method by appending behavior to the method implemented by the Trait? In a typical override, this is done by calling super:

method

   super method
   "extended behavior"
   ...


Is there a way to change "super" to a reference the Trait?

Regards,
Vitor





--
Pablo Tesone.
[hidden email]



--
Pablo Tesone.
[hidden email]