3.3 Type and Signature Declarations
method_decl ::=Formal parameters of the method implementation and the result of the method implementation can be given explicit type declarations.impl_kindmethod_name "(" [formals] ")"[type_decl]"{" (body | prim_body) "}" [";"] impl_kind ::= ["method"] "implementation" declares a method implementation | "method" declares a method signature and implementation specializer ::= [location][type_decl] specialized formal|"@" ":" objectsugar for@object :object
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:
As explained in section 2.2.1, if any of the obji are omitted, they default tosignaturename(type1, ..., typeN):typeR;implementationname(x1@obj1:type1, ..., xN@objN:typeN):typeR { body }
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).
Generated with Harlequin WebMaker