Sunday, May 7

Python style tuples in Lisp

It's easy to extend Lisp to handle python-style tuples. This is all it takes:


(defun |#{-reader| (stream char arg)
(declare (ignore char arg))
`(values ,@(read-delimited-list #\} stream t)))

(set-dispatch-macro-character #\# #\{ #'|#{-reader|)
(set-macro-character #\} (get-macro-character #\) nil))



It installs a despatching macro in the readtable - so that when the reader encounters the #{ sequence it reads it up to the } terminating character, then splices it into a (values ...) form.


You can do neat things like (setf #{x y z} #{ 1.2 3.0 3.0 }) to do tuple assignment with no further work - it all falls out of the standard behaviour of Common Lisp.


What I'm wondering, now is if it's possible to combine readtable hacks with regular expressions to implement a lexical parser for an entirely different language without leaving Lisp. I guess it is, but I haven't got a project with a use for it. Yet.

Monday, May 1

Ludum Dare

Things I learnt on the Ludum Dare.

  1. Even on a 48 hour schedule, after you have done 90% of your game, you still have the other 90% to do - gameplay tweaking.
  2. There are some things I need to learn more about - pixel art, and audio coding. My finished game had no audio.
  3. You can't mix 2D SDL content (menus) and 3D opengl content easily. Although the SDL does let you flip between the modes easily.
  4. Steel Bank Common Lisp is not ready for prime-time application delivery on Win32. Although it is very close.
  5. I can code about 2x as fast in Lisp with SLIME vs C++.
  6. I can still write games.