Hello,
I'm genuinely perplexed why the BKNR datastore throws an error when it tries to load a store that contains symbols that are not present in a given package. Why not just intern them?
Vladimir
On Wed, May 20, 2009 at 20:31, Vladimir Sedach vsedach@gmail.com wrote:
I'm genuinely perplexed why the BKNR datastore throws an error when it tries to load a store that contains symbols that are not present in a given package. Why not just intern them?
I have never seen this as a problem, and it would be easy to change. Maybe you can send me a patch that I could look at? I'd like to see interning on load be controlled by a special variable, *intern-symbols-on-load*.
-Hans
The patch is trivial, but I'd like to know the reason for the current behavior.
There's also something fishy about %decode-symbol's :intern keyword parameter. When it's not true, %decode-symbol returns nil. The only time this is possibly the case occurs in snapshot-read-layout:
(defun snapshot-read-layout (stream layouts) (let* ((id (%decode-integer stream)) (class-name (%decode-symbol stream :usage "class")) (nslots (%decode-integer stream)) (class (find-class-with-interactive-renaming class-name)) (slot-names (loop repeat nslots collect (%decode-symbol stream
:intern (not (null class))
:usage "slot"))) (slots (if class (find-class-slots-with-interactive-renaming class slot-names) slot-names))) (setf (gethash id layouts) (cons class slots))))
So if find-class-with-interactive-renaming doesn't find a class, all %decode-symbol does is read the stream and throw what it reads away? I don't get whether that's intended behavior or a bug.
Vladimir
On Wed, May 20, 2009 at 1:02 PM, Hans Hübner hans.huebner@gmail.com wrote:
On Wed, May 20, 2009 at 20:31, Vladimir Sedach vsedach@gmail.com wrote:
I'm genuinely perplexed why the BKNR datastore throws an error when it tries to load a store that contains symbols that are not present in a given package. Why not just intern them?
I have never seen this as a problem, and it would be easy to change. Maybe you can send me a patch that I could look at? I'd like to see interning on load be controlled by a special variable, *intern-symbols-on-load*.
-Hans
On Thu, May 21, 2009 at 20:18, Vladimir Sedach vsedach@gmail.com wrote:
The patch is trivial, but I'd like to know the reason for the current behavior.
The reason is that we want to be able to read snapshots with new software releases without neccessarily interning all symbols found in them.
There's also something fishy about %decode-symbol's :intern keyword parameter. When it's not true, %decode-symbol returns nil. The only time this is possibly the case occurs in snapshot-read-layout: [...] So if find-class-with-interactive-renaming doesn't find a class, all %decode-symbol does is read the stream and throw what it reads away? I don't get whether that's intended behavior or a bug.
That is indeed the intended behavior. If a snapshot references a class that does not exist in the running Lisp image and that is not interactively renamed, objects of that class should just be skipped. I have used that mechanism when upgrading software releases, finding it easier to hack the store so that old snapshots can be read rather than having to do in-image upgrades (load old software, load snapshot, load new software, dump).
-Hans
That makes sense. I don't think it's a good idea to include the automatic interning option in, since that will change the semantics of store loading, plus is probably an indication that the datastore user is probably making a design mistake in his/her application code (which, in hindsight, is what prompted my original query).
Thank you, Vladimir
On Thu, May 21, 2009 at 1:31 PM, Hans Hübner hans.huebner@gmail.com wrote:
On Thu, May 21, 2009 at 20:18, Vladimir Sedach vsedach@gmail.com wrote:
The patch is trivial, but I'd like to know the reason for the current behavior.
The reason is that we want to be able to read snapshots with new software releases without neccessarily interning all symbols found in them.
There's also something fishy about %decode-symbol's :intern keyword parameter. When it's not true, %decode-symbol returns nil. The only time this is possibly the case occurs in snapshot-read-layout: [...] So if find-class-with-interactive-renaming doesn't find a class, all %decode-symbol does is read the stream and throw what it reads away? I don't get whether that's intended behavior or a bug.
That is indeed the intended behavior. If a snapshot references a class that does not exist in the running Lisp image and that is not interactively renamed, objects of that class should just be skipped. I have used that mechanism when upgrading software releases, finding it easier to hack the store so that old snapshots can be read rather than having to do in-image upgrades (load old software, load snapshot, load new software, dump).
-Hans