[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Macro to define several items - how to

Helmut Jarausch

4/12/2015 11:33:00 AM

Sorry for this simple question.

I'd like to write a macro which generates a bunch of (related) items like

(def-my-class ABC ...)

would generate

(defclass ABC ...)

(defgeneric ABC-get ....)
(defmethod ABC-get ...)

and so on.

AFAIK, the (single) value returned by a macro invocation is processed further.
I do need to process several values.
I tried VALUES but it takes only the first one.

Many thanks for a hint,
Helmut
2 Answers

Pascal J. Bourguignon

4/12/2015 11:41:00 AM

0

jarausch@skynet.be writes:

> Sorry for this simple question.
>
> I'd like to write a macro which generates a bunch of (related) items like
>
> (def-my-class ABC ...)
>
> would generate
>
> (defclass ABC ...)
>
> (defgeneric ABC-get ....)
> (defmethod ABC-get ...)
>
> and so on.
>
> AFAIK, the (single) value returned by a macro invocation is processed further.
> I do need to process several values.
> I tried VALUES but it takes only the first one.

Use PROGN.

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Marco Antoniotti

4/13/2015 12:25:00 PM

0

On Sunday, April 12, 2015 at 1:33:19 PM UTC+2, jara...@skynet.be wrote:
> Sorry for this simple question.
>
> I'd like to write a macro which generates a bunch of (related) items like
>
> (def-my-class ABC ...)
>
> would generate
>
> (defclass ABC ...)
>
> (defgeneric ABC-get ....)
> (defmethod ABC-get ...)
>
> and so on.
>
> AFAIK, the (single) value returned by a macro invocation is processed further.
> I do need to process several values.
> I tried VALUES but it takes only the first one.
>
> Many thanks for a hint,
> Helmut

This is a worthwhile learning project provided that you realize that you really want (if your example above is an indication of your intent) is:

(def-my-class ABC () slot1 slot2 ... slotN)

==>

(defclass ABC ()
((slot1 :accessor ABC-slot1)
(slot2 :accessor ABC-slot2)
...
(slotN :accessor ABC-slotN))
)

Cheers
--
MA