Traits question

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

Traits question

Sophie424
How are Traits and Monticello supposed to work together?

e.g. With Monticello I (expect to) add methods to others' classes, while
managing and versioning these methods in my package.

Object>>myMethod1
Object>>myMethod2

If I have #myMethod1/2 in a trait, can I apply them to the Object class and
still have them Monticello-managed correctly in my package?

Thanks - Sophie




Reply | Threaded
Open this post in threaded view
|

Re: Traits question

Adrian Lienhard
Hi Sophie,

On Dec 15, 2007, at 19:05 , itsme213 wrote:

> How are Traits and Monticello supposed to work together?
> e.g. With Monticello I (expect to) add methods to others' classes,  
> while
> managing and versioning these methods in my package.
>
> Object>>myMethod1
> Object>>myMethod2
>
> If I have #myMethod1/2 in a trait, can I apply them to the Object  
> class and
> still have them Monticello-managed correctly in my package?

Monticello supports class extensions only for methods. Unfortunately  
it is not possible to extend classes with Traits, like it is not  
possible to extend a class with additional instance variables.

A workaround, although often not a very good one, is to move the class  
into your package. However, I would rather leave the class where it is  
and also publish the original package of the class. This mostly works  
well since MC is good at merging (for instance, for each Seaside  
project, I have private versions of the Seaside package for changes  
and then I merge them with new versions when updating).

HTH,
Adrian

___________________
Adrian Lienhard
http://www.adrian-lienhard.ch/

Reply | Threaded
Open this post in threaded view
|

Re: Traits question

Damien Cassou-3
In reply to this post by Sophie424
2007/12/15, itsme213 <[hidden email]>:

> How are Traits and Monticello supposed to work together?
>
> e.g. With Monticello I (expect to) add methods to others' classes, while
> managing and versioning these methods in my package.
>
> Object>>myMethod1
> Object>>myMethod2
>
> If I have #myMethod1/2 in a trait, can I apply them to the Object class and
> still have them Monticello-managed correctly in my package?

If I understand correctly, there is no problem if you own both the
package containing the class and the package containing the trait. For
example, Nile (http://www.squeaksource.com/Nile/) is based on traits
and there is no problem with Monticello. Monticello takes care of
traits as if they were class definitions and also remembers what
traits a class uses.

Does that answer your question?

--
Damien Cassou

Reply | Threaded
Open this post in threaded view
|

Re: Traits question

Sophie424

"Damien Cassou" <[hidden email]> wrote in message
> If I understand correctly, there is no problem if you own both the
> package containing the class and the package containing the trait.

I meant to ask about using traits (belonging to me or, less likely, to
someone else) and applying them to a class that did not belong to me. I
understand Adrian's answer, and also understand the scenario you mention.

Thanks - Sophie




Reply | Threaded
Open this post in threaded view
|

Re: Traits question

Damien Cassou-3
2007/12/17, itsme213 <[hidden email]>:
>
> "Damien Cassou" <[hidden email]> wrote in message
> > If I understand correctly, there is no problem if you own both the
> > package containing the class and the package containing the trait.
>
> I meant to ask about using traits (belonging to me or, less likely, to
> someone else) and applying them to a class that did not belong to me.

In this case, you have the same problem you get when you want to add
an instance variable to a class you do not own.


--
Damien Cassou

Reply | Threaded
Open this post in threaded view
|

Re: Traits question

Sophie424

"Damien Cassou" <[hidden email]> wrote in message
> In this case, you have the same problem you get when you want to add
> an instance variable to a class you do not own.

Correct. I was hoping that since traits are exclusively about methods, and
MC is supposed to handle methods ...