[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I mix ly and scheme in define-music-function
From: |
Nicolas Sceaux |
Subject: |
Re: How do I mix ly and scheme in define-music-function |
Date: |
Sun, 01 Apr 2007 16:15:30 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
Maximilian Albert <address@hidden> writes:
> Nicolas Sceaux schrieb:
>
>> Here is the structure of your function:
>>
>> setAltStaff =
>> #(define-music-function (parser location style lowerOctave upperOctave)
>> (string? number? number?)
>> (if #t
>> #{ ..foo.. #})
>> #{ ..baz.. #})
>>
>> The function return the last form, which is always #{ ..baz.. #}.
>> You should write instead:
>>
>> setAltStaff =
>> #(define-music-function (parser location style lowerOctave upperOctave)
>> (string? number? number?)
>> (if condition
>> #{ ..foo.. #}
>> #{ ..baz.. #}))
>
> But is that what Kevin wants to do? As far as I understood, he wants the
> #{ ..baz.. #} part to be executed unconditionally.
Ok, I misunderstood.
The music expression that is finally inserted into the surrounding music
is what is *returned* by the music function, that is, the last form. So
the #{..foo..#} has to be conditionaly inserted in the last form,
otherwise it is lost in the void.
setAltStaff =
#(define-music-function (parser location ...)
(...)
(make-music 'SequentialMusic
'elements (list (if ..condition..
#{ ..foo.. #}
;; if condition is not fulfilled, empty music:
(make-music 'SequentialMusic))
#{ ..baz.. #})))
nicolas