02 An Introduction To Clascal Jul84
02 An Introduction To Clascal Jul84
Lisa · PDF
| Filename | 02_An_Introduction_To_Clascal_Jul84.pdf |
|---|---|
| Size | 2.17 MB |
| Subsection | toolkit_3.0 / Package_2_Examples |
| Downloads | 2 |
Contents
An Introduction to Clascal
Susan Keohan
nacintoshUser Education
Apple Co.puter, Inc.
Preface
This is a conceptual introduction to ClascaL not a reference manual.
Example programs and syntax diagrams follow the text.
The purpose of this document is to introduce experienced Pascal
programmers to the concepts necessary to make the transition from a
traditional procedure-oriented environment to Clascal's
.
object-oriented environment.
This document assumes you are familiar with Lisa Pascal and QuickDraw.
All programs and program fragments are boldface in this document. for
example, thisShape.Erase is a program fragment.
Table of Contents
Introduction ...... .
Comparing Pascal and Clascal
Pascal.
Clascal
Class Types.
Objects
Methods
1
1
••2
••4
. , ,. 8
·.9
12
SELF.
16
Class Hierarchy and Inheritance
Assignment Checking and Typecasting
.
.
Creating and Freeing Objects
StPERSELF and Extensibility ..... .
Clascal vs. Pascal .....•..
Clascal and the Lisa Applications ToolKit.
.hen to Use the Clascal Extensions
Advanced Topics ....
The Example Programs
17
20
21
22
25
26
26
27
30
.. J./~
AI7 InlrDtb:fion to CI6SC61
"1y198*,
An Introduction to Clascal
Introduction
ellsoll is I set of extensions to Lisl Pasoal that adds objects and
classes of objects to the language. The sesaantic extensions of
elascal were inspired by the language s.Blltalk 76. The syntactic
extensions were influenced by the language SillJII 67.. It is not
necessary to know s.alltalk or Simula before learning elascal.
elascal differs little fro. Pascal syntactically. The ..jor
difference between the languages is in progr_ing technique.
bn you write a Pascal proor., your procedure and fooction
specifications are separate fro. your data structure specifications.
When a Pasoal proor. is rCA data is passed to a procedure or
function, and the procedure or function acts on the data.
In elascal the data structures of an object and its procedures and
functions'ar~ specified together 1n a class declaration.
Ihen the
program is rWl, objects are created. These objects use the functions
and procedures that the program.er specified when defining the data
structure. All the operations that an object eM perf0111 are defined
by the object's class. As a result, progr.. modularity is i~roYed.
In Pascal, to add new variations to an old data type, you ..st either
define new types inc~atible rith the old type, or. edit existing code
to add new cases to a variant record type and to procedures that act
on that type. In ClasoaL you can define subclasses of existing
classes without editing existing code Met without introducing
incDq)atible types. As a result, progr_ extensibility is illproved.
CCJIIparing Pasc.l and Clascal
Clascal is a superset of Lisa Pascal. Because the readers of this
doc\IIent are Pascal progr...ers, CI.scal oonoepts are CGIIPIred to
Pascal concepts throughout. this doouIent. As a Pascal progrlllller, you
should have little difficulty adjusting to ClesoaL because III)St of
w…
Showing first 3,000 characters of 62,562 total. Open the full document →