From: Nyang A. Phra
Subject: Loading without evaluating?
Date: 
Message-ID: <f041311a-72a0-4b1d-a75e-2bfabc0a54d5@e23g2000prf.googlegroups.com>
Pardon my newbieness, but is there a way to load expressions from a
file without evaluating them? IIUC, load sequentially evaluates
everything it loads; what I'd need is a "load-quoted" function.

Or alternatively, is there a more intelligent way to manipulate a
program contained in a source file, and then write the new program
back to a file?

I know this may sound like I'm in this a bit over my head, which
probably is the case, but thank you for your patience :)

From: Pascal J. Bourguignon
Subject: Re: Loading without evaluating?
Date: 
Message-ID: <7cwspz9p6o.fsf@pbourguignon.anevia.com>
"Nyang A. Phra" <······@gmail.com> writes:

> Pardon my newbieness, but is there a way to load expressions from a
> file without evaluating them? IIUC, load sequentially evaluates
> everything it loads; what I'd need is a "load-quoted" function.


So you don't want to load, you want to READ.

  (with-open-file (stream "/some/file") (read stream))


If you want to read several forms:

  (with-open-file (stream "/some/file") 
     (loop :for form = (read stream nil stream)
           :until (eq form stream)
           :collect form))

You may also want to bind *read-eval* to nil to prevent #. evaluation.


> Or alternatively, is there a more intelligent way to manipulate a
> program contained in a source file, and then write the new program
> back to a file?

http://darcs.informatimago.com/lisp/common-lisp/source-text.lisp
http://www.informatimago.com/develop/lisp/index.html

Or you can also process sources from emacs, have a look at map-sexps
et al. in:
http://darcs.informatimago.com/emacs/pjb-sources.el



-- 
__Pascal Bourguignon__
From: Rainer Joswig
Subject: Re: Loading without evaluating?
Date: 
Message-ID: <joswig-A45916.17173724012008@news-europe.giganews.com>
In article 
<····································@e23g2000prf.googlegroups.com>,
 "Nyang A. Phra" <······@gmail.com> wrote:

> Pardon my newbieness, but is there a way to load expressions from a
> file without evaluating them? IIUC, load sequentially evaluates
> everything it loads; what I'd need is a "load-quoted" function.
> 
> Or alternatively, is there a more intelligent way to manipulate a
> program contained in a source file, and then write the new program
> back to a file?

You could just use READ.

(defun read-all-forms-from-stream (stream)
  (loop with eof = '#:eof
        for form = (read stream nil eof)
        until (eq form eof)
        collect form))

(defun read-all-forms (file)
  (with-open-file (stream file)
     (read-all-forms-from-stream stream)))


> 
> I know this may sound like I'm in this a bit over my head, which
> probably is the case, but thank you for your patience :)
From: Alex Mizrahi
Subject: Re: Loading without evaluating?
Date: 
Message-ID: <4798bb07$0$90273$14726298@news.sunsite.dk>
 NAP> Or alternatively, is there a more intelligent way to manipulate a
 NAP> program contained in a source file, and then write the new program
 NAP> back to a file?

do you want to preserve original formatting and comments?
if you don't, simple READ would do that 
From: Nyang A. Phra
Subject: Re: Loading without evaluating?
Date: 
Message-ID: <36298780-1a99-4d37-abd7-cac3a910446a@m34g2000hsb.googlegroups.com>
> do you want to preserve original formatting and comments?
> if you don't, simple READ would do that

No, no need to preserve formatting. So READ it is, thanks, everyone.