* Copying one Lisp_Object to another in C code?
@ 2010-07-02 0:18 James Cloos
2010-07-02 1:33 ` Ken Raeburn
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: James Cloos @ 2010-07-02 0:18 UTC (permalink / raw)
To: emacs-devel
Given:
static void (foo)
Lisp_Object foo;
{
Lisp_Object bar;
/* etc */
is it OK to do:
bar = foo;
or is there a function or macro one should call?
I presume GCPRO1 (foo) is in order either way?
-JimC
--
James Cloos <cloos@jhcloos.com> OpenPGP: 1024D/ED7DAEA6
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Copying one Lisp_Object to another in C code?
2010-07-02 0:18 Copying one Lisp_Object to another in C code? James Cloos
@ 2010-07-02 1:33 ` Ken Raeburn
2010-07-02 1:42 ` Chong Yidong
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Ken Raeburn @ 2010-07-02 1:33 UTC (permalink / raw)
To: James Cloos; +Cc: emacs-devel
On Jul 1, 2010, at 20:18, James Cloos wrote:
> Given:
>
> static void (foo)
> Lisp_Object foo;
> {
> Lisp_Object bar;
> /* etc */
>
> is it OK to do:
>
> bar = foo;
>
> or is there a function or macro one should call?
Simple assignments are done all over the place currently. It would take some drastic reworking if some macro invocation were to become necessary.
> I presume GCPRO1 (foo) is in order either way?
Depending on the details of your usage, yes. (If the value is always stored in other places where the version of the GC system that doesn't scan the entire stack and register set automatically will be able to find it, at any of the points where the GC system can be invoked, then you don't need an explicit GCPRO. But then you have to understand where the old GC scanner will look, and when it can get invoked.) Just being conservative about it shouldn't hurt, either.
Ken
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Copying one Lisp_Object to another in C code?
2010-07-02 0:18 Copying one Lisp_Object to another in C code? James Cloos
2010-07-02 1:33 ` Ken Raeburn
@ 2010-07-02 1:42 ` Chong Yidong
2010-07-02 9:06 ` Andreas Schwab
2010-07-04 22:29 ` Stefan Monnier
3 siblings, 0 replies; 6+ messages in thread
From: Chong Yidong @ 2010-07-02 1:42 UTC (permalink / raw)
To: James Cloos; +Cc: emacs-devel
James Cloos <cloos@jhcloos.com> writes:
> Given:
>
> static void (foo)
> Lisp_Object foo;
> {
> Lisp_Object bar;
> /* etc */
>
> is it OK to do:
>
> bar = foo;
Yes.
> I presume GCPRO1 (foo) is in order either way?
Only if the code ends up calling eval, and for the benefit of the
platforms that don't use stack marking.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Copying one Lisp_Object to another in C code?
2010-07-02 0:18 Copying one Lisp_Object to another in C code? James Cloos
2010-07-02 1:33 ` Ken Raeburn
2010-07-02 1:42 ` Chong Yidong
@ 2010-07-02 9:06 ` Andreas Schwab
2010-07-02 15:37 ` James Cloos
2010-07-04 22:29 ` Stefan Monnier
3 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2010-07-02 9:06 UTC (permalink / raw)
To: James Cloos; +Cc: emacs-devel
James Cloos <cloos@jhcloos.com> writes:
> Given:
>
> static void (foo)
> Lisp_Object foo;
> {
> Lisp_Object bar;
> /* etc */
>
> is it OK to do:
>
> bar = foo;
>
> or is there a function or macro one should call?
Lisp_Object values are just references (except for Lisp_Int values),
so they can be freely copied around.
> I presume GCPRO1 (foo) is in order either way?
Only if you reference a Lisp object that is not already protected from
elsewhere. For example, all argument values of built-ins are implicitly
protected.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Copying one Lisp_Object to another in C code?
2010-07-02 0:18 Copying one Lisp_Object to another in C code? James Cloos
` (2 preceding siblings ...)
2010-07-02 9:06 ` Andreas Schwab
@ 2010-07-04 22:29 ` Stefan Monnier
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2010-07-04 22:29 UTC (permalink / raw)
To: James Cloos; +Cc: emacs-devel
> I presume GCPRO1 (foo) is in order either way?
You may either need GCPRO1(foo) or GCPRO1(bar) or GCPRO2(foo, bar), or
nothing at all. It all depends on what the rest of the code does.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-04 22:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02 0:18 Copying one Lisp_Object to another in C code? James Cloos
2010-07-02 1:33 ` Ken Raeburn
2010-07-02 1:42 ` Chong Yidong
2010-07-02 9:06 ` Andreas Schwab
2010-07-02 15:37 ` James Cloos
2010-07-04 22:29 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.