Adding instance variables to existing classes in Monticello

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

Adding instance variables to existing classes in Monticello

Nick Chen
Hi

I have modified an existing class in the Smalltalk image and added an instance variable to it. I would like to record this change -- added this new instance variable -- in Monticello; that way my team can also pull in the changes and have it work. This existing class is outside of my Monticello package.

Is this possible?

I have tried following these two threads (~ 2008)

* http://forum.world.st/monticello-package-adding-instance-variables-to-existing-classes-td110740.html
* http://forum.world.st/squeak-dev-MC-unload-action-and-postload-actions-td78441.html

by creating a method on the class side e.g. TheObject class>>mcInstallOn: aClassEditor but it does not seem to work.

Is this functionality still supported or is there a new way to achieve this?

Thanks!

--
Nick
Reply | Threaded
Open this post in threaded view
|

Re: Adding instance variables to existing classes in Monticello

Igor Stasenko
On 31 July 2011 05:16, Nick Chen <[hidden email]> wrote:

> Hi
>
> I have modified an existing class in the Smalltalk image and added an
> instance variable to it. I would like to record this change -- added this
> new instance variable -- in Monticello; that way my team can also pull in
> the changes and have it work. This existing class is outside of my
> Monticello package.
>
> Is this possible?
>
> I have tried following these two threads (~ 2008)
>
> *
> http://forum.world.st/monticello-package-adding-instance-variables-to-existing-classes-td110740.html
> *
> http://forum.world.st/squeak-dev-MC-unload-action-and-postload-actions-td78441.html
>
> by creating a method on the class side e.g. TheObject class>>mcInstallOn:
> aClassEditor but it does not seem to work.
>
> Is this functionality still supported or is there a new way to achieve this?
>
> Thanks!
>
As far as i can tell, this is not supported.
If you allow things like that, then system become very fragilie.

Suppose that you have two independently developed packages, which
adding instance variable to same external class
under same name.
Such kind of conflicts is impossible to solve, because you never know
what combination of package(s) could be loaded.

Instead, what you can do is to save own version of package (with class
where you added ivar) and distribute your code with
this version of package.

> --
> Nick
>
> --
> View this message in context: http://forum.world.st/Adding-instance-variables-to-existing-classes-in-Monticello-tp3707174p3707174.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Adding instance variables to existing classes in Monticello

Stéphane Ducasse
yes
when I want to do that for real

Hi nick

I do
        SystemClassFoo addInstanceVariableName: 'myInstanceVariable'

and put it in an initialize of my class

Clear instance Variable management is not that good.

>>
> As far as i can tell, this is not supported.
> If you allow things like that, then system become very fragilie.
>
> Suppose that you have two independently developed packages, which
> adding instance variable to same external class
> under same name.
> Such kind of conflicts is impossible to solve, because you never know
> what combination of package(s) could be loaded.
>
> Instead, what you can do is to save own version of package (with class
> where you added ivar) and distribute your code with
> this version of package.
>
>> --
>> Nick
>>
>> --
>> View this message in context: http://forum.world.st/Adding-instance-variables-to-existing-classes-in-Monticello-tp3707174p3707174.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding instance variables to existing classes in Monticello

patmaddox
In reply to this post by Igor Stasenko
On Jul 31, 2011, at 1:10 AM, Igor Stasenko wrote:

> On 31 July 2011 05:16, Nick Chen <[hidden email]> wrote:
>> Hi
>>
>> I have modified an existing class in the Smalltalk image and added an
>> instance variable to it. I would like to record this change -- added this
>> new instance variable -- in Monticello; that way my team can also pull in
>> the changes and have it work. This existing class is outside of my
>> Monticello package.
>>
>> Is this possible?
>>
>> I have tried following these two threads (~ 2008)
>>
>> *
>> http://forum.world.st/monticello-package-adding-instance-variables-to-existing-classes-td110740.html
>> *
>> http://forum.world.st/squeak-dev-MC-unload-action-and-postload-actions-td78441.html
>>
>> by creating a method on the class side e.g. TheObject class>>mcInstallOn:
>> aClassEditor but it does not seem to work.
>>
>> Is this functionality still supported or is there a new way to achieve this?
>>
>> Thanks!
>>
> As far as i can tell, this is not supported.
> If you allow things like that, then system become very fragilie.
>
> Suppose that you have two independently developed packages, which
> adding instance variable to same external class
> under same name.
> Such kind of conflicts is impossible to solve, because you never know
> what combination of package(s) could be loaded.
>
> Instead, what you can do is to save own version of package (with class
> where you added ivar) and distribute your code with
> this version of package.

...and use metacello to specify that dependency.

Pat

Reply | Threaded
Open this post in threaded view
|

Re: Adding instance variables to existing classes in Monticello

Joan Güell
In reply to this post by Igor Stasenko


HI

MyClass class >>

addMyProgamInstanceVariables
(self instVarNames includes: 'myVariable')
ifFalse: [ self addInstVarNamed: 'myVariable' ].

and put it in an initialize of my class 

or create MyProgranInsaler class >>

addAllNeededInstanceVariables
{MyClass. ClassB. ClassC } do: [ :each | each addMyProgramInstanceVariables ]

initialize
self addAllNeededInstanceVariables.


El 31/07/2011, a las 07:10, Igor Stasenko escribió:

On 31 July 2011 05:16, Nick Chen <[hidden email]> wrote:
Hi

I have modified an existing class in the Smalltalk image and added an
instance variable to it. I would like to record this change -- added this
new instance variable -- in Monticello; that way my team can also pull in
the changes and have it work. This existing class is outside of my
Monticello package.

Is this possible?

I have tried following these two threads (~ 2008)

*
http://forum.world.st/monticello-package-adding-instance-variables-to-existing-classes-td110740.html
*
http://forum.world.st/squeak-dev-MC-unload-action-and-postload-actions-td78441.html

by creating a method on the class side e.g. TheObject class>>mcInstallOn:
aClassEditor but it does not seem to work.

Is this functionality still supported or is there a new way to achieve this?

Thanks!

As far as i can tell, this is not supported.
If you allow things like that, then system become very fragilie.

Suppose that you have two independently developed packages, which
adding instance variable to same external class
under same name.
Such kind of conflicts is impossible to solve, because you never know
what combination of package(s) could be loaded.

Instead, what you can do is to save own version of package (with class
where you added ivar) and distribute your code with
this version of package.

--
Nick

--
View this message in context: http://forum.world.st/Adding-instance-variables-to-existing-classes-in-Monticello-tp3707174p3707174.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.





--
Best regards,
Igor Stasenko AKA sig.


Joan Güell