From: Christopher J. Vogt
Subject: Re: printing the name of a var. in a macro^
Date: 
Message-ID: <391FFB73.349D1A8@computer.org>
kp gores wrote:
> 
> hi,
> 
> i want a macro to set variables to values. it should print what it does,
> eg. (setv a 42) --> setting a
> 
> this does not work with the following code:
> 
> (defmacro setv (v value)
>    `(progn (format t "setting ~S~% to ~S" v ,value)
>             (setf ,v ,value)))

Try this:
(format t "setting ~S~% to ~S" ',v ,value)
                               ^^
-------------------------------||

> 
> how can i print the variables name?
> ciao
>   kp
> 
> --
> superegos talker

From: Barry Margolin
Subject: Re: printing the name of a var. in a macro^
Date: 
Message-ID: <awTT4.47$ej7.682@burlma1-snr2>
In article <···························@news.uni-ulm.de>,
kp gores  <·····@sip.medizin.uni-ulm.de> wrote:
>In article <················@computer.org>, ····@home.com wrote:
>
>> kp gores wrote:
>> > 
>> > hi,
>> > 
>> > i want a macro to set variables to values. it should print what it does,
>> > eg. (setv a 42) --> setting a
>> > 
>> > this does not work with the following code:
>> > 
>> > (defmacro setv (v value)
>> >    `(progn (format t "setting ~S~% to ~S" v ,value)
>> >             (setf ,v ,value)))
>> 
>> Try this:
>> (format t "setting ~S~% to ~S" ',v ,value)
>>                                ^^
>
>thank you. that easy.. :-)

Beware of what this will do if the VALUE form has side effects.  E.g. take
a look at (macroexpand '(setf a (incf b))).  Solving the problem is an
exercise for the reader.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Rob Warnock
Subject: Re: printing the name of a var. in a macro^
Date: 
Message-ID: <8fttif$bt2pv$1@fido.engr.sgi.com>
Barry Margolin  <······@genuity.net> wrote:
+---------------
| >> > (defmacro setv (v value)
| >> >    `(progn (format t "setting ~S~% to ~S" v ,value)
| >> >             (setf ,v ,value)))
| >> Try this:
| >> (format t "setting ~S~% to ~S" ',v ,value)
| >
| >thank you. that easy.. :-)
| 
| Beware of what this will do if the VALUE form has side effects.  E.g. take
| a look at (macroexpand '(setf a (incf b))).  Solving the problem is an
| exercise for the reader.
+---------------

Didn't you mean, "LET the reader beware"...?  ;-}  ;-}

(Sorry, couldn't resist.)


-Rob

-----
Rob Warnock, 41L-955		····@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043