(define x '())
x
in repl console gives => '()
(define x '())
(display x)
gives => () but I want to print it like '()
How can make display print '() rather than () ?
I need this because my function is logging the error incase of bad inputs provided by user and i want to print '() input as '() only, kinda like how scheme does when you run the following:
(define x '())
(cdr x)
gives =>
mcdr: contract violation
expected: mpair?
given: '() (Note the ')
The code:
Thus evaluating
xin a Scheme REPL will show()since when you evaluate'()it evaluates to the thing without the first'.Racket oddeties
In Racket they have configurable how the REPL is supposed to print values in the REPL / interactive window. In
#lang racketwhen you usedisplayyou'll see what the value really isHowever in
$lang r5rsthe default REPL with default settings output setting isprint:With
constructoras output style:With
quasiquoteas output style:All of the above doesn't really print the value. It prints an expression in the chosen style that, when evaluated, will become the same value.
'(),empty, and`()all evaluate to()so all of them are printed for the value you get when evaluating'()The only sensible choice is to use
writeas output style. This will print the real value in the REPL in the same manner as all other scheme implementations: