Is (void) distinct from all other types?
Is this a proper way to check if anything is undefined?
(let () (define a) (eq? a (void)))
I think (define a) does not conform to RnRS, because define requires two arguments. Is there a RnRS conforming way to check if anything is undefined/unspecified?
Afficher les réponses par date
2011/10/28 Vok Vojwo ceving@gmail.com
Is (void) distinct from all other types?
It's a unique value yes. (void) => #!void . (eq? (void) #!void) => #t . (if #f #t) => #!void . (member #!void (list #f 0 "" '() #!unbound (not #!void))) => #f .
Is this a proper way to check if anything is undefined?
(let () (define a)
(eq? a (void)))
I think (define a) does not conform to RnRS, because define requires
two arguments. Is there a RnRS conforming way to check if anything is undefined/unspecified?
Don't base your code on checks for if variables are not defined, it reflects bad coding practice (as it doesn't deliver on transition into local scopes and it renders optimizations ineffective), so reconsider what you want to achieve and how. The B.H. module system does not use anything like this afaik, for instance.
You could do (eval varname-symbol) though, exception shows it didn't exist. For more sophisticated introspection of globals, you could check out Gambit's internal structures for this.
There is a #!unbound value also, that comes into play in some circumstances.
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list