lilypond-user
[Top][All Lists]
Advanced

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

Re: Two arpeggio lines (up and down) next to each other


From: David Kastrup
Subject: Re: Two arpeggio lines (up and down) next to each other
Date: Tue, 12 Oct 2021 16:45:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lukas-Fabian Moser <lfm@gmx.de> writes:

>> set! is very unidiomatic Scheme.  You could use
>> (let* ((one (begin (ly:grob-set-property! ...) (ly:arpeggio::print grob)))
>>        ((two ...
>
> Yes, I'm aware that set! isn't really the essence of what functional
> programming languages are meant for. But basically the whole idea of
> "putting the system in one state, let it do some work, then let it do
> the same work again in some other state" that this arpeggio approach
> uses seemed to force me to use a quite "imperative" style of
> programming. But it didn't occur to me that this could be encapsulated
> in a let-begin-construction, thanks for pointing that out!
>
> (By the way, would there be a guaranteed evaluation order for the
> assignments in a let (not let*)? Of course it doesn't matter in this
> case, and the double use of the combined stencil calls for a let*
> anyway, but I wondered.)

No.  "in some unspecified order":

R5RS:

 -- library syntax: let <bindings> <body>

     _Syntax:_ <Bindings> should have the form

     ((<variable1> <init1>) ...,),


     where each <init> is an expression, and <body> should be a sequence
     of one or more expressions.  It is an error for a <variable> to
     appear more than once in the list of variables being bound.

     _Semantics:_ The <init>s are evaluated in the current environment
     (in some unspecified order), the <variable>s are bound to fresh
     locations holding the results, the <body> is evaluated in the
     extended environment, and the value(s) of the last expression of
     <body> is(are) returned.  Each binding of a <variable> has <body>
     as its region.

     (let ((x 2) (y 3))
       (* x y))                             ==>  6

     (let ((x 2) (y 3))
       (let ((x 7)
             (z (+ x y)))
         (* z x)))                          ==>  35


     See also named 'let', section *note Iteration::.

 -- library syntax: let* <bindings> <body>

     _Syntax:_ <Bindings> should have the form

     ((<variable1> <init1>) ...,),


     and <body> should be a sequence of one or more expressions.

     _Semantics:_ 'Let*' is similar to 'let', but the bindings are
     performed sequentially from left to right, and the region of a
     binding indicated by '(<variable> <init>)' is that part of the
     'let*' expression to the right of the binding.  Thus the second
     binding is done in an environment in which the first binding is
     visible, and so on.

     (let ((x 2) (y 3))
       (let* ((x 7)
              (z (+ x y)))
         (* z x)))                          ==>  70

-- 
David Kastrup



reply via email to

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