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

3.3 Type and Signature Declarations

3.3.3 Type and Object Extension Declarations

As described in section 2.1.3, objects can be extended with new inheritance relations after they have been defined. In a similar fashion, types can be extended with new subtyping relations using type extension declarations of the following form:

type_ext_decl	::=	"extend" "type" named_type {type_relation} ";"

The syntax of object extension declarations is extended to support augmenting either just an object representation or both an representation and a type:

obj_ext_decl	::=	"extend" extend_kind named_object
		    {relation} [field_inits] ";"
extend_kind	::=	"representation"	extend representation
	|	["object"]	extend both type and representation

If the extension uses the representation keyword, then the named representation is extended with the appropriate inheritance and conformance relations. Otherwise, both the representation and the type that are named by the extension are updated. A declaration of the form

extend object name inherits namei1, namei2, ..., namein
                       subtypes names1, names2, ..., namesm
                       isa nameb1, nameb2, ..., namebk ;

is syntactic sugar for the following two declarations:

extend type name 				subtypes names1, names2, ..., namesm,
							           typeof(nameb1), typeof(nameb2), ..., typeof(namebk) ;
extend representation name
				inherits namei1, namei2, ..., namein, nameb1, nameb2, ..., namebk
				subtypes name ;

It is an error if there does not exist both a representation and a type with the corresponding name.

Allowing types to be extended externally to have additional supertypes allows third-parties to integrate separately-developed libraries without modifying the separate libraries directly [Hölzle 93].