Whilst going over let over lambda I happened across
(defmacro! dlambda (&rest ds)
`(lambda (&rest ,g!args)
(case (car ,g!args)
,@(mapcar
(lambda (d)
`(,(if (eq t (car d))
t
(list (car d)))
(apply (lambda ,@(cdr d))
,(if (eq t (car d))
g!args
`(cdr ,g!args)))))
ds))))
Which they subsequently invoke like so:
(setf (symbol-function 'count-test)
(let ((count 0))
(dlambda
(:inc () (incf count))
(:dec () (decf count)))))
Is there a construct like flet / labels / let that I can bind the resulting closure to, so as to avoid using funcall or the setf symbol-function in a global manner? So I can do something like:
(with-closures ((counter (let ((count 0))
(dlambda
(:inc () (incf count))
(:dec () (decf count))))))
(counter :incf))