Pascal Bourguignon <spam@mouse-potato.com> wrote:
+---------------
| "ramza2" <berlin.brown@gmail.com> 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)))
[LAST-SPECIAL-LINE-P & PROCESS-SPECIAL-LINE are left as exercises
for the reader...]
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607