Re: Setting variables in declarative modules

Mikael Djurfeldt <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <CAA2Xvw+j+DS3uAKEAFMLqXzHZCtT0H1YK00DAq81dy4Vki_ONg@mail.gmail.com>
One additional comment regarding this:

The first definition in your example, Tommi, isn't required. The order of
the definitions don't matter as long as a variable reference isn't required
to compute the value being defined. In your case, the variable references
aren't resolved until the procedures are executed. Meanwhile the bindings
my-proc and fw-proc get their values just fine without a need to resolve
the reference to fw-proc inside my-proc.

On Fri, Nov 1, 2024 at 2:21 PM Thompson, David <[email protected]>
wrote:

> Hi Tommi,
>
> On Thu, Oct 31, 2024 at 10:30 PM Tommi Höynälänmaa
> <[email protected]> wrote:
> >
> > Suppose that I have the following code in a Guile module:
> > ---
> > (define fw-proc #f)
> >
> > (define (my-proc x)
> >     (display (fw-proc x)))
> >
> > (define (fw-proc x)
> >     (cons x x))
> > ---
> >
> > Can I declare the module as declarative?
>
> Yes, this is fine. If you put this in a module file and compile it,
> Guile does not issue any warnings. `define` is not `set!`. (Modules
> are declarative by default, btw.)
>
> - Dave
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.