Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Examples from the book "Let Over Lambda" ported to Nu
Nu
branch: master
Failed to load latest commit information.
.gitignore
Nukefile
README
cl_utils.nu
let_over_lambda.nu
test_cl_utils.nu
test_let_over_lambda.nu
with_test.nu

README

INTRODUCTION

This is a Nu version of the code from Doug Hoyte's excellent book 
"Let Over Lambda".  The book is focused on harnessing the power of 
Lisp macros.  If you want to hone your macro-fu, this is a great
book to read.  The book uses and builds on many of the ideas in
Paul Graham's book "On Lisp", so it would be helpful to be familiar
with "On Lisp" first.

You can find more information about Doug Hoyte's book at 
http://letoverlambda.com.


I didn't try to port any of the Common Lisp reader macros, as Nu
doesn't currently have a reader macro facility.

Also, I didn't use Hoyte's defmacro! enhancement.  defmacro! adds two
main features to Common Lisp's defmacro:
1. Ability to use gensyms without first declaring them (g!xxx syntax).
2. Ability to declaratively enforce once-only evaluation of macro
   parameters (o!xxx syntax). 

Nu's macro facility already has feature 1.  And feature 2 is 
only a slight amount of syntactic sugar over a let form, so I 
just use the lets where needed.  I'm sure you get used to seeing
the o!xxx syntax, but I actually like seeing the evaluation steps
of the macro arguments.


HOW TO USE

There are 3 files of "pure code":

1. cl_utils.nu             - Common Lisp functions that aren't part of Nu.

2. with_test.nu            - Macros that wrap NuTestCase.  The benefit of
                             doing this is that you can set the variable
                             "show-verbose-output" to t in either
                             with_test.nu or in any of your test_xxx.nu 
                             files, and when you run the test cases, you'll
                             see the code and output of each assert_equals
                             statement.

3. let_over_lambda.nu      - Example functions and macros from the book.


There are 2 files that exercise the above code:

1. test_cl_utils.nu        - examples for the functions and macros in
                             cl_utils.nu.

2. test_let_over_lambda.nu - examples from the functions and macros
                             in let_over_lambda.nu.


You can run all of the test cases in both test_xxx files running "nuke"
("test" is the default target).  To make it interesting, set 
show-verbose-output to t in with_test.nu so you can see each line of 
code that's being tested along with the result.

The test code in the test_xxx.nu files are in the same order as the 
functions and macros in the respective xxx.nu files, so it's pretty 
easy to follow along.  I usually open up one of the test_xxx.nu files
in TextMate (with the Nu bundle installed) and Shift-Command-R to run
the unit tests.


SYSTEM REQUIREMENTS

This code requires Nu 0.4 or above.


AUTHOR

Doug Hoyte wrote the original Common Lisp code to accompany the book.
The code is available at the book's web site.

Jeff Buck ported the code to Nu, added some Common Lisp support functions
that are not already in Nu, and added some enhancements to the utilities.
Something went wrong with that request. Please try again.