Reputation: 5329
Large part of squeak is implemented using squeak itself. I am curious to know if pseudo variables such as self
or true
are also implemented using squeak. If the answer is yes, where the implementation located?
Specifically, assume that I want to add new subclass of "Boolean" called "Other" which will represent a third option: neither true nor false. I want that other
, the only instance of Other
to be similar to the true/false global singletons.
Any ideas? Thank you.
Upvotes: 2
Views: 145
Reputation: 21
The previous answer won't work without further modification to your Smalltalk image because Boolean overrides new to raise an error
new
self error: 'You may not create any more Booleans - this is two-valued logic'
If you try Boolean subclass: #Other and then try to add the other keyword to the Smalltalk globals as above, you will raise an error.
You could remove Boolean>>new, implement your Other class, add it to your Smalltalk globals, then replace Boolean>>new.
Next, you might consider updating ClassBuilder>reservedNames to protect your new Boolean
reservedNames
"Return a list of names that must not be used for variables"
^#('self' 'super' 'thisContext' 'true' 'false' 'nil'
self super thisContext #true #false #nil).
Upvotes: 1