On Wednesday, July 3, 2002, at 01:21 , Ian Zimmerman wrote:
itz> Hi, does PolyML support the syntax itz> itz> <sig> where type t = foo and t' = bar
Stephen> This is not valid signature expression syntax, however the following Stephen> is.
Stephen> <sig> where type t = foo and type t' = bar Stephen> ^^^^
OK, but what is the standard (ML97) syntax? I got the syntax above from Larry Paulson's book - I'd assume that it follows the standard (although I wouldn't be _that_ much surprised if it unwittingly endorsed some SMLNJisms).
About a year ago there was a discussion in the SML implementers mailing list about various deviations from Standard ML 97. Andreas Rossberg (I think: I can't find the original message) posted a set of test programs along with the results for various compilers. Poly/ML did pretty well but there were a few cases where it failed to conform. Accepting where type t = foo and t' = bar was one of them. I fixed this in release 4.1.2 so that it conforms to SML 97 and it now insists on the repetition of the word "type".
The repetition of the word "type" seems on the face of it inconsistent with the rest of the language. After all you don't write
type t = int and type s = bool;
as part of a declaration. It does make sense, though, as Stephen pointed out, when you need to disambiguate it from another signature declaration. For example, Poly/ML (4.1.2) rejects the following
signature S = sig type t and s end where type t = int and s = bool;
but the error is not a syntax error, it's
Error: Signature (bool) has not been declared Found near bool
since it is parsing this, correctly, as two signature declarations. Writing a second "type" after the "and"
signature S = sig type t and s end where type t = int and type s = bool;
works. I guess if you're trying to make your code portable across various implementations and various versions the safest way is to repeat the "where type" e.g. signature S = sig type t and s end where type t = int where type s = bool;
David.