[Next] [Previous] [Up] [Top] [Contents] [Index]
3.3 Type and Signature Declarations
The syntax of method implementations is extended in the following way to accommodate static types:
method_decl ::= impl_kind method_name
"(" [formals] ")" [type_decl] {pragma}
"{" (body | prim_body) "}" [";"]
impl_kind ::= ["method"] "implementation" declares a method implementation
| "method" declares a method signature and implementation
specializer ::= [location] [type_decl] specialized formal
| "@" ":" object sugar for @object :object
Formal parameters of the method implementation and the result of the method implementation can be given explicit type declarations.
If the implementation
keyword is used, the declaration introduces a new method implementation. If, however, the method
keyword alone is used, the declaration is syntactic sugar for both a method implementation declaration and a signature declaration. A declaration of the form
method name(x1@obj1:type1, ..., xN@objN:typeN):typeR { body }
is syntactic sugar for the following two declarations:
signature name(type1, ..., typeN):typeR; implementation name(x1@obj1:type1, ..., xN@objN:typeN):typeR { body }
As explained in section 2.2.1, if any of the obji are omitted, they default to any
.
A formal in a method or field declaration can be specified with the x@:object
syntax. This syntax is shorthand for x@object:typeof(object)
.
[Next] [Previous] [Up] [Top] [Contents] [Index]
Generated with Harlequin WebMaker