Paul Morris <[email protected]> writes: > 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.
Or be skipped using \default. > 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." The "once one optional argument is skipped" semantics was required to get things like \key and \mark work in a sensible manner when converted to functions from builtin syntax constructs. -- David Kastrup _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
