-
-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use compiler-native IDs instead of our id
/new-id
?
#2991
Comments
Sounds interesting to me. |
Very smart, I like it! :) |
Updated function for some more implementations I've tested: (defun id (object)
#+sbcl (sb-kernel::get-lisp-obj-address object)
#+ccl (ccl::%address-of object)
#+ecl (si:pointer object)
#+abcl (system::identity-hash-code object)
#+clisp (system::address-of object)
#+gcl (system:address object)
#-(or sbcl ccl ecl abcl clisp gcl) (sxhash object)) |
Nonguix has AllegroCL if you feel like testing it :) |
The license has expired and I've sent a patch to Nonguix to fix it :P |
Done! |
I don't see the benefit here. In fact if we serialize an object where we have the id in a slot, that id will be persisted. With this method, it would not, no? |
Yes, but we can compile the data into .FASL-s to preserve the object itself, for example. EDIT: we |
Our ID indexes objects we create, but indexing requires either:
id
slot to an object.Both are cumbersome. What if we had some Lisp-native way to generate object IDs without any work on our side? Like...
print-unreadable-object
's:identity
optionsxhash
!Most implementations use some kind of implementation-internal object ID fetching for unreadable objects, and most have Lisp APIs for getting this ID reliably. Here's what I've been able to hack up for SBCL, CCL, ECL, and ABCL:
For all the other implementations there's always
sxhash
which has nice properties (equal
objects have the samesxhash
), but IDs are even better and come from the reliable compiler internals and are guaranteed to never collide for different objects (which most hash functions occasionally do).So, shall we go down that road?
EDIT: Update for CLISP, GCL, and Allegro.
EDIT: Fix a typo.
The text was updated successfully, but these errors were encountered: