home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
alst-3.04.lha
/
ALSt
/
manual.ms
< prev
next >
Wrap
Text File
|
1994-05-14
|
31KB
|
836 lines
.TL
Little Smalltalk Users Manual - Version Three
.AU
Tim Budd
.AI
Department of Computer Science
Oregon State University
Corvallis, Oregon
97331 USA
.AB
.PP
Version three of Little Smalltalk was designed specifically to
be easy to port
to new machines and operating systems.
This document provides the basic information needed to use Version Three of
Little Smalltalk, plus information needed by those wishing to undertake the
job of porting the system to a new operating environment.
.AE
.PP
The first version of Little Smalltalk, although simple, small and fast, was in
a number of very critical ways very Unix specific. Soon after the
publication of the book \fIA Little Smalltalk\fP, requests started flooding
in asking if there existed a port to an amazingly large number of different
machines, such as the IBM PC, the Macintosh, the Acorn, the Atari, and even
such systems as DEC VMS. Clearly it was beyond our capabilities to
satisfy all these requests, however in an attempt to meet them partway in
the summer of 1988 I designed a second version of Little Smalltalk, which
was specifically designed to be less Unix specific and more amenable to
implementation of different systems.
.PP
This document describes is divided into two parts. In part one I describe
the basic features of the user interface. This is essential information
for anybody wishing to use the system. In part two we give the basic
information needed by anybody wishing to undertake the task of porting
version three Little Smalltalk to a new machine.
.NH
Getting Started
.PP
How you get started depends upon what kind of system you are working on.
Currently there are two styles of interface supported. A line-oriented,
tty style stdin interface is available, which runs under Unix and other systems.
There is also a window based system which runs under X-windows and on the
Mac.
.NH 2
The stdin/stdout interface
.PP
Using the stdin/stdout interface, there is a prompt (the ``>'' caracter)
typed to indicate the system is waiting for input.
Expressions are read at the keyboard and
evaluated following each carrage return. The result of the expression
is then printed.
.DS I
> 5 + 7
12
.DE
Global variables can be created simply by assigning to a name.
The value of an assignment statement is the value of the right hand side.
.DS I
x <- 3
3
.DE
Multiple expressions can appear on the same line separated by periods.
Only the last expression is printed.
.DS I
y <- 17. 3 + 4
7
.DE
.NH 2
The windowing interface
.PP
The windowing interface is built on top of guido van rossums standard
window package, and runs on top of systems that support standard windows.
These include X-11 and the Macintosh.
.PP
When you start up the system, there will be a single window titled
``workspace''. You can enter expressions in the workspace, then select either
the menu items ``do it'' or ``print it''.
Both will evaluate the expression; the latter, in addition, will print the
result.
.PP
A number of other memu commands are also available. These permit you to
save the current image, exit the system, or start the browser.
.PP
The browser is an interface permiting you to easily view system code.
Selecting a class in the first pane of the browser brings up a second pane
in which you can select methods, selecting a method brings up a third pane
in which you can view and edit text. Selecting ``compile'' following the
editing of text will attempt to compile the method. If no errors are
reported, the method is then available for execution.
.NH
Exploring and Creating
.PP
This section describes how to discover information about existing objects
and create new objects using the Little Smalltalk
system (version three).
In Smalltalk one communicates with objects by passing messages to them.
Even the addition message + is treated as a message passed to the
first object 5, with an argument represented by the second object.
Other messages can be used to discover
information about various objects.
The most basic fact you can discover about an object is its class.
This is given by the message \fBclass\fP, as in the following examples:
.DS I
> 7 class
Integer
> nil class
UndefinedObject
.DE
.PP
Occasionally, especially when programming, one would like to ask whether
the class of an object matches some known class. One way to do this would
be to use the message \fB= =\fP, which tells whether two expressions
represent the same object:
.DS I
> ( 7 class = = Integer)
True
> nil class = = Object
False
.DE
.PP
An easier way is to use the message \fBisMemberOf:\fP;
.DS I
> 7 isMemberOf: Integer
True
> nil isMemberOf: Integer
False
.DE
.PP
Sometimes you want to know if an object is an instance of a particular
class or one if its subclasses; in this case the appropriate message is
\fBisKindOf:\fP.
.DS I
> 7 isMemberOf: Number
False
> 7 isKindOf: Number
True
.DE
.PP
All objects will respond to the message \fBdisplay\fP by telling a little
about themselves. Many just give their class and their printable
representation:
.DS I
> 7 display
(Class Integer) 7
> nil display
(Class UndefinedObject) nil
.DE
.LP
Others, such as classes, are a little more verbose:
.DS I
> Integer display
Class Name: Integer
SuperClass: Number
Instance Variables:
no instance variables
Subclasses:
.DE
.LP
The display shows that the class \fBInteger\fP is a subclass of class
\fBNumber\fP (that is, class \fBNumber\fP is the superclass of
\fBInteger\fP). There are no instance variables for this class, and it
currently has no subclasses.
All of this information could be obtained by means of other messages,
although the \fBdisplay\fP form is the easiest.
[ Note: at the moment printing subclasses takes a second or two. I'm not
sure why.]
.DS I
> List variables display
links
> Integer superClass
Number
> Collection subClasses display
IndexedCollection
Interval
List
.DE
About the only bit of information that is not provided when one passes the
message \fBdisplay\fP to a class
is a list of methods the class responds to. There are two
reasons for this omission; the first is that this list can often be quite
long, and we don't want to scroll the other information off the screen
before the user has seen it. The second reason is that there are really
two different questions the user could be asking. The first is what
methods are actually implemented in a given class. A list containing
the set of methods implemented in a class can be found by passing the
message \fBmethods\fP to a class.
As we saw with the message
\fBsubClasses\fP shown above, the command \fBdisplay\fP prints this
information out one method to a line:
.DS I
> True methods display
#ifTrue:ifFalse:
#not
.DE
.PP
A second question that one could ask is what message selectors an instance of a
given class will respond to, whether they are inherited from superclasses
or are defined in the given class. This set is given in response to the
message \fBrespondsTo\fP. [ NOTE: again form some reason I'm not sure of
this command seems to take a long time to execute ].
.DS I
> True respondsTo display
#class
#==
#hash
#isNil
#display
#=
#basicSize
#isMemberOf:
#notNil
#print
#basicAt:put:
#isKindOf:
#basicAt:
#printString
#or:
#and:
#ifFalse:ifTrue:
#ifTrue:
#ifFalse:
#not
#ifTrue:ifFalse:
.DE
.PP
Alternatively, one can ask whether instances of a given class will respond
to a specific message by writing the message selector as a symbol:
.DS I
> String respondsTo: #print
True
> String respondsTo: #+
False
.DE
.PP
The inverse of this would be to ask what classes contain methods for a
given message selector. Class \fBSymbol\fP defines a method to yield just
this information:
.DS I
> #+ respondsTo display
Integer
Number
Float
.DE
.PP
The method that will be executed in response to a given message selector
can be displayed by means of the message \fBviewMethod:\fP
.DS I
> Integer viewMethod: #gcd:
gcd: value
(value = 0) ifTrue: [ \(ua self ].
(self negative) ifTrue: [ \(ua self negated gcd: value ].
(value negative) ifTrue: [ \(ua self gcd: value negated ].
(value > self) ifTrue: [ \(ua value gcd: self ].
\(ua value gcd: (self rem: value)
.DE
.PP
Some Smalltalk systems make it very difficult for you to disc