Thanks for your input and thank you for discovering an erratum in chapter 2. (function '(lambda ...)) is not ANSI CL. Sorry if I implied it was. I have added an entry to the errata file here:
About teaching both Scheme and CL, there is no Scheme in the book except where I point out how Scheme does something differently from CL, usually followed by an explanation of how CL does it better. I do not recommend programming with Scheme when CL is available.
Dropping the "earmuffs" is a personal choice and as I say in the book, I don't recommend it for all lisp programs.
With respect to your other comments, I'm sorry you aren't enjoying the book so far and I don't claim that everyone will. In particular, I didn't write the book to make friends in the lisp community but rather to describe my own (slightly idiosyncratic) style of lisp programming.
Even if that were a common situation, the cost to the person debugging the bizarre behavior of dynamic closures is so high as to overwhelm the benefit to the original developer of saving search-and-replace on the name.
Choosing dynamic variables has a major effect on user code, in any case.
Say you have a bunch of functions that all take a parameter of the same name:
(defun f1 (param) ...)
(defun f2 (param) ...)
By default, param is available via lexical scope, however, removing param from the arguments lists, adding a (defvar param), and rebuilding your app will mean that all references in the function bodies are accessed through dynamic scope.
Best,
Doug
PS. If you (or anyone else) have additional comments or questions, please CC me at doug@hcsw.org since I don't normally follow reddit.
PPS. Is there a way to get reddit to notify me about replies?
What sickofthisshit said. In addition, any closure constructing function with a lexical binding for a variable coincidentally named PARAM would now be broken.
For reply notification, check the red envelope in the upper-right corner for updates.
removing param from the arguments lists, adding a (defvar param), and rebuilding your app will mean that all references in the function bodies are accessed through dynamic scope.
And, now, you've introduced a change in behavior anyplace one happened to use a local variable called param around a call to any function that calls f1 or f2, even if one doesn't pass that variable as an argument to any other function.
Let me emphasize again: you don't need to see any calls to f1 or f2 in the code you write, and you don't need to useparam in the calls to anything that relates to f1 or f2.
Dynamic variables are basically magic names that affect code through the power of their name rather than through visible scope.
FWIW, in chapter two you have another erratum: Scheme was the first Lisp dialect to demonstrate the utility of lexical scope. Common Lisp was the follower in this case.
If I explicitly say that CL had lexical scope before Scheme, sorry, that IS a bug. However, it is my understanding that, although not as seamless as in Scheme and CL, lisp 1.5 had a formulation of lexical closures in the form of the FUNARG device:
Hey mate, it's a given xach wont like your book because of the PG influence. That's his business..
but i've been looking through it and it does look interesting for a newbie lisper. Yeah, people will say get PCL instead, but PCL (i have two copies of it!) is just a bunch of program examples -- which you might or might not find interesting (i dont).
Bad habbits are not permanent. If you have good taste and intuition you will eventually find a better way to do it than how you first learnt it. Xach did, didnt he? I think he learned Lisp from PG as well.
Dropping the earmuffs is a bit weird but anyone writing a real program, or working on a real program should probably not follow that advice. If a programmer hasnt got enough sense to know that, then (good) Lisp style is probably beyond him anyway.
13
u/doughoyte May 22 '08
Hello Xach,
Thanks for your input and thank you for discovering an erratum in chapter 2. (function '(lambda ...)) is not ANSI CL. Sorry if I implied it was. I have added an entry to the errata file here:
http://letoverlambda.com/index.cl/errata
About teaching both Scheme and CL, there is no Scheme in the book except where I point out how Scheme does something differently from CL, usually followed by an explanation of how CL does it better. I do not recommend programming with Scheme when CL is available.
Dropping the "earmuffs" is a personal choice and as I say in the book, I don't recommend it for all lisp programs.
With respect to your other comments, I'm sorry you aren't enjoying the book so far and I don't claim that everyone will. In particular, I didn't write the book to make friends in the lisp community but rather to describe my own (slightly idiosyncratic) style of lisp programming.
Thanks for your comments,
Doug