--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbol.st Fri Jul 16 11:39:45 1993 +0200
@@ -0,0 +1,159 @@
+"
+ COPYRIGHT (c) 1988-93 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+String subclass:#Symbol
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
+!
+
+Symbol comment:'
+
+COPYRIGHT (c) 1988-93 by Claus Gittinger
+ All Rights Reserved
+
+Symbols represent unique strings - every symbol with same printString
+exists exactly once in the system; Symbols are used for selectors, global
+variable-keys etc.
+
+%W% %E%
+'!
+
+!Symbol class methodsFor:'instance creation'!
+
+basicNew:size
+ "catch instance creation - symbols are not created with new"
+
+ self error:'symbols may not be created with new:'
+!
+
+intern:aString
+ "return a unique symbol with printname taken from the String-argument"
+
+%{
+ if (_isString(aString)) {
+ RETURN ( _MKSYMBOL(_stringVal(aString), (OBJ *)0, __context) );
+ }
+%}
+.
+ ^ self mustBeString
+!
+
+internCharacter:aCharacter
+ "return a unique symbol with printname taken from the Character-argument"
+
+ ^ self intern:(aCharacter asString)
+! !
+
+!Symbol class methodsFor:'queries'!
+
+hasInterned:aString ifTrue:trueBlock
+ "for ST-80 compatibility - if the argument, aString is known
+ as Symbol, evaluate the block with the corresponding symbol
+ as argument and return true; otherwise return false"
+
+ aString knownAsSymbol ifTrue:[
+ trueBlock value:(aString asSymbol).
+ ^ true
+ ].
+ ^ false
+! !
+
+!Symbol methodsFor:'accessing'!
+
+basicAt:index put:something
+ "report an error - symbols may not be changed"
+
+ self error:'symbols may not be changed'
+!
+
+at:index put:something
+ "report an error - symbols may not be changed"
+
+ self error:'symbols may not be changed'
+! !
+
+!Symbol methodsFor:'copying'!
+
+deepCopy
+ "return a copy of myself
+ - reimplemented here since symbols are unique"
+
+ ^ self
+! !
+
+!Symbol methodsFor:'converting'!
+
+asString
+ "return a string with printname taken from mine"
+
+ ^ self printString
+!
+
+asSymbol
+ "I am a symbol - just return myself"
+
+ ^ self
+! !
+
+!Symbol methodsFor:'misc'!
+
+species
+ ^ String
+!
+
+nArgsIfSelector
+ "if symbol is used as a selector, how many arguments would it take"
+
+ |binopChars|
+
+ (self size > 2) ifFalse:[
+ binopChars := '|&-+=*/\<>~@,'.
+ (self size == 1) ifTrue:[
+ ((binopChars occurrencesOf:(self at:1)) == 0) ifTrue:[^ 0].
+ ^ 1
+ ].
+ ((binopChars occurrencesOf:(self at:1)) == 0) ifFalse:[
+ ((binopChars occurrencesOf:(self at:2)) == 0) ifFalse:[^ 1]
+ ]
+ ].
+ ^ self occurrencesOf:$:
+! !
+
+!Symbol methodsFor:'printing & storing'!
+
+printString
+%{
+ RETURN ( _MKSTRING(_stringVal(self) COMMA_CON) );
+%}
+!
+
+printOn:aStream
+ "aStream nextPut:$#."
+ aStream nextPutAll:(self printString)
+!
+
+displayString
+ ^ self storeString
+!
+
+storeString
+ "return a String for storing myself"
+
+ ^ $# asString , self
+!
+
+storeOn:aStream
+ aStream nextPut:$#.
+ aStream nextPutAll:(self printString)
+! !