home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
232_01
/
apndx1
< prev
next >
Wrap
Text File
|
1987-06-17
|
55KB
|
1,450 lines
.so macros
.nh
.ds CF
.ds CH
.ps +0.2i
.nr PO +0.2i
.Nm Object
.PP
The class \fBObject\fP is a superclass of all classes in the system, and is
used to provide a consistent basic functionality and default behavior.
Many methods in class \fBObject\fP are overridden in subclasses.
.SH
Responds to
.Rs ==
Return true if receiver and argument are the
same object, false otherwise.
.Rs ~~
Inverse of ==.
.Rs asString
Return a string representation of the receiver,
by default this is the same as \fIprintString\fP, although one or the
other is redefined in many subclasses.
.Rs asSymbol
Return a symbol representing the receiver.
.Rs class
Return object representing the class of the receiver.
.Rs copy
Return shallowCopy of receiver.
Many subclasses redefine shallowCopy.
.Rs deepCopy
Return the receiver. This method is redefined in many sub\%classes.
.Rs do: d
The argument must be a one argument block.
Execute the block on every element of the receiver collection.
Elements in the receiver collection are listed using \fIfirst\fP and \fInext\fP
(below), so the default behavior is merely to execute the block using the
receiver as argument.
.Rs error:
Argument must be a String. Print argument string as error message.
Return \fBnil\fP.
.Rs first n
Return first item in sequence, which is by default simply the receiver.
See \fInext\fP, below.
.Rs isKindOf:
Argument must be a \fBClass\fP. Return true if class of receiver, or any
superclass thereof, is the same as argument.
.Rs isMemberOf:
Argument must be a \fBClass\fP. Return true if receiver is instance of
argument class.
.Rs isNil
Test whether receiver is object \fBnil\fP.
.Rs next n
Return next item in sequence, which is by default \fBnil\fP. This message is
redefined in classes which represent sequences, such as \fBArray\fP
or \fBDictionary\fP.
.Rs notNil
Test if receiver is not object \fBnil\fP.
.Rs print
Display print image of receiver on the standard output.
.Rs printString
Return a string representation of receiver.
Objects which do not redefine printString, and which therefore do not have
a printable representation, return their class name as a string.
.Rs respondsTo:
Argument must be a symbol. Return true if receiver will respond to
the indicated message.
.Rs shallowCopy
Return the receiver. This method is redefined in many sub\%classes.
.Ex
7 ~~ 7.0 True
7 asSymbol #7
7 class Integer
7 copy 7
7 isKindOf: Number True
7 isMemberOf: Number False
7 isNil False
7 respondsTo: #+ True
.Nm Object UndefinedObject
.PP
The pseudo variable \fBnil\fP is an instance (usually the only instance) of the
class \fBUndefinedObject\fP. \fBnil\fP is used to represent undefined values,
and is
also typically returned in error situations. \fBnil\fP is also used as a terminator
in sequences, as for example in response to the message \fInext\fP when there are
no further elements in a sequence.
.SH
Responds to
.Rs isNil r
Overrides method found in Object. Return true.
.Rs notNil r
Overrides method found in Object. Return false.
.Rs printString r
Return 'nil'.
.Ex
nil isNil True
.Nm Object Symbol
.PP
Instances of the class \fBSymbol\fP are created either by their literal
representation, which is a pound sign followed by a string of nonspace
characters (for example #aSymbol ),
or by the message \fIasSymbol\fP being passed to an object.
Symbols cannot be created using \fInew\fP. Symbols are guaranteed to have
unique representations; that is, two symbols representing the same
characters will always test equal to each other. Inside of literal
arrays, the leading pound signs on symbols can be eliminated, for example:
#(these are symbols).
.SH
Responds to
.Rs == r
Return true if the two symbols represent the same characters,
false otherwise.
.Rs asString r
Return a String representation of the symbol without the leading pound
sign.
.Rs printString r
Return a String representation of the symbol, including the leading pound
sign.
.Ex
#abc == #abc True
#abc == #ABC False
#abc ~~ #ABC True
#abc printString #abc
\&'abc' asSymbol #abc
.Nm Object Boolean
.PP
The class \fBBoolean\fP provides protocol for manipulating true and false values.
The pseudo variables \fBtrue\fP and \fBfalse\fP are instances of the subclasses of
\fBBoolean\fP; \fBTrue\fP and \fBFalse\fP, respectively.
The subclasses \fBTrue\fP and \fBFalse\fP, in combination with blocks, are used to
implement conditional control structures. Note, however, that the
bytecodes may optimize conditional tests by generating
code in-line, rather than using message passing.
Note that bit-wise boolean operations are provided by class \fBInteger\fP.
.SH
Responds To
.Rs &
The argument must be a boolean. Return the logical conjunction (and)
of the two values.
.Rs |
The argument must be a boolean. Return the logical disjunction (or)
of the two values.
.Rs and:
The argument must be a block. Return the logical conjunction (and)
of the two values. If the receiver is false the second argument is not
used, otherwise the result is the value yielded in evaluating the argument
block.
.Rs or:
The argument must be a block. Return the logical disjunction (or)
of the two values. If the receiver is true the second argument is not
used, otherwise the result is the value yielded in evaluating the argument
block.
.Rs eqv:
The argument must be a boolean. Return the logical equivalence (eqv)
of the two values.
.Rs xor:
The argument must be a boolean. Return the logical exclusive or (xor)
of the two values.
.Ex
(1 > 3) & (2 < 4) False
(1 > 3) | (2 < 4) True
(1 > 3) and: [2 < 4] False
.Nm Object Boolean True
.PP
The pseudo variable \fBtrue\fP is an instance (usually the only instance) of
the class \fBTrue\fP.
.SH
Responds To
.Rs ifTrue:
Return the result of evaluating the argument block.
.Rs ifFalse:
Return \fBnil\fP.
.Rs ifTrue:ifFalse:
Return the result of evaluating the first argument block.
.Rs ifFalse:ifTrue:
Return the result of evaluating the second argument block.
.Rs not
Return \fBfalse\fP.
.Ex
(3 < 5) not False
(3 < 5) ifTrue: [17] 17
.Nm Object Boolean False
.PP
The pseudo variable \fBfalse\fP is an instance (usually the only instance) of
the class \fBFalse\fP.
.Rs ifTrue:
Return \fBnil\fP.
.Rs ifFalse:
Return the result of evaluating the argument block.
.Rs ifTrue:ifFalse:
Return the result of evaluating the second argument block.
.Rs ifFalse:ifTrue:
Return the result of evaluating the first argument block.
.Rs not
Return \fBtrue\fP.
.Ex
(1 < 3) ifTrue: [17] 17
(1 < 3) ifFalse: [17] nil
.Nm Object Magnitude
.PP
The class \fBMagnitude\fP provides protocol for those subclasses possessing
a linear ordering. For the sake of efficiency, most subclasses redefine
some or all of the relational messages. All methods are defined in
terms of the basic messages <, = and >, which are in turn defined
circularly in terms of each other. Thus each subclass of \fBMagnitude\fP
must redefine at least one of these messages.
.Rs <
Relational less than test. Returns a boolean.
.Rs <=
Relational less than or equal test.
.Rs =
Relational equal test. Note that this differs from ==, which is
an object equality test.
.Rs ~=
Relational not equal test, opposite of =.
.Rs >=
Relational greater than or equal test.
.Rs >
Relational greater than test.
.Rs between:and:
Relational test for inclusion.
.Rs max:
Return the maximum of the receiver and argument value.
.Rs min:
Return the minimum of the receiver and argument value.
.Ex
$A max: $a $a
4 between: 3.1 and: (17/3) True
.Nm Object Magnitude Char
.PP
This class defines protocol for objects with character values.
Characters possess an ordering given by the underlying representation,
however arithmetic is not defined for character values.
Characters are written literally by preceding the character desired with
a dollar sign, for example: $a \0 $B \0 $$.
.SH
Responds to
.Rs == r
Object equality test. Two instances of the same character always test equal.
.Rs asciiValue
Return an \fBInteger\fP representing the ascii value o