Object is the root class of all other classes. All objects are indirect instances of class Object. We call the "receiver" the object the message is sent to:
Read in an object from a text archive.
A String containing the archive file's path.
Create a new instance. The creation of new instances of any Object actually happens in this method (or with
newCopyArgs) when it is called by a child class. See Writing Classes.
Creates a new instance and copies the arguments to the instance variables in the order that the variables were defined. If the superclass's
new method requires arguments, the first arguments passed to
newCopyArgs will be passed on to that method, and the following arguments will be copied to this class's instance variables. Class variables are ignored.
Answer the class of the receiver.
Answer a Boolean whether the receiver understands the message selector.
A selector name. Must be a Symbol.
Answer a Boolean indicating whether the receiver is a direct or indirect instance of aClass. Use of this message in code must be questioned, because it often indicates a missed opportunity to exploit object polymorphism.
Answer a Boolean whether the receiver is a direct instance of aClass. Use of this message in code is almost always a design mistake.
Different classes respond to this message differently. Object always returns 0.
Make a copy of the receiver. The implementation of this message depends on the object's class. In class Object, copy calls shallowCopy.
Makes a copy of the object. The copy's named and indexed instance variables refer to the same objects as the receiver.
Recursively copies the object and all of the objects contained in the instance variables, and so on down the structure. This method works with cyclic graphs.
If object is immutable then return a shallow copy, else return receiver.
To convert an object of a certain class into a similar object of another class, Object provides a number of methods.
Returns a similar new Object of a different class.
Returns an Array with the receiver, unless it is an Array already.
Returns a String that can be interpreted to reconstruct a copy of the receiver. For the complementary method, see String: -interpret.
Shorthand for -asCompileString.
Object implements methods for writing and retrieving objects from disk. Note that you cannot archive instances of Thread and its subclasses (i.e. Routine), or open Functions (i.e., a Function which refers to variables from outside its own scope).
Write an object to disk as a text archive.
A String containing the resulting file's path.
Answer whether the receiver equals anotherObject. The definition of equality depends on the class of the receiver. The default implementation in Object is to answer if the two objects are identical.
Answer whether the receiver is the exact same object as anotherObject.
Answer whether the receiver does not equal anotherObject. The default implementation in Object is to answer if the two objects are not identical (see below).
Returns the degree of equality between two objects with regard to a given precision. Objects to compare must support max, substraction, and division.
A number in the range 0 to 1.
Tests if two Objects (of the same class) are the same in a certain respect: It returns true if instVarNames are equal in both. If none are given, all instance variables are tested (see also: -instVarHash)
Answer a code used to index into a hash table. This is used by Dictionary and Set and their subclasses to implement fast object lookup. Objects which are equal == should have the same hash values. Whenever == is overridden in a class, hash should be overridden as well.
Answer a code used to index into a hash table. This method is implemented by a primitive and is not overridden. Objects which are identical === should have the same hash values.
Returns a combined hash value for the object's instance variables and the object's class. If none are given, all instance variables are tested (see also: -compareObject).
Answer a Boolean indicating whether the receiver is nil.
Answer a Boolean indicating whether the receiver is not nil.
Answer a Boolean indicating whether the receiver is an instance of Number.
Answer a Boolean indicating whether the receiver is an instance of Integer.
Answer a Boolean indicating whether the receiver is an instance of Float.
If the receiver is nil then answer anObject, otherwise answer the receiver.
If the receiver is nil, evaluate the Function and return the result.
If the receiver is not nil, evaluate the Function passing in the receiver as argument and return the result, otherwise return nil.
This method allow building up chains of actions to be performed on an object (possibly across several methods) without having to check if the object is nil or not. After all the desired actions are performed, -?? can be used to check if result the result is nil and supply a default value in that case.
x = nil, this will result in:
It was a nil, so I give a default value Point( 1, 1 )
x = Point(3,4), the result will be:
Point( 9, 12 )
Nested nil checks:
Returns true if receiver has a direct reference to obj.
Returns true if receiver is mutable.
Returns true if receiver is frozen.
Object implements a switch method which allows for conditional evaluation with multiple cases. These are implemented as pairs of test objects (tested using if this == test.value) and corresponding functions to be evaluated if true. In order for switch to be inlined (and thus be as efficient as nested if statements) the matching values must be literal Integers, Floats, Chars, Symbols and the functions must have no variables or arguments.
Instead of directly sending a method to an object, a method may be invoked given a method selector only (a Symbol). The other arguments may be provided by passing them directly, from an environment. If it is not known whether the receiver implements the method, tryPerform only sends if it does, and superPerform invokes the method of the superclass.
The selector argument must be a Symbol. Sends the method named by the selector with the given arguments to the receiver.
If the first argument is an Array or List, this method behaves like
performMsg. However, this usage is discouraged, and
performMsg ought to be used instead.
The selector argument must be a Symbol. Sends the method named by the selector with the given arguments to the receiver. If the last argument is a List or an Array, then its elements are unpacked and passed as arguments.
The argument must be a List or Array whose first element is a Symbol representing a method selector. The remaining elements are unpacked and passed as arguments to the method named by the selector.
A Symbol representing a method selector.
The remaining arguments derived from the environment and passed as arguments to the method named by the selector.
A Symbol representing a method selector.
Array or List with key-value pairs.
Like 'perform', but tryPerform passes the method to the receiver only if the receiver understands the method name. If the receiver doesn't implement that method, the result is nil. Note that this does not catch errors like 'try' does (see Exception). If the receiver does have a matching method but that method throws an error, execution will halt. But, 'tryPerform' is faster than 'try'.
Like perform, superPerform calls a method, however it calls the method on the superclass. selector: A Symbol representing a method selector. args: Method arguments.
Like performList, superPerformList calls a method, however it calls the method on the superclass. selector: A Symbol representing a method selector. args: Method arguments. If the last argument is a List or an Array, then its elements are unpacked and passed as arguments.
Perform selector with multichannel expansion. See also: Multichannel Expansion.
A Symbol representing a method selector.
Method arguments which, if they contain an array, will call the method multiple times for each sub-element.
Method definitions not yet implemented may be added to an Object instance.
Add a unique method.
Remove a unique method.
Remove all unique methods of an Object.
Add aDependant to the receiver's list of dependants.
Remove aDependant from the receiver's list of dependants.
Returns an IdentitySet of all dependants of the receiver.
Notify the receiver's dependants that the receiver has changed. The object making the change should be passed as theChanger.
An object upon which the receiver depends has changed. theChanged is the object that changed and theChanger is the object that made the change.
Remove all dependants of the receiver. Any object that has had dependants added must be released in order for it or its dependants to get garbage collected.
Object implements a number of methods which throw instances of Error. A number of methods (e.g. doesNotUnderstand) are 'private' and do not normally need to be called directly in user code. Others, such as those documented below can be useful for purposes such as object oriented design (e.g. to define an abstract interface which will be implemented in subclasses) and deprecation of methods. The reserved keyword thisMethod can be used to refer to the enclosing method. See also Method and Function (for exception handling).
Throws the receiver as an Exception, which may or may not be caught and handled by any enclosing Function.
Throws a SubclassResponsibilityError. Use this to indicate that this method should be defined in all subclasses of the receiver.
Throws a ShouldNotImplementError. Use this to indicate that this inherited method should not be defined or used in the receiver.
Throws a DeprecatedError. Use this to indicate that the enclosing method has been replaced by a better one (possibly in another class), and that it will likely be removed in the future. Unlike other errors, DeprecatedError only halts execution if
Error.debug == true. In all cases it posts a warning indicating that the method is deprecated and what is the recommended alternative.
Print a string representation of the receiver to the post window.
Print a string representation of the receiver followed by a newline.
Print a string representation of the receiver preceded by comments.
Print a string representation of the receiver preceded by comments, followed by a newline.
Print the compile string representation of the receiver, followed by a newline.
Print a detailed low level representation of the receiver to the post window.
Posts garbage collector information in a table format.
Then for each size class: numer of black, white and free objects, total number of objects and the total set size.
You can also query the amount of free memory with
Object.totalFree and dump the currently grey objects with
Object.dumpGrey. More memory status methods are: largestFreeBlock, gcDumpSet, and gcSanity.
Object evaluates the function with itself as an argument, returning the result. Different classes respond to this message differently.
Object iterates by the message do, sent to the receiver. This method is used internally by list comprehensions.
Duplicates the receiver n times, returning an array of n copies. Different classes respond to this message differently. The shortcut "!" can be used in place.
The scheduling time in beats. This is equal to the current logical time (Thread: -beats).
The scheduling time in seconds. This is equal to the current logical time (Thread: -seconds).
The clock on which the object was scheduled.
Does nothing; simply returns the object itself.
Does nothing; simply returns the object itself.
Objects support the basic interface of Stream, just returning itself in response to the following messages: next, reset, stop, free, clear, removedFromScheduler, asStream.
Must be called from inside a Routine. Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The result of yield will be the value passed to the Routine's next method the next time it is called.
Must be called from inside a Routine. Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The Routine is reset so that the next time it is called, it will start from the beginning. yieldAndReset never returns within the Routine.
Must be called from inside a Routine. Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The Routine, when called subsequently will always yield the receiver until it is reset. alwaysYield never returns within the Routine.
Yields the receiver
within a routine, return values (the receiver) until this time is over. (see also Routine: play) Time is measured relative to the thread's clock.
Returns a OneShotStream with the receiver as return value.
Embeds the receiver in the stream n times (default: inf), each time resetting it.
Calls next with the receiver n times only (default: 1), yielding the result.
Repeatedly embeds the receiver in the stream using a Pn (may thus be used for patterns and other objects alike)
Indefinitely embeds the receiver in the stream
Returns an array with the results of calling -next a given number of times
Number of message calls
argument passed to the next message
Dependent on whether an object that is passed to a stream the object will behave differently: it may be embedded in the stream or used as stream directly.
If set to true, the object embeds itself into the stream (and thus return only once). If set to false, it returns itself forever. For simplicity, subclasses implement this method without this switch.
Lineraly interpolate between this and argument