On 9 Dec 2009, at 02:11, Robert Poor wrote:
I now understand a bit more about initialization of static variables -- more accurately, about execution of top-level code -- and while it's not earth-shattering, I thought I'd pass it along. It may avoid some astonishment.
The rules are simple, but are different than I thought:
-- top level forms INSIDE a class definition are executed every time an instance of that class is created.
-- top level forms OUTSIDE of a class definition are executed once when the file loads.
Yes, that is what was discussed in the "static bug" thread. If one throws in some "static" data into the class for use with static functions, that data is not initialized until there has been an object of that class initialized. And the static data is probably re- initialized every time an new object is initialized. Also, it seems possible to use "static" outside a class, but I do not know the semantics. Hans