Hi Werner, Am 22.02.26 um 20:22 schrieb Werner LEMBERG:
I have a problem with understanding Guile's scoping rules. Take, for example, function `accidental->markup`. This is defined in file `chord-name.scm` as``` (define (accidental->markup alteration) ...) ``` However, the function is also used in other files, for example, in `chord-ignatzek-names.scm`. Why does this work? I always thought that `define` sets up a function that is local to a file, but this seems not to be case. My working hypothesis is that those two files are both loaded in `lily.scm` (via the `init-scheme-files` list), which means that they are actually part of the 'lily' module – a function defined with `define` in one of the loaded files of this module is thus visible to all other loaded files (but not outside). Is this interpretation correct?
Yes AFAIK. If I'm not mistaken, a file like `chord-ignatzek-names.scm` is not actually loaded using the module system but using `primitive-load-path` in `lily.scm`.
You can see the difference when looking at a `.scm` file that defines its own module, say, `page.scm` (which starts with `(define-module (lily page))`). It is not being loaded in `lily.scm`, and hence, you cannot access its non-public symbols in other LilyPond `.scm` files.
Lukas
