lilypond-user
[Top][All Lists]
Advanced

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

Re: Is there an equivalent of #define ... #ifndef ... #endif in lilypond


From: Michael Hendry
Subject: Re: Is there an equivalent of #define ... #ifndef ... #endif in lilypond?
Date: Mon, 20 Feb 2012 01:33:56 -0800 (PST)



lilypond-7 wrote:
> 
> 
> Please forgive my exercise in total conjecture, as I have not
> tested any of the concepts below, but perhaps UNIX's m4 macro
> preprocessor can provide the tools you seek without requiring any
> changes to LilyPond.
> 
> Since that I infer you possess knowledge of the C language's
> macro capabilities, would it suit your needs to simply write your
> LilyPond source code to conform with m4(1), and then use m4's
> macro capabilities to do what you want?  Using a wheel which
> has already been invented, as it were.
> 
> I'll admit that I'm not intimately familiar with m4, so please
> forgive me if you've tried this and found it unworkable.
> 
>> I envisage a series of #define statements at the head of the main .ly
>> file
>> such as:
>> 
>> #define concert_part
>> #define guitar_part
>> #undef alto_part
>> #define clarinet_part
>> 
>> which would alter the output from the included "parts.ly" file.
>  
> Or, you could set/unset variables from the command line:
> 
> m4 -Dconcert_part -Dguitar_part -Ualto_part -Dclarinet_part \
>       parts.ly \
> | lilypond
> 
> 
> Jim
> 
> 

Thanks, Helge and Jim.

I was forgetting that when a C program is compiled, the pre-processor is
deployed first of all, and that #define etc. are pre-processor directives.

This approach would make my files much less portable to other Lilypond
users, so although I think it I could make it work, the gain wouldn't be
worth the pain!

So I'll have to do what I want to do within the resources provided by
Lilypond itself.

I've been experimenting with \tag, but it doesn't seem to be possible to use
it in the \book {} context.

Many years of amateur programming have taught me the value of modular code,
which can be debugged thoroughly then left untouched - brought in wherever
it is needed using \include (or equivalent) statements. Copying-and-pasting
this sort of code into every program that might need it runs the risk of
inadvertently changing it, and also means having to keep track of every
instance of it so that bugs can be fixed or enhancements introduced, instead
of just changing the master copy.

I expect to use Lilypond mainly with jazz charts, which have a predictable
format and lend themselves to modular construction - I'll keep at it!


-- 
View this message in context: 
http://old.nabble.com/Is-there-an-equivalent-of--define-...--ifndef-...--endif-in-lilypond--tp33346188p33355609.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.




reply via email to

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