EVAL limitations
(let ((name (gensym)))
(eval `(defvar ,name "FOO"))
(symbol-value name))
errors, but
(let ((name 'foo))
(eval `(defvar ,name "FOO"))
(symbol-value name))
works.
The reason is dump-symbol creates a different symbol, if and only if the symbol is uninterned.
(eval some-atom) should also works for any atom, but in fact does not work for objects which literal/dump-* doesn't know how to dump.
I'm not sure the right way to fix this. I think maybe dump-* logic should have two mode -- in compilation mode it should dump everything and errors if it doesn't know how to dump; in eval mode it prefers just keeping a reference to the original object. But I'm not sure about the details yet.
I wonder if this was another bootstrap specific logic, and the logic could be in bootstrap vs non-bootstrap mode instead?
I wonder if this was another bootstrap specific logic, and the logic could be in bootstrap vs non-bootstrap mode instead?
I don't think this is (directly) related to bootstrap. The root cause is that we have a compiler only implementation, but eval suppose to support more code than what can be compiled into file (e.g. those that contain arbitrary literal objects). I'll take a look at how SBCL handles this!
SBCL does treat constant differently for in-process compile and file compile. I think it stores a constant vector for each component, which either store reference to the constant directly (for in-process), or filled by MAKE-LOAD-FORM (for file compile).