On 24 Sep 2023, at 18:13, Dr. Arne Babenhauserheide <arne_...@web.de> wrote:

> This keeps ordering rules simple (earlier code is always executed before
> code that depends on it), but I think it is slightly too limited.
> Therefore I would propose a slight extension:
> 
> "It is an error for the evaluation of any expression to require
> knowledge of the value of a variable whose definition is to the right of
> the expression."

This is not what Guile allows either:

(let ()
  (define x (+ y 1))
  (define y 2)
  (values x y))

This fails.

I believe Guile is merely separating lambda definitions from non-lambda 
definitions and executing the former first. This is not tremendously useful 
behaviour, and I suspect it’s just a strange result of however Guile implements 
letrec*/internal definitions internally, and not ‘defined behaviour’ of Guile, 
so to speak. It is not mentioned in the manual, for example.

More generally, if we were to allow what you asked for, there would be no 
reason not to allow general use before definition, which makes implementation 
much more complicated and introduces error cases such as those in our previous 
mails where it isn’t possible to re-order the definitions without affecting the 
observed order of side-effectual operations.


Daphne

Reply via email to