[squeak-dev] Re: Small question about ReadOnlyVariableBinding
andreas.raab at gmx.de
Wed Nov 23 08:17:15 UTC 2011
On 11/22/2011 21:52, Ricardo Moran wrote:
> Hi guys,
> I have just a small question: how dangerous would it be if I change a
> system dictionary association (such as #SerialPort) to be a read-write
> I want to be able to provide a different abstraction for SerialPort than
> the one squeak provides, but I don't want to change all the code that
> uses it. So I though a quick and dirty way to do it would be to replace
> it in the SystemDictionary, like this:
> Smalltalk at: #SqueakSerialPort put: SerialPort.
> (Smalltalk associationOrUndeclaredAt: #SerialPort) beReadWriteBinding.
> Smalltalk at: #SerialPort put: MySerialPort
> Apart from being an ugly hack, do you think that could be dangerous in
> some way?
This should work fine. ReadOnlyVariableBindings are there to protect
against accidentally overwriting system globals (i.e., when executing
"Array := new" in a workspace which is one of my favorite mistakes :-)
But as long as you know what you're doing, go ahead.
BTW, it will be faster to install your class if you do the following (it
avoids the need to recompile all references):
[SerialPort := SqueakSerialPort]
do:[:ex| ex resume: true].
More information about the Squeak-dev