From: Rock
Subject: A defvars macro
Date: 
Message-ID: <d46f992a-c1d5-4d07-bde3-12ff140c9927@s9g2000prg.googlegroups.com>
I wrote a very simple little macro:

(defmacro defvars (names values)
  `(progn
     ,@(loop for name in names for value in values
          collect `(defvar ,name ,value))
     NIL))

that's supposed to allow me to do something like this:

(defvars (*a* *b*) ((sin 1) (complex 3 4)))

Does that look ok or can it be improved?

Thanks.

Rock

From: Tamas K Papp
Subject: Re: A defvars macro
Date: 
Message-ID: <6th3neFadcekU1@mid.individual.net>
On Sun, 18 Jan 2009 08:17:42 -0800, Rock wrote:

> I wrote a very simple little macro:
> 
> (defmacro defvars (names values)
>   `(progn
>      ,@(loop for name in names for value in values
>           collect `(defvar ,name ,value))
>      NIL))
> 
> that's supposed to allow me to do something like this:
> 
> (defvars (*a* *b*) ((sin 1) (complex 3 4)))
> 
> Does that look ok or can it be improved?

If it does what you want, than I guess it is OK.  I would make it
parse pairs though, eg

(defvars *a* (sin 1)
	 *b* (complex 3 4))

because if you have many arguments, it might be difficult to follow
what goes where with the original syntax (at least for me).  Cf the
syntax of setf.

Tamas
From: Rock
Subject: Re: A defvars macro
Date: 
Message-ID: <59816c7e-a4e8-4967-aaaa-dd4bec0faaec@r10g2000prf.googlegroups.com>
On Jan 18, 5:29 pm, Tamas K Papp <······@gmail.com> wrote:
> On Sun, 18 Jan 2009 08:17:42 -0800, Rock wrote:
> > I wrote a very simple little macro:
>
> > (defmacro defvars (names values)
> >   `(progn
> >      ,@(loop for name in names for value in values
> >           collect `(defvar ,name ,value))
> >      NIL))
>
> > that's supposed to allow me to do something like this:
>
> > (defvars (*a* *b*) ((sin 1) (complex 3 4)))
>
> > Does that look ok or can it be improved?
>
> If it does what you want, than I guess it is OK.  I would make it
> parse pairs though, eg
>
> (defvars *a* (sin 1)
>          *b* (complex 3 4))
>
> because if you have many arguments, it might be difficult to follow
> what goes where with the original syntax (at least for me).  Cf the
> syntax of setf.
>
> Tamas

Yes, that's an interesting possibility. Thank you.
From: Rob Warnock
Subject: Re: A defvars macro
Date: 
Message-ID: <JrqdnTC7WdwDfu7UnZ2dnUVZ_gOdnZ2d@speakeasy.net>
Tamas K Papp  <······@gmail.com> wrote:
+---------------
| Rock wrote:
| > I wrote a very simple little macro:
...
| > that's supposed to allow me to do something like this:
| > (defvars (*a* *b*) ((sin 1) (complex 3 4)))
...
| If it does what you want, than I guess it is OK.  I would make it
| parse pairs though, eg
| (defvars *a* (sin 1)
| 	   *b* (complex 3 4))
+---------------

Where are you going to put the documentation strings?
You'd need something like this to cover all the cases:

    (defvars (*x*)                ; No initial value.
	     (*a* (sin 1))        ; A value, but no doc string.
	     (*b* (complex 3 4))) "A point on the plane." ; Both.

And given that, I really don't see any advantage over the default:

    (defvar *x*)               ; No initial value.
    (defvar *a* (sin 1))       ; A value, but no doc string.
    (defvar *b* (complex 3 4)) "A point on the plane." ; Both.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607