Trait Statement

Makes a trait, a construct that changes how a class or structure behaves.

Syntax

[ @Abstract ] _
Trait trait_name [ type_list ] [ Does trait_list ]
    [ Where generic_constraints ]
    …
    [ statements ]
End [ Trait ]

Parts

@Abstract
Optional modifier specifies that the trait contains only signatures of procedures, not control statements or variables.
trait_name
Mandatory name for the trait
type_list
Optional one or more type parameters, with a comma between each, all between brackets ([ ]). See Type List for more information.
trait_list
Mandatory after Does, one or more traits, with a comma between each. See Does Clause (Traits) for more information.
Where
Optional keyword you can use again and again. See Where Clause (Generics) for more information.
statements
Optional declarative statements.
End
Completes the statement. You can also use End Trait.
You can change this part of the syntax. See @Option Directive for more information.

Instructions

A trait defines a set of members that can become a part of the interface of classes and structures. If the trait does not implement a method or property, the class or structure must implement it. A trait that supplies only an interface, and does not implement its methods or properties, is known as an abstract trait.

When you make a class or structure that uses a trait, the code supplied by the trait becomes part of your class or structure. If a trait member is not implemented, you must implement that member in a concrete class or structure.

You can use traits only at module level. The declaration context can be a class, structure, module, or trait, and cannot be a procedure or block. See Declaration Contexts and Default Access Levels for more information.

Rules

TODO

Behavior

TODO

Examples

TODO

See also