Back: String-testing functionality Up: Base classes Forward: Symbol class-built ins   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.157 Symbol

Defined in namespace Smalltalk
Superclass: String
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.

1.157.1 Symbol class: built ins  (class)
1.157.2 Symbol class: instance creation  (class)
1.157.3 Symbol class: symbol table  (class)
1.157.4 Symbol: basic  (instance)
1.157.5 Symbol: built ins  (instance)
1.157.6 Symbol: converting  (instance)
1.157.7 Symbol: misc  (instance)
1.157.8 Symbol: storing  (instance)
1.157.9 Symbol: testing  (instance)
1.157.10 Symbol: testing functionality  (instance)


1.157.1 Symbol class: built ins

intern: aString
Private - Same as 'aString asSymbol'


1.157.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


1.157.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.

calculates

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.


1.157.4 Symbol: basic

deepCopy
Returns a deep copy of the receiver. As Symbols are identity objects, we actually return the receiver itself.

keywords
Answer an array of keywords that compose the receiver, which is supposed to be a valid message name (#+, #not, #printOn:, #ifTrue:ifFalse:, etc.)

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.


1.157.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


1.157.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.


1.157.7 Symbol: misc

species
Answer `String'.


1.157.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.

storeLiteralOn: aStream
Print Smalltalk code on aStream that compiles to the same symbol as the receiver.

storeOn: aStream
Print Smalltalk code on aStream that compiles to the same symbol as the receiver.


1.157.9 Symbol: testing

isSimpleSymbol
Answer whether the receiver must be represented in quoted-string (e.g. #'abc-def') form.


1.157.10 Symbol: testing functionality

isString
Answer `false'.

isSymbol
Answer `true'.



Back: Symbol-testing Up: Symbol Forward: SymLink   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on July, 23 2009 using texi2html