lilypond-user
[Top][All Lists]
Advanced

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

Re: `ly:context-property` and empty alist


From: Jean Abou Samra
Subject: Re: `ly:context-property` and empty alist
Date: Sun, 10 Jul 2022 14:03:28 +0200


> Le 10 juil. 2022 à 13:47, Werner LEMBERG <wl@gnu.org> a écrit :
> 
> 
> The documentation of `ly:context-property` is as follows.
> 
>  -- Function: ly:context-property context sym def
> 
>     Return the value for property SYM in CONTEXT.  If DEF is given,
>     and property value is ‘'()’, return DEF.
> 
> I have a use case where I want to say
> 
> ```
> \set SYM = #'()
> ```
> 
> i.e., I explicitly want to override the default DEF with an empty
> list.  How can I do that?



As a user, if the code is written that way, you have no proper solution. Yes, 
that’s a bit sad. (If the property is an alist, though, you can use a dummy 
alist with a key that is not in the set of keys the code looks for, e.g. a 
string if the alist is supposed to map numbers to something.)

As a developer, you should not write the code that way. I suspect you ask this 
in the context of your figured bass code, right? You need to put the default in 
the definition of the context in ly/engraver-init.ly so that you don’t need to 
use the third argument of ly:context-property. That also makes the default 
appear in the IR.

Jean





reply via email to

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