Clascal Reference Manual Mar83
Clascal Reference Manual Mar83
Lisa · PDF
| Filename | Clascal_Reference_Manual_Mar83.pdf |
|---|---|
| Size | 2.27 MB |
| Subsection | toolkit_university |
| Downloads | 1 |
Contents
CLASCAL REFERENCE MANUAL
for the LISA
1N
First Dratt~ March· 9th , MCMLXXXIII
by
Da.vid Casseres
IApple Co"puter. Inc. 198J
Cla.sca1
Reference ManuaJ
CONTENTS
1
Introduction to Clascal Concepts
1.1
Class-Types ....•.....
1.2
Objects ............ .
1.3
The Class H1erarchy .... .
1.4 ~~ce ........... .
1.5
Assignment-Compa;tibillty of Objects
Expa.ns1on ofEx1st1ng Pasca.1. Syntax ..
'Def1rdng a Class .......................... .
l)ef'ining a Metl\.od . • • • • • • . . . • . • • • • . • . • • • . • • • • .
..........
2
3
4
4.1
4.2
4.3
4.4
4.5
4.6
5
6
'l
OverrldingInher1tedMethods •••
Self-Reference via. the Self Pseudova.ria.ble
Self-Reference via a Class-Identif1er
Cla.sswid.e Methods
Abstra.ctMethods •
The New Metl\.od
Class Object .•••••.
Objects as Handles ...... .
$H+ a.n.d$H- Compiler Commands
Appendix A:· Sample lJstings ............. .
1
1
1
. . •. 2
2
3
3
•. 6
9
9
9
11
13
13
14
14
15
16
A-l
Reference Manual
Cla.sca.J
1 Introduction to Clascal Concepts
Clascal is a set of extensions to Pascal on the Lisa. These extensions
support "object-oriented" programming in a style th.a.t somewhat resembles SIMULA and SmalltaJk. The purpose is to provide a very highlevel interface to code libraries, allowing the user program to perform
highly complicated functions with simple eaJ.ls, while still reta.irrlng
flexibility .
1.1 Class-Types
Cla.sealis ba.sed on a new category of user-def1ned types called clasS'"
types. An individual class-type is referred to as a aJass.
A cla.ss-type is a klnd of S'trUctured-type, resembling a reeord-type in
that it contains na.med fields. A class can have two kinds of fields:
• 1)8,:ta. Oelds are like the fields of a record; they. contain variable
data, and each data field has its own type.
• .Methods are procedures and functions.
The fields are referenced lUte fields of a record, using a period and a
field-identlf1er (or a w1th-statement that references a. field-identlf1er).
For' exa.mple, it. area. identi:f1es a· field· defined in class Triangle, and
c:rntTria:ngleis decla:rec:1 by
va.r c:rntTr.ia.ngle: Tr.ia.ngle;
then crntTrla.ngle. 8J'."e& is a reference to the area. field of cri\.tTrla.ngle.
If azea. is a data. field, then crntTr.ia.ngle. area. is a va.ria.ble-referen.c:e;
if area. is a. method, then crntTrla.ngle.area. is either a proceduresta.ternent or a. :t\mction-ca.ll.
A class-type is declared in the interface-part of a unit, and is
supported by a .method-block in th.eimplementation-part of the same
unit. Section 3 gives the syntax for class-types and method-blocks.
12 Objects
A class defines the behavior (data. fields and methods) of its objects:.
Each objeetis an .tnsta.nce of the class tha.t def1nes its behavior.
Each object is stored. in a. dyn~ca.lly alloca.ted.,pot.entially reloeatable data area. w1th,1n a heap. An. object of a given class is created by
the new method defined. for that class; .this method returns a newlY
created object of the cl.a.ss(see Seetl.on <4.6).
…
Showing first 3,000 characters of 28,484 total. Open the full document →