Older blog entries for bmastenbrook (starting at number 3)

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)
                 (do/while
                  ((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.

Mergearrific!

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!