ProtoObject » Object
Class Object is the superclass of all classes. The Object protocol defines the common protocol of all objects. The most important protocol categories are:
It is possible to create instances of Object, but this is usually not done. An instance of Object can have dependents, but normally an instance of Model is used to manage dependent objects.
Class Object implements the general mechanism for dependency management and changes notification. Dependent objects are kept in a WeakIdentityKeyDictionary.
initialize
Replace the dictionary of all dependents with a new, empty one.
Evaluation of this method removes all dependencies that are not
managed by instances of class Model.
The dictionary of all dependent objects is a WeakIdentityKeyDictionary.
Dependents are automatically removed from such a dictionary when they
become unreachable. It is therefore normally not necessary to evaluate
this method.
These methods are used by the debugger and by the various inspectors. The use of these methods in applications is not recommended. detailed description
== anObject
The method answers true if the receiver and anObject are
the same object, otherwise, is answers false.
It is not recommended to redefine this method in a subclass
~~ anObject
The method answers true if the receiver is not identic with
anObject, otherwise, is answers false.
This method is defined in terms of == and there is no need
to redefine it for a subclass.
= anObject
The method answers whether the receiver and the argument are the same
object. The default implementation checks object identity, but many
subclasses redefine this method. Whenever this method is redefined, an
appropriate redefinition of method hash is required.
A definition of this method for a subclass should never fail.
For robust definitions it is good practice to check class equality
(or class compatibility) first. A good method template is :
= anObject self class = anObject class ifFalse: [^false] ifTrue: [" additional checks can now use the instance protocol of self to access instance variables of anObject " ^"result of comparision" ]
~= anObject
The method answers whether the receiver and the argument are not the
same object.
This method is defined in terms of = and there is no need
to redefine it for a subclass.
hash
The method answers a SmallInteger whose value is related to the
receiver's identity. May be overridden, and should be overridden in any
classes that define =.
A hash function is required to map equal objects to the same integer value.
shallowCopy
Answer a copy of the receiver which shares the receiver's instance
variables.
deepCopy
Answer a copy of the receiver with its own copy of each instance
variable.
copy
Answer another instance just like the receiver. Subclasses typically
override postCopy; they typically do not override shallowCopy. This
method answers essentially a shallow copy, but for some classes this
method copies objects that would be shared in a shallow copy. (Set
is an example of a class that redefines the method copy to
create a shallow copy of an Array that cannot be shared among copies.)
error: aString
An error with description aString is signaled. An exception
handler for the
exception Error will handle this error. If no handler is
present, an
error notification window will be displayed. From this window, the user
can enter the
debugger.
halt
The exception Halt is signaled. An exception handler for the
exception Halt will handle this error. If no handler is
present, an
error notification window will be displayed. From this window, the user
can enter the
debugger.
inspect
An inspector for the receiver is opened.
doesNotUnderstand: aMessage
This message is sent by the virtual machine when an attempt to send
aMessage to the receiver failed. This happens when the message
is not defined in the receiver's protocol.
The default behaviour is first to try to define the unknown message as
an accessor method. If this is either unwanted or impossible, the
exception MessageNotUnderstood is signalled.
The method doesNotUnderstand: can be
redefined in any subclass that needs special handling of unknown
messages. In fact, redefinition of this method is often used in wrappers
to forward messages to the wrapped object.
This method is also implemented in ProtoObject and the implementation in Object adds only the additional attempt to autodefine missing accessor methods.
dependents
The method answers the possibly empty collection of the receivers dependents.
breakDependents
This method drops all dependents of the receiver.
It is designed for use by subclasses of
Model in local implementations of method postCopy.
addDependent: anObject
This method registers anObject as a dependent object of
the receiver.
removeDependent: anObject
This method removes anObject from the collection of the receivers
dependent objects. The method does nothing if anObject is not
registered as a dependnet of the receiver.
changed
An object sends this message to itself to inform itself about
an unspecified change of state. The default implementation
translates the message
self changed.
self changed: self.
changed: anObject
An object sends this message to itself to inform itself about
a change of state that is further specified by the message argument.
The default implementation reacts by sending an update:
message to all dependents.
changed: anAspect
with: anObject
An object sends this message to itself to inform itself about
a change of state that is further specified by the message arguments.
The default implementation reacts by sending an update:with:
message to all dependents.
update: anObject
default is to do nothing
update: anAspect
with: anObject
The default implementation translates this into
self update: anAspect.
class
Returns the class of the receiver.
species
Answer the preferred class for reconstructing the receiver. For
example, collections create new collections whenever enumeration
messages such as collect: or select: are invoked. The new kind of
collection is determined by the species of the original collection.
Species and class are not always the same. For example, the species of
Interval is Array.
isKindOf: aClass
Answer whether the class, aClass, is a superclass or class of the
receiver.
isMemberOf: aClass
Answer whether the receiver is an instance of the class, aClass.
respondsTo: aSymbol
Answer whether the method dictionary of the receiver's class contains
aSymbol as a message selector.