lilypond-user
[Top][All Lists]
Advanced

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

Re: LSR-snippet 878: Customizing individual staff lines


From: David Kastrup
Subject: Re: LSR-snippet 878: Customizing individual staff lines
Date: Thu, 23 May 2013 11:54:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> To the author of LSR-snippet 878: Customizing individual staff lines
> (currently not approved)
> http://lsr.dsi.unimi.it/LSR/Item?id=878
> Hope you're on this list.
>
> I had a look at your file and noticed a small gap when the normal
> staff is restored. Visible with high zoom.
>
> What do you think about the modified code below.
> (In the example I've set 'layer and 'color to gain better visibility.)
>
> \version "2.14.2"
>
> #(define-public ((custom-staff-lines . rest) grob)
>
>    (define (index-cell cell dir)
>      (if (equal? dir RIGHT)
>          (cdr cell)
>          (car cell)))

That's the same as interval-bound

>    (define (index-set-cell! x dir val)
>      (case dir
>        ((-1) (set-car! x val))
>        ((1) (set-cdr! x val))))

Not necessarily schemeish in its destructive way.

>    (let* ((common (ly:grob-system grob))
>           (span-points '(0 . 0))

[...]

>             (set-cdr! span-points width)

And right here

>               (index-set-cell! span-points dir
>                                (ly:grob-relative-coordinate bound common X))

and here this breach of Scheme philosophy blows up around the code.

'(0 . 0) is a _constant_.  It will denote the _same_ global cons cell
throughout the whole code base, and it is getting written and read all
over the place.

Overwriting literally constant pairs is undefined behavior.  In Guilev1,
it will likely lead to bad surprises like values changing that you don't
expect to change, because they are still sharing the same cons cell with
code running later.  In Guilev2, it might just throw an error.

-- 
David Kastrup




reply via email to

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