help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plist-put changes literal argument


From: Philipp Stephani
Subject: Re: Plist-put changes literal argument
Date: Sat, 5 Sep 2020 17:53:52 +0200

Am Do., 3. Sept. 2020 um 01:59 Uhr schrieb Yuan Fu <casouri@gmail.com>:
>
>
>
> > On Sep 2, 2020, at 7:55 PM, Yuan Fu <casouri@gmail.com> wrote:
> >
> > I found plist-put changes the literal argument I pass to a function:
> >
> > (defun test ()
> >  (test-2 '(:a b)))
> >
> > (defun test-2 (form)
> >  (print form)
> >  (plist-put form :a 'c)
> >  nil)
> >
> > (progn (test) (test))
> >
> > (:a b)
> >
> > (:a c)
> > nil
> >
> > I thought Elisp is pass-by-copy? Is this expected?
> >
> > P.S., (setf (alist-get )) does the same, I guess this IS expected?
> >
> > Yuan
>
> I also tried setcar, same result. So Elisp doesn’t copy arguments?

Lists (actually all values except fixnums/small integers) are always
passed by reference; or, in other words, a list argument actually
contains a pointer to the list, not the list itself. Copying the
pointer doesn't copy the list.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]