lilypond-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] scm/music-functions.scm: Let booleans be booleans.


From: David Kastrup
Subject: Re: [PATCH] scm/music-functions.scm: Let booleans be booleans.
Date: Thu, 07 Apr 2011 16:09:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Valentin Villenave <address@hidden> writes:

> On Thu, Apr 7, 2011 at 9:27 AM, David Kastrup <address@hidden> wrote:
>> @@ -910,12 +908,10 @@ then revert skipTypesetting."
>>   (let*
>>       ((show-last (ly:parser-lookup parser 'showLastLength))
>>        (show-first (ly:parser-lookup parser 'showFirstLength))
>> -       (show-last-length (if (ly:music? show-last)
>> -                             (ly:music-length show-last)
>> -                             #f))
>> -       (show-first-length (if (ly:music? show-first)
>> -                              (ly:music-length show-first)
>> -                              #f))
>> +       (show-last-length (and (ly:music? show-last)
>> +                             (ly:music-length show-last)))
>> +       (show-first-length (and (ly:music? show-first)
>> +                              (ly:music-length show-first)))
>>        (orig-length (ly:music-length music)))
>
> This one's on me. Nice catch!

Not as bad as several (if (not (equal? whatever #f)) ...) I have seen
(there does not appear to be any system behind people picking equal? or
eq?), but I find it confusing to track complex conditionals just to
figure out how a boolean is interpreted.

In particular when some things get long, like in
(if condition twenty-line-long-sexp #f)
and you have to hunt for the lone #f at the end of the maze.

I am tempted to just push this one: I checked it reasonably carefully.
There is just one comparison with #t I simplified (something like
(equal? x #t) => x), and the term in question is set in the same
definition and can only be #t or #f.  Simplifying comparisons with #f,
in contrast, should not require cross-checking as long as the result is
used as a condition right away.

-- 
David Kastrup




reply via email to

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