Download SilTools Developer`s Guide

Transcript
The Object System
The definition of a class in SIL is very similar to a Pascal (or SIL)
record definition:
type <new-class> = class
superclass:<class1>;
superclass:<class2>;
…
<instance-var-1>:<type1>
<instance-var-2>:<type2>
…
end;;
Rather than introducing a special syntax for passing messages, SIL
uses ordinary function-application syntax. For example, if x is an
object, and you want to send it the message f with additional
arguments a1 .. an, you would enter f(x,a1 .. an). Also, to define a
method f for a class A, you would use ordinary function-definition
syntax:
function f(x:A;<a1>:<type1> ....):<result-type>
var …
begin
…
end;
In SIL, as in any object-oriented language, an object usually belongs
to several classes—if it belongs to a class A, it will also belong to
each of the superclasses of A, and their superclasses, and so forth.
Internally, an object is represented in SIL by a linked list of “views”,
and one view exists for each class to which the object belongs. A
view is a record structure containing the values of instance variables
for its class, and a few words of object-system overhead. A SIL
object can be visualized as a property list, with one property for each
class to which the object belongs.
Developer’s Guide
(7/96)
1-5
Introduction to the
SIL Language
SIL Language Overview