lilypond-user
[Top][All Lists]
Advanced

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

Re: Having trouble understanding optional and variable amount of argumen


From: Caagr98
Subject: Re: Having trouble understanding optional and variable amount of arguments
Date: Thu, 1 Mar 2018 00:02:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

I think \tempo (and a few other commands such as \repeat\alternative, \set, and 
\override) are hardcoded in the Lilypond compiler using methods not accessible 
through Scheme, so you can't make that kind of functions yourself. You can make 
functions with optional arguments, though. I think the syntax is something like 
(define-music-function (optional-int-defaults-to-4 music) ((int? 4) ly:music?) 
...).

On 02/28/18 23:54, Stefano Troncaro wrote:
> Hello everyone,
> 
> I need a little help again. I'm struggling to understand how one would make a 
> music function like \tempo, that accepts a variable number of arguments. I 
> couldn't find its definition so I couldn't look for myself.
> 
> So far I know about making lambdas that take additional arguments and store 
> the extras in a list, but this does not work in a music function (or if it 
> works I don't know how to do it). And while I could make a lambda that then 
> passes the arguments to a music function, then I can't use it with Lilypond 
> syntax, so I'm forced to put the lambda and all it's arguments between 
> parenthesis.
> 
> But \tempo doesn't require parenthesis, and the parser still understands what 
> is part of the function and what not. How would one go about writing a 
> function that behaves like this?
> 
> Thank you in advance for your help!
> Stéfano
> 
> 
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user
> 



reply via email to

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