[r6rs-discuss] [Formal] Bodies should be more widely permitted.

From: Alan Watson <alan>
Date: Tue Nov 14 22:41:53 2006

---
This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html
---
Submitter: Alan Watson
Email address: alan_at_alan-watson.org
Issue type: Enhancement
Priority: Minor
Component: Base Library and Miscellaneous
Report Version: Version: 5.91
Summary: Bodies should be more widely permitted.
Text:
I propose that bodies be allowed in the clauses of cond, case, do, when,
unless, and begin forms. Essentially, this would permit these clauses to
be have declarations and internal definitions.
This change simplies the description of the language. Currently, there
are three kinds of "sequences of forms":
(1) The bodies of binding forms.
(2) The sequences of expressions in cond, case, do, when, and unless
     forms and non-splicing begin forms.
(3) The sequences of forms in splicing begin forms (those that are
     spliced into bodies, library bodies, and script bodies as described
     in section 9.5.7).
This proposal unifies the first two classes and thereby simplifies the
language and removes an arbitrary restriction.
This change is backwards compatible with R5RS.
Currently, this behaviour can be obtained by, for example, using a (let
() ...) form in the sequence, but this seems a bit of a hack.
This change is easy to implement. Consider an existing Scheme
implementation that allows only sequences of expression in the contexts
mentioned in (2) above. Such an implementation could be converted to
accept bodies in these contexts by modifying it to wrap the sequences in
(let () ...).
The changes to the draft are:
9.4: Add "begin", "cond", "case", and "do" to the list of forms that
   have bodies. (I suggest not adding "when" and "unless" as these are
   not in the base library.)
9.5.5: Replace the expression sequences in the first and third forms or
  cond clauses and in both forms of case clauses with bodies. Add a
  comment that these clauses establish new lexical regions.
9.5.7: Replace the expression sequences in the second form of begin with
   a body. Add a comment that this form establishes a new lexical region.
9.18: In the description of the values procedure, write "The
   continuations of all non-final expressions within a body as well as
   the continuations of the before and after arguments to dynamic-wind
   take an arbitrary number of values."
9.19: Replace both expression sequences in the do form with bodies. Add
   a comment that this form establishes new lexical regions in these
   bodies.
20.1: Replace the expression sequences in when and unless forms with
   bodies. Add a comment that these forms establish new lexical regions.
The syntax definitions of cond, case, do, when, and unless in 19.9,
20.1, and Appendix B do not need changing if begin takes a body.
Received on Tue Nov 14 2006 - 18:07:46 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC