Reputation: 1058
I read on https://ds26gte.github.io/tyscheme/index-Z-H-11.html tree.girth returns "an undefined value". Is this right? Have Scheme really multiply undefined values?
Upvotes: 1
Views: 214
Reputation: 15803
Undefined
means that you must not use the return value -- it can be anything.
In scheme a command like display
will return the #!unspecific
symbol and in racket(i.e. the old plt-scheme) the void
symbol. You should not use the value #!unspecific
returned by display
. This means undefined
value.
% mit-scheme
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2019 Massachusetts Institute of Technology
1 ]=> (display (display "ok"))
ok#!unspecific
;Unspecified return value
% racket
Welcome to Racket v7.3.
> (display (display "ok"))
ok#<void>
>
Upvotes: 1
Reputation: 782130
"Undefined" is not a specific value. What it's saying is that the value returned is not defined by the language specification, so it could be anything.
Some implementations may have a specific object that they return in these situations, to aid with debugging. But there's no requirement to do so. And whether different instances of these object are equal to each other is not specified -- it's not like #false
, which is always the same object.
Upvotes: 3