Oleg Semenovsky
Oleg Semenovsky

Reputation: 61

Is there any way to get a variable address in Common Lisp?

I'm trying to implement XOR-linked lists on Common Lisp, but i need to get an address of a variable to perform any bitwise operations on it. Is there any way to get memory address of a variable, similar to python's id() function?

Upvotes: 5

Views: 701

Answers (2)

SpyroSoft
SpyroSoft

Reputation: 243

If you're using Allegro Common Lisp, maybe this is what you're looking for: Escape from the Heap: Low-Level Programming in Common Lisp

Upvotes: 0

Renzo
Renzo

Reputation: 27444

Usually, memory management in Common Lisp is performed by some kind of Garbage Collector. Many of these algorithms move the objects in memory during a collection cycle.

So the consequencies are that you cannot count on a fixed address for each object, and for this reason no operation in the standard is provided to get the address of a Common Lisp object.

Upvotes: 7

Related Questions