Subject: [bug#53878] [PATCH v3 09/15] gnu: Add racket-vm-cgc.

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 20 Feb 2022 19:13:58 +0100

Hi,

Am Sonntag, dem 20.02.2022 um 12:52 -0500 schrieb Philip McGrath:
> AFAICT the error is not from applying the function bound to the
> variable `racket-vm-for-system` (or `make-racket-vm-bc`, or
> whatever), but from evaluating the reference to a variable imported
> from a sibling `(gnu packages ...)` module, regardless of the value
> to which the variable is bound.
> 
> My current best guess at Guile's semantics for mutually-recursive
> modules is that it's something like the `letrec` restriction, e.g.
> the difference between these two examples (given an implementation
> that fully enforces `letrec` semantics, as opposed to `letrec*`):
> 
> --8<---------------cut here---------------start------------->8---
> $ scheme 
> Chez Scheme Version 9.5.6
> Copyright 1984-2021 Cisco Systems, Inc.
> 
> > (letrec ((a (lambda () 1))
>            (b a))
>     2)
> Exception: attempt to reference undefined variable a
> Type (debug) to enter the debugger.
> > (letrec ((a (lambda () 1))
>            (b (lambda () (a))))
>     (b))
> 1
> --8<---------------cut here---------------end--------------->8---
> 
> > 
> > See (standard-packages) in guix/build-system/gnu.scm pointing to
> > (gnu
> > packages commencement) or (default-python) in guix/build-
> > system/python.scm for pointers.
> 
> Given Ludo’'s explanation, I think the difference (or at least an
> important difference) is that those functions are defined in `(guix
> ...)` modules, as  opposed to `(gnu packages ...)` modules.
> 
> But I wish I knew with any degree of certainty *why* this would be
> true, if indeed it is.
> 
> Maybe Maxime knows?
Both Ludo and Maxime already explained this, but to be extra clear,
it's the thunking.

(define foo <something-in-bar.scm>)
(define bar <something-in-foo.scm>) <- problem

(define (foo) <something-in-bar.scm>)
(define bar <something-in-foo.scm>) <- no problem.

Since inputs are thunked, you can define chez in chez.scm and racket in
racket.scm and use them as input to each other without breaking the
compiler (you will break the package builder though).  If you want
something more meaningful, you can define racket-minimal in racket.scm
and use it in chez.scm as input to a package, then use that package as
input to racket.  This does not work for (source ) and (inherit )
however, because those forms are not thunked.  You would have to thunk
them until you reach a save haven (like a package's inputs), where you
can call the thunk to produce a value.

Cheers