Primary expressions (ref)

From Nemerle Homepage

<< Back to Reference Manual.

Contents

Primary expressions

Primary expressions are a grammar category referring to expressions that have a closed structure and are otherwise simple. Primary expressions and plain expressions do not differ at the semantic level.

<primary_expr> ::=
    <literal>
|   'this'
|   'base'


this expression can only be used within non-static methods and indicates a reference to the current instance of the class (which posses this method).

Expression like this.foo can be shortened to foo unless it would generate an identifier ambiguity with some variable being in this lexical scope.

The this keyword can be also used to call instance constructor from another constructor.

base expression can only be used within non-static methods and indicates a reference to the current instance of the class coerced to the type of the base class. Calls made on base pointer are non virtual.

The base keyword can be also used to call instance constructor of base class from another constructor.


Grouping expression

<grouping_expr> ::=
    '(' <expr> ')'


A grouping expression allows to enforce particular syntax decomposition of expression.

Member reference

<member_reference_expr> ::=


This expression allows referring to the field or method that the object represented by primary_expr contains.

Tuple constructor

<tuple_ctor> ::=
    '(' <expr> ',' <expr> { ',' <expr> } ')'


The type of that tuple is type_1 * ... * type_n where type_1 and the following are types of corresponding expressions.

Indexer reference

<indexer_reference_expr> ::=
    <expr> '[' <expr> { ',' <expr> } ']'


This expression allows to refer to indexed (even by multiple indexes) fields of objects represented by leftmost expr where second (and further) expr are indexes values of the field we want to refer to. expr must refer to object with an indexer defined. This includes arrays, strings, hashtables and other collections.

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