forcer <email@example.com> wrote:
| I'm implementing a load replacement that caches files. For this,
| i want to write a function which reads in a file, and makes it a
| function that, when called, duplicates the actions of loading the file.
| Does anyone have an idea on how to implement this in a better way?
What's wrong with this?
(define (my-load filename)
(do ((form (read) (read)))
(eval form (interaction-environment))))))
Then you can put your cache hooks in as you see fit. But... Be careful!
1. Scheme's top-level "define" doesn't have the same distinctions available
as Common Lisp's "defvar/defparameter" (see <URL:http://www.harlequin.com/
education/books/HyperSpec/Body/mac_defparametercm_defvar.html> for the
details). You're going to have to have some way of indicating which of
those behaviors you want (that is, leave the var alone if already bound,
or stomp it unconditionally, respectively).
2. Also, you'll need a way to "mark" a file as non-cacheable, say,
whenever a top-level form in that file involves non-idempotent
Rob Warnock, 8L-855 firstname.lastname@example.org
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. FAX: 650-933-0511
Mountain View, CA 94043 PP-ASEL-IA