Strange instance class valiable behavior 
Author Message
 Strange instance class valiable behavior

Hi,

    I'm experiencing a strange behavior here, perhaps someone could bring
some ligth to this matter.

    This app had a singleton that holds configuration info and I mada that
this object saves on disk (stb format) and loads from disk. As every
singleton does, it verifies for it's class instance variable called
'current' (so original :).

    In the development environment everithing is ok, but in the executable,
current isn't nil at the begining. Even when I check for allInstances of
that class (having 0), and inspect this class instance variable with flipper
to check that where nil.

    I've logged the instanciation of the variable and never (in the exe)
enters inside the true

    current ifNil:[ current := self loadInstnace ].

    ^ current

    mrs. wizards... I need some help here..

    regards

Seb



Wed, 06 Jul 2005 21:34:49 GMT  
 Strange instance class valiable behavior
Seb,

Quote:
>     This app had a singleton that holds configuration info and I mada that
> this object saves on disk (stb format) and loads from disk. As every
> singleton does, it verifies for it's class instance variable called
> 'current' (so original :).

>     In the development environment everithing is ok, but in the
executable,
> current isn't nil at the begining. Even when I check for allInstances of
> that class (having 0), and inspect this class instance variable with
flipper
> to check that where nil.

>     I've logged the instanciation of the variable and never (in the exe)
> enters inside the true

>     current ifNil:[ current := self loadInstnace ].

Are you sure this isn't some kind of weird #ifNil: behavior???   I raise the
question only because I don't use those shortcut methods.

The variable is class-side, but you're using a name starting w/ lower case.
That's not conventional, and I vaguely recall Dolphin or Squeak informing me
of that/refusing to cooperate when I did the same thing.

Could you be getting fooled by a workspace variable?  Maybe you are looking
at a "hidden" current in the IDE and the exe is looking for Current, or vice
versa.  As you can tell, I think workspace variables are a bug, not a
feature :)

Those issue aside, have you output a print string or something to show what
current/Current holds in the exe?  Could a Lagoon script be assigning
something to the variable?  Also, on the off chance that you are using
SuiteBuilder, look at your #suiteBuilderPreDeploy methods to verify that
they don't set Current late in the game.

Good luck!

Bill

--
Wilhelm K. Schwab, Ph.D.



Thu, 07 Jul 2005 04:11:57 GMT  
 Strange instance class valiable behavior

Quote:

> Even when I check for
> allInstances of that class (having 0), and inspect this class
> instance variable with flipper to check that where nil.

Are you doing this just before you strip? The Deployment log that is
produced when stripping shows how many instances of each class remain in the
stripped image. Is that showing 0?

Assuming the problem is that for some reason current is not nil, you could
try setting it to nil in the deployment "Pre-Strip Script". Alternatively,
the first thing your SessionManager>>main method could do is to set it to
nil.

Hope this helps,
Steve

--
Steve Waring

About: http://www.dolphinharbor.org/dh/harbor/steve.html
Journal: http://www.stevewaring.net/blog/home/index.html



Thu, 07 Jul 2005 05:37:42 GMT  
 Strange instance class valiable behavior

Quote:
> The variable is class-side, but you're using a name starting w/ lower
case.
> That's not conventional, and I vaguely recall Dolphin or Squeak informing
me
> of that/refusing to cooperate when I did the same thing.

I only  relatively began Smalltalking seriously but I think that for class
instance variables this rule is not correct, as it is in fact the instance
var of a class object. The speciality about CLASS vraiables is that they are
visible to all instances AND classes even for all subclasses, so there is a
good point in defining them capitalized as mixup with instance vars is quite
likely. For class instance vars there is IMO no point in naming the
uppercase at all, especially as the same mixup with ClassVars exists.

Anyway I remember Squeak used uppercase class inst vars, but I am not shure
it is enforced. At least I consider it bad practise for the above reasons.

Just my two cents...

Ciao

...Jochen



Fri, 08 Jul 2005 17:05:00 GMT  
 Strange instance class valiable behavior
Hi Steve,

    thats a good point I'll try it to unmistify this :)

    Anyway I had to make it some other way to get it 'on time' and worked.

    thank you all,

Seb



Quote:

> > Even when I check for
> > allInstances of that class (having 0), and inspect this class
> > instance variable with flipper to check that where nil.

> Are you doing this just before you strip? The Deployment log that is
> produced when stripping shows how many instances of each class remain in
the
> stripped image. Is that showing 0?

> Assuming the problem is that for some reason current is not nil, you could
> try setting it to nil in the deployment "Pre-Strip Script". Alternatively,
> the first thing your SessionManager>>main method could do is to set it to
> nil.

> Hope this helps,
> Steve

> --
> Steve Waring

> About: http://www.dolphinharbor.org/dh/harbor/steve.html
> Journal: http://www.stevewaring.net/blog/home/index.html



Fri, 08 Jul 2005 18:50:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Unexpected behavior with class and instance variables...

2. How to change class instances behavior via reload?

3. instances of classes and instances of instances

4. Instance of class as a class

5. Can a class instance also be a class?

6. Classes - instance/class, methods/members, inheritance and best p ractices

7. Comparing class instance with class

8. Problem with calling instance of one class from another class

9. repeated class redefinition and update-instance-for-redefined-class

10. Classes - instance/class, methods/members, inheritance and be st practices

11. Strange positioning of class function calls within classes

12. Instance-Epecific Behavior

 

 
Powered by phpBB® Forum Software