Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity in SML grammar definition #1

Closed
shwestrick opened this issue Jan 29, 2021 · 1 comment
Closed

Ambiguity in SML grammar definition #1

shwestrick opened this issue Jan 29, 2021 · 1 comment

Comments

@shwestrick
Copy link
Owner

Is this valid SML?

val 1 : int :: [] = [1]

Both SML/NJ and MLton's parsers reject it, but I think it's valid according to the Definition.

The Definition says: "If vid has infix status, then “exp1 vid exp2” (resp. “pat1 vid pat2”) may occur – in parentheses if necessary – wherever the application “vid{1=exp1,2=exp2}” or its derived form “vid(exp1,exp2)” (resp “vid(pat1,pat2)”) would otherwise occur."

This suggests that if the following program is valid, the program up above should be too. (And of course, both MLton and SML/NJ happily accept this program.)

nonfix ::
val ::(1 : int, []) = [1]

Just to be clear, the grammar for patterns is:

<pat> ::= <pat> <vid> <pat>     # where <vid> is an infixed identifier
        | <pat> : <ty>
        | ...

So there is seemingly nothing preventing 1 : int :: [] from being a valid pattern. Why don't SML/NJ and MLton accept it??

@shwestrick
Copy link
Owner Author

Aha... this is specifically mentioned in Andreas Rossberg's "Defects in the Revised Definition of Standard ML":

Screen Shot 2021-01-28 at 9 51 21 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant