Subject: Re: Simple Read File and Eval
From: (Rob Warnock)
Date: Wed, 29 Dec 2004 00:29:54 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Pascal Bourguignon  <> wrote:
| "ramza2" <> writes:
| > This may or may not be what I am looking for.  I want to load a file,
| > part of the file is lisp and the other part is something else.  Kind of
| > a like a config file or annotated file.  I could use the simple 'load'
| > if the file was all lisp, but I am going to read the lisp part of the
| > file and get the pure lisp syntax and I want to 'evaluate once I have
| > loaded it'
| ...
| You have basically two choices:
| - have lisp somewhat "interpret" the non-lisp part of the file using
|   reader-macros, then you can just (load "the-file")
| - implement your own parser reading the lines or characters of the
|   file, and filtering out the sexps that you will pass to eval.

Third choice: If the file is non-Lisp followed by pure Lisp, then you
can read the non-Lisp part with your own parser, then at a clean token
boundary call the normal Lisp LOAD with the already-open stream, e.g.:

	(with-open-file (stream "filename")
	  (loop for line = (read-line stream nil nil)
		while (and line (not (last-special-line-p line)))
	    do (process-special-line line)
	    finally (load stream)))

for the reader...]


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607