Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.lisp Subject: Re: Calling C functions from Franz Lisp Message-ID: <12417@mimsy.UUCP> Date: 12 Jul 88 14:52:00 GMT References: <12196@sunybcs.UUCP> <484@aiva.ed.ac.uk> <12363@mimsy.UUCP> <433@laura.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 61 In article <433@laura.UUCP> markhof@exunido.uucp (Ingolf Markhof) writes: > There is is passage in the paper "The Franz Lisp - C Interface", written >by Fred P. Andresen, ... (I think it is `Anderson'---he was `fpa@cvl' but is not there anymore. Ah well.) >"7.1 When creating a list in C (...) don't leave any stray lispobjs >lying around which have no other lispobjs pointing to them (C pointers >don't count)." > > But what is exactly the meaning of "C Pointers don't count"? That means that code like this is wrong: Lfoo() { register lispval node; chkarg(0, "foo"); node = newdot(); node->d.car = inewint(1); node->d.cdr = matom("bar"); return (node); } Instead, you must write Lfoo() { register lispval node; chkarg(0, "foo"); node = newdot(); protect(node); /* important! */ node->d.car = inewint(1); node->d.cdr = matom("bar"); return (node); } On the other hand, Lbaz() { lispval l; chkarg(1, "baz"); l = lbot[0].val; if (TYPE(l) != DTPR) ncerror("baz() needs a dotted pair"); /* like rplacd */ l->d.cdr = newdot(); l->d.cdr->d.car = inewint(1); l->d.cdr->d.cdr = matom("bar"); } *is* correct, because there is a pointer to the new dot somewhere in the lisp system (namely lbot[0].val->d.cdr). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris