[Top][All Lists]

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

Re: parser variables persist beyond { } scope

From: Han-Wen Nienhuys
Subject: Re: parser variables persist beyond { } scope
Date: Fri, 31 Jul 2009 04:28:10 +0000

On Thu, Jul 30, 2009 at 7:19 PM, Mark Polesky<address@hidden> wrote:
> The problem with this approach is that if one uses "define" (or
> preferably "set!" as Neil mentioned) to change the variable within a
> music block, the new value persists beyond the closing curly-brace of
> the music block. It will even persist into any subsequent score blocks,
> which can lead to unexpected results. Even worse, the source of these
> unexpected results may be difficult to track down, especially in large
> projects with multiple score blocks.
> One reason that I found this particularly frustrating was the implicit
> (and apparently incorrect?) belief that curly braces in LilyPond define
> boundaries for a local scope (as in many programming languages). Please

Braces are overloaded in LilyPond.  In some cases they define scopes
(like \paper and \header), and in other cases, they just group
syntactic constructs (\book, \score, sequential musics).

The solution you propose sounds hairy to me. I think you probably want
are looking for a real scoping construct inside music expressions.  I
don't think this is a very neat idea, because these scoping constructs
will necessarily not nest correctly wrt { } and << >>.  The confusion
arises from your use of #(set! .. ), ie. direct interaction with the
scheme interpreter. It is assumed that people who do this know what
they are doing.  Note that in 'native' lilypond syntax, this problem
is nonexistent, since assignments may only occur at toplevel.

Han-Wen Nienhuys - address@hidden -

reply via email to

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