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
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
> 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
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
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/