squeak-smalltalk / squeak-object-memory

Issues and assets related to the Squeak object memory.
https://bugs.squeak.org
MIT License
11 stars 1 forks source link

Class initialization order for file out of Change Sorter #22

Open dram opened 2 years ago

dram commented 2 years ago

When doing file out in Change Sorter, classes are sorted by inheritance hierarchy, i.e. super classes first, and then subclasses, but the class initialization statements are written in reversed order, which will cause problem if class variables are involved.

Take Swiki for example, following are definition of SwikiFile and SwikiImage, class variable MimeToClass is initialized in SwikiFile class>>initialize, and SwikiImage class>>initialize relies on that class variable.

SwikiEntry subclass: #SwikiFile
    instanceVariableNames: 'fileSize versions'
    classVariableNames: 'MimeToClass'
    poolDictionaries: ''
    category: 'Swiki-FileServer'
SwikiFile subclass: #SwikiImage
    instanceVariableNames: 'width height'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Swiki-FileServer'

Currently in Squeak 6.0, following is the initialization order in file out result of Swiki code, which I think is incorrect:

...
SwikiImage initialize!
SwikiFile initialize!
...

Actually, I have checked relevant code (ChangeSet>>fileOutOn:) in Squeak 3, Squeak 2 and even Squeak 1, it seems that code logic has been like this for a long time.

So I'm not really sure, is this a bug, or is there something wrong with my understanding?

P.S. Source code of Swiki downloaded from https://wiki.squeak.org/swiki/15 has correct order, not sure if it is tweaked manually after filing out.