lilypond-user
[Top][All Lists]
Advanced

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

Re: Attaching an alist to a grob


From: Urs Liska
Subject: Re: Attaching an alist to a grob
Date: Wed, 14 Jan 2015 13:56:50 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0


Am 14.01.2015 um 12:42 schrieb Mattes:
Am Mittwoch, 14. Januar 2015 12:34 CET, Urs Liska <address@hidden> schrieb:

#(define (annotation? obj)
      (and
       (list? obj)
       (every pair? obj)
       (if (assoc-ref obj "type") #t #f)
       (if (assoc-ref obj "location") #t #f)))
...  and is this just equivalent to:

#(define (annotation? obj)
       (and
        (list? obj)
        (every pair? obj)
        (assoc-ref obj "type")
        (assoc-ref obj "location")))


???
I don't think so because the result of the function would be the result
of the last expression.
assoc-ref returns the "value" to the "key", so if passed a valid object
the result of the predicate wouldn't be #t but the content of "location".
That's why I enclosed these checks in if constructs.
Richard is right, the if-clauses aren't neccessary. Scheme has the
concept "generalized" booleans, i.e. anything that isn't explicitly
false is considered to be true:

  guile> (if 42 'true 'false)

I was just trying to keep as much of your code as possible ....

  Cheers, RalfD


OK, I see.
But somehow it feels wrong that

#(display annotation? some-obj)

doesn't produce #t but the content of "location".
Should I ignore that feeling?

Urs




reply via email to

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