On 2018-05-18 16:03, Thomas Morley wrote:
2018-05-19 0:36 GMT+02:00 Aaron Hill <lilyp...@hillvisions.com>:
On 2018-05-18 14:24, Thomas Morley wrote:
#(define (proc bool x y)
(if bool x y))
Your `proc` function does not have this behavior, as the arguments
passed in
will be evaluated before you get to the inner `if`.
Hm, then I should reword my request.
Is there a way to circumvent this behaviour?
Yes, you need to use some form of lazy evaluation. Perhaps the most
explicit way is to pass in lambdas:
%%%%
\version "2.19.81"
#(define (proc bool x y) ((if bool x y)))
\paper {
#(proc #t
(lambda () (set-paper-size "a8" 'landscape))
(lambda () (set-paper-size "a8")))
}
\markup { "Are we landscape or not?" }
%%%%
NOTE: There is an extra set of parentheses in the `proc` body in order
to evaluate the selected parameter.
Another less verbose option is to simply quote the arguments and `eval`
them as needed:
%%%%
#(define (proc bool x y)
(eval (if bool x y) (interaction-environment)))
\paper {
#(proc #t '(set-paper-size "a8" 'landscape) '(set-paper-size "a8"))
}
%%%%
NOTE: Unlike before, we *need* the extra quote for `landscape` in this
case, so there is a potential gotcha.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user