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

2.5 Statements and Expressions

2.5.7 Object Constructors

New objects are created either through object declarations (as described in section 2.1) or by evaluating object constructor expressions. The syntax of an object constructor expression is as follows:

object_expr 	::=	"object" {relation} [field_inits]

This syntax is the same as for an object declaration except that no object name is specified. Object constructor expressions are analogous to object instantiation operations found in class-based languages. The only difference between named objects introduced through object declarations and anonymous objects created through object constructor expressions is that named objects have statically-known names. As a consequence, only named objects can have methods and fields attached to them and can have descendants.