|
From: | Aaron Hill |
Subject: | Re: Procedure for set-paper-size in \paper ? |
Date: | Fri, 18 May 2018 16:36:21 -0700 |
User-agent: | Roundcube Webmail/1.3.6 |
On 2018-05-18 16:03, Thomas Morley wrote:
2018-05-19 0:36 GMT+02:00 Aaron Hill <address@hidden>: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 inwill 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
[Prev in Thread] | Current Thread | [Next in Thread] |