[Next] [Previous] [Up] [Top] [Contents] [Index]

2.1 Objects and Inheritance

2.1.2 Object Instantiation

Rather than introduce a distinct instantiation concept into the language, new "instances" of some object are created solely by inheriting from the object. Object declarations allow statically-known, named "instances" to be defined, while object constructor expressions allow new anonymous "instances" to be created at run-time. An object constructor expression is syntactically and semantically similar to an object declaration, except that there is no name for the object being created. For example:

let s1 := object isa square;  -- create a fresh "instance" of square when executed

Section 2.5.7 describes object constructor expressions in more detail. Note that the parent of an object must be statically known; Cecil does not allow objects to be created whose parents are run-time computed expressions. This is a restriction over some other prototype-based languages.