lilypond-user
[Top][All Lists]
Advanced

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

Re: scm functions scope and arguments


From: Nicolas Sceaux
Subject: Re: scm functions scope and arguments
Date: Fri, 24 Jun 2005 22:18:52 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

VSD <address@hidden> writes:

> #(def-markup-command (E-one layout props arg) (markup?)
>    (let
>      (
>        (definition-list
>          (fret-parse-definition-string
>         (cons '((thickness . 0.8) (size . 1.05)) props)
>         "h:3;f:1;6-o;5-2-2;4-2-3;3-1-1;2-o;1-o;"
>          )
>        )
>      )
>      (make-fret-diagram layout (car definition-list) (cdr definition-list)))
> )

There should not be parens alone on a line. When you read Lisp or Scheme
code, parentheses are not that important, what you look at is
indentation. The above function should be formatted:

#(def-markup-command (E-one layout props arg) (markup?)
   (let ((definition-list
           (fret-parse-definition-string
             (cons '((thickness . 0.8) (size . 1.05)) props)
             "h:3;f:1;6-o;5-2-2;4-2-3;3-1-1;2-o;1-o;")))
     (make-fret-diagram layout (car definition-list) (cdr definition-list))))

which makes more clear what form belong to what.

> This code works fine as long as E-one is defined inside the file
> "fret-diagrams.scm" (without the starting "#"). But if I define it
> outside  that file (e.g. in the calling ly file as in the given
> example), then  lilypond complains:
>
> "ERROR: Unbound variable: fret-parse-definition-string"

That's because the code from fret-diagrams.scm is defined inside the
(lily) module. Only symbols that are exported from (lily) are visible
outside that module. fret-parse-definition-string is not exported, which
means that it is "private" to the (lily) module, and cannot be seen from
your .ly file.

One reason 'fret-parse-definition-string' is not exported may be that it
is indeed internal, and then you should try another exported ("public")
function. Or maybe that function is not that internal, and ought to be
exported.

To find out how to export a symbol, see guile documentation, chapter
about modules: export, define-public.

> Yet one more thing: How could I define the E-one function so it takes
> no  arguments?
>
> I've tried
>
> #(def-markup-command (E-one layout props)
>     (...)
> )

Look at scm/define-markup-commands.scm, in particular where \flat,
\sharp, etc, are defined.

nicolas




reply via email to

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