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
Does anyone know how to remove a trait programatically?
Thanks in advance for any information.
Cheers,
J
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
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?
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