home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
018.lha
/
docs
/
appendix1
< prev
next >
Wrap
Text File
|
1986-10-19
|
84KB
|
3,279 lines
OOOObbbbjjjjeeeecccctttt
The class OOOObbbbjjjjeeeecccctttt is a superclass of all classes in the
system, and is used to provide a consistent basic func-
tionality and default behavior. Many methods in class
OOOObbbbjjjjeeeecccctttt are overridden in subclasses.
_R_e_s_p_o_n_d_s _t_o
== Return true if receiver and argument are the
same object, false otherwise.
~~ Inverse of ==.
asString Return a string representation of the
receiver, by default this is the same as
_p_r_i_n_t_S_t_r_i_n_g, although one or the other is
redefined in many subclasses.
asSymbol Return a symbol representing the receiver.
class Return object representing the class of the
receiver.
copy Return shallowCopy of receiver. Many subc-
lasses redefine shallowCopy.
deepCopy Return the receiver. This method is rede-
fined in many subclasses.
_d do: 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 _f_i_r_s_t
and _n_e_x_t (below), so the default behavior is
merely to execute the block using the
receiver as argument.
error: Argument must be a String. Print argument
string as error message. Return nnnniiiillll.
_n first Return first item in sequence, which is by
default simply the receiver. See _n_e_x_t,
below.
isKindOf: Argument must be a CCCCllllaaaassssssss. Return true if
class of receiver, or any superclass thereof,
is the same as argument.
isMemberOf: Argument must be a CCCCllllaaaassssssss. Return true if
receiver is instance of argument class.
class OOOObbbbjjjjeeeecccctttt (continued)
isNil Test whether receiver is object nnnniiiillll.
_n next Return next item in sequence, which is by
default nnnniiiillll. This message is redefined in
classes which represent sequences, such as
AAAArrrrrrrraaaayyyy or DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy.
notNil Test if receiver is not object nnnniiiillll.
print Display print image of receiver on the stan-
dard output.
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.
respondsTo: Argument must be a symbol. Return true if
receiver will respond to the indicated mes-
sage.
shallowCopy Return the receiver. This method is rede-
fined in many subclasses.
_E_x_a_m_p_l_e_s
Printed result
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
Object
UUUUnnnnddddeeeeffffiiiinnnneeeeddddOOOObbbbjjjjeeeecccctttt
The pseudo variable nnnniiiillll is an instance (usually the
only instance) of the class UUUUnnnnddddeeeeffffiiiinnnneeeeddddOOOObbbbjjjjeeeecccctttt. nnnniiiillll is used to
represent undefined values, and is also typically returned
in error situations. nnnniiiillll is also used as a terminator in
sequences, as for example in response to the message _n_e_x_t
when there are no further elements in a sequence.
_R_e_s_p_o_n_d_s _t_o
_r isNil Overrides method found in Object. Return
true.
_r notNil Overrides method found in Object. Return
false.
_r printString Return 'nil'.
_E_x_a_m_p_l_e_s
Printed result
nil isNil True
Object
SSSSyyyymmmmbbbboooollll
Instances of the class SSSSyyyymmmmbbbboooollll 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 _a_s_S_y_m_b_o_l being passed to an object. Sym-
bols cannot be created using _n_e_w. Symbols are guaranteed to
have unique representations; that is, two symbols represent-
ing 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 sym-
bols).
_R_e_s_p_o_n_d_s _t_o
_r == Return true if the two symbols represent the
same characters, false otherwise.
_r asString Return a String representation of the symbol
without the leading pound sign.
_r printString Return a String representation of the symbol,
including the leading pound sign.
_E_x_a_m_p_l_e_s
Printed result
#abc == #abc True
#abc == #ABC False
#abc ~~ #ABC True
#abc printString #abc
'abc' asSymbol #abc
Object
BBBBoooooooolllleeeeaaaannnn
The class BBBBoooooooolllleeeeaaaannnn provides protocol for manipulating
true and false values. The pseudo variables ttttrrrruuuueeee and ffffaaaallllsssseeee
are instances of the subclasses of BBBBoooooooolllleeeeaaaannnn; TTTTrrrruuuueeee and FFFFaaaallllsssseeee,
respectively. The subclasses TTTTrrrruuuueeee and FFFFaaaallllsssseeee, 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 opera-
tions are provided by class IIIInnnntttteeeeggggeeeerrrr.
_R_e_s_p_o_n_d_s _T_o
& The argument must be a boolean. Return the
logical conjunction (and) of the two values.
| The argument must be a boolean. Return the
logical disjunction (or) of the two values.
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.
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.
eqv: The argument must be a boolean. Return the
logical equivalence (eqv) of the two values.
xor: The argument must be a boolean. Return the
logical exclusive or (xor) of the two values.
_E_x_a_m_p_l_e_s
Printed result
(1 > 3) & (2 < 4) False
(1 > 3) | (2 < 4) True
(1 > 3) and: [2 < 4] False
Object
Boolean
TTTTrrrruuuueeee
The pseudo variable ttttrrrruuuueeee is an instance (usually the
only instance) of the class TTTTrrrruuuueeee.
_R_e_s_p_o_n_d_s _T_o
ifTrue: Return the result of evaluating the argument
block.
ifFalse: Return nnnniiiillll.
ifTrue:ifFalse:
Return the result of evaluating the first
argument block.
ifFalse:ifTrue:
Return the result of evaluating the second
argument block.
not Return ffffaaaallllsssseeee.
_E_x_a_m_p_l_e_s
Printed result
(3 < 5) not False
(3 < 5) ifTrue: [17] 17
Object
Boolean
FFFFaaaallllsssseeee
The pseudo variable ffffaaaallllsssseeee is an instance (usually the
only instance) of the class FFFFaaaallllsssseeee.
ifTrue: Return nnnniiiillll.
ifFalse: Return the result of evaluating the argument
block.
ifTrue:ifFalse:
Return the result of evaluating the second
argument block.
ifFalse:ifTrue:
Return the result of evaluating the first
argument block.
not Return ttttrrrruuuueeee.
_E_x_a_m_p_l_e_s
Printed result
(1 < 3) ifTrue: [17] 17
(1 < 3) ifFalse: [17] nil
Object
MMMMaaaaggggnnnniiiittttuuuuddddeeee
The class MMMMaaaaggggnnnniiiittttuuuuddddeeee provides protocol for those subc-
lasses possessing a linear ordering. For the sake of effi-
ciency, most subclasses redefine some or all of the rela-
tional messages. All methods are defined in terms of the
basic messages <, = and >, which are in turn defined circu-
larly in terms of each other. Thus each subclass of MMMMaaaaggggnnnniiii----
ttttuuuuddddeeee must redefine at least one of these messages.
< Relational less than test. Returns a
boolean.
<= Relational less than or equal test.
= Relational equal test. Note that this
differs from ==, which is an object equality
test.
~= Relational not equal test, opposite of =.
>= Relational greater than or equal test.
> Relational greater than test.
between:and: Relational test for inclusion.
max: Return the maximum of the receiver and argu-
ment value.
min: Return the minimum of the receiver and argu-
ment value.
_E_x_a_m_p_l_e_s
Printed result
$A max: $a $a
4 between: 3.1 and: (17/3) True
Object
Magnitude
CCCChhhhaaaarrrr
This class defines protocol for objects with character
values. Characters possess an ordering given by the under-
lying 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 $B $$.
_R_e_s_p_o_n_d_s _t_o
_r == Object equality test. Two instances of the
same character always test equal.
asciiValue Return an IIIInnnntttteeeeggggeeeerrrr representing the ascii
value of the receiver.
asLowercase If the receiver is an uppercase letter
returns the same letter in lowercase, other-
wise returns the receiver.
asUppercase If the receiver is a lowercase letter returns
the same letter in uppercase, otherwise
returns the receiver.
_r asString Return a length one string containing the
receiver. Does not contain leading dollar
sign, compare to _p_r_i_n_t_S_t_r_i_n_g.
digitValue If the receiver represents a number (for
example $9) return the digit value of the
number. If the receiver is an uppercase
letter (for example $B) return the position
of the number in the uppercase letters + 10,
($B returns 11, for example). If the
receiver is neither a digit nor an uppercase
letter an error is given and nnnniiiillll returned.
isAlphaNumericRespond true if receiver is either digit or
letter, false otherwise.
isDigit Respond true if receiver is a digit, false
otherwise.
isLetter Respond true if receiver is a letter, false
otherwise.
isLowercase Respond true if receiver is a lowercase
letter, false otherwise.
isSeparator Respond true if receiver is a space, tab or
class CCCChhhhaaaarrrr (continued)
newline, false otherwise.
isUppercase Respond true if receiver is an uppercase
letter, false otherwise.
isVowel Respond true if receiver is $a, $e, $i, $o or
$u, in either upper or lower case.
_r printString Respond with a string representation of the
character value. Includes leading dollar
sign, compare to _a_s_S_t_r_i_n_g, which does not
include $.
_E_x_a_m_p_l_e_s
Printed result
$A < $0 False
$A asciiValue 65
$A asString A
$A printString $A
$A isVowel True
$A digitValue 10
Object
Magnitude
NNNNuuuummmmbbbbeeeerrrr
The class NNNNuuuummmmbbbbeeeerrrr is an abstract superclass for IIIInnnntttteeeeggggeeeerrrr
and FFFFllllooooaaaatttt. Instances of NNNNuuuummmmbbbbeeeerrrr cannot be created directly.
Relational messages and many arithmetic messages are rede-
fined in each subclass for arguments of the appropriate
type. In general, an error message is given and nnnniiiillll
returned for illegal arguments.
_R_e_s_p_o_n_d_s _T_o
+ Mixed type addition.
- Mixed type subtraction.
* Mixed type multiplication
/ Mixed type division.
_n |^ Exponentiation, same as raisedTo: .
@ Construct a point with coordinates being the
receiver and the argument.
abs Absolute value of the receiver.
exp e raised to the power.
_n gamma Return the gamma function (generalized fac-
torial) evaluated at the receiver.
ln Natural logarithm of the receiver.
log: Logarithm in the given base.
negated The arithmetic inverse of the receiver.
negative True if the receiver is negative.
_n pi Return the approximate value of the receiver
multiplied by (3.1415926...).
positive True if the receiver is positive.
_n radians Argument converted into radians.
raisedTo: The receiver raised to the argument value.
reciprocal The arithmetic reciprocal of the receiver.
roundTo: The receiver rounded to units of the argu-
class NNNNuuuummmmbbbbeeeerrrr (continued)
ment.
sign Return -1, 0 or 1 depending upon whether the
receiver is negative, zero or positive.
sqrt Square root. nil if receiver is less than
zero.
squared Return the receiver multiplied by itself.
strictlyPositive
True if the receiver is greater than zero.
to: Interval from receiver to argument value with
step of 1.
to:by: Interval from receiver to argument in given
steps.
truncatedTo: The receiver truncated to units of the argu-
ment.
_E_x_a_m_p_l_e_s
Printed result
3 < 4.1 True
3 + 4.1 7.1
3.14159 exp 23.1406
9 gamma 40320
5 reciprocal 0.2
0.5 radians 0.5 radians
13 roundTo: 5 15
13 truncateTo: 5 10
Object
Magnitude
Number
IIIInnnntttteeeeggggeeeerrrr
The class IIIInnnntttteeeeggggeeeerrrr provides protocol for objects with
integer values.
_R_e_s_p_o_n_d_s _T_o
_r == Object equality test. Two integers
representing the same value are considered to
be the same object.
// Integer quotient, truncated towards negative
infinity (compare to _q_u_o:).
\\ Integer remainder, truncated towards negative
infinity (compare to _r_e_m:).
allMask: Argument must be IIIInnnntttteeeeggggeeeerrrr. Treating receiver
and argument as bit strings, return ttttrrrruuuueeee if
all bits with 1 value in argument correspond
to bits with 1 values in the receiver.
anyMask: Argument must be IIIInnnntttteeeeggggeeeerrrr. Treating receiver
and argument as bit strings, return true if
any bit with 1 value in argument corresponds
to a bit with 1 value in the receiver.
asCharacter Return the Char with the same underlying
ascii representation as the low order eight
bits of the receiver.
asFloat Floating point value with same magnitude as
receiver.
bitAnd: Argument must be IIIInnnntttteeeeggggeeeerrrr. Treating the
receiver and argument as bit strings, return
logical aaaannnndddd of values.
bitAt: Argument must be IIIInnnntttteeeeggggeeeerrrr greater than 0 and
less than underlying word size. Treating
receiver as a bit string, return the bit
value at the given position, numbering from
low order (or rightmost) position.
bitInvert Return the receiver with all bit positions
inverted.
bitOr: Return logical oooorrrr of values.
bitShift: Treating the receiver as a bit string, shift
bit values by amount indicated in argument.
class IIIInnnntttteeeeggggeeeerrrr (continued)
Negative values shift right, positive left.
bitXor: Return logical eeeexxxxcccclllluuuussssiiiivvvveeee----oooorrrr of values.
even Return true if receiver is even, false other-
wise.
factorial Return the factorial of the receiver. Return
as Float for large numbers.
gcd: Argument must be IIIInnnntttteeeeggggeeeerrrr. Return the
greatest common divisor of the receiver and
argument.
highBit Return the location of the highest 1 bit in
the receiver. Return nnnniiiillll for receiver zero.
lcm: Argument must be IIIInnnntttteeeeggggeeeerrrr. Return least com-
mon multiple of receiver and argument.
noMask: Argument must be IIIInnnntttteeeeggggeeeerrrr. Treating receiver
and argument as bit strings, return true if
no 1 bit in the argument corresponds to a 1
bit in the receiver.
odd Return true if receiver is odd, false other-
wise.
quo: Return quotient of receiver divided by argu-
ment.
radix: Return a string representation of the
receiver value, printed in the base
represented by the argument. Argument value
must be less than 36.
rem: Remainder after receiver is divided by argu-
ment value.
timesRepeat: Repeat argument block the number of times
given by the receiver.
_E_x_a_m_p_l_e_s
Printed result
5 + 4 7
5 allMask: 4 True
4 allMask: 5 False
5 anyMask: 4 True
5 bitAnd: 3 1
5 bitOr: 3 7
5 bitInvert -6
254 radix: 16 16rFE
class IIIInnnntttteeeeggggeeeerrrr (continued)
-5 // 4 -2
-5 quo: 4 -1
-5 \\ 4 1
-5 rem: 4 -1
8 factorial 40320
Object
Magnitude
Number
FFFFllllooooaaaatttt
The class FFFFllllooooaaaatttt provides protocol for objects with
floating point values.
_R_e_s_p_o_n_d_s _T_o
_r == Object equality test. Return true if the
receiver and argument represent the same
floating point value.
_n |^ Floating exponentiation.
arcCos Return a RRRRaaaaddddiiiiaaaannnn representing the arcCos of
the receiver.
arcSin Return a RRRRaaaaddddiiiiaaaannnn representing the arcSin of
the receiver.
arcTan Return a RRRRaaaaddddiiiiaaaannnn representing the arcTan of
the receiver.
asFloat Return the receiver.
ceiling Return the Integer ceiling of the receiver.
coerce: Coerce the argument into being type Float.
exp Return e raised to the receiver value.
floor Return the Integer floor of the receiver.
fractionPart Return the fractional part of the receiver.
_n gamma Return the value of the gamma function
applied to the receiver value.
integerPart Return the integer part of the receiver.
ln Return the natural log of the receiver.
radix: Return a string containing the printable
representation of the receiver in the given
radix. Argument must be an Integer less than
36.
rounded Return the receiver rounded to the nearest
integer.
class FFFFllllooooaaaatttt (continued)
sqrt Return the square root of the receiver.
truncated Return the receiver truncated to the nearest
integer.
_E_x_a_m_p_l_e_s
Printed result
4.2 * 3 12.6
2.1 |^ 4 19.4481
2.1 raisedTo: 4 19.4481
0.5 arcSin 0.523599 radians
2.1 reciprocal 0.47619
4.3 sqrt 2.07364
Object
Magnitude
RRRRaaaaddddiiiiaaaannnn
The class RRRRaaaaddddiiiiaaaannnn is used to represent radians. Radians
are a unit of measurement, independent of other numbers.
Only radians will responds to the trigonometric functions
such as _s_i_n and _c_o_s. Numbers can be converted into radians
by passing them the message _r_a_d_i_a_n_s. Similarly, radians can
be converted into numbers by sending them the message
_a_s_F_l_o_a_t. Notice that only a limited range of arithmetic
operations are permitted on Radians. Radians are normalized
to be between 0 and 2J.
_R_e_s_p_o_n_d_s _t_o
+ Argument must be a Radian. Add the two radi-
ans together and return the normalized
result.
- Argument must be a Radian. Subtract the
argument from the receiver and return the
normalized result.
* Argument must be a Number. Multiply the
receiver by the argument amount and return
the normalized result.
/ Argument must be a Number. Divide the
receiver by the argument amount and return
the normalized result.
asFloat Return the receiver as a floating point
number.
cos Return a floating point number representing
the cosine of the receiver.
sin Return a floating point number representing
the sine of the receiver.
tan Return a floating point number representing
the tangent of the receiver.
_E_x_a_m_p_l_e_s
Printed result
0.5236 radians sin 0.5
0.5236 radians cos 0.866025
0.5236 radians tan 0.577352
0.5 arcSin asFloat 0.523599
Object
Magnitude
PPPPooooiiiinnnntttt
PPPPooooiiiinnnntttts are used to represent pairs of quantities, such
as coordinate pairs.
_R_e_s_p_o_n_d_s _T_o
< True if both values of the receiver are less
than the corresponding values in the argu-
ment.
<= True if the first value is less than or equal
to the corresponding value in the argument,
and the second value is less than the
corresponding value in the argument.
>= True if both values of the receiver are
greater than or equal to the corresponding
values in the argument.
* Return a new point with coordinates multi-
plied by the argument value.
/ Return a new point with coordinates divided
by the argument value.
// Return a new point with coordinates divided
by the argument value.
+ Return a new point with coordinates offset by
the corresponding values in the argument.
abs Return a new point with coordinates having
the absolute value of the receiver.
dist: Return the Euclidean distance between the
receiver and the argument point.
max: The argument must be a PPPPooooiiiinnnntttt. Return the
lower right corner of the rectangle defined
by the receiver and the argument.
min: The argument must be a PPPPooooiiiinnnntttt. Return the
upper left corner of the rectangle defined by
the receiver and the argument.
transpose Return a new point with coordinates being the
transpose of the receiver.
class PPPPooooiiiinnnntttt (continued)
x Return the first coordinate of the receiver.
x: Set the first coordinate of the receiver.
x:y: Sets both coordinates of the receiver.
y Return the second coordinate of the receiver.
y: Set the second coordinate of the receiver.
_E_x_a_m_p_l_e_s
Printed result
(10@12) < (11@14) True
(10@12) < (11@11) False
(10@12) max: (11@11) 11@12
(10@12) min: (11@11) 10@11
(10@12) dist: (11@14) 2.23607
(10@12) transpose 12@10
Object
RRRRaaaannnnddddoooommmm
The class RRRRaaaannnnddddoooommmm provides protocol for random number
generation. Sending the message _n_e_x_t to an instance of RRRRaaaannnn----
ddddoooommmm results in a FFFFllllooooaaaatttt between 0.0 and 1.0, randomly distri-
buted. By default, the pseudo random sequence is the same
for each object in class RRRRaaaannnnddddoooommmm. This can be altered using
the message _r_a_n_d_o_m_i_z_e.
_R_e_s_p_o_n_d_s _T_o
_n between:and: Return a random number uniformly distributed
between the two arguments.
_n first Return a random number between 0.0 and 1.0.
This message merely provides consistency with
protocol for other sequences, such as Arrays
or Intervals.
next Return a random number between 0.0 and 1.0.
_d next: Return an AAAArrrrrrrraaaayyyy containing the next n random
numbers, where n is the argument value.
_n randInteger: The argument must be an integer. Return a
random integer between 1 and the value given.
_n randomize Change the pseudo-random number generator
seed by a time dependent value.
_E_x_a_m_p_l_e_s
Printed result
i <- Random new
i next 0.759
i next 0.157
i next: 3 #( 0.408 0.278 0.547 )
i randInteger: 12 5
i between: 4 and: 17.5 10.0
Object
CCCCoooolllllllleeeeccccttttiiiioooonnnn
The class CCCCoooolllllllleeeeccccttttiiiioooonnnn provides protocol for groups of
objects, such as AAAArrrrrrrraaaayyyys or SSSSeeeetttts. The different forms of col-
lections are distinguished by several characteristics, among
them whether the size of the collection is fixed or
unbounded, the presence or absence of an ordering, and their
insertion or access method. For example, an AAAArrrrrrrraaaayyyy is a col-
lection with a fixed size and ordering, indexed by integer
keys. A DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy, on the other hand, has no fixed size or
ordering, and can be indexed by arbitrary elements.
Nevertheless, AAAArrrrrrrraaaayyyyssss and DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyyssss share many features in
common, such as their access method (_a_t: and _a_t:_p_u_t:), and
the ability to respond to _c_o_l_l_e_c_t:, _s_e_l_e_c_t:, and many other
messages.
The table below lists some of the characteristics of
several forms of collections:
___________________________________________________________________
Name Creation Size Ordered? Insertion Access
Method fixed? method method
___________________________________________________________________
Bag/Set new no no add: includes:
Dictionary new no no at:put: at:
Interval n to: m yes yes none at:
List new no yes addFirst: first
addLast: last
Array new: yes yes at:put: at:
String new: yes yes at:put: at:
___________________________________________________________________
|||||||||||||||||||
|||||||||||||||||||
The list below shows messages that are shared in common
by all collections.
_R_e_s_p_o_n_d_s _t_o
addAll: The argument must be a CCCCoooolllllllleeeeccccttttiiiioooonnnn. Add all
the elements of the argument collection to
the receiver collection.
asArray Return a new collection of type AAAArrrrrrrraaaayyyy con-
taining the elements from the receiver col-
lection. If the receiver was ordered, the
elements will be in the same order in the new
class CCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
collection, otherwise the elements will be in
an arbitrary order.
asBag Return a new collection of type BBBBaaaagggg contain-
ing the elements from the receiver collec-
tion.
_n asList Return a new collection of type LLLLiiiisssstttt contain-
ing the elements from the receiver collec-
tion. If the receiver was ordered, the ele-
ments will be in the same order in the new
collection, otherwise the elements will be in
an arbitrary order.
asSet Return a new collection of type SSSSeeeetttt contain-
ing the elements from the receiver collec-
tion.
asString Return a new collection of type SSSSttttrrrriiiinnnngggg con-
taining the elements from the receiver col-
lection. The elements to be included must
all be of type CCCChhhhaaaarrrraaaacccctttteeeerrrr. If the receiver
was ordered, the elements will be in the same
order in the new collection, otherwise the
elements will be listed in an arbitrary
order.
coerce: The argument must be a collection. Return a
collection, of the same type as the receiver,
containing elements from the argument collec-
tion. This message is redefined in most
subclasses of collection.
collect: The argument must be a one argument block.
Return a new collection, like the receiver,
containing the result of evaluating the argu-
ment block on each element of the receiver
collection.
detect: The argument must be a one argument block.
Return the first element in the receiver col-
lection for which the argument block evalu-
ates true. Report an error and return nnnniiiillll if
no such element exists. Note that in unor-
dered collections (such as BBBBaaaaggggssss or DDDDiiiiccccttttiiiioooonnnn----
aaaarrrryyyyssss) the first element to be encountered
that will satisfy the condition may not be
easily predictable.
detect:ifAbsent:
Return the first element in the receiver col-
lection for which the first argument block
evaluates true. Return the result of
evaluating the second argument if no such
class CCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
element exists.
do: The argument must be a one argument block.
Evaluate the argument block on each element
in the receiver collection.
includes: Return true if the receiver collection con-
tains the argument.
inject:into: The first argument must be a value, the
second a two argument block. The second
argument is evaluated once for each element
in the receiver collection, passing as argu-
ments the result of the previous evaluation
(starting with the first argument) and the
element. The value returned is the final
value generated.
isEmpty Return true if the receiver collection con-
tains no elements.
occurrencesOf:Return the number of times the argument
occurs in the receiver collection.
remove: Remove the argument from the receiver collec-
tion. Report an error if the element is not
contained in the receiver collection.
remove:ifAbsent:
Remove the first argument from the receiver
collection. Evaluate the second argument if
not present.
reject: The argument must be a one argument block.
Return a new collection like the receiver
containing all elements for which the argu-
ment block returns false.
select: The argument must be a one argument block.
Return a new collection like the receiver
containing all elements for which the argu-
ment block returns true.
size Return the number of elements in the receiver
collection.
class CCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
_E_x_a_m_p_l_e_s
Printed result
i <- 'abacadabra'
i size 10
i asArray #( $a $b $a $c $a $d $a $b $r $a )
i asBag Bag ( $a $a $a $a $a $r $b $b $c $d)
i asSet Set ( $a $r $b $c $d )
i occurrencesOf: $a 5
i reject: [:x | x isVowel] bcdbr
Object
Collection
BBBBaaaagggg////SSSSeeeetttt
BBBBaaaaggggssss and SSSSeeeettttssss are each unordered collections of ele-
ments. Elements in the collections do not have keys, but are
added and removed directly. The difference between a BBBBaaaagggg
and a SSSSeeeetttt is that each element can occur any number of times
in a BBBBaaaagggg, whereas only one copy is inserted into a SSSSeeeetttt.
_R_e_s_p_o_n_d_s _t_o
add: Add the indicated element to the receiver
collection.
add:withOccurences:
(BBBBaaaagggg only) Add the indicated element to the
receiver BBBBaaaagggg the given number of times.
_n first Return the first element from the receiver
collection. As the collection is unordered,
the first element depends upon certain values
in the internal representation, and is not
guaranteed to be any specific element in the
collection.
_n next Return the next element in the collection.
In conjunction with _f_i_r_s_t, this can be used
to access each element of the collection in
turn.
_E_x_a_m_p_l_e_s
Printed result
i <- (1 to: 6) asBag Bag ( 1 2 3 4 5 6 )
i size 6
i select: [:x | (x \\ 2) strictlyPositive]Bag ( 1 3 5 )
i collect: [:x | x \\ 3] Bag ( 0 0 1 1 2 2 )
j <- ( i collect: [:x | x \\ 3] ) asSet Set ( 0 1 2 )
j size 3
NNNNooootttteeee:::: Since BBBBaaaaggggssss and SSSSeeeettttssss are unordered, there is no way to
establish a mapping between the elements of the Bag i in the
example above and the corresponding elements in the collec-
tion that resulted from the message collect: [:x | x \\ 3].
Object
Collection
KKKKeeeeyyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn
The class KKKKeeeeyyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn provides protocol for collec-
tions with keys, such as DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyyssss and AAAArrrrrrrraaaayyyyssss. Since each
entry in the collection has both a key and value, the method
_a_d_d: is no longer appropriate. Instead, the method _a_t:_p_u_t:,
which provides both a key and a value, must be used.
_R_e_s_p_o_n_d_s _t_o
asDictionary Return a new collection of type DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy
containing the elements from the receiver
collection.
at: Return the item in the receiver collection
whose key matches the argument. Produces and
error message, and returns nil, if no item is
currently in the receiver collection under
the given key.
at:ifAbsent: Return the element stored in the dictionary
under the key given by the first argument.
Return the result of evaluating the second
argument if no such element exists.
atAll:put: The first argument must be a collection con-
taining keys valid for the receiver. At each
location given by a key in the first argument
place the second argument.
binaryDo: The argument must be a two argument block.
This message is similar to _d_o:, however both
the key and the element value are passed as
argument to the block.
includesKey: Return true if the indicated key is valid for
the receiver collection.
indexOf: Return the key value of the first element in
the receiver collection matching the argu-
ment. Produces an error message if no such
element exists. Note that, as with the mes-
sage _d_e_t_e_c_t:, in unordered collections the
first element may not be related in any way
to the order in which elements were placed
into the collection, but is rather implemen-
tation dependent.
indexOf:ifAbsent:
Return the key value of the first element in
the receiver collection matching the argu-
ment. Return the result of evaluating the
class KKKKeeeeyyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
second argument if no such element exists.
keys Return a Set containing the keys for the
receiver collection.
keysDo: The argument must be a one argument block.
Similar to _d_o:, except that the values passed
to the block are the keys of the receiver
collection.
keysSelect: Similar to _s_e_l_e_c_t, except that the selection
is made on the basis of keys instead of
values.
removeKey: Remove the object with the given key from the
receiver collection. Print an error message,
and return nnnniiiillll, if no such object exists.
Return the value of the deleted item.
removeKey:ifAbsent:
Remove the object with the given key from the
receiver collection. Return the result of
evaluating the second argument if no such
object exists.
values Return a Bag containing the values from the
receiver collection.
_E_x_a_m_p_l_e_s
Printed result
i <- 'abacadabra'
i atAll: (1 to: 7 by: 2) put: $e ebecedebra
i indexOf: $r 9
i atAll: i keys put: $z zzzzzzzzzz
i keys Set ( 1 2 3 4 5 6 7 8 9 10 )
i values Bag ( $z $z $z $z $z $z $z $z $z $z )
#(how odd) asDictionary Dictionary ( 1 @ #how 2 @ odd )
Object
Collection
KeyedCollection
DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy
A DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy is an unordered collection of elements, as
are BBBBaaaaggggssss and SSSSeeeettttssss. However, unlike these collections, ele-
ments inserted and removed from a DDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy must reference
an explicit key. Both the key and value portions of an ele-
ment can be any object, although commonly the keys are
instances of SSSSyyyymmmmbbbboooollll or NNNNuuuummmmbbbbeeeerrrr.
_R_e_s_p_o_n_d_s _t_o
at:put: Place the second argument into the receiver
collection under the key given by the first
argument.
currentKey Return the key of the last element yielded in
response to a _f_i_r_s_t or _n_e_x_t request.
_n first Return the first element of the receiver col-
lection. Return nil if the receiver collec-
tion is empty.
_n next Return the next element of the receiver col-
lection, or nil if no such element exists.
_E_x_a_m_p_l_e_s
Printed result
i <- Dictionary new
i at: #abc put: #def
i at: #pqr put: #tus
i at: #xyz put: #wrt
i print Dictionary ( #abc @ #def #pqr @ #tus #xyz @ #wrt )
i size 3
i at: #pqr #tus
i indexOf: #tus #pqr
i keys Set ( #abc #pqr #xyz )
i values Bag ( #wrt #def # tus )
i collect: [:x | x asString at: 2]Dictionary ( #abc @ $e #pqr @ $u #xyz @ $r)
Object
Collection
KeyedCollection
Dictionary
SSSSmmmmaaaallllllllttttaaaallllkkkk
The class SSSSmmmmaaaallllllllttttaaaallllkkkk provides protocol for the pseudo
variable ssssmmmmaaaallllllllttttaaaallllkkkk. Since it is a subclass of Dictionary,
this variable can be used to store information, and thus
provide a means of communication between objects. Other
messages modify various parameters used by the Little
Smalltalk system.
_R_e_s_p_o_n_d_s _T_o
_n date Return the current date and time as a string.
_n display Set execution display to display the result
of every expression typed, but not for
assignments. Note that the display behavior
can also be modified using the -d argument on
the command line.
_n displayAssignSet execution display to display the result
of every expression typed, including assign-
ment statements.
_n doPrimitive:withArguments:
Execute the indicated primitive with argu-
ments given by the second array. A few prim-
itives (such as those dealing with process
management) cannot be executed in this
manner.
_n noDisplay Turn off execution display - no results will
be displayed unless explicitly requested by
the user.
_d perform:withArguments:
Send indicated message to the receiver, using
the arguments given. The first value in the
argument array is taken to be the receiver of
the message. Unpredictable results if the
number of arguments is not appropriate for
the given message.
_n sh: The argument, which must be a string, is exe-
cuted as a Unix command by the shell. The
value returned is the termination status of
the shell.
_n time: The argument must be a block. The block is
executed, and the number of seconds elapsed
during execution returned. Time is only
class SSSSmmmmaaaallllllllttttaaaallllkkkk (continued)
accurate to within about one second.
_E_x_a_m_p_l_e_s
Printed result
smalltalk date Fri Apr 12 16:15:42 1985
smalltalk perform: #+ withArguments: #(2 5)7
smalltalk doPrimitive: 10 withArguments: #(2 5)7
Object
Collection
KeyedCollection
SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooolllllllleeeeccccttttiiiioooonnnn
The class SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooolllllllleeeeccccttttiiiioooonnnn contains protocol for
collections that have a definite sequential ordering and are
indexed by integer keys. Since there is a fixed order for
elements, it is possible to refer to the last element in a
SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooolllllllleeeeccccttttiiiioooonnnn.
_R_e_s_p_o_n_d_s _t_o
, Appends the argument collection to the
receiver collection, returning a new collec-
tion of the same type as the receiver.
copyFrom:to: Return a new collection, like the receiver,
containing the designated subportion of the
receiver collection.
copyWith: Return a new collection, like the receiver,
with the argument added to the end.
copyWithout: Return a new collection, like the receiver,
with all occurrences of the argument removed.
equals:startingAt:
The first argument must be a SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooollll----
lllleeeeccccttttiiiioooonnnn. Return true if each element of the
receiver collection is equal to the
corresponding element in the argument offset
by the amount given in the second argument.
findFirst: Find the key for the first element whose
value satisfies the argument block. Produce
an error message if no such element exists.
findFirst:ifAbsent:
Both arguments must be blocks. Find the key
for the first element whose value satisfies
the first argument block. If no such element
exists return the value of the second argu-
ment.
findLast: Find the key for the last element whose value
satisfies the argument block. Produce an
error message if no such element exists.
findLast:ifAbsent:
Both arguments must be blocks. Find the key
for the last element whose value satisfies
the first argument block. If no such element
exists return the value of the second
class SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
argument block.
firstKey Return the first key valid for the receiver
collection.
indexOfSubCollection:startingAt:
Starting at the position given by the second
argument, find the next block of elements in
the receiver collection which match the col-
lection given by the first argument, and
return the index for the start of that block.
Produce an error message if no such position
exists.
indexOfSubCollection:startingAt:ifAbsent:
Similar to _i_n_d_e_x_O_f_S_u_b_C_o_l_l_e_c_t_i_o_n:_s_t_a_r_t_i_n_g_A_t:,
except that the result of the exception block
is produced if no position exists matching
the pattern.
last Return the last element in the receiver col-
lection.
lastKey Return the last key valid for the receiver
collection.
replaceFrom:to:with:
Replace the elements in the receiver collec-
tion in the positions indicated by the first
two arguments with values taken from the col-
lection given by the third argument.
replaceFrom:to:with:startingAt:
Replace the elements in the receiver collec-
tion in the positions indicated by the first
two arguments with values taken from the col-
lection given in the third argument, starting
at the position given by the fourth argument.
_n reversed Return a collection, like the receiver, with
elements reversed.
reverseDo: Similar to _d_o:, except that the items are
presented in reverse order.
_n sort Return a collection, like the receiver, with
the elements sorted using the comparison <=.
Elements must be able to respond to the
binary message <=.
_n sort: The argument must be a two argument block
which yields a boolean. Return a collection,
like the receiver, sorted using the argument
to compare elements for the purpose of
class SSSSeeeeqqqquuuueeeennnncccceeeeaaaabbbblllleeeeCCCCoooolllllllleeeeccccttttiiiioooonnnn (continued)
ordering.
with:do: The second argument must be a two argument
block. Present one element from the receiver
collection and from the collection given by
the first argument in turn to the second
argument block. An error message is given if
the collections do not have the same number
of elements.
_E_x_a_m_p_l_e_s
Printed result
i <- 'abacadabra'
i copyFrom: 4 to: 8 cadab
i copyWith: $z abacadabraz
i copyWithout: $a bcdbr
i findFirst: [:x | x > $m] 9
i indexOfSubCollection: 'dab' startingAt: 16
i reversed arbadacaba
i , i reversed abacadabraarbadacaba
i sort: [:x :y | x >= y] rdcbbaaaaa
Object
Collection
KeyedCollection
SequenceableCollection
IIIInnnntttteeeerrrrvvvvaaaallll
The class IIIInnnntttteeeerrrrvvvvaaaallll represents a sequence of numbers in
an arithmetic sequence, either ascending or descending.
Instances of IIIInnnntttteeeerrrrvvvvaaaallll are created by numbers in response to
the message _t_o: or _t_o:_b_y:. In conjunction with the message
_d_o:, IIIInnnntttteeeerrrrvvvvaaaallllssss create a control structure similar to do or
for loops in Algol like languages. For example:
(1 to: 10) do: [:x | x print]
will print the numbers 1 through 10. Although they are a
collection, IIIInnnntttteeeerrrrvvvvaaaallllssss cannot be added to. They can, how-
ever, be accessed randomly using the message _a_t:.
_R_e_s_p_o_n_d_s _t_o
first Produce the first element from the interval.
In conjunction with _l_a_s_t, this message may be
used to produce each element from the inter-
val in turn. Note that IIIInnnntttteeeerrrrvvvvaaaallllssss also
respond to the message _a_t:, which can be used
to produce elements in an arbitrary order.
from:to:by: Initialize the upper and lower bounds and the
step size for the receiver. (This is used
principally internally by the method for
number to create new Intervals).
next Produce the next element from the interval.
size Return the number of elements that will be
generated in producing the interval.
_E_x_a_m_p_l_e_s
Printed result
(7 to: 13 by: 3) asArray #( 7 10 13 )
(7 to: 13 by: 3) at: 2 10
(1 to: 10) inject: 0 into: [:x :y | x + y]55
(7 to: 13) copyFrom: 2 to: 5 #( 8 9 10 11 )
(3 to: 5) copyWith: 13 #( 3 4 5 13 )
(3 to: 5) copyWithout: 4 #( 3 5 )
(2 to: 4) equals: (1 to: 4) startingAt: 2True
Object
Collection
KeyedCollection
SequenceableCollection
LLLLiiiisssstttt
Lists represent collections with a fixed order, but
indefinite size. No keys are used, and elements are added
or removed from one end of the other. Used in this way,
Lists can perform as _s_t_a_c_k_s or as _q_u_e_u_e_s. The table below
illustrates how stack and queue operations can be imple-
mented in terms of messages to instances of List.
_s_t_a_c_k _o_p_e_r_a_t_i_o_n_s _q_u_e_u_e _o_p_e_r_a_t_i_o_n_s
_____________________________________________________________
push addLast: add addLast:
pop removeLast first in queue first
top last remove first in queue removeFirst
test empty isEmpty test empty isEmpty
|||||||
_R_e_s_p_o_n_d_s _t_o
add: Add the element to the beginning of the
receiver collection. This is the same as
_a_d_d_F_i_r_s_t:.
addAllFirst: The argument must be a SequenceableCollec-
tion. The elements of the argument are
added, in order, to the front of the receiver
collection.
addAllLast: The argument must be a SequenceableCollec-
tion. The elements of the argument are
added, in order, to the end of the receiver
collection.
addFirst: The argument is added to the front of the
receiver collection.
addLast: The argument is added to the back of the
receiver collection.
removeFirst Remove the first element from the receiver
collection, returning the removed value.
removeLast Remove the last element from the receiver
collection, returning the removed value.
class LLLLiiiisssstttt (continued)
_E_x_a_m_p_l_e_s
Printed result
i <- List new
i addFirst: 2 / 3 List ( 0.6666 )
i add: $A
i addAllLast: (12 to: 14 by: 2)
i print List ( 0.6666 $A 12 14 )
i first 0.6666
i removeLast 14
i print List ( 0.6666 $A 12 )
Object
Collection
KeyedCollection
SequenceableCollection
List
SSSSeeeemmmmaaaapppphhhhoooorrrreeee
Semaphores are used to synchronize concurrently running
PPPPrrrroooocccceeeesssssssseeeessss.
_R_e_s_p_o_n_d_s _T_o
new: If created using _n_e_w, a SSSSeeeemmmmaaaapppphhhhoooorrrreeee starts out
with zero excess signals. Alternatively, a
SSSSeeeemmmmaaaapppphhhhoooorrrreeee can be created with an arbitrary
number of excess signals by giving it an
argument to _n_e_w:.
signal If there is a process blocked on the sema-
phore is it scheduled for execution, other-
wise the number of excess signals is incre-
mented by one.
wait If there are excess signals associated with
the semaphore the number of signals is decre-
mented by one, otherwise the current process
is placed on the semaphore queue.
Object
Collection
KeyedCollection
SequenceableCollection
FFFFiiiilllleeee
A FFFFiiiilllleeee is a type of collection where the elements of
the collection are stored on an external medium, typically a
disk. For this reason, although most operations on collec-
tions are defined for files, many can be quite slow in exe-
cution. A file can be opened on one of three _m_o_d_e_s: In
_c_h_a_r_a_c_t_e_r mode every read returns a single character from
the file. In _i_n_t_e_g_e_r mode every read returns a single word,
as an integer value. In _s_t_r_i_n_g mode every read returns a
single line, as a SSSSttttrrrriiiinnnngggg. For writing, character and string
modes will write the string representation of the argument,
while integer mode must write only a single integer.
_R_e_s_p_o_n_d_s _T_o
at: Return the object stored at the indicated
position. Position is given as a character
count from the start of the file.
at:put: Place the object at the indicated position in
the file. Position is given as a character
count from the start of the file.
characterModeSet the mode of the receiver file to _c_h_a_r_a_c_-
_t_e_r.
currentKey Return the current position in the file, as a
character count from the start of the file.
integerMode Set the mode of the receiver file to _i_n_t_e_g_e_r.
open: Open the indicated file for reading. The
argument must be a SSSSttttrrrriiiinnnngggg.
open:for: The _f_o_r: argument must be one of 'r', 'w' or
'r+' (see fopen(3) in the Unix programmers
manual). Open the file in the indicated
mode.
read Return the next object from the file.
size Return the size of the file, in character
counts.
stringMode Set the mode of the receiver file to _s_t_r_i_n_g.
write: Write the argument into the file.
Object
Collection
KeyedCollection
SequenceableCollection
AAAArrrrrrrraaaayyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn
The class AAAArrrrrrrraaaayyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn provides protocol for col-
lections with a Fixed size and integer keys. Unlike other
collections, which are created using the message _n_e_w,
instances of AAAArrrrrrrraaaayyyyeeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn must be created using the one
argument message _n_e_w:. The argument given with this message
must be a positive integer, representing the size of the
collection to be created. In addition to the protocol
shown, many of the methods inherited from superclasses are
redefined in this class.
_R_e_s_p_o_n_d_s _t_o
= The argument must also be an AAAArrrrrrrraaaayyyy. Test
whether the receiver and the argument have
equal elements listed in the same order.
at:ifAbsent: Return the element stored with the given key.
Return the result of evaluating the second
argument if the key is not valid for the
receiver collection.
_n padTo: Return an array like the received that is at
least as long as the argument value. Returns
the receiver if it is already longer than the
argument.
_E_x_a_m_p_l_e_s
Printed result
'small' = 'small' True
'small' = 'SMALL' False
'small' asArray #( $s $m $a $l $l)
'small' asArray = 'small' True
#(1 2 3) padTo: 5 #(1 2 3 nil nil)
#(1 2 3) padTo: 2 #(1 2 3)
Object
Collection
KeyedCollection
SequenceableCollection
ArrayedCollection
AAAArrrrrrrraaaayyyy
Instances of the class AAAArrrrrrrraaaayyyy are perhaps the most com-
monly used data structure in Smalltalk programs. AAAArrrrrrrraaaayyyyssss are
represented textually by a pound sign preceding the list of
array elements.
_R_e_s_p_o_n_d_s _t_o
at: Return the item stored in the position given
by the argument. An error message is pro-
duced, and nnnniiiillll returned, if the argument is
not a valid key.
at:put: Store the second argument in the position
given by the first argument. An error mes-
sage is produced, and nnnniiiillll returned, if the
argument is not a valid key.
grow: Return a new array one element larger than
the receiver, with the argument value
attached to the end. This is a slightly more
efficient command than _c_o_p_y_W_i_t_h:, although
the effect is the same.
_E_x_a_m_p_l_e_s
Printed result
i <- #(110 101 97)
i size 3
i <- i grow: 116 #( 110 101 97 116)
i <- i collect: [:x | x asCharacter] #( #n #e #a #t )
i asString neat
Object
Collection
KeyedCollection
SequenceableCollection
ArrayedCollection
BBBByyyytttteeeeAAAArrrrrrrraaaayyyy
A BBBByyyytttteeeeAAAArrrrrrrraaaayyyy is a special form of array in which the
elements must be numbers in the range 0-255. Instances of
BBBByyyytttteeeeAAAArrrrrrrraaaayyyy are given a very compact encoding, and are used
extensively internally in the Little Smalltalk system. A
BBBByyyytttteeeeAAAArrrrrrrraaaayyyy can be represented textually by a pound sign
preceding the list of array elements surrounded by a pair of
square braces.
_R_e_s_p_o_n_d_s _t_o
at: Return the item stored in the position given
by the argument. An error message is pro-
duced, and nnnniiiillll returned, if the argument is
not a valid key.
at:put: Store the second argument in the position
given by the first argument. An error mes-
sage is produced, and nnnniiiillll returned, if the
argument is not a valid key.
_E_x_a_m_p_l_e_s
Printed result
i <- #[110 101 97]
i size 3
i <- i copyWith: 116 #[ 110 101 97 116 ]
i <- i asArray collect: [:x | x asCharacter]#( #n #e #a #t )
i asString neat
Object
Collection
KeyedCollection
SequenceableCollection
ArrayedCollection
SSSSttttrrrriiiinnnngggg
Instances of the class SSSSttttrrrriiiinnnngggg are similar to AAAArrrrrrrraaaayyyyssss,
except that the individual elements must be CCCChhhhaaaarrrraaaacccctttteeeerrrr.
SSSSttttrrrriiiinnnnggggssss are represented literally by placing single quote
marks around the characters making up the string. SSSSttttrrrriiiinnnnggggssss
also differ from AAAArrrrrrrraaaayyyyssss in that Strings possess an ordering,
given by the underlying ascii sequence.
_R_e_s_p_o_n_d_s _t_o
, Concatenates the argument to the receiver
string, producing a new string. If the argu-
ment is not a SSSSttttrrrriiiinnnngggg it is first converted
using _p_r_i_n_t_S_t_r_i_n_g.
< The argument must be a SSSSttttrrrriiiinnnngggg. Test if the
receiver is lexically less than the argument.
For the purposes of comparison case differ-
ences are ignored.
<= Test if the receiver is lexically less than
or equal to the argument.
>= Test if the receiver is lexically greater
than or equal to the argument.
> Test if the receiver is lexically greater
than the argument.
_r asSymbol Return a SSSSyyyymmmmbbbboooollll with characters given by the
receiver string.
at: Return the character stored at the position
given by the argument. Produce and error mes-
sage, and return nnnniiiillll, if the argument does
not represent a valid key.
at:put: Store the character given by second argument
at the location given by the first argument.
Produce an error message, and return nnnniiiillll, if
either argument is invalid.
_n copyFrom:length:
Return a substring of the receiver. The sub-
string is taken from the indicated starting
position in the receiver and extends for the
given length. Produce an error message, and
return nnnniiiillll, if the given positions are not
class SSSSttttrrrriiiinnnngggg (continued)
legal.
_r copyFrom:to: Return a substring of the receiver. The sub-
string is taken from the indicated positions.
Produce an error message, and return nnnniiiillll, if
the given positions are not legal.
_n printAt: The argument must be a PPPPooooiiiinnnntttt which describes
a location on the terminal screen. The
string is printed at the specified location.
size Return the number of characters stored in the
string.
sameAs: Return true if the receiver and argument
string match with the exception of case
differences. Note that the boolean message =
, inherited from ArrayedCollection, can be
used to see if two strings are the same
including case differences.
_E_x_a_m_p_l_e_s
Printed result
'example' at: 2 $x
'bead' at: 1 put: $r read
'small' > 'BIG' True
'small' sameAs: 'SMALL' True
'tary' sort arty
'Rats live on no evil Star' reversed ratS live on no evil staR
Object
BBBBlllloooocccckkkk
Although it is easy for the programmer to think of
blocks as a syntactic construct, or a control structure,
they are actually objects, and share attributes of all other
objects in the Smalltalk system, such as the ability to
respond to messages.
_R_e_s_p_o_n_d_s _t_o
fork Start the block executing as a PPPPrrrroooocccceeeessssssss. The
value nnnniiiillll is immediately returned, and the
PPPPrrrroooocccceeeessssssss created from the block is scheduled
to run in parallel with the current process.
forkWith: Similar to _f_o_r_k, except that the array is
passed as arguments to the receiver block
prior to scheduling for execution.
newProcess A new PPPPrrrroooocccceeeessssssss is created for the block, but
is not scheduled for execution.
_n newProcessWith:
Similar to _n_e_w_P_r_o_c_e_s_s, except that the array
is passed as arguments to the receiver block
prior to it being made into a process.
value Evaluates the receiver block. Produces an
error message, and returns nil, if the
receiver block required arguments. Return
the value yielded by the block.
value: Evaluates the receiver block. Produces an
error message, and returns nil, if the
receiver block did not require a single argu-
ment. Return the value yielded by the block.
value:value: Two argument block evaluation.
value:value:value:
Three argument block evaluation.
value:value:value:value:
Four argument block evaluation.
value:value:value:value:value:
Five argument block evaluation.
whileTrue: The receiver block is repeatedly evaluated.
While it evaluates to true, the argument
block is also evaluated. Return nil when the
class BBBBlllloooocccckkkk (continued)
receiver block no longer evaluates to true.
whileTrue The receiver block is repeatedly evaluated
until it returns a value that is not true.
whileFalse: The receiver block is repeatedly evaluated.
While it evaluates to false, the argument
block is also evaluated. Return nil when the
receiver block no longer evaluates to false.
whileFalse The receiver block is repeatedly evaluated
until it returns a value that is not false.
_E_x_a_m_p_l_e_s
Printed result
['block indeed'] value block indeed
[:x :y | x + y + 3] value: 5 value: 7 15
Object
CCCCllllaaaassssssss
The class CCCCllllaaaassssssss provides protocol for manipulating
class instances. An instance of class CCCCllllaaaassssssss is generated
for each class in the Smalltalk system. New instances of
this class are then formed by sending messages to the class
instance.
_R_e_s_p_o_n_d_s _t_o
_n deepCopy: The argument must be an instance of the
receiver class. A deepCopy of the argument
is returned.
_n edit The user is placed into a editor editing the
file from which the class description was
originally obtained. When the editor ter-
minates, the class description will be
reparsed and will override the previous
description. See also _v_i_e_w (below).
_n list Lists all subclasses of the given class
recursively. In particular, OOOObbbbjjjjeeeecccctttt _l_i_s_t will
list the names of all the classes in the sys-
tem.
new A new instance of the receiver class is
returned. If the methods for the receiver
contain protocol for _n_e_w, the new instance
will first be passed this message.
new: A new instance of the receiver class is
returned. If the methods for the receiver
contain protocol for _n_e_w:, the new instance
will first be passed this message.
_n respondsTo List all the messages that the current class
will respond to.
_d respondsTo: The argument must be a Symbol. Return true
if the receiver class, or any of its superc-
lasses, contains a method for the indicated
message. Return false otherwise.
_n shallowCopy: The argument must be an instance of the
receiver class. A shallowCopy of the argu-
ment is returned.
_n superClass Return the superclass of the receiver class.
_n variables Return an array containing the names of the
instance variables used in the receiver
class CCCCllllaaaassssssss (continued)
class.
_n view Place the user into an editor viewing the
class description from which the class was
created. Changes made to the file will not,
however, affect the current class representa-
tion.
_E_x_a_m_p_l_e_s
Printed result
Array new: 3 #( nil nil nil )
Bag respondsTo: #add: True
SequenceableCollection superClass KeyedCollection
Object
PPPPrrrroooocccceeeessssssss
Processes are created by the system, or by passing the
message _n_e_w_P_r_o_c_e_s_s or _f_o_r_k to a block; they cannot be
created directly by the user.
_R_e_s_p_o_n_d_s _T_o
block The receiver process is marked as being
blocked. This is usually the result of a
semaphore wait. Blocked processes are not
executed.
resume If the receiver process has been _s_u_s_p_e_n_ded,
it is rescheduled for execution.
suspend If the receiver process is scheduled for exe-
cution, it is marked as suspended. Suspended
processes are not executed.
state The current state of the receiver process is
returned as a Symbol.
terminate The receiver process is terminated. Unlike a
blocked or suspended process, a terminated
process cannot be restarted.
unblock If the receiver process is currently blocked,
it is scheduled for execution.
yield Returns nnnniiiillll. As a side effect, however, if
there are pending processes the current pro-
cess is placed back on the process queue and
another process started.