In the mit-scheme
REPL if I evaluate
(list 1 2 3)
I get this the first time
;Value 13: (1 2 3)
then this the second time
;Value 14: (1 2 3)
and this the third time
;Value 15: (1 2 3)
Every time the value increments by one.
In other scheme REPLs I've noticed the ;Value xx
part isn't displayed at all.
What does the value mean? I'm guessing it's the memory address of the list? If so, why does it always start at 13 and why only show the address for lists?
A quick search of the manual didn't help me.
I'm running mit-scheme
version 9.1.1
What does the value mean?
The number displayed is the hash of the list.
1 ]=> (define my-list '(1 2 3))
;Value: my-list
1 ]=> my-list
;Value 13: (1 2 3)
1 ]=> (hash-object my-list)
;Value: 13
(For MIT Scheme before version 10, use hash
instead of hash-object
).
For details on hashing, see section about Object Hashing of the MIT/GNU Scheme reference.
why [does it] only show the address for lists?
It's the way the authors of MIT Scheme chose to write the REPL. Lines 491-500 of src/runtime/rep.scm
from the MIT Scheme 9.1.1 source code deal with printing REPL results:
(define (default/repl-write object s-expression environment repl)
(port/write-result (cmdl/port repl)
s-expression
object
(and repl:write-result-hash-numbers?
(object-pointer? object)
(not (interned-symbol? object))
(not (number? object))
(object-hash object))
environment))
As you can see, the object hash is displayed in the REPL only if the object is a pointer (which is an implementation detail), is not an interned symbol, and is not a number.