LISP In Small Pieces - best LISP environment to run code in?
Asked Answered
T

5

14

Christian Queinnec has written a masterpiece called LISP In Small Pieces, which features eleven Lisp Interpreters and two Lisp compilers.

When you go to download the code from the website here - it has the comment:

The programs of this book are available on the net. 
These programs used to run with some Scheme systems around 1994.

Any idea:

(a) What Scheme systems these ran on at the time, and more importantly;

(b) What Scheme systems these would run on today?

Trocki answered 28/4, 2012 at 9:46 Comment(10)
Why don't you just install racket and attempt to run a few of the programs?Cabriolet
I use guile en.wikipedia.org/wiki/GNU_Guile or Kawa en.wikipedia.org/wiki/Kawa_(Scheme_implementation)Northern
@Northern So the programs in this book worked for you?Trocki
@Trocki no I just what to say that as scheme implementation in my daily usage I use those implementations. One note: if the code that you try to run have brackets instead of parent in some places like in let then it will work only on drScheme or racket, and drScheme is not real scheme because real scheme don't use brackets.Northern
@Northern That's a little harsh. My opinions on square brackets notwithstanding, it's part of R6RS and has been with a number of major implementations (like Chez and Racket) for a long time. You can't say they aren't real Scheme implementations.Suzetta
It desn't work on guile or kawa and Raket is different language (wikipedia says that it's Influenced by Scheme and Eiffel), it's not scheme. and braket look more like clojure to me then scheme or lisp that should be create from S-Expressions but that's only my opinion. I only wanted to say that when I was learning scheme I read one book where the only implementation that I can run those examples was drScheme, So I find another book,Northern
Actually, Guile has accepted square brackets by default for over two years.Teddytedeschi
@Northern Chicken also optionally accepts square brackets.. I'm not personally fond of that style, but at this point it really does just seem to be preference.Gregoriogregorius
@AsumuTakikawa To which version it belong to, I use guile 1.8.7 and this (let ([x 10]) (* x x)) throw Bad binding [x in expression (let ([x 10]) (* x x)). ABORT: (syntax-error) the same if I call [* 10 20] it throw Unbound variable: [* display 10 and then throw Unbound variable: 20]Northern
@Northern Judging from the release dates, I think Guile 1.8.8 started accepting square brackets.Teddytedeschi
R
8

There's a lot of programs in there. I did a few tests to see how well I could answer this without having to try them individually. There are 131 files in the tarball with extension ".scm". However there appear to be Scheme programs with other extensions such as .bgl. So I did a search for files containing 'L i S P' in the first five lines. That yields 173 files. I tried running all of these on my preferred Scheme implementation. 31 of these run without error. Almost all of these are in the "src" directory. So the language-specific programs really do seem language-specific. Let's look at one of the src/ files that failed, "chap9z.scm". It's choking on define-abbreviation. I don't know the origin of this symbol, but it's not defined anywhere in guile. But all of its uses could be performed by guile's syntax-rules.

Rampart answered 1/5, 2012 at 22:44 Comment(4)
I bet that define-abbreviation is defined as a macro somewhere else in the source.Crapulous
I looked but haven't found it. I need an sexp - based (rather than line-based) grep!Rampart
@gcbeison, it seems to be defined in the platform-specific portions. For example, see elk/book.elk, where it's defined via a call to expand-syntax.Crapulous
That's awesome - you've made a really big effort to answer the question.Trocki
C
6

Some Scheme implementations that existed in 1994 still are still around and maintained: Scheme 48, Chez Scheme, Gambit, Bigloo, MIT Scheme and SCM.

Probably the code from LiSP will run in other modern Scheme systems such as Guile or Larceny.

Personally, I would recommend using Racket. Most likely, much of the code will run in #lang racket with no changes, and there's no requirement to use [] (but your code may be easier to read :). Things that don't work are probably easy to fix, and you can also use the R5RS language implementation provided by Racket which will likely work for all of the code.

Crapulous answered 30/4, 2012 at 15:9 Comment(2)
The code (at least from ch. 1) doesn't run 'as-is' in #lang racket due to con cells not being mutable.Balbinder
You can probably run it in the r5rs mode (either select that language in DrRacket, use the plt-r5rs executable, or add #lang r5rs` at the top of the file).Crapulous
M
5

(a) What Scheme systems these ran on at the time

The Makefile in the source tarball from the author's website has targets for running the code under bigloo, elk, gambit, mit-scheme, scheme2c, and scm.

The Makefile mentions SCM 4e1 and Bigloo 1.9d as known working versions, though I haven't tested them myself. I didn't find any mention of specific versions for the other schemes.

(b) What Scheme systems these would run on today?

The code in this github repo has been updated so that almost all of the tests in the included test suite pass with current (as of 06/2014) versions of bigloo, gambit, and mit-scheme.

If you just want to be able to run the code and follow along with the book, one of those schemes should work for you.

[full disclosure: I'm the owner of the repo and I'm a Scheme noob. The code in the repo is WOMM certified, but your mileage may vary.]

If, on the other hand, you're not content to use bigloo / gambit / mit-scheme, it shouldn't be too hard to add support for guile / racket / insert-favorite-scheme-here. Use one of the book.* files as a starting point, e.g. gambit/book.scm or mitscheme/book.mit. If you can get a version of book.scm to load in your favorite scheme, then have a look at the test.interpreters make target, and finally the grand.test target to verify things are working as expected.

Millwright answered 28/4, 2012 at 9:47 Comment(0)
S
2

The included README file states:

These files were tested with a Scheme interpreter augmented with a test-suite driver (tester.scm), the define-syntax and define-abbreviation macros (using Dybvig's syntax-case package), and an object system: Meroonet (meroonet.scm).

Bigloo, Scheme->C, Gambit, Elk or SCM can be used. The first three are better since a specialized interpreter may be built that contains a compiled Meroonet and compiled hygienic macros.

Sulemasulf answered 2/5, 2012 at 8:27 Comment(0)
B
0

Apparently Appleby has posted an updated version of the source code. Racket is missing though )=

See https://github.com/appleby/Lisp-In-Small-Pieces

Balbinder answered 4/7, 2014 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.