6

I was pleasantly surprised when I saw that SML/NJ recently made some major changes in version 110.79 which is part of a move towards something called Successor ML. This seems to be a cooperative venture between SML/NJ and MLton and bodes well for the future of SML.

However, I seem to encounter a weird bug (on 64-bit Windows 7) when I try to use some of the new features. To try it out, I wrote the following in a file called sml_successor_test.sml:

Control.succML := true;
val n = 123_456;
print (Int.toString n);

when I try to load it into the REPL using use "C:\Programs\sml_successor_test.sml"; the compiler balks at the second line in the file (which uses a new type of number literal which should be enabled). But -- when I immediately run the exact same use command as before -- it works.

If first use Control.succML := true; in the REPL and then use use to load the file (after removing that line from the file) it does work. On the other hand, if I just fire up SML, enable succML, and then have the assignment val n = 123_456; directly in the REPL, it fails the first time but then works.

To sum up -- there seems to be a weird lag between when Control.succML := true is evaluated and when it takes effect, a lag which happens in some contexts but not others. Any idea what is behind this and any workaround?

John Coleman
  • 51,337
  • 7
  • 54
  • 119

2 Answers2

2

This happens to me on Mac OS X as well. What I did, though, was to use the -Cparser.succ-ml=true flag in my sml alias, which behaves as expected:

alias sml="rlwrap /usr/local/bin/sml -Cparser.succ-ml=true"

I forget now what's the Windows equivalent. You may have to create your own sml wrapper script and place it before the SML/NJ one in PATH.

Ionuț G. Stan
  • 176,118
  • 18
  • 189
  • 202
  • Windows does have a way to create aliases -- but I found it more natural to take your idea of writing a wrapper script, which I will include as a second answer for Windows users. – John Coleman Jan 03 '16 at 15:33
  • Hmm, seems reasonable to have a quick way to choose between SML and SuccML. I might do that, too. – Ionuț G. Stan Jan 03 '16 at 20:44
2

This is a variation of the accepted answer. I used @IonutGStan 's idea of a wrapper script as follows. I created a VBScript program named SuccessorML.vbs with the code:

Set WS = WScript.CreateObject("WScript.Shell")
WS.RUN("sml -Cparser.succ-ml=true")

and put the icon in the folder that I usually program in. When I click it an instance of the SML REPL with the successor features already enabled pops up. I already have the path to sml on my system's path. If you don't -- you would have to add the full path in the run command.

On Windows the command sml links to a small .bat file. You could probably edit that file so it opens sml with succ-ml enabled -- by I like the idea of being able to easily launch SML either way.

John Coleman
  • 51,337
  • 7
  • 54
  • 119