On 2019-03-28 3:14 pm, Thomas Morley wrote:
Am Do., 28. März 2019 um 22:22 Uhr schrieb Aaron Hill
<lilyp...@hillvisions.com>:
On 2019-03-28 2:18 pm, Valentin Villenave wrote:
> On 3/28/19, Pedro Pessoa <pedrops...@gmail.com> wrote:
>> I imagined something like:
>>
>> %%% pseudo
>> #(define var
>> (not (is-bound? var) 0))
>> %%%
>
> I’d probably probably do something like
>
> (null? (ly:parser-lookup 'var))
>
> But I’m sure there are better ways :-)
;;;;
(if (not (defined? 'foo)) (define foo 47))
;;;;
-- Aaron Hill
It's worth mentioning, the above will throw an error in guilev2:
error: GUILE signaled an error for the expression beginning here
#
(if (not (defined? 'foo)) (define foo 47))
definition in expression context, where definitions are not allowed
Probably better get used to below:
#(if (not (defined? 'foo)) (ly:parser-define! 'foo 47))
Wouldn't...
(define foo (if (defined? 'foo) foo 123))
...work? Since foo is not defined (or redefined) until the S-expression
is fully evaluated, it should be able to resolve the existing value
should it exist. This also keeps the define at the top-level.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user