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

No Subject



I like approach #3 best.  Nevertheless this discussion has
convinced me that if we really want to strengthen the requirement
for proper tail recursion that appears within the Scheme standards,
then we should opt for approach #1.  Though it presumes a certain
kind of implementation, it is the simplest to explain, and it must
be understood in order to understand the implementation techniques
that are ordinarily used to achieve proper tail recursion in
the sense of approaches #2 or #3.

No matter what formulation of proper tail recursion might be
required by the Scheme standards, an implementation will remain
free to deviate from it so long as the deviation cannot be
detected by its users; the benefit of explicitly requiring
a precisely defined notion of proper tail recursion is that
users will be able to cite the standard when complaining that,
through bugs or ignorance or general perversity, an implementor
has allowed users to detect violations of proper tail recursion.

I would therefore support a strengthening of the R4RS requirement
for proper tail recursion, with wording somewhat as follows (which
borrows from John Ramsdell's suggested paragraph):

  Implementations of Scheme are required to be properly
  tail-recursive.  This means implementations must recognize
  syntactically tail-recursive calls, whose result will be
  returned by the procedure whose body contains the
  tail-recursive call.  In effect, implementations must
  arrange for the result of a tail-recursive call to be
  returned directly to the continuation that was passed to
  the procedure that contains the tail-recursive call,
  instead of being returned to that procedure.  This
  allows iteration to be expressed using the ordinary
  procedure-call mechanics, so that special iteration
  constructs are useful only as syntactic sugar.

Note the use of the phrase "in effect": we don't care how
implementations actually do it, but they must achieve the
effect of doing it as described.

Will