lilypond-user
[Top][All Lists]
Advanced

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

Re: Does this 'and' construct make sense?


From: Urs Liska
Subject: Re: Does this 'and' construct make sense?
Date: Fri, 06 Mar 2015 11:18:07 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Am 06.03.2015 10:57, schrieb Richard Shann:
On Fri, 2015-03-06 at 08:25 +0100, Urs Liska wrote:
I find

%% switch on debugging.
#(if (and #t (defined? 'set-debug-cell-accesses!))
    (set-debug-cell-accesses! 5000))

(found in init.ly)

strange.
Wouldn't it be better ot simply remove the 'and' construct?
#t evaluates to #t always, isn't it?
The terminology used in the manual is "#t evaluates to true". (And,
indeed #f is the only thing that evaluates to false). I think I then
found it tricky to find where in the manual this concept (true/false)
was explained, but came to understand it applies to the semantics of
"if" and "while".

The point in this is that if an expression evaluates to "something" this "something" is considered #t with regard to conditionals but the return value is "something".

So

#(if (get-something-that-returns-an-empty-or-non-empty-list)
     (do-something)
     (do-nothing))
#(let
  ((result (get-something-that-returns-an-empty-or-non-empty-list)))
    (if result
        (display result)))

In the second case result can be passed to "if" but holds the result of the procedure that can then be used. This can also be made fruitful in 'and' or 'or' constructs that will hold a result in the end - instead of only the boolean result of the condition.


Or is this one more Scheme subtlety I don't get?
so, I don't think so - the commonest cause is where someone starts with
(if (and Debug (defined? 'xxx))

and then decides not to have a separate Debug flag and replaces it in
bulk with #t

Richard


OK, I think this means that could be removed.

Best
Urs




--
Urs Liska
address@hidden




reply via email to

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