Re: questions: how to load a file "inlined" inside a let, and how to reference count objects



MK> in summary, my question is if there is any standard macro or whatnot
MK> that does this for me: inlining loaded files so the example closure
MK> will work.

no, there is no standard macro for this, and that's for reason -- this
construct is weird and will be hard to maintain.

but if you really want it..

(defmacro form-from-file (filename)
(with-open-file (s filename) (read s)))

this reads only one form, if you want many, add a loop and wrap stuff into
progn.

MK> my second query is if there is any way to count references of a
MK> variable, for the purposes of maintaining an object pool.
MK> After a brief google search I didn't find anything.

most implementations use garbage collector that doesn't use "variable
reference counting" (whatever it is), and it would be too much hassle to
maintain this information just for you.
however, there is stuff called finalizers, so you have a chance to do
something when object is garbage-collected, probably you can do something
with it..
but it's implementation-dependent, consult documentation of your
implementation.

and it's not a widespread practice to do so, so probably you don't need
this. do you have profiling results that say that object creation/garbage
collection is inefficient and you need to maintain pool yourself?


.