Discussion:
[Larceny-users] current-{in, out}put-port assignable but not current-error-port
Derick Eddington
2009-03-20 07:56:10 UTC
Permalink
Is current-error-port intentionally not assignable? I have code which
parameterizes all three current-*-port (and imports them via a
compatibility library because R6RS's are technically not directly
assignable (I think) (but they should be)).


Larceny v0.97a4 (alpha test) (Mar 18 2009 22:48:58, precise:Linux:unified)
larceny.heap, built on Wed Mar 18 22:50:40 PDT 2009
ERR5RS mode (no libraries have been imported)
(import (rnrs io ports))
Autoloading (rnrs io ports)
Autoloading (larceny deprecated)
Autoloading (rnrs lists)
(current-input-port (current-input-port))
#<INPUT PORT *console-input*>
(current-output-port (current-output-port))
#<OUTPUT PORT *console-output*>
(current-error-port (current-error-port))
Error: Wrong number of arguments to procedure #<PROCEDURE current-error-port>,
which expected 0 but got 1
Entering debugger; type "?" for help.
debug>
William D Clinger
2009-03-20 14:40:42 UTC
Permalink
Post by Derick Eddington
Is current-error-port intentionally not assignable?
Yes. As src/Lib/Common/stdio.sch puts it:

; Rebinding the current-error-port can cause an infinite loop
; when errors occur, so current-error-port isn't a parameter.
Post by Derick Eddington
I have code which
parameterizes all three current-*-port (and imports them via a
compatibility library because R6RS's are technically not directly
assignable (I think) (but they should be)).
Variables exported from an R6RS library area are never
assignable, and the R6RS has no notion of parameters.

By making current-input-port and current-error-port into
parameters that accept an optional argument, Larceny
violates absolute ("must") requirements of R6RS 5.4 and
this very explicit requirement of R6RS 6.2:

A procedure that detects an argument that it is not
specified to handle must raise an exception with
condition type &assertion. Also, the argument
specifications are exhaustive: if the number of
arguments provided in a procedure call does not
match any number of arguments accepted by the
procedure, an exception with condition type
&assertion must be raised.

That is just one of many similar extensions that prevent
Larceny from being R6RS-conforming, even though Larceny is
certainly one of the more R6RS-compatible implementation
now available.

Will
Derick Eddington
2009-03-20 18:04:35 UTC
Permalink
Post by William D Clinger
Post by Derick Eddington
Is current-error-port intentionally not assignable?
; Rebinding the current-error-port can cause an infinite loop
; when errors occur, so current-error-port isn't a parameter.
I wonder if we should still be given the ability to do it somehow,
like via a current-error-port/risk. Or maybe have two default
exception handlers and the outermost's error port is unchangeable and
its sole purpose is to handle exceptions caused by the inner handler
which is the usual default handler which uses the changeable
current-error-port (?).
Post by William D Clinger
Post by Derick Eddington
I have code which
parameterizes all three current-*-port
The reason I want to parameterize current-error-port as well is
because I have a REPL library which provides REPLs over given ports,
and during the eval of read expressions I want any output to
current-error-port to go to the given error port. It's just a toy and
I don't use it for anything currently. But being able to redirect all
the standard ports seems like something that should be doable.
Post by William D Clinger
Post by Derick Eddington
(and imports them via a
compatibility library because R6RS's are technically not directly
assignable (I think) (but they should be)).
Variables exported from an R6RS library area are never
assignable, and the R6RS has no notion of parameters.
By making current-input-port and current-output-port into
parameters that accept an optional argument, Larceny
violates absolute ("must") requirements of R6RS 5.4 and
That's what I meant by "technically not directly assignable", as
opposed to indirectly assignable via with-input-from-file and
with-output-to-file.

--
: Derick
----------------------------------------------------------------

Loading...