Hi,

thank you for creating SRFI-245! In Guile I enjoy it very much to be
able to intersperse definitions and expressions.

The specification in SRFI-245 looks a bit too strict for me, though:

> It is an error for the evaluation of any expression or of the
> right-hand side of any definition in the sequence of definition or
> expressions to require knowledge of the value of a variable whose
> definition is to the right of it.

Do I understand it correctly that this would mean that this would not
work, because

(define (using-later-procedure)
  (define x (y))
  (define (y) #t)
  x)

Or that it would stop to work if I interspersed logging messages?

(define (using-later-procedure)
  (define x (y))
  (display x)(newline)
  (define (y) #t)
  x)

Both of these work in Guile, because Guile treats expressions before the
final definition as implicit definitions:

(define (using-later-procedure)
  (define x (y))
  (define _1 (display x))
  (define _2 (newline))
  (define (y) #t)
  x)

For details, see
https://www.gnu.org/software/guile/manual/html_node/Internal-Definitions.html

>      (let ()
>        (define a 1)
>        (foo)
>        (define b 2)
>        (+ a b))
> 
> is equivalent to
> 
>      (let ()
>        (letrec* ((a 1) (_ (begin (foo) #f)) (b 2))
>          (+ a b)))

It may be useful to enforce an ordering between expressions and blocks
of definitions, though, to ensure that logging code runs before the
later definitions.

Do I understand the letrec* implementation in the SRFI correctly that it
would enforce the ordering of expressions before the directly following
definition?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

Attachment: signature.asc
Description: PGP signature

Reply via email to