stock
hausen.


incompati
bilities
with SML

overview ________________________________



Most Alice extensions to SML'97 are conservative. There are some incompatibilies to SML'97 however. Most of them are quite pathological, caught on compile time, and can easily be fixed in an SML compatible way.

Another limitation of Stockhausen Operette 1 is the lack of support for overloading: the toplevel arithmetic operators are only defined for type int. Moreover, Stockhausen currently does not distinguish equality types: equality is permitted on any type. Both features will probably be subsumed when we add something similar to type classes to the language in a later step.

reserved words __________________________



The following are reserved words in Alice and may not be used as identifiers:

	any     constructor   fct     from       import     non
	pack    unpack        when    withfun    withval
  

open and infix __________________________



Open pulls in infix status. Opening a structure that

  1. contains infix declarations, and
  2. has not been constrained by a signature

will change the infix environment, while in SML it would not.

Example:

	structure S =
	  struct
	    infix ++
	    fun l1++l2 = l1 @ l2
	  end

	open S

	val l = ++([1],[2])		(* error: misplaced infix *)
  

Fixes:

val rec _________________________________



Recursive value bindings do not remove constructor status on the identifiers bound. You cannot bind functions to an identifier that was a constructor previously.

Example:

	val rec NONE = fn x => x
	fun NONE x = x
  

Both these declarations are legal in SML'97 due to some artefact of the formal language specification and would introduce a function named NONE, hiding the constructor status of NONE. In Alice it produces a type clash because it is interpreted as trying to match NONE with a lambda expression. This is consistent with SML'90 and other SML implementations like SML/NJ, however, and probably what the user would expect.

Fix:

constructor arity _______________________



For interoperability reasons, Stockhausen currently has the concept of syntactic arity for constructors. For example, in

	type     t = int * real
	datatype t = A of int * real | B of {a:bool, b:string} | C of t
  

constructor A and B both have arity 2, while C has arity 1. Usually, syntactic arity can be ignored. However, signature matching is restricted to disallow changing the syntactic arity of constructors.

Example:

Fix:

Note that the syntactic arity is calculated after elimination of derived forms. Therefore C has arity 3 in the following example:

	datatype t = C of u
	withtype u = int * int * string
  

namespaces ______________________________



Alice provides higher-order functors. To integrate them smoothly into the language it was necessary to give up the separation between namespaces for structures and those for functors - both are modules.

This may break programs that declare structures and functors with identical names.

Example:

Fix:

include _________________________________



Because of syntactic ambiguity with uses of parameterized signatures, Alice does not support the multiple include derived form.

Example:

	signature S =
	  sig
	    include A B		(* error: A is not parameterized *)
	  end
  

Fix:

sharing _________________________________



In Alice, datatypes are not generative, but are just structural types similar to records. This has an impact on the use of sharing constraints, which require flexible (ie. generative) type constructors.

Alice relaxes the rules for sharing constraints and allows sharing of type constructors as long as one of the following conditions holds:

  1. both are identical type synonyms, or
  2. the type constructor introduced later (lexically) is abstract.

This makes sharing between datatypes possible in most cases. There are exceptions, however.

Example:

Fixes:



last modified 2012/05/23