On Tuesday 13 May 2008 1:44 pm, David Matthews wrote:
Tjark Weber wrote: ...
The relevant syntactic constructs, omitting other options, are: atpat ::= <op> longvid (pat1, ..., patn) (pat)
pat ::= atpat <op>longvid atpat pat1 vid pat2
That seems to suggest that while <op> longvid can be parenthesised it can only then be a nullary constructor. So val (op nil) = [] val (op :: (h,t)) = [1,2,3] are valid but val (op ::) (h,t) = [1,2,3] is not.
I agree. Pace Larry, I can't find anything in the definition of Standard ML to suggest that parentheses should be allowed here. Moscow ML, MLton and Standard ML of New Jersey all reject this syntax.
On a side note, I noticed earlier that different SML implementations treat (op *) differently, as *) could also mark the end of a comment. I'm not sure what the standard says about this either.
To be honest, I'm not sure either. The original 1990 Definition of Standard ML says, "An unmatched comment bracket should be detected by the compiler." The Commentary on Standard ML (1991) expands this and says, "Even an unmatched *) should be detected by the compiler. Thus the expression (op *) is illegal." The 1997 version though, says, "An unmatched (* should be detected by the compiler." This seems to imply that in ML 97 '(op *)' is legal and that's the interpretation that Poly/ML takes.
The wording there is indeed very vague. For the record MLton agrees with Poly/ML in allowing (op *) while Moscow ML and Standard ML of New Jersey disallow (op *).
Regards,
Rob.