lilypond-user
[Top][All Lists]
Advanced

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

Re: newbie question on scheme functions


From: Nicolas Sceaux
Subject: Re: newbie question on scheme functions
Date: Fri, 31 Dec 2004 16:58:39 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Andrea Rossato <address@hidden> writes:

> Nicolas Sceaux wrote:
>> You can do
>> #(define-module (lily))
>> #(export accidental->markup)
>> #(define-module (*anonymous-ly-0*))
>> at the beginning of your file, or alternatively, copy and paste the
>> `accidental->markup' definition from scm/accidental->markup to your
>> input file.
>
> yes, both methods work perfectly.
> Thank you very much.
>
> I'll now try to understand the hows and whys...;-)

The code in scm/chords.scm defines functions in the module named
(lily). Some symbols are exported (the one introduced by
`define-public'), thus they are part of the module interface, whereas
some other are internal (the one introduced by `define').

`accidental->markup' is simply `define'd, not `define-public'ed, so
this function is only accessible inside the (lily) module.

In your input file, the module in which you work is
(*anonymous-ly-0*), which "uses" the module (lily), that is to say it
can use symbols that are exported by the (lily) module, which is not
the case of `accidental->markup'. That's why we first exported it in
the (lily) module:

%% 1) switch to the (lily) module
#(define-module (lily))

%% 2) export accidental->markup so that it can be used outside (lily)
%% this is as if it had been defined using `define-public' iso
%% `define'.
#(export accidental->markup)

%% 3) switch back to (*anonymous-ly-0*)
#(define-module (*anonymous-ly-0*))

The second solution consisted in defining inside the module
(*anonymous-ly-0*) a function called accidental->markup, that can be
called inside (*anonymous-ly-0*).

nicolas





reply via email to

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