[MLton-user] Linking (?) 'print' means I can only run from the mingw command line

Wesley W. Terpstra wesley at terpstra.ca
Mon Sep 15 09:45:04 PDT 2008


On Mon, Sep 15, 2008 at 7:22 PM, Matthew Fluet <fluet at tti-c.org> wrote:

> On Mon, 15 Sep 2008, Wesley W. Terpstra wrote:
>
>> The problem is that -mwindows removes the stdin/out/err file descriptors
>> from the program.
>>
>
> What happens to an 'fprintf(stderr,...);' or an 'fwrite(s,size,n,stderr);'
> statement with -mwindows? An exception raised during the evaluation of the
> Basis Library will be printed using functions from
> <src>/runtime/basis/Stdio.c.  (See <src>/basis-library/primitive/prim2.sml.)


They will all silently fail. The C code in my previous email will correct
std*, however, so if it is called soon enough, stderr will work.

There are two fixes that come to mind:
>> 1) handle/ignore the exception from fstat (isReg posix/io.sml:187)
>> 2) setup place-holder stdin/out/err if none exist
>>
>> I tend towards option #2.
>>
>
> How does one determine that stdin/out/err 'exist'?  It seems as though they
> exist as values/handles, but don't support the full range of operations.


The test fileno(stdout) == 1 in my previous email has worked on all the
platforms / combinations I was able to test.

However,
>> if stderr is missing one loses exception information. Perhaps it could
>> create a popup window. A TextPrimIO.writer that creates a window and adds
>> text on write* calls shouldn't be that hard to implement.
>>
>
> As noted above, this wouldn't help in this situation, because the exception
> printer (that is in scope for the evaluating the Basis Library) doesn't go
> through TextIO.print.
>

Yes. I no longer advocate this. My current suggestion is that we instead
attach a hidden console, and display it if it is used.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton-user/attachments/20080915/d60b7708/attachment.htm


More information about the MLton-user mailing list