[Top][All Lists]

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

Re: Having trouble understanding optional and variable amount of argumen

From: Urs Liska
Subject: Re: Having trouble understanding optional and variable amount of arguments
Date: Thu, 8 Mar 2018 17:09:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

Am 08.03.2018 um 16:52 schrieb Urs Liska:
Great! I tested it a bit and it seems to be working as intended.

I have forgotten one thing that I've only halfway completed by now: "accepted" properties without type checking. Currently, if the "strict" flag is set, only keys present in the rules are accepted. But these are also expected, so what's still missing is a way to specify rules as optional so we can filter unknown properties but still have optional ones. I've started on it and I think I know how to do it but I had to leave the computer.

I've pushed another commit to allow "accepted" but "optional" arguments.

Now with the "strict" option unknown properties are still rejected, but if a rule has 'opt as its last element the argument is ignored if it is not supplied.

This is something to test with:

\version "2.19.80"

\include "oll-core/package.ily"

#(define rules
   `((ind ,number? 5)
     (target ,symbol?)
     (accepted-arg ,fraction? opt)
     (accepted-without-type opt)
     (msg ,string? "No message given")))

testRules =
#(define-void-function (opts) (ly:context-mod?)
   (let ((props (context-mod->props rules #t opts)))
     (pretty-print props)))

\testRules \with {
  msg = "Something"
  unk = "Unknown option"
  target = something
%  accepted-arg = 7/4
%  accepted-without-type = #(ly:make-moment 3/16)


reply via email to

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