lilypond-devel
[Top][All Lists]
Advanced

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

Re: What's the deal with the module system?


From: Nicolas Sceaux
Subject: Re: What's the deal with the module system?
Date: Mon, 23 Nov 2009 22:36:19 +0100

Le 23 nov. 2009 à 19:03, David Kastrup a écrit :

> Han-Wen Nienhuys <address@hidden> writes:
> 
>> On Mon, Nov 23, 2009 at 1:21 PM, David Kastrup <address@hidden> wrote:
>> 
>>>>  lilypond a.ly b.ly
>>>> 
>>>> we want to reuse the built-in definitions, without changes effected
>>>> in a.ly leaking into the processing of b.ly
>>> 
>>> Wouldn't just putting the built-in definition at public scope
>>> accomplish that?
>> 
>> I don't know.  Why don't you try it, and send us a patch if it passes
>> the regression tests?
> 
> That would not be my first thought when meddling with code I know
> nothing about, and where I assume that somebody had created it because
> of some inherent necessity.  And not every dead end needs to be entered
> repeatedly.  It is a waste of time.

A waste of time for you.

I think it's a waste of time *for me* to explain you things when I read
a subject line like "WTF with..." and no thank you in the end.

As you can easily guess, there are three possible reasons why I did
something complicated in ly/markup-init.ly and a bit a code duplication
from scm/markup.scm:

1) I like to make me some bad
2) There's no easier way
3) There is an easy way, but I didn't see it.

The answer is between 2 and 3, and hopefully you will prove that it
is 3.  Otherwise you will at least understand why I insisted that
define-builtin-markup-command and define-markup-command are not exactly
the same thing (with respect to modules).

The reason why I've used this define-public-toplevel macro has something
to do with the modules being not the same when a .ly file is included into
another.  So that hack was a way to define all markup commands in the same
module.  I didn't find at that time an easier way to define a function in
a given module (not the current one) than to define this macro.

BTW, the guile module is not bypassed: module-define!, module-export!
and module-ref are all guile module primitives.

When you modify that code, try something like:

file1.ly:
  \include "file2.ly"
  \markup \foo

file2.ly:
   #(define-markup-command (foo ...) ...)

and compile file1.ly

Also try to compile file3.ly:

file3.ly:
  myInclude =
  #(define-music-function (parser location file) (string?)
     #{ \include $file #}
     (make-music 'void #t))

  \myInclude "file2.ly"
  \markup \foo

Please send *complete* patches for review at retvield.





reply via email to

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