(defmacro lambda-rec (name args &body body)
"Just like lambda except BODY can make recursive calls to the
lambda by calling the function NAME."
(let ((fargs
(iterate:iterate (for el in args)
(unless (member el '(&key &optional &body &rest))
(collect (if (consp el) (car el) el))))))
`(lambda ,args
(labels ((,name ,args ,@body))
(,name ,@fargs)))))
(funcall (lambda-rec fib (n &optional (a 0) (b 1))
(if (= n 0)
a
(fib (1- n) b (+ a b)))) 4)
Can't you just return the labels function?
(defmacro lambda-rec (name args &body body)
`(labels ((,name ,args ,@body))
#',name))
wow - indeed that works. I just double checked and that's what PG's
does. I don't know where i was coming from...
(defmacro alambda (parms &body body)
`(labels ((self ,parms ,@body))
#'self))
I think the arnesi implementation
What to do in this particular case has already been posted, but in
any case the usual simple solution to the "keyword problem", using
the above example, is along the lines of
(defmacro named-lambda (name lambda-list &body body)
`(lambda (&rest args)
(labels ((,name ,lambda-list ,@body))
(apply #',name args))))
(modulo a gensym for ARGS, of course).
---Vassil.
--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"