|
|
6.134 Symbol
- Defined in namespace Smalltalk
- Category: Language-Implementation
- My instances are unique throughout the Smalltalk system. My instances
behave for the most part like strings, except that they print differently,
and I guarantee that any two instances that have the same printed
representation are in fact the same instance.
6.134.1 Symbol class: built ins
- intern: aString
- Private - Same as 'aString asSymbol'
6.134.2 Symbol class: instance creation
- internCharacter: aCharacter
- Answer the one-character symbol associated to the given character.
- new
- This method should not be called for instances of this class.
- new: size
- This method should not be called for instances of this class.
- with: element1
- Answer a collection whose only element is element1
- with: element1 with: element2
- Answer a collection whose only elements are the parameters in the order they were passed
- with: element1 with: element2 with: element3
- Answer a collection whose only elements are the parameters in the order they were passed
- with: element1 with: element2 with: element3 with: element4
- Answer a collection whose only elements are the parameters in the order they were passed
- with: element1 with: element2 with: element3 with: element4 with: element5
- Answer a collection whose only elements are the parameters in the order they were passed
6.134.3 Symbol class: symbol table
- hasInterned: aString ifTrue: aBlock
- If aString has not been interned yet, answer false. Else, pass the interned version to aBlock and answer true. Note that this works because String>>#hash calculates the same hash value used by the VM when interning strings into the SymbolTable. Changing one of the hashing methods without changing the other will break this method.
- isSymbolString: aString
- Answer whether aString has already been interned. Note that this works because String>>#hash calculates the same hash value used by the VM when interning strings into the SymbolTable. Changing one of the hashing methods without changing the other will break this method.
- rebuildTable
- Rebuild the SymbolTable, thereby garbage-collecting unreferenced Symbols. While this process is done, preemption is disabled because it is not acceptable to leave the SymbolTable in a partially updated state. Note that this works because String>>#hash calculates the same hash value used by the VM when interning strings into the SymbolTable. Changing one of the hashing methods without changing the other will break this method.
6.134.4 Symbol: basic
- deepCopy
- Returns a deep copy of the receiver. As Symbols are identity objects, we actually return the receiver itself.
- numArgs
- Answer the number of arguments supported by the receiver, which is supposed to be a valid message name (#+, #not, #printOn:, #ifTrue:ifFalse:, etc.)
- shallowCopy
- Returns a deep copy of the receiver. As Symbols are identity objects, we actually return the receiver itself.
6.134.5 Symbol: built ins
- = aSymbol
- Answer whether the receiver and aSymbol are the same object
- hash
- Answer an hash value for the receiver. Symbols are optimized for speed
6.134.6 Symbol: converting
- asString
- Answer a String with the same characters as the receiver
- asSymbol
- But we are already a Symbol, and furthermore, Symbols are identity objects! So answer the receiver.
6.134.7 Symbol: misc
- species
- Answer `String'.
6.134.8 Symbol: storing
- displayOn: aStream
- Print a represention of the receiver on aStream. For most objects this is simply its #printOn: representation, but for strings and characters, superfluous dollars or extra pairs of quotes are stripped.
- displayString
- Answer a String representing the receiver. For most objects this is simply its #printString, but for strings and characters, superfluous dollars or extra pair of quotes are stripped.
- printOn: aStream
- Print a represention of the receiver on aStream.
6.134.9 Symbol: testing
- isSimpleSymbol
- Answer whether the receiver must be represented in quoted-string (e.g. #'abc-def') form.
6.134.10 Symbol: testing functionality
- isString
- Answer `false'.
- isSymbol
- Answer `true'.
|