Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of class-side #initialize is not portable #838

GoogleCodeExporter opened this issue Mar 25, 2015 · 1 comment

Usage of class-side #initialize is not portable #838

GoogleCodeExporter opened this issue Mar 25, 2015 · 1 comment


Copy link

The semantics of when the class-side #initialize method are not consistent 
across implementations.

In Pharo, the class-side #initialize is run on the first load of code or when 
the source of the #initialize method changes.

In VA Smalltalk, the class side #initialize is run on every load of code.

I don't know the semantics on other platforms.

This problem has apparently been discovered in the past since some Seaside 
#initialize methods contain guard code to ensure they are not rerun. For 
example, WAEnvironment class>>#initialize calls configureApplicationDefaults 
which has this (guard coded) implementation:

    (configuredApplicationDefaults ifNil: [ false ]) ifFalse: [
        WAAdmin applicationDefaults
            at: #responseGenerator put: WAHtmlResponseGenerator.
        configuredApplicationDefaults := true ]

So, assuming that guard codes are the proper way to handle this situation, I 
find only one problematic class-side initialization - WASharedConfiguration 

    instances := Set new

This needs to be changed to:

    instances ifNil: [ instances := Set new ]

Since Pharo will run the #initialize method only once, this will cause no harm 
there, and since VA Smalltalk will run the #initialize method every time the 
code is loaded, it is necessary there.

Original issue reported on by on 9 Feb 2015 at 10:34

Copy link

Name: Seaside-Core-pmm.862
Author: pmm
Time: 17 July 2015, 10:32:50.323475 am
UUID: 82f075d2-59cd-4b21-8c18-2b2d91eac009
Ancestors: Seaside-Core-pmm.861

#838 Usage of class-side #initialize is not portable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants