From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.lisp.guile.devel Subject: The GC and Guardians Date: Tue, 8 Jul 2003 01:21:43 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <16138.135.876984.169207@localhost.localdomain> References: Reply-To: hanwen@cs.uu.nl NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1057620372 2488 80.91.224.249 (7 Jul 2003 23:26:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 7 Jul 2003 23:26:12 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jul 08 01:26:09 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19ZfN3-0000dh-00 for ; Tue, 08 Jul 2003 01:26:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19ZfNc-00053v-8I for guile-devel@m.gmane.org; Mon, 07 Jul 2003 19:26:44 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19ZfKJ-0003fu-6a for guile-devel@gnu.org; Mon, 07 Jul 2003 19:23:19 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19ZfJR-0003SD-TT for guile-devel@gnu.org; Mon, 07 Jul 2003 19:22:26 -0400 Original-Received: from smtpzilla5.xs4all.nl ([194.109.127.141]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19ZfIl-0003Pb-4Z for guile-devel@gnu.org; Mon, 07 Jul 2003 19:21:43 -0400 Original-Received: from localhost.localdomain.xs4all.nl (byrd.xs4all.nl [213.84.26.127]) by smtpzilla5.xs4all.nl (8.12.9/8.12.9) with ESMTP id h67NLfVx080250; Tue, 8 Jul 2003 01:21:42 +0200 (CEST) Original-To: Thamer Al-Harbash In-Reply-To: X-Mailer: VM 7.14 under Emacs 21.2.1 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2602 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2602 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