lilypond-user
[Top][All Lists]
Advanced

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

Re: Anyone up for a Scheme code review?


From: David Nalesnik
Subject: Re: Anyone up for a Scheme code review?
Date: Tue, 28 Apr 2015 19:41:06 -0500

Hi Steven,

On Tue, Apr 28, 2015 at 5:40 PM, Steven Weber <address@hidden> wrote:

I finally managed to hack together highlighting code for key signatures that does what I want (ignores the initial key signature, and only highlights key signatures at the beginning of the line if it was broken across the line).


But what about the break at measure 14?  (I like the highlighting of both.)
 

 

But, my code feels…inelegant.  In particular, I’m using a global variable


Why not move the binding into the let-block of the engraver?  A cursory look isn't showing any reason for a global variable, and making it local works with your example.
 

and I had to define my own alist equality function because I couldn’t find one with google.  Can one of you Scheme gods take a look at what I’m doing and see if there’s anything obvious I could be doing better?


You write:

 #(define (alist-equal? l r)
   (cond 
    ;; Both items are null - this is equal
    ((and (null? l) (null? r)) #t)
    ;; Left is null and right isn't is not equal
    ((and (null? l) (not (null? r))) #f)
    ;; Left is not null and right is is not equal
    ((and (not (null? l)) (null? r)) #f)
    ;; Check for equality of the items
    ((not (equal? (car l) (car r))) #f)
    ;; Recurse to the next item
    (else (alist-equal? (cdr l) (cdr r)))))

Why not just:

#(define (alist-equal? l r)
   (equal? l r))


 

And apologies for the formatting.  Scheme and I do not get along.  Counting parens drives me crazy, so I format it like I do any other language that uses braces instead of parens (expect lots and lots of extra white space!)

 


Frescobaldi highlights matching parentheses, and it will automatically indent for you.  OK, well, the default reduces your whitespace dramatically, but weigh that against super-long lines!  Possibly you can configure the indent.

HTH,
David. 


reply via email to

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