building traits programmatically

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

building traits programmatically

Ciprian Teodorov-3
Hi guys,

Can anyone give me some pointers on how to create traits dynamically?
I have tried something like: 

model := RBNamespace new.

model defineClass: ('Trait named: #TMyTrait
uses: {}
category: ''My-Tests''').

and I get a DNU: RBAddTraitChange>>superclassName

Cheers,
--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

stephane ducasse

On Mar 8, 2013, at 7:57 PM, Ciprian Teodorov <[hidden email]> wrote:

Hi guys,

Can anyone give me some pointers on how to create traits dynamically?

you mean with the refactoring engine?
I know that one argentinian student added support for traits in RB but I never got the time to have a look and integrate it.


I have tried something like: 

model := RBNamespace new.

model defineClass: ('Trait named: #TMyTrait
uses: {}
category: ''My-Tests''').

and I get a DNU: RBAddTraitChange>>superclassName

Cheers,
--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro

Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

Ciprian Teodorov-3


On Fri, Mar 8, 2013 at 10:32 PM, stephane ducasse <[hidden email]> wrote:

On Mar 8, 2013, at 7:57 PM, Ciprian Teodorov <[hidden email]> wrote:

Hi guys,

Can anyone give me some pointers on how to create traits dynamically?

you mean with the refactoring engine?
Yes something like it, I am little confused with all ring, rb stuff. But I know that I can build classes, add methods, and see changes (and apply them) using RBNamespace api... it does not seem to work with traits. Some time ago I have spend some time patching the RB thingy to accept trait also... but then I have run into other problems (i don't remember exactly what)... Moreover, it was just hacks to make it work... so I've lost them over time... and I don't like patching every new image that I download with my changes to make It work...

So maybe, I don't use them right... or there are things that should be done... I'm willing to contribute, if it helps.

I know that one argentinian student added support for traits in RB but I never got the time to have a look and integrate it.
cool, maybe we should have a look...

Then again, it is not clear in my head what is the politics of traits and pharo... I know that there were some discussions about them being bad because their methods are copied to classes, not being well integrated.... how exactly do they fit in the big picture (next pharo versions). Can we use them as they are now, or the implementation is likely to change in the near future? -- stateful traits, or something else? 

cheers,
ciprian


I have tried something like: 

model := RBNamespace new.

model defineClass: ('Trait named: #TMyTrait
uses: {}
category: ''My-Tests''').

and I get a DNU: RBAddTraitChange>>superclassName

Cheers,
--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro




--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

stephane ducasse

On Mar 8, 2013, at 11:50 PM, Ciprian Teodorov <[hidden email]> wrote:



On Fri, Mar 8, 2013 at 10:32 PM, stephane ducasse <[hidden email]> wrote:

On Mar 8, 2013, at 7:57 PM, Ciprian Teodorov <[hidden email]> wrote:

Hi guys,

Can anyone give me some pointers on how to create traits dynamically?

you mean with the refactoring engine?
Yes something like it, I am little confused with all ring, rb stuff.

ring is simple: imagine that all the tools can manipulate objects that represent objects that get executed.
for RB you have an engine to transform code.
Now to programmatically create traits you do not need RB nor ring

But I know that I can build classes, add methods, and see changes (and apply them) using RBNamespace api... it does not seem to work with traits. Some time ago I have spend some time patching the RB thingy to accept trait also... but then I have run into other problems (i don't remember exactly what)... Moreover, it was just hacks to make it work... so I've lost them over time... and I don't like patching every new image that I download with my changes to make It work...

So maybe, I don't use them right... or there are things that should be done... I'm willing to contribute, if it helps.

looking a the enhancements proposed to make rb handle traits would be good


I know that one argentinian student added support for traits in RB but I never got the time to have a look and integrate it.
cool, maybe we should have a look...

Then again, it is not clear in my head what is the politics of traits and pharo... I know that there were some discussions about them being bad because their methods are copied to classes, not being well integrated….

it was just for implementors. 

how exactly do they fit in the big picture (next pharo versions). Can we use them as they are now, or the implementation is likely to change in the near future? -- stateful traits, or something else? 

No stateful traits in the horizon.
For now traits will stay but we should have a look at the internal implementation to simplify it.
Second the internal change should not impact external users and will be transparent.



cheers,
ciprian


I have tried something like: 

model := RBNamespace new.

model defineClass: ('Trait named: #TMyTrait
uses: {}
category: ''My-Tests''').

and I get a DNU: RBAddTraitChange>>superclassName

Cheers,
--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro




--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro

Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

Igor Stasenko
In reply to this post by Ciprian Teodorov-3
how to create trait programmatically?

Here you go:

trait := Trait named: #MyProgrammaticallyCreatedTrait.


You can also do the same trick with classes, btw:

newclass := Object subclass: #MyNewClass.

;)

--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

Ciprian Teodorov-3


On Sat, Mar 9, 2013 at 4:00 PM, Igor Stasenko <[hidden email]> wrote:
how to create trait programmatically?

Here you go:

trait := Trait named: #MyProgrammaticallyCreatedTrait.


You can also do the same trick with classes, btw:

newclass := Object subclass: #MyNewClass.

;)

cool... ;) 
+igor

but then why do we need changes and change classes ?

but yeah I asked a stupid question ... the DNU is still there though
--
Best regards,
Igor Stasenko.




--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro
Reply | Threaded
Open this post in threaded view
|

Re: building traits programmatically

Igor Stasenko


On 9 March 2013 18:58, Ciprian Teodorov <[hidden email]> wrote:


On Sat, Mar 9, 2013 at 4:00 PM, Igor Stasenko <[hidden email]> wrote:
how to create trait programmatically?

Here you go:

trait := Trait named: #MyProgrammaticallyCreatedTrait.


You can also do the same trick with classes, btw:

newclass := Object subclass: #MyNewClass.

;)

cool... ;) 
+igor

but then why do we need changes and change classes ?

but yeah I asked a stupid question ... the DNU is still there though

that belongs to RB.. not Trait's problems.
file a bug entry :)
 
--
Best regards,
Igor Stasenko.




--
Dr. Ciprian TEODOROV
Ing
énieur Développement CAO

tél : 06 08 54 73 48

mail : [hidden email]
www.teodorov.ro



--
Best regards,
Igor Stasenko.