composing Scheme identifiers?

2014-03-02 Thread Simon Albrecht

Hello,

I currently work on a mass setting by Palestrina. The music is stored in 
variables sopranoK, altoK, tenorK, bassK, sopranoVerseK, …, sopranoG, 
altoG, etc. etc. for the different parts and movements. Now since I need 
a separate \score block for each movement, but these score blocks will 
all be identical except for the single letter appended to the variables, 
I thought it would be elegant to define a music function like (in short)

scoreSetup =
#(define-music-function
(parser location letter)
(string?)
#{
\score {
\new Staff = bassus \with { instrumentName = bassus }
% this is supposed to give the same result as @code{\bassK} for example…
#(string-identifier (string-append bass $letter))
}
#}
)

Unfortunately, there is no such procedure like string-identifier in 
Scheme and string-symbol doesn’t work. Can you help me (as a newbie in 
Scheme) to find a working solution?

Thanks in advance,

Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: composing Scheme identifiers?

2014-03-02 Thread David Kastrup
Simon Albrecht simon.albre...@mail.de writes:

 Hello,

 I currently work on a mass setting by Palestrina. The music is stored
 in variables sopranoK, altoK, tenorK, bassK, sopranoVerseK, …,
 sopranoG, altoG, etc. etc. for the different parts and movements. Now
 since I need a separate \score block for each movement, but these
 score blocks will all be identical except for the single letter
 appended to the variables, I thought it would be elegant to define a
 music function like (in short)
 scoreSetup =
 #(define-music-function
 (parser location letter)
 (string?)
 #{
 \score {
 \new Staff = bassus \with { instrumentName = bassus }
 % this is supposed to give the same result as @code{\bassK} for example…
 #(string-identifier (string-append bass $letter))
 }
 #}
 )

 Unfortunately, there is no such procedure like string-identifier in
 Scheme and string-symbol doesn’t work. Can you help me (as a newbie
 in Scheme) to find a working solution?

$(ly:parser-lookup parser (string-symbol (string-append bass letter)))

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: composing Scheme identifiers?

2014-03-02 Thread Paul Morris
Simon Albrecht-2 wrote
 scoreSetup =
 #(define-music-function
 (parser location letter)
 (string?)
 #{
 \score {
 \new Staff = bassus \with { instrumentName = bassus }
 % this is supposed to give the same result as @code{\bassK} for example…
 #(string-identifier (string-append bass $letter))
 }
 #}
 )

I recently tried a music function like this.  I wanted it to return a score,
but I always got:

  error: music function cannot return #Score

I wonder whether music functions can return a score at all, or whether I'm
just doing something wrong? Here's a simple example that produces that error
for me:

\version 2.18.0
scoreSetup =
#(define-music-function
  (parser location letter)
  (string?)
  #{
\score {
  { a b c d }
}
  #})
\scoreSetup K



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/composing-Scheme-identifiers-tp160030p160040.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: composing Scheme identifiers?

2014-03-02 Thread David Kastrup
Paul Morris p...@paulwmorris.com writes:

 Simon Albrecht-2 wrote
 scoreSetup =
 #(define-music-function
 (parser location letter)
 (string?)
 #{
 \score {
 \new Staff = bassus \with { instrumentName = bassus }
 % this is supposed to give the same result as @code{\bassK} for example…
 #(string-identifier (string-append bass $letter))
 }
 #}
 )

 I recently tried a music function like this.  I wanted it to return a score,
 but I always got:

   error: music function cannot return #Score

Ah, overlooked that one.

 I wonder whether music functions can return a score at all,

No, use define-scheme-function for that.  With regard to using that
scheme function as a score replacement then, it may conceivably work
only with recent versions of 2.19.  I think that I pulled some commits
for that purpose into 2.18, but that will only get available with 2.18.2
I think.

It's not really all that important as you can always leave out the
\score, and then do use a music function and \score { \scoreSetup ... }
as long as what you want in \scoreSetup does not include output or
header definitions.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: composing Scheme identifiers?

2014-03-02 Thread Paul Morris
David Kastrup wrote
 I wonder whether music functions can return a score at all,
 
 No, use define-scheme-function for that.  With regard to using that
 scheme function as a score replacement then, it may conceivably work
 only with recent versions of 2.19.  I think that I pulled some commits
 for that purpose into 2.18, but that will only get available with 2.18.2
 I think.

Ok, thanks!  I tried it as a scheme function with 2.19.2 and everything
worked fine.  


 It's not really all that important as you can always leave out the
 \score, and then do use a music function and \score { \scoreSetup ... }
 as long as what you want in \scoreSetup does not include output or
 header definitions.

That's true, but it's still nice to be able to do it (and learn how to do
it).

Thanks again,
-Paul




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/composing-Scheme-identifiers-tp160030p160056.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user