Tobias C. Rittweiler <tcr@freebits.de.invalid> wrote:
+---------------
| Adam White <spudboy@iinet.net.au> writes:
| > Bugger. So which types can I count on as being "copies" rather than a
| > copy of the "pointer" to the object itself?
|
| None. Arguments are never copied, they're passed by object identity.
+---------------
Yes, but... This is not necessarily true for characters and numbers.
As the CLHS says:
Function EQ
...
An implementation is permitted to make "copies" of characters
and numbers at any time. The effect is that Common Lisp makes
no guarantee that eq is true even when both its arguments are
"the same thing" if that thing is a character or number.
And conversely: copying of characters or numbers is permitted, but
not required.
But for all other types than characters and numbers, the object you
pass in a function call will be EQ to the object that the callee receives.
[Reminder: EQ *defines* "object identity".] So as Tobias said [with
a qualification added]:
Arguments are passed by object identity, they're never copied
[except possibly for characters and numbers].
-Rob
p.s. That said, I don't know of a modern CL implementation for which
the following will *ever* return NIL, regardless of input value [even
though it's permitted to return NIL for characters and numbers]:
(defun test (obj)
(eq obj obj))
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607