29 November 2006

Focusing the Mind

At my place of work 2006 started with three Unix sysadmins. It appears it's going to end with one, namely me. Today was my third day solo.

A lack of options, the saying goes, focuses the mind admirably. In my situation, that means I've been scripting like mad to make sure I get information in a timely way and don't overlook anything. And the last few days I've been coming home and writing even more code, but of a more complicated nature. Normally this would make me cranky, to be doing work programming in the evening, but since this particular project is intended only for me, I get to choose my language. I've been reacquainting myself with Common Lisp. I had forgotten how fun programming could be —

;;; Insert timed data point, returning the previous value (useful for
;;; some statistical models).
(defmethod update ((dh ts-datahistory) val &key timestamp)
(let ((ts (if (null timestamp) (get-universal-time) timestamp)))
(multiple-value-bind (idx daytype) (bin-index dh ts)
(macrolet ((ref-and-set (accessor)
`(prog1
(,accessor dh idx)
(setf (,accessor dh idx) val))))
(if (eq daytype 'weekday)
(ref-and-set weekday-history-ref)
(ref-and-set weekend-history-ref))))))


I don't know how many of my readers will understand that, but it just fills me with joy to use such a tool. Lexically scoped macros!

Next up, quality time with North & Hillard's Greek Prose Composition...

No comments: