[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why named LET anyway?



Personally, I see named let, letrec, and let* as having three very different
uses.  Named let is for loops and other single-function recursions in which I
wish immediately to call the function after its binding.  Letrec is for
multiple-function recursions and those single-function ones in which there is
other work to be done before calling the function.  Let* is completely unrelated
to recursion and is simply to avoid the indenting complexity of
immediately-nested (unnamed) lets.

Both named let and letrec can be simulated reasonably well with internal
defines, but for named let cases, I find the extra overhead of breaking out the
function definition explicitly in a define a bit distasteful and a bit harder to
read.  Really, it is a matter of taste.  I do use internal defines quite
extensively for the definition of locally-required auxillary functions,
recursive or otherwise.  I think, though I 'm not really aware of it at the
time, that I usually avoid letrec in favor of internal defines, simply for
indenting reasons.

I hope that I've made one programmer's reasoning clear.

As for SI&CP being considered a good book in spite of its silence on let*,
letrec*, and named let, it is worth remembering that the book does not have as
its major purpose the teaching of the Scheme programming language, but rather
some concepts much more general than that.  For its particular pedagogical
purposes, internal defines are entirely sufficient.

	Pavel