[Top][All Lists]

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

Re: Fixes boolean/SCM confusions, part 1. (issue 4875054)

From: David Kastrup
Subject: Re: Fixes boolean/SCM confusions, part 1. (issue 4875054)
Date: Fri, 19 Aug 2011 23:23:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Han-Wen Nienhuys <address@hidden> writes:

> On Fri, Aug 19, 2011 at 6:14 AM, Bertrand Bordage
> <address@hidden> wrote:
>>> It is somewhat amusing, by the way, that Lilypond's to_boolean is
>>> required in order to let '() and #f be interpreted in the same manner.
>>> It would seem that Lisp's conflating them into `nil' is not the worst
>>> idea.
>> This also mislead me a long time ago.
> It's a historical artefact of old lilypond code that would add objects
> to lists like
>   set_property("foo", scm_cons(bla, get_property("foo"))
> for this to work, the default value of get_property() must be '().
> For booleans, it's a reasonable default to be off, so we have to
> interpret '() as false.

It is not just an old artifact.  If one wants to have a sensible
interpretation for setting a nested property when the corresponding
parent property has not been set yet, the parent property has to be
assumed to default to an empty list, or you would not be able to inject
a nested value.

Since properties can be nested arbitrarily deep and we don't have a
corresponding type system reaching below the top level, we can't infer
different defaults for unset nested properties depending on the type
(say #f for booleans, 0 for integers, '() for lists and alists).

My implementation for nested properties deals with conflicts like
(excuse the simplified syntax, I don't want to look this up all the

\override Voice x.y #7   ; x.y is 7
\override Voice.x ##f    ; x.y is nonexistent
\override Voice.x.y.z #3 ; x.y is '((z . 3))

by masking the Voice.x incompatible with nested properties and replacing
it with '() effectively while a nested property is visible.  So strictly
speaking a default of '() is not necessary since a '() will introduce
itself magically when it is mandatory.  But it still makes things less

David Kastrup

reply via email to

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