From: Sacha
Subject: more macro problems
Date: 
Message-ID: <DPqRf.314217$aj3.10115159@phobos.telenet-ops.be>
In a macro i have this loop which will collects a serie of "(defmethod 
forms"
So i end up with a list of theses :

((defmethod .....) (defmethod ....) (defmethod...))

What i really would like to get is :

(defmethod ...)
(defmethod ...)

I'm looking for the opposite of the "ensure-list" function.
I tried using "values-list" but this won't work it seems.

Any help would be greatly apreciated.

Sacha 

From: Tayssir John Gabbour
Subject: Re: more macro problems
Date: 
Message-ID: <1142307579.543750.182750@v46g2000cwv.googlegroups.com>
Sacha wrote:
> In a macro i have this loop which will collects a serie of "(defmethod
> forms"
> So i end up with a list of theses :
>
> ((defmethod .....) (defmethod ....) (defmethod...))
>
> What i really would like to get is :
>
> (defmethod ...)
> (defmethod ...)
>
> I'm looking for the opposite of the "ensure-list" function.
> I tried using "values-list" but this won't work it seems.

If I understand you correctly:

a) If you're using backquote syntax, use ,@ to splice the list of
defmethods into your code.

b) You could also use PROGN to execute those defmethods sequentially,
if that's your goal.

Tayssir
From: Sacha
Subject: Re: more macro problems
Date: 
Message-ID: <bYqRf.314229$%N3.10157085@phobos.telenet-ops.be>
> a) If you're using backquote syntax, use ,@ to splice the list of
> defmethods into your code.

Oh god, how did i forget about that....
Now THAT's being a newbie =P

Thanks a lot !

Sacha 
From: Ken Tilton
Subject: Re: more macro problems
Date: 
Message-ID: <a4uRf.2273$7o7.1453@fe09.lga>
Sacha wrote:
>>a) If you're using backquote syntax, use ,@ to splice the list of
>>defmethods into your code.
> 
> 
> Oh god, how did i forget about that....

Sounds like you already have a progn at the toplevel. Anyway, it is not 
an option, it is the only way to go:

(defmacro fs (n)
   (let ((x (loop for n below n
               collect `(defparameter ,(nth n '(aa bb cc dd ee)) ,n))))
     `(progn ,@x)))

(macroexpand-1 '(fs 3))
-> (PROGN (DEFPARAMETER AA 0) (DEFPARAMETER BB 1) (DEFPARAMETER CC 2))


-- 
Cells: http://common-lisp.net/project/cells/

"And I will know my song well before I start singing."  - Bob Dylan
From: Pascal Costanza
Subject: Re: more macro problems
Date: 
Message-ID: <47ndk3Fgf7elU2@individual.net>
Sacha wrote:
> In a macro i have this loop which will collects a serie of "(defmethod 
> forms"
> So i end up with a list of theses :
> 
> ((defmethod .....) (defmethod ....) (defmethod...))
> 
> What i really would like to get is :
> 
> (defmethod ...)
> (defmethod ...)
> 
> I'm looking for the opposite of the "ensure-list" function.
> I tried using "values-list" but this won't work it seems.
> 
> Any help would be greatly apreciated.

(progn
   (defmethod ...)
   (defmethod ...)
   (defmethod ...)
   ...)

BTW, progn makes the compiler treat its subforms as toplevel forms when 
it is in a toplevel position itself. In other words, the compiler will 
recognize that these methods are indeed unconditionally available.


Pascal

-- 
3rd European Lisp Workshop
July 3-4 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/