[racket] Turning car/cdr into multi-methods

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sun Oct 16 22:37:05 EDT 2011

Patrick Li wrote at 10/16/2011 09:15 PM:
> Does anyone have some tips for wrapping their heads around recursive 
> things like this?
> e.g. writing multi-methods using normal functions, and then somehow 
> turning everything into multi-methods?

I think that might be a simple module (or Racket #lang) problem: your 
module imports the ``primitive'' "car" and "cdr", and exports the 
multimethod replacements for the primitives, using the same names as the 
primitives.

>    OR writing an object system, where your classes are also objects, 
> etc...

When I was using Smalltalk or Self, I believe this was sometimes called 
``infinite meta-regress.''  I would use that term as a Google starting 
point.  I'd also read up on all the Gregor Kiczales et al. writings on 
CLOS, including the *Art of the Metaobject Protocol* book.

I'd also take another look at Eli Barzilay's Swindle package for Racket, 
which, IIRC, included a CLOS-like object system including multimethods.  
Although, you have the advantage of modern Racket, which Eli didn't have 
a bazillion years ago when Swindle was first written, so there might be 
some new fun opportunities.

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.