[BUG][FIX] DeclarativePools
Andrew P. Black
black at cse.ogi.edu
Fri Jun 6 23:29:47 UTC 2003
I realize that I might be treading on the robes of wizards here, but
I can never resist asking a few "dumb" questions.
At 16:20 -0700 06/05/2003, Tim Rowledge wrote:
>Let's say we have converted GZipConstants to be one of your nice
>SharedPool subclasses and now we try to load a package where the old
>dictionary of GZipConstants was included in the fileout (I suspect this
>is pretty rare but not infinitely so). The file will start with
>
>Smalltalk at: #GZipConstants put: Dictionary new!
>GZipConstants at: #foo put: 'bar'!
So the problem -- if I understand what's been said so far -- is that
our nice global variable GZipConstants that used to point to our nice
new class now refers a dictionary instead, and any attempt to compile
new code referencing the GZipConstants class will instead end up
referencing the dictionary, and that would be be bad. It would be
particularly bad because the problem might not be discovered for
weeks (how often do I compile code that references GZipConstants?),
and when I discover the problem, I've completely forgotten that I
ever *filed in some package or other ...
My naive question was going to be: can't we just fix the filein code
so that any attempt to execute Smalltalk at: aSymbol where aSymbol
is already bound to a class would be an error. This would generate
the error at the earliest possible time, when it would be relatively
easy to fix.
Then I thought: isn't that EXACTLY what the read-only variable
binding stuff is designed to accomplish (in addition to stopping me
from accidentally doing SmallInterger := 3 in a workspace).
So I started to look at ReadOnlyVariableBinding, and yes, it does
just the right thing.
BUT I can't find any place that *uses* ReadOnlyVariableBinding. That
is, the class is used in
LookupKey >> beReadOnlyBindingAnnouncing:
which is sent by
LookupKey >> beReadOnlyBinding
which does not appear to be sent at all in my 3.4 image.
Of the 2084 bindings in Smalltalk, 2056 are to classes. Most of
these are ReadOnlyVariableBindings, but
Smalltalk associations reject: [:a | (a value isKindOf:
Class) ==> [a isKindOf: ReadOnlyVariableBinding] ]
388 of them are not. I would expect that somewhere down in
ClassBuilder, when installing a newly compiled class in Smalltalk,
the binding would be made readOnly, but I still can't find that code,
although I can find the code that handles the Error that is raises
when a ReadOnlyVariableBinding is updated.
So, finally, my "naive" question:
(1) When are ReadOnlyVariableBindings created,
(2) Why is this mechanism not applied to those other 388 classes, and
(3) If ReadOnlyVariableBindings were used uniformly, would
they not solve the problem of turning PoolDictionaries into classes
and then protecting them from overwriting
Along the way, I encountered a need to clean up the various kinds of
Association, for example, so that ReadOnlyVariableBindings print as a
-> b. But that is another topic.
Andrew
More information about the Squeak-dev
mailing list
|