lilypond-user
[Top][All Lists]
Advanced

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

Re: Optional arguments


From: Paul Morris
Subject: Re: Optional arguments
Date: Thu, 6 Mar 2014 15:22:29 -0800 (PST)

David Kastrup wrote
> The last argument of a function is never "really" optional (the only way
> to get the default value is by writing \default).
> 
>> Relevant docs:
>> http://lilypond.org/doc/v2.19/Documentation/extending/scheme-function-definitions
> 
> The next one tells the story about optional arguments:
> <URL:http://lilypond.org/doc/v2.19/Documentation/extending/scheme-function-usage>

Ok, thanks, I see how it works now.  

So if I understand this[1] correctly...  then the way that LilyPond knows an
optional argument is being omitted is by getting an argument of a different
type in place of that optional argument (e.g. a string rather than a
number).  An optional argument has to be followed by an argument of a
different type for things to work when it is omitted.  It clearly won't work
if you have two argument of the same type in a row and try to omit the first
one as optional.  (And there's also the case of omitting several optional
arguments in a row...)

[1] "Once an optional argument predicate does not match an argument,
LilyPond skips this and all following optional arguments, replacing them
with their specified default, and ‘backs up’ the argument that did not match
to the place of the next mandatory argument. Since the backed up argument
needs to go somewhere, optional arguments are not actually considered
optional unless followed by a mandatory argument."

Thanks again,
-Paul



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Optional-arguments-tp160187p160193.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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