lilypond-user
[Top][All Lists]
Advanced

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

Re: Procedure for set-paper-size in \paper ?


From: David Kastrup
Subject: Re: Procedure for set-paper-size in \paper ?
Date: Sat, 19 May 2018 16:08:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> 2018-05-19 9:45 GMT+02:00 David Kastrup <address@hidden>:
>> Thomas Morley <address@hidden> writes:
>
> Uh, oh, another typo/oversight.
> Note to self: Don't post anything while being overtired...
>
>>
>> Now if you want to execute only conditionally, you either need to wrap
>> in lambdas or use a macro rather than a procedure:
>>
>> #(define-macro (proc bool x y)
>>    (if bool x y))
>>
>> \paper {
>>   #(if #t (set-paper-size "a8" 'landscape) (set-paper-size "a8"))
>> }

Talk about type/oversight: I don't even use the proc macro here.  You
need to write it instead of "if" in the paper block, or the example does
not make a whole lot of sense.

>> Note that this will only work with a _literal_ #f or #t as argument:
>> you'll likely want to have some actual condition evaluated at runtime,
>> like some variable name.  Then you'll need to write
>>
>> #(define-macro (proc bool x y)
>>   `(if ,bool ,x ,y))
>
> Thanks for the insights,

The last bit is a whole lot of quasiquote obviously equivalent to

(list 'if bool x y)

But in the context of macro expansions, using quasiquotes is sort of
customary for emphasizing the structure of what gets returned rather
than how it is getting built.

-- 
David Kastrup



reply via email to

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