lilypond-devel
[Top][All Lists]
Advanced

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

Re: Issue 1320: Rewriting bar-line::print


From: David Kastrup
Subject: Re: Issue 1320: Rewriting bar-line::print
Date: Wed, 21 Mar 2012 11:03:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)

Marc Hohl <address@hidden> writes:

> Am 21.03.2012 03:20, schrieb David Kastrup:
>> Marc Hohl<address@hidden>  writes:
>>
>>> Is this a feasible approach? What am I currently doing wrong?
>>
>>> #(define bar-line-stencil-alist
>>>    '(("|" . thin-stil)
>>>      ("." . thick-stil)
>>>      ("" . empty-stil)
>>>      ))
>>>            (thin-stil (bar-line::simple-bar-line grob hair extent rounded))
>>>            (thick-stil (bar-line::simple-bar-line grob fatline extent 
>>> rounded))
>>>            (empty-stil (make-filled-box-stencil (cons 0 0) (cons 0 extent)))
>>>            (stencil (assoc-get glyph bar-line-stencil-alist empty-stil))
>>>            )
>>>
>>>           stencil
>>>           ))
>> That does not work.  stencil is set to a symbol, and that symbol is
>> never converted to a value.  When the function is being executed, the
>> _symbols_ thin-stil, stick-stil and empty-stil have long lost any
>> connection with the expressions that they were associated with while the
>> let-statement was being compiled.
>>
>> You could write (local-eval stencil (the-environment)) to let the
>> lexical environment of the function compilation linger over long enough
>> to make this work, but you would earn a reward for the unnecessarily
>> most ugly and unstable code imaginable.
>>
>> Instead, try using a case statement.  There is no need to calculate all
>> stencils and throwing most of them away.
> That's what I originally did, but my idea was to provide an easy way to
> add new stencils/bar lines without fiddling with bar-line::print.
> But if this way is a no-go, I'll use case.

thin-stil and thick-stil are internals of the function.  The way to make
this work is as an association list of functions (I don't know the
problem well enough to know what parameter list they should be getting,
but they would likely return a stencil, and so it would probably make
sense to have them get the same parameter list that a stencil callback
would) and/or finished stencils.  If the variability is likely to be
restricted to the thickness, you can provide something like

(define ((bar-line::simple-bar-line-maker thickness) grob)
  [...]
  (bar-line::simple-bar-line grob thickness extent rounded))

And then put (bar-line::simple-bar-line-maker 1.5) as the function into
the association list.

-- 
David Kastrup




reply via email to

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