Older blog entries for bmastenbrook (starting at number 4)

As a quick follow up to my post of yesterday, I've updated my common-idioms package to contain 100% MORE EVIL. Included are two symbol property-list abusing macros, one of which depends on order of expansion and is thus technically not ANSI.

The first of these macros is symbolic IF, which works as follows:

(let ((x (list 1 2 3)))
  (sif (cdr x)
       (sif (car it)
            (setf it 'foo))) x) => (1 foo 3)

The second is let-env, which is the unportable one I mentioned:

(let ((x 1)
      (y 2))
  (let-env env
            (let ((x 3)
                  (y 4))
              (setf x 5)
              (env (x)
                   (setf x 6)
                   (setf y 7))
              (list x y)) (list x y)))) => (5 7 6 2)
Also, the completely unportable but highly useful EXPAND-ONLY has been extended to allow expanding of all macros (pass T for the name list) and to return a second value containing an alist of (form expansion) pairs for forms that couldn't be found in the current expansion (happens often with SETF).

If you're interested, head over to CLiki and check it out.

So, I've decided to embarrass myself and release my s-expression to C translator. The goal here is to come up with a suitable target representation for a compiler, without having to worry about actual C syntax in the compiler itself. Since it supports macros, you can build the target language a bit higher too. As an example, consider Duff's Device - it can be expressed for a fixed amount of unrolling in plain C, but you can't vary that except with possibly some horrendously complex C++ templates. The macro to generate Duff's Device reads as follows:

#@(defmacro #@make-duff #@(to from count n-type size)
    `#@(let ((,n-type n (/ (+ ,count ,#@(- #@size 1)) ,size)))
         (switch (mod ,count ,size)
                 (case 0)
                  ((setq (deref ,to) (deref (post-incf ,from)))
                   ,@#@(loop for i from (- #@size 1) downto 1
                          append `#@((case ,#@i)
                                     (setq (deref ,to) (deref (post-incf ,from))))))
                  (> (decf n) 0)))))
The #@'s there are to bounce back and forth between readtables - the s-expression C needs to be read into a table which preserves case and also preserves backslashes in strings, so #@ is defined to take you between that table and an ordinary one.

There is documentation up as well, and a developer mailing list. It's not complete yet at all, but already it's useful to me. Ideas, suggestions, and complaints about opening up lisp macros to C are welcome :-)

Also, I should mention my common-idioms package here - I see a lot of similar macros out there, and I recently noted that Pascal Costanza reinvented the destructuring-case macro. Mine has a few more features, so if you're doing some heavy destructuring you might want to take a look at it.

The rest of the package is worthwhile to me too - it contains an anaphoric if with a setf-it macro, an anaphoric if that tests on the second return value and binds "it" to the first (very useful!), multiple-value aggregating reduce (my favorite iteration construct of all time), and some other useful tools.


SBCL 0.8.8 has been released, and contains the OS X patch I previously maintained in the main distribution. No more patching! Big big thank you to Brian Downing for cleaning up the build process in the patch so it was cleanly buildable; I clearly lack any sort of abilities with make. Oh well. Big thank you also to Pierre Mai for finding the source of the RUN-PROGRAM bugs and to Christophe Rhodes for fixing the SIGTRAP handler to reflect this. Owners of single-processor machines rejoice in their SBCL buildability.

Hopefully binaries should be available shortly for a broad variety of platforms and uploaded in the UK morning. OS X binaries are prepared, and binaries for many of our other architectures that haven't seen binaries in a little while are also being built.

One thing that has come to my attention is that setting LD_PREBIND to YES on OS X interferes with SBCL buildability. You will have to unset this before building SBCL.

SBCL's 0.8.8 freeze is fast approaching, and Christophe Rhodes thinks he's got the SIGTRAP handler problem fixed (which manifests itself in hagning when using RUN-PROGRAM). I have put up a binary that has this fix in it; it would be lovely if people tested this and reported back whether it works or not. In particular we have had intermittent "illegal instruction" (SIGILL) problems and I would like to know if anyone can reproduce this on this binary - I can't.

On a side note, Clotho 0.2 is out. If you are interested in shaping what a native OS X Lisp IDE looks like, please join the project and produce MORE CODE!

29 Jan 2004 (updated 29 Jan 2004 at 22:57 UTC) »

Hey, cool! I have a diary!

Anyone who is interested in working on native OS X IDEs for Lisp, please visit the mac-lisp-ide list. To quote from that page:

The purpose of the mac-lisp-ide list is to encourage discussion about what a true, native Mac OS X ide for Common Lisp development would look and feel like, and to encourage the coding of such an IDE. Native here is defined as Cocoa, Carbon, or OpenGL, but not X11, terminal, or GNU Emacs/XEmacs-based. Topics of discussion should include but not be limited to:

  • Built in Emacs-like editor, based on CL
  • Socket connection to other Lisps, perhaps non-Common Lisps (Scheme)
  • Debugging and backtracing
  • Presentation-based GUIs using Cocoa
  • Object clipboard and REPL history
  • Integrated documentation
  • Threading

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!