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: Richard Shann
Subject: Re: Does this 'and' construct make sense?
Date: Fri, 06 Mar 2015 10:34:09 +0000

On Fri, 2015-03-06 at 11:18 +0100, Urs Liska wrote:
> 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

no, it isn't "considered to be #t". It is considered to be true (that
is, it is considered not to be #f). You can tell this by testing

(eq? expr #t) 

will be false if expr is anything true except for #t which is one of the
(many) true things in Scheme.


>  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.

certainly!

Richard





reply via email to

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