On 19/09/2012 15:46, Lars-Henrik Eriksson wrote:
Hi,
I've noticed that Poly/ML handles console I/O differently than at
least SML/NJ and Moscow ML.
When you read from stdIO in the interactive system, reading starts
immediately after the end of the ML compiler input:
Poly/ML 5.5.0 Release
TextIO.inputLine TextIO.stdIn;Hello.
val it = SOME "Hello.\n": string option
...while in SML/NJ and Moscow ML, reading starts with the next input
line:
Standard ML of New Jersey v110.74 [built: Tue Jan 31 16:23:10 2012] -
TextIO.inputLine TextIO.stdIn; Hello. val it = SOME "Hello.\n" :
string option
This matters especially if you are writing an interactive program
which writes prompts to stdOut. Using Poly/ML, the program must do a
dummy read to "consume" the rest of the compiler input before writing
a prompt. This causes an incompatibility with SML/NJ and Moscow ML.
Worse, if you run a stand-alone application of the program built
using Poly/ML there is no compiler input to read, so Poly/ML becomes
incompatible with itself...
I feel that the reasonable behavior is that of SML/NJ and Moscow ML.
Is it possible to change this in Poly/ML?
The problem is that there may be more than one ML command on a line and
there has to be a consistent way to deal with it. In my view Poly/ML is
consistent about this. The compiler reads exactly as many characters as
it needs to form a valid ML "program" and leaves the input pointer
pointing at the next character. When the "program" has completed
executing the compiled code, which may consume further characters from
the input, the read-eval-print loop returns to the compiler to start
compiling ML. Consider the following input:
TextIO.inputLine TextIO.stdIn; 1;
2;
With Poly/ML this prints:
val it = SOME " 1;\n": string option
val it = 2: int
With SML/NJ it prints
val it = SOME "2;\n" : string option
val it = 1 : int
As far as I'm aware the Definition does not describe what should happen
here.
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml