lilypond-devel
[Top][All Lists]
Advanced

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

Re: \once \revert


From: Carl Sorensen
Subject: Re: \once \revert
Date: Sun, 21 Aug 2011 07:04:17 -0600

On 8/21/11 3:01 AM, "David Kastrup" <address@hidden> wrote:

> Carl Sorensen <address@hidden> writes:
> 
>> On 8/21/11 1:45 AM, "David Kastrup" <address@hidden> wrote:
>> 
>>> My suggestion
>>> would be
>>> 
>>> \set x = 4           ; setting the default
>>> \override x = 5      ; context set has 5
>>> \override x = 2      ; context set has 5 2, result 5
>>> \once\override x = 3 ; context set has 3(o) 5 2, result 3
>>> \revert x            ; context set has 3(o) 2, result 3
>>> [wait ...]           ; context set has 2 result 2
>>> 
>> Yes, this is clearly better than my proposal.
> 
> Also wrong, since I mixed up the order of 2 and 5.  I hope you
> understood what I meant rather than what I wrote.  The following should
> be better:
> 
> \set x = 4           ; setting the default
> \override x = 5      ; context set has 5
> \override x = 2      ; context set has 2 5, result 2
> \once\override x = 3 ; context set has 3(o) 2 5, result 3
> \revert x            ; context set has 3(o) 5, result 3
> [wait ...]           ; context set has 5 result 5

Yes, I understood what you meant.

I would propose the following:

\override -- pushes a value on the stack to remain until reverted
\once \override -- pushes a value on the stack to last only for this time
step.  Should be marked as special since it is a \once
\revert -- pulls a non-once value from the stack.
\once \revert -- pulls a non-once value from the stack, but the pull will
last only for this time step.  Because there's no way to keep the pull on
the stack, this would require something like a separate once stack.
\revert \once -- pulls a once value from the stack.  Lasts only for the
current time step (as does the corresponding \once \override that is
pulled).

I think these semantics are clearly explainable and are close to the current
performance, IIUC.  The changes are that \revert and \once \revert ignore
\once \override, and \revert \once is added to allow the reversion of a
\once \override.

Note that I still have a hard time seeing a reasonable use of \revert \once.
It's only valuable if you know that you already have a \once \override on
the stack.  But I can see that we ought to have a means to cancel anything
we can override.

 \set x = 4           ; setting the default
 \override x = 5      ; context set has 5; once set has '()
 \override x = 2      ; context set has 2 5; once set has '(); result 2
 \once\revert x       ; context set has 2 5; once set has 5; result 5
 \once\override x = 3 ; context set has 2 5; once set has 3(o),5; result 3
 \revert x            ; context set has 5; once set has 3(o),5; result 3
 [wait ...]           ; context set has 5; once set has '() result 5

Or another set of commands:

 \set x = 4           ; setting the default
 \override x = 5      ; context set has 5; once set has '()
 \override x = 2      ; context set has 2 5; once set has '(); result 2
 \once\revert x       ; context set has 2 5; once set has 5; result 5
 \revert x            ; context set has 5; once set has 4; result 4
 [wait ...]           ; context set has 5; once set has '(); result 5

Yet another:

 \set x = 4           ; setting the default
 \override x = 5      ; context set has 5; once set has '()
 \override x = 2      ; context set has 2 5; once set has '(); result 2
 \once\revert x       ; context set has 2 5; once set has 5; result 5
 \once\override x = 3 ; context set has 2 5; once set has 3(o),5; result 3
 \revert\once x       ; context set has 2 5; once set has 5; result 5
 [wait ...]           ; context set has 2 5; once set has '() result 2

I think all are predictable.

Thanks,

Carl




reply via email to

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