Colin Walters <walters@cis.ohio-state.edu> wrote:
+---------------
| "felix" <felix@anu.ie> writes:
| > Is '(begin)' an error or not?
|
| If you look at R5RS, Section 7.1.3, you can see that
| <expression> -> <derived expression> -> (begin <sequence>)
| and <sequence> must have at least one <expression>, as far as I can tell.
| Thus, the answer is yes.
+---------------
Well, in an "<expression>", yes, it's illegal. But from section
7.1.6 "Programs and definitions", you can derive the following:
<program> ->
<command or definition>* ->
<definition> ->
(begin <definition>*) ->
(begin) ; by the definition of "*"
So I'd say that at the top level of a program *or* the beginning of
a "body" (that is, wherever a "definition" may appear), it's legal.
And MzScheme (which someone else complained about) actually does it
right, IMHO:
> (begin)
> (begin (begin (begin (begin (begin)))))
> (begin (begin) (+ 2 3))
5
> (+ 2 (begin (begin) 3))
begin: bad syntax (empty form) in: (begin)
>
-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