Re: booleans and conditional compilation?

2016-04-01 Thread Simon Albrecht

On 01.04.2016 22:43, Simon Albrecht wrote:

you can use Guile Scheme.


LilyPond uses Guile 1.8, whose Reference Manual is here: 
.


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


Re: booleans and conditional compilation?

2016-04-01 Thread Simon Albrecht

On 01.04.2016 21:23, Johannes Waldmann wrote:

Hi.

Is there a standard way of conditional compilation,
e.g., to turn parts (on any level) of a score on and off?


The standard way is using tags, as Urs said.
But of course you can do everything you like via scheme:

\version "2.19.38"
foo = ##f
A = { c' }
B = { d' }
{
  #(if foo A B)
}

or, without music variables,

\version "2.19.38"
foo = ##f
{
  #(if foo
   #{ { c' } #}
   #{ { d' } #})
}




However that seems like a work-around because lilypond
has LISP inside and that sure has booleans and conditionals.

Oh, and I looked up "conditional" in the docs
(D. LilyPond command index) (no results).


There are no conditionals in LilyPond syntax, but you can use Guile 
Scheme. The use of it in LilyPond is explained in the Extending Manual 
<http://lilypond.org/doc/v2.19/Documentation/extending/index.html>.


HTH, Simon

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


Re: booleans and conditional compilation?

2016-04-01 Thread Urs Liska


Am 1. April 2016 21:23:17 MESZ, schrieb Johannes Waldmann 
<johannes_waldm...@web.de>:
>Hi.
>
>Is there a standard way of conditional compilation,
>e.g., to turn parts (on any level) of a score on and off?
>

Yes, look up \tag.

HTH
Urs

>From a programmer's standpoint,
>I'd want booleans, and branching, something like
>
>let foo = true % or false, somewhere at the top of the file,
>   % or even on the command line
>
>% and then (just to show the idea)
>
>...
><<  % (possibly deeply nested)
>  { c d
>  if foo then   e f  else  c d  endif
>  g }
>  { e f
>  if foo then g a else ... endif
>  }
>>>
>
>I know I can define variables,
>and then (un)comment the use of the variables,
>but that does not solve my problem
>because then I had to (un)comment all uses of one variable.
>
>I also know I can just use CPP (external preprocessor).
>However that seems like a work-around because lilypond
>has LISP inside and that sure has booleans and conditionals.
>
>Oh, and I looked up "conditional" in the docs
>(D. LilyPond command index) (no results).
>
>
>... Then I looked it up in the mailing list archive, and found
>https://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00786.html
>
>this seems to indicate that I can only switch named parts:
>$(if foo thing)  seems to require  \thing?
>Then how can I avoid this definition?
>
>
>- J.
>
>Thanks for answers on the "unfold" question.
>
>___
>lilypond-user mailing list
>lilypond-user@gnu.org
>https://lists.gnu.org/mailman/listinfo/lilypond-user

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

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


booleans and conditional compilation?

2016-04-01 Thread Johannes Waldmann
Hi.

Is there a standard way of conditional compilation,
e.g., to turn parts (on any level) of a score on and off?

>From a programmer's standpoint,
I'd want booleans, and branching, something like

let foo = true % or false, somewhere at the top of the file,
   % or even on the command line

% and then (just to show the idea)

...
<<  % (possibly deeply nested)
  { c d
  if foo then   e f  else  c d  endif
  g }
  { e f
  if foo then g a else ... endif
  }
>>

I know I can define variables,
and then (un)comment the use of the variables,
but that does not solve my problem
because then I had to (un)comment all uses of one variable.

I also know I can just use CPP (external preprocessor).
However that seems like a work-around because lilypond
has LISP inside and that sure has booleans and conditionals.

Oh, and I looked up "conditional" in the docs
(D. LilyPond command index) (no results).


... Then I looked it up in the mailing list archive, and found
https://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00786.html

this seems to indicate that I can only switch named parts:
$(if foo thing)  seems to require  \thing?
Then how can I avoid this definition?


- J.

Thanks for answers on the "unfold" question.

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


Conditional compilation

2013-01-30 Thread Jérôme Plût
I am writing some ensemble music and want the file to compile in two
modes: with -dfull, compile all individual parts; without it, compile
only the conductor part (for debugging). This is probably a FAQ but I
cannot find an answer on the site: what is the preferred way to
implement conditional compilation in Lilypond-guile? I naively tried
several variants of

\bookpart { \relative c' { c4 e g } }
#(if (ly:get-option 'full) #{
\bookpart { \relative c' { c4 d e } }
#})

but it looks like the second \bookpart is not exported to the
top-level lilypond. I can more or less reimplement \bookpart in Scheme
(why is it not already a Scheme construct anyway?) but there is
certainly a simpler solution.

Also, bonus points for shortness of solution: I am actually writing
lots of small pieces and don't mind including some Scheme in all of
them as the files already include a common header, but I would very
much like to keep the files themelves short and human-readable.

Thanks in advance!

-- 
Jérôme Plût

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


Re: Conditional compilation

2013-01-30 Thread David Kastrup
Jérôme Plût jerome.p...@normalesup.org writes:

 I am writing some ensemble music and want the file to compile in two
 modes: with -dfull, compile all individual parts; without it, compile
 only the conductor part (for debugging). This is probably a FAQ but I
 cannot find an answer on the site: what is the preferred way to
 implement conditional compilation in Lilypond-guile? I naively tried
 several variants of

 \bookpart { \relative c' { c4 e g } }
 #(if (ly:get-option 'full) #{
 \bookpart { \relative c' { c4 d e } }
 #})

 but it looks like the second \bookpart is not exported to the
 top-level lilypond. I can more or less reimplement \bookpart in Scheme
 (why is it not already a Scheme construct anyway?) but there is
 certainly a simpler solution.

 Also, bonus points for shortness of solution:

Replace the first # with $.

-- 
David Kastrup


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