|
|
6.100 Namespace
- Defined in namespace Smalltalk
- Category: Language-Implementation
- I am a special form of dictionary. I provide special ways to access my
keys, which typically begin with an uppercase letter. Classes hold on
an instance of me; it is called their `environment').
My keys are (expected to be) symbols, so I use == to match searched keys
to those in the dictionary -- this is done expecting it brings a bit more
speed.
6.100.1 Namespace class: accessing
- current
- Answer the current namespace
- current: aNamespace
- Set the current namespace to be aNamespace.
6.100.2 Namespace class: disabling instance creation
- new
- Disabled - use #addSubspace: to create instances
- new: size
- Disabled - use #addSubspace: to create instances
6.100.3 Namespace: accessing
- inheritedKeys
- Answer a Set of all the keys in the receiver and its superspaces
6.100.4 Namespace: namespace hierarchy
- siblings
- Answer all the other namespaces that inherit from the receiver's superspace.
- siblingsDo: aBlock
- Evaluate aBlock once for each of the other namespaces that inherit from the receiver's superspace, passing the namespace as a parameter.
6.100.5 Namespace: overrides for superspaces
- associationAt: key ifAbsent: aBlock
- Return the key/value pair associated to the variable named as specified by `key'. If the key is not found search will be brought on in superspaces, finally evaluating aBlock if the variable cannot be found in any of the superspaces.
- associationsDo: aBlock
- Pass each association in the namespace to aBlock
- at: key ifAbsent: aBlock
- Return the value associated to the variable named as specified by `key'. If the key is not found search will be brought on in superspaces, finally evaluating aBlock if the variable cannot be found in any of the superspaces.
- at: key ifPresent: aBlock
- If aKey is absent from the receiver and all its superspaces, answer nil. Else, evaluate aBlock passing the associated value and answer the result of the invocation
- do: aBlock
- Pass each value in the namespace to aBlock
- includesKey: key
- Answer whether the receiver or any of its superspaces contain the given key
- keysAndValuesDo: aBlock
- Pass to aBlock each of the receiver's keys and values, in two separate parameters
- keysDo: aBlock
- Pass to aBlock each of the receiver's keys
- set: key to: newValue ifAbsent: aBlock
- Assign newValue to the variable named as specified by `key'. This method won't define a new variable; instead if the key is not found it will search in superspaces and evaluate aBlock if it is not found. Answer newValue.
- size
- Answer the number of keys in the receiver and each of its superspaces
6.100.6 Namespace: printing
- name
- Answer the receiver's name
- nameIn: aNamespace
- Answer Smalltalk code compiling to the receiver when the current namespace is aNamespace
- storeOn: aStream
- Store Smalltalk code compiling to the receiver
6.100.7 Namespace: testing
- isSmalltalk
- Answer `true'.
|