[Next] [Previous] [Up] [Top] [Contents] [Index]
2 Dynamically-Typed Core
 The basic features of objects in Cecil are illustrated by the following declarations, which define a simple shape hierarchy. Comments in Cecil either begin with "--" and extend to the end of the line or are bracketed between "(--" and "--)" and can be nested.
object shape; object circle isa shape; object rectangle isa shape; object rhombus isa shape; object square isa rectangle, rhombus;
The syntax of an object declaration, excluding features relating to static type checking and modules, is as follows:[2]
object_decl	::=	"object" name {relation} [field_inits] ";"
relation	::=	"isa" parents
parents	::=	named_object { "," named_object }
named_object	::=	name
 (name is the token for regular identifiers beginning with a letter; see appendix A.2 for more details on the lexical rules of Cecil.)
 Cecil has a classless (prototype-based) object model: self-sufficient objects implement data abstractions, and objects inherit directly from other objects to share code. Cecil uses a classless model primarily because of its simplicity, but also because this avoids problems relating to first-class classes and metaclasses and because it makes defining unique named objects with specialized behavior easy. Section 2.2 shows how treating "instance" objects and "class" objects uniformly enables CLOS-style eql specializers to be supported with no extra mechanism.
Section 2.3 describes field initializers.
[Next] [Previous] [Up] [Top] [Contents] [Index]
Generated with Harlequin WebMaker