|
From: | Freeman Gilmore |
Subject: | Re: scheme with Frescobaldi |
Date: | Mon, 25 Jun 2018 23:53:55 -0400 |
On 2018-06-25 17:25, Freeman Gilmore wrote:
On Mon, Jun 25, 2018 at 9:29 AM, Urs Liska <address@hidden> wrote:
Try this file:
\version "2.19.80"
#(let
((something 'something-else))
(display something)
(newline)
(display something)(display something))
In you first example #(let...) what function does 'let' preform?
Here is the reference on `let` for Guile:
https://www.gnu.org/software/guile/manual/html_node/Local-Bi ndings.html#Local-Bindings
Without repeating verbatim what is there, `let` is a way of defining locally-scoped variables.
In the example above, `something` is being defined as `'something-else`, and it is being referenced later in the function body several times. But as a local variable, `something` is ephemeral and will no longer be valid outside of the scope of the let-block body. Consider:
%%%%
#(let
((a 1) (b 2))
(display (+ a b)) #! should output 3 !#
(let
((a b) (c 3))
(display (+ a c)) #! should output 5 !#
)
(display a) #! should output 1 !#
#!(display c)!# #! error: unbound variable c !#
)
%%%%
The inner let here redefines `a` while also defining `c`. Outside of its body, the original value of `a` is effectively restored but then `c` is no longer bound so you cannot refer to it.
Hope that helps,
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user
[Prev in Thread] | Current Thread | [Next in Thread] |