Refactoring in Lisp is already built into the language via macros :) Consider this case: I was writing a compiler for a random language that had its own somewhat quirky view of datatypes and the operators defined over them, e.g. 1+2=3, [1]+2 = [3], [1]+[2]=[3]. When the types of operands were known, I wanted efficient machine code, and with unknown types, I wanted correct default behavior. I expected to have to refactor the code that expressed this several times (i.e. I had no idea what problems I would encounter.) Macros to the rescue:
(def-op op+ (a b) default-op+ ((double-float double-float ) (the double-float (+ a b))) ((array array ) (array-array+ a b)) ((hash-table hash-table ) (hash-hash+ a b)) ((hash-table double-float ) (hash-scalar+ a b)) ((simple-string simple-string ) (strcat a b)) ((structure-object structure-object) (structure-op+ a b)) ((array double-float ) (array-scalar+ a b))) I rewrote def-op many times, but rarely changed the code that used it. By making def-op a macro, I could define a syntax for expressing the bits of the problem I understood, and then refine the implementation as I saw more use-cases. Oh, the above code now expands into a couple of pages of Lisp -- a default function, piles of compiler hints, etc. -- Michael On Thu, 2004-04-29 at 19:34, Jim Prewett wrote: > > > Hi All, > > Does anyone have any pointers to decent eXtreme Programming tools for > LISP? (especially CMU friendly ones :) > > I'm just starting to learn about XP, and some of what they talk about is > definantly already built into the language (for an ancient, dead, > language, thats not bad ;) > > I'm primarily interested in anything that will help me do refactoring a > little better. > > Any pointers would be appreciated, > Jim > > -- > James E. Prewett "everything that is, that was, was not enough" > Systems Team Leader 505.277.8210 > Designated Security Officer [EMAIL PROTECTED] [EMAIL PROTECTED] > HPC Systems Engineer III @ [EMAIL PROTECTED] OpenPGP key: pub > 1024D/31816D93 > >
