Type declarations (ref)
From Nemerle Homepage
Contents |
Type header
Type header is similar to .NET. The main difference is the optional type_parameters list, defined below.
Type parameters
When defining polymorphic type one has to specify list of type variables
in declaration. It can have following form:
class Foo [a, b]
An optional list of where parameters can be used to add constraints to the type variables.
where a : Nemerle.Collections.IEnumerable, IComparable where b : Nemerle.Collections.IDictionary
Declarations
Type alias
Much like typedef in C.
Interface
Class like
A module is much like a class, but all module members are static. There
is no need to place static attributes on module members. It is also not
possible to create instances of module types.
Struct types are like classes, but they are passed by value and cannot inherit from other types.
Variants
A variant declaration consists of a type name and a list of bar-separated
variant options enclosed in brackets.
The variant option describes the constructor associated with this variant type. An option may take an argument. Option name must be capitalized.
Variants (unlike variant options) can also have other members (methods and fields). These fields and methods are inherited by all the options.
Enums
Enums are like variants, but cannot take arguments. They are passed by
value and can be used with bitwise operations.