scheme@(guile-user)> (define val (when #f 1))
scheme@(guile-user)> val
scheme@(guile-user)> (null? val)
$6 = #f
scheme@(guile-user)> (boolean? val)
$7 = #f
scheme@(guile-user)> (pair? val)
$8 = #f
scheme@(guile-user)> (when val 1)
$9 = 1
It does evaluate to #t but what is it?
update: the docs says: "When ... the test evaluates to #f, the value of the expression is not specified." So it might be anything, and shouldn't be relied upon for anything.
It returns a value which is not null?, not boolean? and not pair?:
scheme@(guile-user)> (null? val)
$6 = #f
scheme@(guile-user)> (boolean? val)
$7 = #f
scheme@(guile-user)> (pair? val)
$8 = #f
It is not an #f, as evidenced by
scheme@(guile-user)> (when val 1)
$9 = 1
And it prints as nothing,
scheme@(guile-user)> val
scheme@(guile-user)>
So what is it? A value is defined by its interactions. Its internal representation in a specific implementation is not that important.
Short answer is, it is a "not a value". (sic)
Chez Scheme prints it as #<void>:
(define val (when #f 1))
(display val)
; Output:
#<void>
And Guile 2.0.13 at ideone.com prints it as #<unspecified>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With