lilypond-devel
[Top][All Lists]
Advanced

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

Re: comment in #{ ... #}


From: David Kastrup
Subject: Re: comment in #{ ... #}
Date: Thu, 24 Nov 2011 12:56:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

Reinhold Kainhofer <address@hidden> writes:

> Am Freitag, 22. Oktober 2010, um 20:30:29 schrieb Werner LEMBERG:
>> Interesting.  This
>> 
>>   T = #(define-music-function (parser location music) (ly:music?)
>>         #{
>>            \times 2/3 $music   % $
>>         #}
>>       )
>> 
>> does *not* work.  Looks like a bug...
>
> It seems like the way to replace all $xxxx variables in the #{ ... #} section 
> is not foolproof: It tries to replace everything starting with $, even if it 
> is inside a comment. In particular, try this out:
>
>    T = #(define-music-function (parser location music) (ly:music?)
>          #{
>             \times 2/3 $music   % $m
>          #}
>        )
> This complains about Unbound variable: m

With the patch to
<URL:http://code.google.com/p/lilypond/issues/detail?id=1356>, the
latter example will work (it will actually use the Scheme reader to read
and create (lambda () m) but never executes it).  The first example,
however, is hopeless.

Lilypond can't properly parse #{ ... #} at compile time since the lexer
is stateful and the states depend on the actual variables and values.
So it determines its bounds by reading through and employing the Scheme
reader whenever it hits $ and #.  Just make sure that the Scheme reader
finds something to occupy itself with before the comment ends (and most
definitely before #} ends!), and things will work fine after this patch
makes it into Lilypond.

-- 
David Kastrup




reply via email to

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