Thanks Aaron!

On Mon, 25 Jan 2021 at 15:54, Aaron Hill <lilyp...@hillvisions.com> wrote:
> Did you mean to attach or include a code snippet?  Hard to spot any
> problem without it.  :)
>

Oops, guilty as charged.

> Regardless, review the following:
>
> %%%%
> \version "2.22.0"
>
> valueOrDefault =
> #(define-scheme-function
>    (module symbol default)
>    ((module? (current-module)) symbol? scheme?)
>    (module-ref module symbol default))
>
> defineOnce =
> #(define-void-function
>    (module symbol value)
>    ((module? (current-module)) symbol? scheme?)
>    (or (module-defined? module symbol)
>        (module-define! module symbol value)))
>
> {
>    \valueOrDefault foo { b'1 }
>    \defineOnce foo { b'4 4 2 }
>    \valueOrDefault foo { b'1 }
>    \defineOnce foo { b'8 8 2. }
>    \foo
> }
> %%%%
>

That works well. I was tying my brain in knots thinking about symbols and
variables. Using the module definitions looks very robust.

Thanks again!
Vaughan

Reply via email to