Interpreting LISP: Programming and Data Structures
C**L
Have Fun
If you are running windows you can get Gary's Own Version Of Lisp compiled by changing just a few lines::I'm running Win7Using an editor that can handle LF text files, like Watcom, Ted or Cedt...Open Lisp.c and make these changes./* I added the following for the cmd shell in windows */# include "stdio.h"# include "stdlib.h"# include "math.h"# include "string.h"#include <setjmp.h>void longjmp( jmp_buf env, int return_value );/* Commented the following out *//*#if defined(__GNUC__)# include "linuxenv.h"#else# include "c:\csihead\turbcenv.h"#endif*/( the rest of the code goes here)I used the (free) Open Watcom IDE version 1.9Chose File/ New Project/ Gave it the name lisp.wpj/ Chose Target Environment Win32/ Chose Character-Mode-Executable/ Right Click in the Source File window/ Click New Source/ Then choose Lisp.c Had to click on the Make All widget/icon to compile and link it to make the executable.You'll need the lispinit file in the same directory or the lisp.exe will just wink and go away.It executes, it grabs the lispinit file and it dribbles into a file called lisp.logA cursory romp in the REPL was 'felicitous'.From the book..."The GOVOL dialect of LISP presented here is similar to the originalLISP 1.5 [MIT62]; it is not as complex as the most frequently used varieties of LISP found thesedays, but it contains all the essential features of these more complex varieties, so that what youlearn here will be immediately applicable for virtually every LISP dialect."So that means ... fun!You'll notice some things right away.The book explains Lisp, GOVOL and the code that makes the interpreter ( in three different ways (the book, the K code and the C code)(I have never heard of K code)UPDATE:I may have found a small syntax error in Lisp.cI'll try to give proof (in a non-mathematical sense (or is it?)) here by using S-Expressions that pattern match SORT and MERGE.(With the exception of GREATERP in the function DESCEND)(Please excuse the '_' s)(setqSORT_ASCEND (lambda (X) (cond ((eq X nil) X) (t (ASCEND (car X) (SORT_ASCEND (cdr X)))) ) ) )(setqSORT_DESCEND (lambda (X) (cond ((eq X nil) X) (t (DESCEND (car X) (SORT_DESCEND (cdr X)))) ) ) )(setqASCEND (lambda (Obj Lst) (cond ((or (null Lst) (lessp Obj (car Lst))) (cons Obj Lst)) (t (cons (car Lst) (ASCEND Obj (cdr Lst)))) ) ) )(setqDESCEND (lambda (Obj Lst) (cond ((or (null Lst) (greaterp Obj (car Lst))) (cons Obj Lst)) (t (cons (car Lst) (DESCEND Obj (cdr Lst)))) ) ) )Here is what I get in the REPL(sort_descend '(56 8 4 7 0 -99 0))(56 8 4 7 0 -99 0)Hmmm...Shot in the dark here but the Case statements in Lisp.c (around line 800 plus or minus) for GREATERP compared to LESSP has an extra semicolon ie ... Ntab[ptrv(E2)].num); <---- extra semicolonSo,,,/* Commented the following out */;(note: added a ; before GREATERP to massage the block comment) /* case 21: ; GREATERP if (Ntab[ptrv(E1)].num>Ntab[ptrv(E2)].num); v= tptr; break; */; added this case 21: /* GREATERP */ if (Ntab[ptrv(E1)].num>Ntab[ptrv(E2)].num) v= tptr; break;;;;;; Compile the codeExecute Lisp.exeIn the REPLLet's do it again.(sort_descend '(56 8 4 7 0 -99 0))(56 8 7 4 0 0 -99)Seems to work great now.Goes to show how powerful Lisp really is.
A**T
Caveat emptor
Buyer beware. I just received the book and haven’t read it yet. I’m giving it a “neutral” 3 based on a scathing (and seemingly well informed) review by “flaming_bird” on Reddit:Lisp, which I suggest an eventual buyer should look up. Basically, the book is apparently an unmodified, and unstated, reprint of a 1988 edition, long outdated and with no provision made for whatever happened in the Lisp world posterior to Lisp 1.5 (dead by 1970). A book, that is, with little more than historical interest and potentially misleading for anyone interested in the current state of Lisp. Make up you own mind. I’ll correct my review if I end up discovering it’s unfair.
P**R
A little dry but plenty of goodies.
Thorough and serious. How else are you going to teach Lisp?
Trustpilot
1 day ago
1 month ago