I am curious as to why Chez Scheme does not treat numbers as symbols. Whether they are in a list or are quoted alone, number?
returns true, meaning that it was not made into a symbol. Is there a practical reason for this?
Chez Scheme Version 9.5.4
Copyright 1984-2020 Cisco Systems, Inc.
> (number? (car '(1 2 3 4 5)))
#t
> (symbol? (car '(1 2 3 4 5)))
#f
> (define symbolic-num '5)
> (number? symbolic-num)
#t
> (symbol? symbolic-num)
#f
>
This is not specific to Chez, but is standard behaviour; see e.g. R5RS:
So a numeric literal can't be a symbol, because it's not an identifier.
Now,
'e
is shorthand for(quote e)
, andThat is,
(quote 1)
-'1
- evaluates to1
, which is an integer, and(quote a)
-'a
- evaluates toa
, which is a symbol.This gets a bit confusing because REPLs print some things in the "shorthand-quoted" form, but that's just an output convention.
Note that
(display 'a)
will showa
, not'a
.