September 2011
3 posts
http://slime-tips.tumblr.com/ →
Sep 30th
Lazy slots
The slot-unbound generic function is useful for initializing slot values on demand. (defmethod slot-unbound (class (object my-object) (slot-name (eql 'my-lazy-slot))) (setf (slot-value object 'my-lazy-slot) (expensive-computation object))) This method computes the value and initializes the slot’s value. The return value of setf becomes the return value...
Sep 30th
1 note
Dynamic format control
Most format control directives can take parameters. These parameters are often embedded in the control string. For example, to print some text at column 16, you could do this: * (format t "~16THello, world")                 Hello, world What if you only know the parameter at runtime? You might be tempted to try something like this: * (format t (format nil "~~~DTHello, world" width)) ; BOGUS ...
Sep 29th