Subject: Re: how to validate input?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/04/27
Newsgroups: comp.lang.lisp
Message-ID: <8e97j2$4dumc$1@fido.engr.sgi.com>
Kragen Sitaker <kragen@dnaco.net> wrote:
+---------------
| Dorai Sitaram <ds26@goldshoe.gte.com> wrote:
| >Cross-tail-recursion, OTOH, permits a pass-the-baton
| >style way of writing procedures...
|
| Pass-the-baton-style programs can be written as a case statement inside a
| loop. It doesn't help the readability, that's for sure, but it can be done.
+---------------

Sure, and all subroutine calls and returns and random GOTOs can be converted
into one huge case statement inside a loop, too [with a manual stack to hold
the case indices for the returns]. I believe it was Bill Wulf who pointed
this out decades ago in a paper titled "Global Variable Considered Harmful".
That still doesn't make me want to do it very often.

The problem is that readability *does* matter, and both pass-the-baton-style
tail-call-optimized programs and CPS-style programs have their place, where
they're the most natural & readable style of doing some task. In particular,
having written a couple of lexical analyzers in Scheme in the pass-the-baton
style, I find that I really like it for that sort of thing. Sadly, it doesn't
really translate well to non-TCO environments.

Does that mean that I will always choose to accept the *other* pains of
writing in Scheme just for the benefits of TCO?  Not at all, if by using
some other environment (such as CL) I can gain *more* convenience and/or
readability for the whole task than what's been lost by having to rewrite
some pass-the-baton or CPS pieces. But the presence of cross-routine TCO
*is* one (but just one) of the considerations that affects my choice of
language for a given task...


-Rob

-----
Rob Warnock, 41L-955		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043