On Mon, 27 Aug 2001 21:45:06 GMT, <······@spacy.Boston.MA.US> wrote:
>>>>>> On Mon, 27 Aug 2001 16:08:14 GMT, Mike Eggleston ("Mike") writes:
> Mike> I'm playing with lisp some and am trying to make a macro.
>
> Mike> What I want is to hand a symbol to a function and have
> Mike> that function print a readable form of the symbol out to
> Mike> stdout or a stream. I'm not looking for the open file
> Mike> symantics just yet, only the macro.
>
> Mike,
>
> You're trying to make this a lot more complicated than necessary.
> You don't need a macro do this. Symbols are an ordinary type of data,
> and Lisp functions can manipulate them as easily as any other thing.
> A symbol (like most anything else) can be output to a file with PRINT,
> and input with READ.
>
> Here is a function that does what you are asking. I have included
> the file stream protocol in it, because otherwise there would be
> nothing to the function -- all it does is call PRINT!
>
> (defun psexp (sym file)
> (with-open-file (o file :direction :output)
> (print sym o)))
>
> The corresponding input function simply needs to call READ.
> (In a real program, you might be concerned with controlling
> certain parameters of READ, but you can ignore all that for now.)
<snip>
> This doesn't make any sense, and looks like you are somewhat confused
> and mixed up about many basic elements of Lisp, including functions,
> symbols, variables, and quoting. Rather than trying to explain
> everything all at once, I'll let you consider what I've already
> written and ask more questions from that point.
>
> Chris
I tried with the (print), but am looking for something that can
receive a symbol and print the full (setq) line for that symbol
so that a (read) and (eval) reloads the symbol definition into core.
Mike
·····@kensho.eggtech.com (Mike Eggleston) wrote in message news:<····················@kensho.eggtech.com>...
> On Mon, 27 Aug 2001 21:45:06 GMT, <······@spacy.Boston.MA.US> wrote:
> >>>>>> On Mon, 27 Aug 2001 16:08:14 GMT, Mike Eggleston ("Mike") writes:
> > Mike> I'm playing with lisp some and am trying to make a macro.
> >
> > Mike> What I want is to hand a symbol to a function and have
> > Mike> that function print a readable form of the symbol out to
> > Mike> stdout or a stream. I'm not looking for the open file
> > Mike> symantics just yet, only the macro.
> >
> > Mike,
> >
> > You're trying to make this a lot more complicated than necessary.
> > You don't need a macro do this. Symbols are an ordinary type of data,
> > and Lisp functions can manipulate them as easily as any other thing.
> > A symbol (like most anything else) can be output to a file with PRINT,
> > and input with READ.
> >
> > Here is a function that does what you are asking. I have included
> > the file stream protocol in it, because otherwise there would be
> > nothing to the function -- all it does is call PRINT!
> >
> > (defun psexp (sym file)
> > (with-open-file (o file :direction :output)
> > (print sym o)))
> >
> > The corresponding input function simply needs to call READ.
> > (In a real program, you might be concerned with controlling
> > certain parameters of READ, but you can ignore all that for now.)
>
> <snip>
>
> > This doesn't make any sense, and looks like you are somewhat confused
> > and mixed up about many basic elements of Lisp, including functions,
> > symbols, variables, and quoting. Rather than trying to explain
> > everything all at once, I'll let you consider what I've already
> > written and ask more questions from that point.
> >
> > Chris
>
> I tried with the (print), but am looking for something that can
> receive a symbol and print the full (setq) line for that symbol
> so that a (read) and (eval) reloads the symbol definition into core.
>
> Mike
I think you want:
(defmacro psexp (variable)
`'(SETQ ,variable ',(eval variable)))
> I tried with the (print), but am looking for something that can
> receive a symbol and print the full (setq) line for that symbol
> so that a (read) and (eval) reloads the symbol definition into core.
>
> Mike
>
How about:
CL-USER 17 > (setf foo 27)
27
CL-USER 18 > (defun print-setf-form (symbol &optional (stream
*standard-output*))
(print `(setf ,symbol ,(symbol-value symbol)) stream))
PRINT-SETF-FORM
CL-USER 19 > (print-setf-form 'foo)
(SETF FOO 27)
(SETF FOO 27)
Coby
--
(remove #\space "coby . beck @ opentechgroup . com")