lilypond-devel
[Top][All Lists]
Advanced

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

Re: Solution for including a file only once


From: Reinhold Kainhofer
Subject: Re: Solution for including a file only once
Date: Thu, 11 Feb 2010 20:07:13 +0100
User-agent: KMail/1.12.4 (Linux/2.6.31-19-generic; KDE/4.3.5; i686; ; )

Am Donnerstag, 11. Februar 2010 19:05:26 schrieb Michael J. O'Donnell:
> Here's what I *now think* is correct code O:-) :
> 
> includeIfAbsent =
> 
> #(define-music-function (parser location fileName) (string?)
> 
> (let ((guardName (string-append "Already Got " fileName)))
> (if (not (defined? (string->symbol guardName)))

Huh? So you are constructing a string like "Already Got testinclude.ily" and 
turn that into a symbol?

First, I suppose the "Already Got" is there just for testing purposes? (Or are 
you trying to prevent symbols that start with ../somedir/...?)

And second, why don't you simply store the strings in a global list or so? I 
doubt that the overhead of the (a)list member lookup can have any influence on 
speed. On the other hand it means one global symbol less per included file.

> (ly:parser-parse-string (ly:parser-clone parser) (string-concatenate
> (list "\\include \"" fileName "\"")))
> 
> #{ #}

Wouldn't it be better to put that only once after the (let...) function?


Instead of #{ #} you can also use the scheme construct for an empty music 
expression:
(make-music 'Music 'void #t)

In scm/ly-syntax-constructors.scm a (void-music) function is defined, which 
creates also an empty music expression, but does not set the 'void property... 
I'm not sure if that would also work, in particulat since collect-music-aux in 
scm/lily-library explicitly checks for the 'void property and discards the 
music if 'void is set to #t...

So, is this an oversight and 'void #t should / needs to be added to the 
definition of (void-music)?


Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org




reply via email to

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