unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Han-Wen Nienhuys <hanwen@cs.uu.nl>
Cc: guile-devel@gnu.org
Subject: The GC and Guardians
Date: Tue, 8 Jul 2003 01:21:43 +0200	[thread overview]
Message-ID: <16138.135.876984.169207@localhost.localdomain> (raw)
In-Reply-To: <Pine.BSF.4.51.0307071717530.84296@helena.whitefang.com>

tmh@whitefang.com writes:
> int foo(...)
> {
>   SCM mysmob;
> 
>   mysmob = create_mysmob(...);
>   scm_define(scm_str2symbol(...), mysmob);
> 
>   return;
> }
> 
> My understanding is that since the SMOB bound to the top level
> environment, the garbage collector should not destroy it since
> its referenced by the top root. I do later undefine it when I no
> longer care about it.

Yup, this looks ok.

> Also, on an unrelated problem, I want to be able to create a C
> structure and have it reference non-immediate SCM data, but I
> cannot turn this C structure into a SMOB. Unfortunately the folks
> using my code may not be happy dealing with guile
> directly. Should I use a guardian on the SCM data like so?
> 
> foo_t *foo_create(void)
> {
>   foo_t *foo = create_foo();
>   SCM guardian;
> 
>   foo->mylist = SCM_EOL;
>   guardian = scm_make_guardian(...);
> 
>   scm_apply(....); /* protect foo->mylist with the guardian procedure */
> 
>   return foo;
> }

I don't know anything about guardians, but why don't you simply use
scm_gc_(un)protect_object()?

--
Han-Wen Nienhuys   |   hanwen@cs.uu.nl   |   http://www.xs4all.nl/~hanwen 


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2003-07-07 23:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-07 21:50 The GC and Guardians Thamer Al-Harbash
2003-07-07 23:21 ` Han-Wen Nienhuys [this message]
2003-07-08  0:03   ` Thamer Al-Harbash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16138.135.876984.169207@localhost.localdomain \
    --to=hanwen@cs.uu.nl \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).