next up previous contents index
Next: 3.4 Traits Up: 3 The Slate World Previous: 3.2 Core Behaviors   Contents   Index

Subsections

3.3 Introspection

3.3.1 Slot Queries

Objects may be queried directly for various attributes that they have. These should not be used in ordinary ``non-private'' code, only in specific uses which need to operate on arbitrary object-slot structures or inside of accessor methods.

atSlotNamed:
answers the value of the slot with the given name.
atSlotNamed:put:
fills the delegate slot with the given name. It answers the object modified.
atDelegateNamed:
answers the value of the delegate slot with the given name.
atDelegateNamed:put:
fills the delegate slot with the given name. It answers the object modified.
slotNames
answers an Array of the names of the object's direct slots.
delegateNames
answers an Array of the names of the object's direct delegate slots.
slotsDo:
applies a block to each slot's value.
delegatesDo:
applies a block to each delegate slot's value.
addAccessorFor:
defines a default accessor (aka ``getter'') method for the slot with the given name.
addMutatorFor:
defines a default mutator (aka ``setter'') method for the slot with the given name.
addAccessor:for:
installs the given method as accessor for the slot with the given name.
addMutator:for:
installs the given method as mutator for the slot with the given name.

3.3.2 Method Queries

Slate includes a protocol for common query operations on Method objects:

selector
answers the Symbol naming the Method if it has been defined and installed under some objects' roles, or Nil if it is unnamed (an ordinary block).
isNamed
answers whether the Method is a named method; that is, whether it is installed with a dispatch signature and selector.
arity
answers the number of arguments expected as input to the Method. This excludes any optional keyword arguments or rest arguments that it may accept. This also applies to the quoted form of a literal method.
acceptsAdditionalArguments
answers whether the Method takes a rest parameter.
allSelectorsSent
answers an Array of all Symbols that the block directly (in its defining source) sends. This also applies to the quoted form of a literal method.
methodsNamed:
answers all distinct Method objects with the given name stored in roles on the given object.
methodsAt:
answers all distinct Method objects stored in the role position given on the given object.
methodsNamed:at:
answers all distinct Method objects stored in roles on the given object with the given name and at the given role position.
methodsSending:
answers all distinct Method objects stored in roles on the given object which send the given selector.
signature &in:
answers a Signature object (roles plus selector) corresponding to the given (named) Method's definition. This currently involves a search and takes a variable amount of time.
Symbol implementations
answers a Set of all Methods whose selector is the argument. An &in: optional parameter restricts the search to one object (as namespace).
Symbol senders
answers a Set of all Methods which send the argument selector. An &in: optional parameter restricts the search to one object (as namespace).
Symbol macroSenders
answers a Set of all Methods which send the argument selector. An &in: optional parameter restricts the search to one object (as namespace).


next up previous contents index
Next: 3.4 Traits Up: 3 The Slate World Previous: 3.2 Core Behaviors   Contents   Index
Brian Rice 2005-11-21