On 4 Dec 2023, at 10:27, Amirouche <amirou...@hyper.dev> wrote:

> The wording, and specification of 251 is better, and makes explicit code 
> reading practice.
> 
> 251 forbid mutually recursive definition in <body> and that is easier that 
> way.

251 does not forbid mutually recursive definitions; it merely makes them 
impossible when an expression (which, as previously mentioned, is not 
necessarily a transparent concept when reading) appears between two definitions.

So this is fine in 251:

(define (even-or-odd n)
  (define (even? n) (or (= n 0) (odd? (- n 1))))
  (define (odd? n) (even? (- n 1)))

  (if (even? n) 'even 'odd))

But not this:

(define (even-or-odd n)
  (define (even? n) (or (= n 0) (odd? (- n 1))))
  
(some-macro-that-expands-into-an-expression-or-a-mix-of-definitions-and-expressions)
  (define (odd? n) (even? (- n 1)))

  (if (even? n) 'even 'odd))

Either of these is fine in 245. Either is also fine in the R6RS top-level 
program. Either is also fine in an R7RS small library body. One of the purposes 
of 245 is to simplify Scheme by applying the same expansion order and scoping 
rules to all bodies. 251 could not do this even just for R7RS small.

The following also works in an R6RS top-level program body, but not in 251:

(define x (x-stx))
(some-expression)
(define-syntax x-stx
  (syntax-rules ()
    ((_) some-expansion-for-x-stx)))

If the specification of 245 is not sufficiently complete, you could also look 
at the macrological fascicle’s adaptation of the R6RS expansion order, which 
(preliminarily, as noted) explains how R7RS extends the process to cover (among 
other new features) mixed definitions and expressions in any context:
<https://codeberg.org/scheme/r7rs/src/commit/f31ef57eff12a2606b5afcfd05273421a3fdf432/fascicles/syntax-fascicle.txt#L1090-L1195>

I didn’t include this in its entirety in 245 because, in fact, only one 
paragraph of the R6RS spec is affected by this specific change (as explained in 
the ‘R6RS-compatible semantics’ section). But I could add it at the last minute 
(less the additions for identifier property and syntax parameter definitions) 
if it would help 245 to have ‘better wording and specification’.

> It is different from top level libraries.

Ungrounded assertions do not an argument make. (How? Why?)


Daphne

Reply via email to