[Larceny-users] (newline port) in err5rs mode

will at ccs.neu.edu will at ccs.neu.edu
Sun Feb 27 20:11:35 EST 2011


Jon Wells wrote:

> I guess it's me this doesn't seem right but...
> 
>         jon at pow 68% larceny -path . -err5rs
>         Larceny v0.97 "Funny in the Head" (Aug 19 2009 06:31:24,
>         precise:Linux:unified)
>         larceny.heap, built on Wed Aug 19 06:33:35 EDT 2009
>         ERR5RS mode (no libraries have been imported)
>         
>         > (import (rnrs))
>         > (newline (standard-error-port))
>         
>         Error: put-char: not an output port #<OUTPUT PORT
>         *error-output*>
>         Entering debugger; type "?" for help.
>         debug> #<EOF>
> 
> while
>     
>         > (display "stuff" (standard-error-port))
>         stuff

Good catch.  Neither newline nor display nor put-char should
work with (standard-error-port), which the R6RS requires to be
a "fresh binary output port".  I suspect that the usefulness
of display with (standard-error-port) was a transitional matter
to help with the transition to R6RS i/o semantics.  With that
transition complete, all textual output operations should raise
exceptions when used with a (standard-error-port) or
(standard-output-port).

The error message was misleading as well.  I'll log both bugs
tomorrow.

The portable way to write text to a (standard-output-port) or
(standard-error-port) is to use the transcoded-port procedure
to obtain a textual output port, as in the following example:

> (define p (transcoded-port (standard-error-port) (native-transcoder)))

> (newline p)

Will



More information about the Larceny-users mailing list