questions: how to load a file "inlined" inside a let, and how to reference count objects
- From: Michael Kohout <mwkohout@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 23:54:27 -0800 (PST)
Hello folks, a relative noob with a couple of two questions for you.
Of late, I've been working my way through the Little Schemer, PG's
ANSI Lisp and On Lisp, and Siebel's book.
I understand lexical closures...but I'm having some trouble making
them suit my needs. Is there was any(standard) way to "inline" files
into them?
Here's my example.
In the repl, I've got this:
(let ((x 1)) (load "test-scope.lisp")
and in the file "test-scope.lisp", I've got a function that simply
returns a var named x:
(defun return-x () ( list x ))
after running the first line in the repl, I call the return-x method
but it errors, complaining x isn't bound.
Of course if I simply inline the code from the file into the repl it
works just fine:
CL-USER> (let ((x 1))(defun return-x () ( list x )))
RETURN-X
CL-USER> (return-x)
(1)
in summary, my question is if there is any standard macro or whatnot
that does this for me: inlining loaded files so the example closure
will work.
my second query is if there is any way to count references of a
variable, for the purposes of maintaining an object pool. After a
brief google search I didn't find anything.
thanks for your help
Mike Kohout
.
- Follow-Ups:
- Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- From: Pascal J. Bourguignon
- Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- From: Alex Mizrahi
- Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- From: Espen Vestre
- Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- Prev by Date: Re: Security
- Next by Date: Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- Previous by thread: Security
- Next by thread: Re: questions: how to load a file "inlined" inside a let, and how to reference count objects
- Index(es):