I personally changed some code to start using $#'if-let, $#'when-let, $#'curry, $#'rcurry of Alexandria instead of my own. (Actually i think i sometimes even found CL functions/macros to suit the utility i originally met with my own macro/function.
Some macros i still use have my own variant for:
setf- change a setf-able by a function; (defmacro setf- (change-function to-set &rest args) `(setf ,to-set (,change-function ,@args))), for instance (setf- max var ...) does the same as (alexandria:maxf var ...) (it is just more general) Of course i usually don't use setting anything, usually end up using it if i am writing a simulation.
with-mod-slots allows you do do two things 1) treat slots as interned into the current package, and 2) have the slots of two objects with same-named slots accessible directly without writing a $#'symbol-macrolet yourself. I also encounter this usually in simulations.
Code: Select all
(defmacro with-mod-slots (mod (&rest slots) object &body body)
(with-gensyms (obj)
`(let ((,obj ,object))
(symbol-macrolet
(,@(mapcar (lambda (slot)
`(,(intern (format nil "~D~D" mod slot))
(slot-value ,obj ',slot)))
slots))
,@body))))
And, as i whined before, denest, but not very often at all. I use a more complicated version than the below.(too complicated infact, and i don't make use of it, but i can just cut it out)
Code: Select all
(defmacro denest (&rest forms)
(if (null (cdr forms))
(car forms)
`(,@(car forms) (denest ,@(cdr forms)))))
More minorly, constant Just a function of the constant given with an ignored (&rest rest) argument, sqr, and i have some more in the file that i either end up not using much(case-let, mk for make-instance), or i should phase out using. Also got vector stuff i use. (Not this just use lisps vectors and pray that optimizes now.. (The suggested packages there seem to involved there, i just wanted basic vectors, and maybe matrices.)
So what little functions/macros do you use? And which libraries or do you keep them yourself? Have any libraries to suggest to others?