calling methods directly on traits

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

calling methods directly on traits

Peter Uhnak
Hi,

would it be possible to somehow call a method directly on a trait?

e.g.

Trait named: #TMyTrait.

then add method

TMyTrait>>twelve
        ^ 12


and then I could do `TMyTrait twelve "-> 12"`.

Note that I cannot use Class-side of a regular class, because of name clashes with system (Class, ClassDescription, ...) selectors.

Thanks,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: calling methods directly on traits

Guillermo Polito
Hi,

No, it's the same as in classes. If methods are on the instance side, you cannot call them unless you instantiate the class.

Guille

On Wed, Apr 26, 2017 at 2:24 PM, Peter Uhnak <[hidden email]> wrote:
Hi,

would it be possible to somehow call a method directly on a trait?

e.g.

Trait named: #TMyTrait.

then add method

TMyTrait>>twelve
        ^ 12


and then I could do `TMyTrait twelve "-> 12"`.

Note that I cannot use Class-side of a regular class, because of name clashes with system (Class, ClassDescription, ...) selectors.

Thanks,
Peter


Reply | Threaded
Open this post in threaded view
|

Re: calling methods directly on traits

Peter Uhnak
But trait is already instance, no? (instance of Trait class)
Or is that like an instance of an instance?

On Wed, Apr 26, 2017 at 03:03:42PM +0200, Guillermo Polito wrote:

> Hi,
>
> No, it's the same as in classes. If methods are on the instance side, you
> cannot call them unless you instantiate the class.
>
> Guille
>
> On Wed, Apr 26, 2017 at 2:24 PM, Peter Uhnak <[hidden email]> wrote:
>
> > Hi,
> >
> > would it be possible to somehow call a method directly on a trait?
> >
> > e.g.
> >
> > Trait named: #TMyTrait.
> >
> > then add method
> >
> > TMyTrait>>twelve
> >         ^ 12
> >
> >
> > and then I could do `TMyTrait twelve "-> 12"`.
> >
> > Note that I cannot use Class-side of a regular class, because of name
> > clashes with system (Class, ClassDescription, ...) selectors.
> >
> > Thanks,
> > Peter
> >
> >

Reply | Threaded
Open this post in threaded view
|

Re: calling methods directly on traits

Guillermo Polito
Traits are instances as classes are instances :)

On Wed, Apr 26, 2017 at 3:22 PM, Peter Uhnak <[hidden email]> wrote:
But trait is already instance, no? (instance of Trait class)
Or is that like an instance of an instance?

On Wed, Apr 26, 2017 at 03:03:42PM +0200, Guillermo Polito wrote:
> Hi,
>
> No, it's the same as in classes. If methods are on the instance side, you
> cannot call them unless you instantiate the class.
>
> Guille
>
> On Wed, Apr 26, 2017 at 2:24 PM, Peter Uhnak <[hidden email]> wrote:
>
> > Hi,
> >
> > would it be possible to somehow call a method directly on a trait?
> >
> > e.g.
> >
> > Trait named: #TMyTrait.
> >
> > then add method
> >
> > TMyTrait>>twelve
> >         ^ 12
> >
> >
> > and then I could do `TMyTrait twelve "-> 12"`.
> >
> > Note that I cannot use Class-side of a regular class, because of name
> > clashes with system (Class, ClassDescription, ...) selectors.
> >
> > Thanks,
> > Peter
> >
> >


Reply | Threaded
Open this post in threaded view
|

Re: calling methods directly on traits

Peter Uhnak
Ah, right. Well, one less dead-end to worry about. :)

Thanks,
Peter

On Wed, Apr 26, 2017 at 04:20:07PM +0200, Guillermo Polito wrote:

> Traits are instances as classes are instances :)
>
> On Wed, Apr 26, 2017 at 3:22 PM, Peter Uhnak <[hidden email]> wrote:
>
> > But trait is already instance, no? (instance of Trait class)
> > Or is that like an instance of an instance?
> >
> > On Wed, Apr 26, 2017 at 03:03:42PM +0200, Guillermo Polito wrote:
> > > Hi,
> > >
> > > No, it's the same as in classes. If methods are on the instance side, you
> > > cannot call them unless you instantiate the class.
> > >
> > > Guille
> > >
> > > On Wed, Apr 26, 2017 at 2:24 PM, Peter Uhnak <[hidden email]> wrote:
> > >
> > > > Hi,
> > > >
> > > > would it be possible to somehow call a method directly on a trait?
> > > >
> > > > e.g.
> > > >
> > > > Trait named: #TMyTrait.
> > > >
> > > > then add method
> > > >
> > > > TMyTrait>>twelve
> > > >         ^ 12
> > > >
> > > >
> > > > and then I could do `TMyTrait twelve "-> 12"`.
> > > >
> > > > Note that I cannot use Class-side of a regular class, because of name
> > > > clashes with system (Class, ClassDescription, ...) selectors.
> > > >
> > > > Thanks,
> > > > Peter
> > > >
> > > >
> >
> >