David Sumbler <da...@aeolia.co.uk> writes: > -----Original Message----- > From: msk...@ansuz.sooke.bc.ca > To: David Sumbler <da...@aeolia.co.uk> > CC: David Kastrup <d...@gnu.org>, lilypond-user <lilypond-user@gnu.org> > Subject: Re: Not Nice Review of the LilyPond > Date: Sun, 2 Dec 2018 14:17:11 -0500 (EST) > > On Sun, 2 Dec 2018, David Sumbler wrote: >> > But MusiXTeX can do "if" statements. >> I felt that an "if" would be useful, so I eventually came up with: > > That is useful for conditional includes, but it can't be embedded in > the > data structure that LilyPond calls "music" and stores in variables. As > soon as something is turned into "music" it has to be data, not code; > conditionals must either be evaluated before the input is turned into > "music," or by separate code (usually, in Scheme rather than in > LilyPond > as such) that conditionally modifies the static "music." That latter > approach, with tags in the "music" that can be filtered out, is what's > usually recommended as a substitute for real conditionals in LilyPond, > but > it's quite limiting compared to what programming languages can do with > "if." > > For those familiar with programming languages it's not so mysterious > why > this situation comes about. LilyPond takes care to call its variables > variables in the documentation. You reference them; you don't execute > them. They contain data, not code. Obviously, data will be the same > every time you look at it, unless you externally change it. But I wish > that without escaping to Scheme I could have something more like a > macro > than like a variable, evaluating its conditionals (and doing other > programming-language stuff) every time it is used. > > ************* > > Well, I'm not quite sure what you are after but this works:
For late evaluation, there are a number of callbacks. Including using the "elements-callback" field on sequential music, by the way. In particular that latter one makes music length calculations less dependable, of course, as is to be expected from any late-evaluated "conditional". -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user