Creating new pseudovariables in Squeak
Most of the violin is implemented using the squeak itself. I'm curious to see if pseudo variables like self
or can true
use squeak. If the answer is yes, where is the implementation implemented?
In particular, suppose I want to add a new "Boolean" subclass called "Other" that will represent the third option: neither true nor false. I want the other
single instance to other
be like true / false global singletons.
Any ideas? Thanks.
a source to share
The previous answer will not work without additional modification to your Smalltalk image, because Boolean overrides a new one to throw 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 adding another keyword to Smalltalk globals as above, you will throw an error.
You can remove Boolean -> new, implement your other class, add it to your Smalltalk globals, and then replace Boolean -> new.
Next, you might consider updating the ClassBuilder> Reserved Names 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).
a source to share