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

3.3 Type and Signature Declarations

3.3.4 Signature Declarations

Signatures can be declared using the following syntax:

signature_decl	::=	"signature" method_name
		    "(" [arg_types] ")" [type_decl] ";"
arg_types	::=	arg_type { "," arg_type }
arg_type	::=	[[name] ":"] type
type_decl	::=	":" type

The names of formals in a signature are for documentation purposes only; they do not impact the meaning of the signature nor do they have any effect during type checking.

Signatures can also be declared in a field-like notation, as follows:

field_sig_decl	::=	["var"] "field" "signature" method_name
		    "(" arg_type ")" [type_decl] ";"

A field signature declaration of the form

var field signature name(type):typeR;

is syntactic sugar for the following two declarations:

signature name(type):typeR;
signature set_name(type,typeR):void;

A field signature declaration does not require that implementations of the resulting signatures be fields, only that their interface "looks" like they could be implemented by fields. If the var keyword is omitted, then the second set accessor signature is not generated.