[plt-scheme] Confused about current-print
I was expecting the output of the following expressions to be the same
(and specifically be the same as the latter). What am I missing?
Welcome to DrScheme, version 4.1.3 [3m].
Language: Module; memory limit: 384 megabytes.
> (list
(with-output-to-string
(λ ()
(let ([print (current-print)])
(print 42)))))
42
("")
> (list
(with-output-to-string
(λ ()
(print 42))))
("42")
My expectation came from the documentation on current-print:
(current-print) → (any/c -> any)
(current-print proc) → void?
proc : (any/c -> any)
A parameter that determines the print handler that is called by
read-eval-print-loop to print the result of an evaluation (and the
result is ignored).
The default print handler prints the value to the current output
port (as determined by the current-output-port parameter) and
then outputs a newline, except that it prints nothing when the
value is #<void>.
--
Jens Axel Søgaard