Method Statement

Defines a method procedure for a class or library.

Syntax

Usual construct

[ modifiers ] Method method_name [ type_list ] [ parameter_list ] [ return_type ]
    [ Where generic_constraints ]
    [ statements ]
End [ Method ]

Abstract construct

@Abstract Method method_name [ parameter_list ]

Name-replacement construct

[ modifiers ] Method method_name Does trait_name.old_name

Parts

modifiers
Optional, usually one, but possibly two:
  • @Abstract – The method must be overridden by a concrete child class. Only applicable in an abstract class or trait.
  • @Open – The method can be overridden by a child class. Only applicable in an open class.
  • @Override – The method overrides one inherited from a parent class or trait.
  • @Shared – The method is a child of its parent construct, not an instance of some object.
method_name
Necessary name.
type_list
Optional. See Type List for more information.
Not permitted in the name-replacement construct.
parameter_list
Optional in the usual construct. One or more local variables with a comma between each one. The caller gives them their values. See Parameter List for more information.
Not permitted in the name-replacement construct.
return_type
Optional in the usual construct.
Not permitted in the name-replacement construct.

Syntax

As type
or
In unit
type
TODO
unit
TODO
generic_constraints
Optional. See Where Clause (Generics) for more information.
statements
Optional in the usual construct.
Not permitted in the abstract and aliasing constructs.
End
Completes the statement. You can also use End Method.
You can change this part of the syntax. See @Option Directive for more information.
Not permitted in the abstract and aliasing constructs.
trait_name
Necessary in the name-replacement construct, the name of one trait that the class applies.
old_name
Necessary in the name-replacement construct, the name of the procedure supplied by a trait.

Instructions

Do not confuse the part End Method with the statement Exit Method.

Method is the primary type of procedure contained in a Class, Object, Trait, or Library. Such procedures (along with Property) can be called from any place in a program where its container is in scope. Procedures of the types Function and Sub can only be seen by other procedures in the same container.

Usual construct

TODO

Abstract construct

The abstract construct acts like a template. It is used within an abstract class or trait. It is a guarantee that a concrete child class or the user of a trait will provide its own implementation of the method. Therefore, it cannot contain statements of its own.

Name replacement construct

You use the name replacement construct when you need to change the name of a method supplied by a trait which causes a collision with a different procedure in your class.

If you must keep a method out of your class, the Function Statement has an equivalent form that can convert a public method into a private function.

Examples

TODO

See also