Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!ix.netcom.com!netcom.com!netcom10!gunter
From: gunter@netcom10.netcom.com (Mike Gunter)
Subject: Re: Avoiding garbage collection
In-Reply-To: bh@anarres.CS.Berkeley.EDU's message of 11 Feb 1996 17:36:12 GMT
Message-ID: <GUNTER.96Feb11140536@netcom10.netcom.com>
Sender: gunter@netcom10.netcom.com
Organization: NETCOM On-line services
References: <4fk7v8$1bfi@msunews.cl.msu.edu> <4fl9ec$jsc@agate.berkeley.edu>
Date: Sun, 11 Feb 1996 22:05:33 GMT
Lines: 42


In article <4fl9ec$jsc@agate.berkeley.edu> bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:

   bakicale@cps.msu.edu (Aleksandar Bakic) writes:
   >(define funct
   >  (lambda ()
   >    (define x (button ".a"))))
   >but I would like x to be a top-level variable [...]

   (define funct
	 (lambda ()
	   (eval '(define x (button ".a")))))

Which works but isn't R4RS Scheme.

But Aleksandar also writes:
   >I am having problems with widgets and anonymous procedures bound to
   >them in Guile/Tk. I think that SCM garbage collector deletes live
   >objects which represent Tcl commands. I have tried to bind these
   >objects "more strongly" (so that the GC can see that I need them), but
   >without success. My question is: is there a way in Scheme to locally
   >define top-level variables and assign locally generated objects to
   >them? I mean something like this:

Wouldn't something like the following work:

(define *save-from-gc-list* '())
(define (save-from-gc obj)
	(set! *save-from-gc-list* (cons obj *save-from-gc-list*)))

;; I'm not exactly sure what you want w.r.t. funct and x
(define funct
  (lambda ()
    (let ((x (button ".a")))
      (save-from-gc x)
      x)))

	hope that helps,
	mike gunter


	
