lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Understanding scope of functions in Scheme modules


From: Urs Liska
Subject: Understanding scope of functions in Scheme modules
Date: Sat, 25 Jul 2020 10:28:10 +0200
User-agent: Evolution 3.36.4-1

Hi,

I'm trying to clean up some code in openLilyLib, most of which had been
added when I was just starting to understand the topics I had to deal
with at any point ...

One thing I'm right now struggling with and that I'd like to get right
this time is the scoping of code within Scheme modules.

My observation at this point seems to be:

 * I can define procedures or variables in a Scheme module equivalently
   with (define-public my-proc) or (define my-proc) (export my-proc)
 * I can include such a module in a .ly file with (use-modules (my-
   module)) (if it's in the Guile path).
 * my-proc will then be available for any later LilyPond code (i.e.
   also in other files that are later in that compilation's parsing)
 * my-proc will *not* be available in other .scm files, in these I
   would have to explicitly include my-module with use-modules.

Is this correct so far?
If so is there a way to make names from modules only available within
the LilyPond file that uses the module?

I would like to have more encapsulation, so that the helper functions
needed for the implementation are only visible where needed to have
less clutter in the global namespace, like in many other languages
where you have to explicitly import modules you want to use within each
file.

I think it will already be progress just to have the code *organized*
like that, the camelCase-d user-facing LilyPond functions in the .ily
file and the Scheme-define-d helper code in a separate .scm file. But
if there were a way for real scoping it would be better.

Any suggestions available?

Thanks
Urs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]