lilypond-devel
[Top][All Lists]
Advanced

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

Re: Yet Another music macro proposal


From: Nicolas Sceaux
Subject: Re: Yet Another music macro proposal
Date: Fri, 12 May 2006 20:05:49 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Erik Sandberg <address@hidden> writes:

> Hi,
>
> I have yet another suggestion for how \relative can be soft-coded in a 
> generic 
> way. It's inspired by criticism of earlier attempts. It's similar, but not 
> identical, to a previous suggestion.
>
> Macros is that they operate on syntax, not on music. And the parser spits out 
> music directly. So what I suggest, is to let the parser spit out yet another 
> intermediate format, which is a Scheme expression that more or less 
> corresponds to the the parse tree. So, for example,
>
> \repeat volta 2 { c8 d e \foo }
>
> would parse into a Scheme expression
> (repeat 'volta 2 (sequential <c8> <d8> <e8> foo))
> where <c8> etc. are Music objects (or possibly expressions that evaluate to 
> Music objects).
>
> When a top-level expression has been parsed into such scheme expression, it 
> is 
> evaluated in a Scheme module, where repeat, sequential etc. are defined as 
> functions that return music; this evaluation produces the final music 
> expression.
>
> Some benefits:
> - It will be easy to make \relative a music macro, by defining relative as a 
> Scheme macro.
> - The parser will be reduced to a thin layer of syntactic sugar, so a large 
> portion of parser.yy can be moved to scheme. Application of music functions 
> and dereferencing of variables is completely outsourced to guile.
> - For those who want to do programming using lily syntax, it will be easy to 
> export Scheme functions and macros to the lily parser at runtime. This will 
> probably reduce the number of feature requests that come to our mailing 
> lists.

What you're describing over-reaches my mental capabilities (I can't
understand exactly how you'd do that, and if the promised flexibility
would actually arise). But if the root problem is actually the \relative
mode, couldn't it be coded as a music function?

Your post just reminded me that I've written a version of \parallelMusic
with relative mode after a request by Werner (and I forgot about it
during holidays). To accomplish that, I've written a `relativize-music'
function, which change a sequence of notes as if it were written using
\relative mode. (As is, it would be buggy for a general use, but
fixable).

nicolas

(reading this message before sending: I'm proposing a workaround to a
specific problem whereas your post was more general, sorry)




reply via email to

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