Expression/Definition dependency semantics Dr. Arne Babenhauserheide (24 Sep 2023 15:44 UTC)
Re: Expression/Definition dependency semantics Daphne Preston-Kendal (24 Sep 2023 15:54 UTC)
Re: Expression/Definition dependency semantics Dr. Arne Babenhauserheide (24 Sep 2023 16:52 UTC)
Re: Expression/Definition dependency semantics Amirouche (24 Sep 2023 20:39 UTC)
Re: Expression/Definition dependency semantics Dr. Arne Babenhauserheide (25 Sep 2023 10:20 UTC)
Re: Expression/Definition dependency semantics Marc Nieper-Wißkirchen (25 Sep 2023 11:33 UTC)
Re: Expression/Definition dependency semantics Daphne Preston-Kendal (24 Sep 2023 21:14 UTC)
Re: Expression/Definition dependency semantics Dr. Arne Babenhauserheide (25 Sep 2023 10:04 UTC)
Re: Expression/Definition dependency semantics Amirouche (24 Sep 2023 20:12 UTC)

Re: Expression/Definition dependency semantics Amirouche 24 Sep 2023 20:12 UTC

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

+1

> 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.

OT: It is dubious to log the return of procedure: if the procedure is buggy,
the logs from initial deployment are all useless. In fact, outside the human
readable message, no value should more complex than a literal number, boolean,
symbol, or even a string. The only exception, I can think of, is time zone aware.

My rationales for the SRFI specification are:

1. Re use-before-definition: I can see, or think for, no rationales that mention
  usability, ease of programming, debugging, maintenance.

2. The description of the interpretation, or compilation of use-before-definition
  is complicated;

3. Having the body of lambda behave the way the body of a program behave is easy

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

Thanks, Arne, for chiming in, I hope, again, you take part, once more, in SRFI process.

Best, and due regards,

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