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

3.3 Type and Signature Declarations

3.3.6 Field Implementation Declarations

Field implementation declarations are similarly extended to accommodate static types:

field_decl	::=	["shared"] ["var"] "field" field_kind method_name
		    "(" formal ")" [type_decl] {pragma} [":=" expr] ";"
field_kind	::=	empty	declare accessor method impl(s) and sig(s)
	| 	"implementation"	declare just accessor method implementation(s)

If the implementation keyword is used, then the declaration introduces a field get accessor method implementation, and also a set accessor method implementation if the field is declared with the var keyword. The result type of the field is used as the type of the second argument of the set accessor method; the result type of the set accessor method is void.

If the plain field keyword is used, then the field declaration is syntactic sugar for a field implementation declaration and a field signature declaration. A field declaration of the form

shared? var? field name(x@obj:type):typeR := expr;

where shared? is either the shared keyword or empty and var? is the var keyword or empty, is syntactic sugar for the following declarations:

shared? var? field implementation name(x@obj:type):typeR := expr;
var? field signature name(type):typeR;

The field signature declaration is itself syntactic sugar for one or two signature declarations, depending on whether the var keyword was used.