In R5RS, there are three kinds of BEGINs:
1) All subforms are expressions; this can be used wherever an expression can be used. (4.2.3)
2) All subforms are definitions; this can be used wherever an internal definition can be used. (5.2.2)
3) Subforms can be definitions or expressions intermixed in any order; this can be used only at top level. (In R7RS we extend this to module top level as well). (5.1)
In particular,
(define (x) (define y 32) (begin (define z 45) (set! y z)) y)is not licensed by any of these provisions, and consequently is not valid R5RS Scheme. Nevertheless, all of my usual Schemes accept the above definition except Scheme48/scsh and SSCM -- actually, SSCM fails when you invoke x rather than when you define it. So I'm proposing that we unify them for R7RS.
We voted not to change this.