[Pharo-users] Updating a project and NIL class variables

Sven Van Caekenberghe sven at stfx.eu
Wed Jan 20 14:20:35 EST 2016


> On 20 Jan 2016, at 18:06, Henrik Nergaard <henrik.nergaard at uia.no> wrote:
> 
> “The warning is: this only happens when the *source* code of the #initialize methods changes. So sometimes, you will have to touch that method to force it.”
> Perhaps there should be an overload able method that decides whether or not to initialize the class, such that classes relying on reinitializing  every time a change is merged, can do this by simply answering true?

Seems like a good idea, to modify the logic in MCMethodDefinition>>#postloadOver:

However, I have a feeling that maybe people already have thought/discussed about this in the past, maybe we should find out why it was decided to do it like this.

A question is also: will the test method only run in the existing image, and/or does the incoming code have an influence, because that could require two version before an initialiser runs in the worst case (previous version says no, incoming says yes).

Just thinking out loud.

> From: Pharo-users [mailto:pharo-users-bounces at lists.pharo.org] On Behalf Of Dimitris Chloupis
> Sent: Wednesday, January 20, 2016 3:47 PM
> To: Any question about pharo is welcome <pharo-users at lists.pharo.org>
> Subject: Re: [Pharo-users] Updating a project and NIL class variables
>  
> no apologies owed, I just asked because I want to make sure Pharo wont do anything weird behind my back :)
>  
> On Wed, Jan 20, 2016 at 4:39 PM Sven Van Caekenberghe <sven at stfx.eu> wrote:
> 
> > On 20 Jan 2016, at 15:34, Dimitris Chloupis <kilon.alios at gmail.com> wrote:
> >
> > Thank you for the info but I think I did not make myself clear because you say "remain nil"
> >
> > Ok Imagine a class SomeClass and that class has a variable we will call SomeVariable, class variable that is
> > , there is no class initialize method, now that class has a method that is eventually called ,
> > someMethod
> >
> > SomeVariable ifNil: [ SomeVariable := 'hello world']
> >
> > so when I decide to update this class via metacello loading the latest version from github ,  SomeVariable will have the value 'hello world'
> >
> > My question is , will SomeVariable after I do the update revert back to nil  or stay 'hello world' ?
> >
> > If your answer is no, and it stays 'hello world' then yes i need an initialize method and call it at update time.
> 
> Argh, I should have said: keeps it value, will not revert to nil.
> 
> Sorry for the confusion !
> 
> > On Wed, Jan 20, 2016 at 2:54 PM Sven Van Caekenberghe <sven at stfx.eu> wrote:
> > They remain nil.
> >
> > That is why #initialize on the class side is needed.
> >
> > You can call that explicitly in a post load script, or rely on the class loading mechanism that normally calls #initialize automatically when loading a class. The warning is: this only happens when the *source* code of the #initialize methods changes. So sometimes, you will have to touch that method to force it.
> >
> > I hope that makes sense.
> >
> > See MCMethodDefinition>>#postloadOver:
> >
> > > On 20 Jan 2016, at 13:41, Dimitris Chloupis <kilon.alios at gmail.com> wrote:
> > >
> > > So my question is this , I have a class with nil variables that are lazy initialised only when needed the first time and of course they keep their values from there on.
> > >
> > > Lets say I get the latest update from github via metacello over an older update that I already have inside the image , do those variables revert back to nil values ? or do they keep their values as they are ?
> >
> >
> 





More information about the Pharo-users mailing list