pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

How to flatten traits

JJ
Jupiter Jones
Thu, Jun 4, 2020 2:03 AM

Hi All,

There used to be a method to #flattenDownTraits that I can’t find the equivalent in Pharo 8.

How do you go about flattening traits now?

Thanks for any advice.

Cheers,

J

Hi All, There used to be a method to #flattenDownTraits that I can’t find the equivalent in Pharo 8. How do you go about flattening traits now? Thanks for any advice. Cheers, J
JJ
Jupiter Jones
Wed, Oct 27, 2021 9:07 AM

Does anyone know how to remove a trait programatically?

Thanks in advance for any information.

Cheers,

J

Does anyone know how to remove a trait programatically? Thanks in advance for any information. Cheers, J
MD
Marcus Denker
Tue, Nov 2, 2021 1:41 PM

You can just create

On 27 Oct 2021, at 11:07, Jupiter Jones jupiter.jones@mail.com wrote:

Does anyone know how to remove a trait programatically?

you could use the class installer / class builder, e.g. imagine you have:

Object subclass: #MyVisitor
uses: TRBProgramNodeVisitor
instanceVariableNames: ''
classVariableNames: ''
package: ‘PackageTest’

you can now remove the Trait with:

ShiftClassInstaller make: [ :aClassBuilder |
aClassBuilder fillFor: MyVisitor.
aClassBuilder traitComposition: {  }
]

Marcus
You can just create > On 27 Oct 2021, at 11:07, Jupiter Jones <jupiter.jones@mail.com> wrote: > > Does anyone know how to remove a trait programatically? > you could use the class installer / class builder, e.g. imagine you have: Object subclass: #MyVisitor uses: TRBProgramNodeVisitor instanceVariableNames: '' classVariableNames: '' package: ‘PackageTest’ you can now remove the Trait with: ShiftClassInstaller make: [ :aClassBuilder | aClassBuilder fillFor: MyVisitor. aClassBuilder traitComposition: { } ] Marcus
JJ
Jupiter Jones
Thu, Nov 4, 2021 6:25 PM

Hi Marcus,

Thanks for your reply - very much appreciated.

This is the approach I’ve taken and so far so good :)

Cheers,

J

On 3 Nov 2021, at 12:41 am, Marcus Denker marcus.denker@inria.fr wrote:

You can just create

On 27 Oct 2021, at 11:07, Jupiter Jones jupiter.jones@mail.com wrote:

Does anyone know how to remove a trait programatically?

you could use the class installer / class builder, e.g. imagine you have:

Object subclass: #MyVisitor
uses: TRBProgramNodeVisitor
instanceVariableNames: ''
classVariableNames: ''
package: ‘PackageTest’

you can now remove the Trait with:

ShiftClassInstaller make: [ :aClassBuilder |
aClassBuilder fillFor: MyVisitor.
aClassBuilder traitComposition: {  }
]

Marcus
Hi Marcus, Thanks for your reply - very much appreciated. This is the approach I’ve taken and so far so good :) Cheers, J > On 3 Nov 2021, at 12:41 am, Marcus Denker <marcus.denker@inria.fr> wrote: > > You can just create > >> On 27 Oct 2021, at 11:07, Jupiter Jones <jupiter.jones@mail.com> wrote: >> >> Does anyone know how to remove a trait programatically? >> > > you could use the class installer / class builder, e.g. imagine you have: > > > Object subclass: #MyVisitor > uses: TRBProgramNodeVisitor > instanceVariableNames: '' > classVariableNames: '' > package: ‘PackageTest’ > > > you can now remove the Trait with: > > > ShiftClassInstaller make: [ :aClassBuilder | > aClassBuilder fillFor: MyVisitor. > aClassBuilder traitComposition: { } > ] > > Marcus
S
sean@clipperadams.com
Sun, Nov 21, 2021 1:21 PM

I thought the question was how to install/duplicate the trait methods on each client (maybe for a deployment image without Traits). I had the same question. Doesn’t the suggestion remove the trait completely or am I missing something?

I thought the question was how to install/duplicate the trait methods on each client (maybe for a deployment image without Traits). I had the same question. Doesn’t the suggestion remove the trait completely or am I missing something?
MD
Marcus Denker
Mon, Nov 22, 2021 1:19 PM

On 21 Nov 2021, at 14:21, sean@clipperadams.com wrote:

I thought the question was how to install/duplicate the trait methods on each client (maybe for a deployment image without Traits). I had the same question. Doesn’t the suggestion remove the trait completely or am I missing something?

This removes the Trait, yes…

Removing in the sense of Flattening (that is, remove the Trait but change the class to contain the methods, e.g. to port to a system without Traits) is interesting.. it would be more
like a refactoring…

Marcus
> On 21 Nov 2021, at 14:21, sean@clipperadams.com wrote: > > I thought the question was how to install/duplicate the trait methods on each client (maybe for a deployment image without Traits). I had the same question. Doesn’t the suggestion remove the trait completely or am I missing something? > This removes the Trait, yes… Removing in the sense of Flattening (that is, remove the Trait but change the class to contain the methods, e.g. to port to a system without Traits) is interesting.. it would be more like a refactoring… Marcus