lilypond-devel
[Top][All Lists]
Advanced

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

Re: Discussion: Improved Scheme interface for finding contexts


From: Jean Abou Samra
Subject: Re: Discussion: Improved Scheme interface for finding contexts
Date: Tue, 11 Jan 2022 17:35:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1

Le 09/01/2022 à 12:21, Valentin Petzel a écrit :
Hello,

https://gitlab.com/lilypond/lilypond/-/merge_requests/1126

I’ve proposed some changes to ly:context-find &c. to allow better music
function support for talking to other contexts.

Feel free to throw in your opinion about the matter and the interface.


Well, if you are looking for opinions, here is mine:
I prefer interfaces with several functions each
serving a specific purposes over interfaces with
one function serving all purposes. I find this to
make code generally easier to grasp, disambiguate
the interpretation of arguments and save remembering
the order and meaning of each argument (though you
could make them named with #: keywords if you accept
to parse the argument list yourself; I don't think
any equivalent to define*/lambda* exists on the
C++ level). So my take would be along the lines of:

(ly:context-find context name)
   (as existing)

(ly:context-find-below context name)

(ly:context-find-id context)
   (No direction: there cannot be two contexts with the
   same ID, can there? I cannot imagine a use case for
   restricting the search to parents or children.)

(ly:make-context context name)
   (Creating a context below.)

As you can see, cases that are unlikely to be useful
are not provided: finding by name everywhere, finding
by ID above or below, creating above or anywhere.
(Your mileage may vary.)

My 2 cents, and having only skimmed the code
due to lack of time.

HTH
Jean




reply via email to

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