Re: r6rs implementation? Marc Nieper-Wißkirchen 11 Oct 2020 13:38 UTC

Am So., 11. Okt. 2020 um 05:56 Uhr schrieb John Cowan <xxxxxx@ccil.org>:

> On Wed, Oct 7, 2020 at 3:07 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

>> That is only superficially the case. For the compiler, there is not a
>> single type of variable reference. You may reference an imported
>> variable, a variable defined at top-level, a local variable defined in
>> an outer scope, a local variable earlier in this scope, or a local
>> variable that will be defined later in this scope.
>
>
> As someone says:  "Having discovered that wine and water, whiskey and water, brandy and water, etc. all intoxicate, we may conclude that the intoxicant is the common ingredient, namely water."

I am uncertain about what do you exactly want to say in this context?

[...]

>> What about the R7RS model? I hope it is supposed to do the same.
>> (Otherwise, the meaning of the code would change if the order of the
>> two inner definitions is switched, making the idea that inner
>> definitions are equivalent to a letrec* questionable. Moreover,
>> reasoning in a lexical-local sense would become harder.)
>
>
> Specifically this means that the scope of variables declared in a body or library-body is the whole block/library, but the scope of syntax keywords may be the whole body or just the part after the definition.

So outer syntax definition is not applied if there is a variable
definition of the same name somewhere in the body? That's good as it
would be compatible with the clear semantics of R6Rs.

>> That said, we also have the library or program top-level. In R6RS,
>> their semantics are as in a <body>, which I also use in Unsyntax as
>> deferring the expansion of the right-hand sides is the only sensible
>> thing to do.
>
>
> Expressions cannot precede definitions in a body, but in a library body they can.

This point is not relevant to the discussion here, because I can (and
R6RS does this conceptionally for program bodies) always turn an
expression into a definition binding a dummy variable.