9.2 Activating the SML translator9.2 Activating the SML translator
9 SML translator 9 SML translator
9.4 Class expressions 9.4 Class expressions
9.3 Declarations

9.3 Declarations

A declaration translates to one or more type, constant, function or variable declarations as described below for the various kinds of declarations.

9.3.1 Scheme declarations

Apart from the top level module (which is translated as if it were an object), schemes are only translated when they are instantiated as objects. So a scheme that is instantiated several times will therefore be translated several times. This may appear wasteful, but it saves the need for the restrictions on scheme parameters that would be needed if functors were used for schemes.

9.3.2 Object declarations

An object translates as its translated declarations in a structure of the same name as the object.

An object definition in RSLSML cannot have a formal array parameter.

9.3.3 Type declarations

Type declarations are translated according to their constituent definitions.

Mutually recursive type definitions are not accepted.

Sort definitions

Not accepted.

Variant definitions

A variant definition translates to a structure containing an SML datatype defining the constructors, plus definitions of any destructors and reconstructors. Equality and "toString" functions are also defined.

Wildcard constructors are not accepted.

Short record definitions

A short record definition translates to a structure containing an SML datatype defining the constructor, plus definitions of any destructors and reconstructors. Equality and "toString" functions are also defined.

Abbreviation definitions

An abbreviation definition translates to an SML type definition.

9.3.4 Value declarations

Typings

Typings are not accepted.

Explicit value definitions

An explicit value definition translates to an SML value definition.

Implicit value definitions

Implicit value definitions are not accepted.

Explicit function definitions

An explicit function definition translates to an SML function definition.

If the parameter type(s) are subtype(s), run-time checking that arguments satisfy the relevant conditions is included.

If there is a precondition, run-time checking the the precondition is true when the function is invoked is included.

Access descriptors are ignored. The kind of function arrow (→ or -~->) does not matter.

It is not required that the number of parameters matches the number of components in the domain of the function's type expression. For example, the following are all accepted:

                                     
 type
 U = Int × Bool
 value
 f1: Int × BoolBool
 f1(x, y) ≡ ...,
 f2: (Int × Bool) → Bool
 f2(x, y) ≡ ...,
 f3: U → Bool
 f3(x, y) ≡ ...,
 f4: U × IntBool
 f4(x, y) ≡ ...,
 f5: (Int × Bool) × IntBool
 f5(x, y) ≡ ...
 f6: (Int × Bool) × IntBool
 f6(x) ≡ ...
 f7: Int × BoolBool
 f7(x) ≡ ...,
 f8: (Int × Bool) → Bool
 f8(x) ≡ ...,
 f9: U → Bool
 f9(x) ≡ ...,
 f10: U × IntBool
 f10((x, y), z) ≡ ...,
 f11: (Int × Bool) × BoolBool
 f11((x, y), z) ≡ ...

Implicit function definitions

Implicit function definitions are not accepted.

9.3.5 Variable declarations

A variable declaration translates to SML variable definitions.

If the variable type is a subtype, run-time checking that the initial value is in the subtype is included.

Multiple variable definitions, and uninitialised single variable definitions are not accepted.

9.3.6 Channel declarations

Not accepted.

9.3.7 Axiom declarations

Not accepted.
Chris George, April 17, 2008

9.3 Declarations
9.2 Activating the SML translator9.2 Activating the SML translator
9 SML translator 9 SML translator
9.4 Class expressions 9.4 Class expressions