Type members (ref)

From Nemerle Homepage

<< Back to Reference Manual.

The following fields are allowed in class, module and variant body:

<type_member> ::=


Contents

Field definition

<field_definition> ::=
    <attributes> <IDENTIFIER> ':' <type> [ '=' <expr> ] ';'


Unless the optional mutable attribute is used, the field can be modified only inside the constructor.

Property definition

<property_definition> ::=
<property_body> ::=
    { <field_definition> } 'get' <method_body> [ 'set' <method_body> ]


The fields defined in a property are local for it, they cannot be referenced outside the property.

Event definition

<event_definition> ::=
<event_body> ::=
    'add' <block> 'remove' <block>
|   'remove' <block> 'add' <block>


Interface member

<interface_member> ::=
    [ 'new' ] <method_header> ';'
|   [ 'new' ] 'event' <IDENTIFIER> ':' <type> ';'
|   [ 'new' ] <IDENTIFIER> ':' <type> <property_body>


Keyword new is necessary when the declared method hides the inherited one from another interface.

Method definition

<method_definition> ::=


This is a definition of method within class or module. Program entry point is method static Main.

Operator definition

<operator_definition> ::=


Operator definitions must have the static attribute. The name of method must be simply any valid OPERATOR, which can be then used (as a prefix or unary operator) on expressions of type specified by parameters.

Method header

<method_type_parameters> ::=
    '[' <IDENTIFIER> { ',' <IDENTIFIER> } ']'


The declaration of a polymorphic method needs its type variables listed after the identifier.

<method_header> ::=


This is a declaration of method. Unlike in C#, the type is specified after the parameters list.

A special method named this specifies a constructor. This declaration cannot contain the method type and the method has to have type void.

<method_implements> ::=
    [ 'implements' <qualified_identifier> { ',' <qualified_identifier> } ]


Method parameters

<method_parameter> ::=
    [ 'params' ] <identifier_or_dummy> [ ':' <type> ]


A method parameter is a pair consisting of identifier or _ and its type specification. Type declaration can be omitted in local functions definitions.

<method_parameters> ::=


Method parameters are comma-separated list of parameter specification.

Method body

<method_body> ::=
    ';'
|   <block>


Body of a method can be empty, or be a block.

remember
You are very welcome to contribute to the documentation here!