Subject: Re: Pass by value
From: (Rob Warnock)
Date: Tue, 10 Feb 2009 04:31:26 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Tobias C. Rittweiler <> wrote:
| Adam White <> 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].


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			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607