Question

I came to this question, when I wanted to check something about the syntax of functor declarations. I came to two contradictory syntax definitions, while the syntax of Standard ML '97, as its name suggest, is supposed to be part of a standard, defined in “The definition of Standard ML — Revised”.

From the book

“The definition of Standard ML — Revised”, by R. Milner, page 14, on Google Books says:

fundec ::= functor funbinf
funbind ::= funid (strid : sigexp) = strexp <and funbind>

I read it as “A functor gets exactly one argument and cannot be said to match a signature”.

From another reliable source

“Standard ML syntax summary”, by L. Paulson, page 2, on PDF says (schema approximately re‑expressed using the same notation as in the definition of SML '97):

FunctorDeclaration ::= functor FunctorBinding <and FunctorBinding>
FunctorBinding ::= Ident ( FunctorArguments ) : Signature = Structure
FunctorArguments ::= Ident : Signature | Specification

I read it as “A functor may get multiple arguments and may be said to match a signature”.

Question

The two documents says different things, so I'm confused. What is the real definition of Standard ML '97? Or am I just miss‑reading the standard definition?

Was it helpful?

Solution

Chapters 2 and 3 of the Definition only give the bare syntax of the language. That's extended by the "derived forms" (i.e., syntactic sugar) defined in Appendix A, which include the funid (spec) form (which is short for funid (X : sig spec end) with X being opened on the RHS).

See here for a complete SML grammar including all derived forms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top