openlilylib / snippets

A place to store useful pieces of LilyPond code - custom functions, engravers, hacks, templates, examples etc.
Other
119 stars 39 forks source link

Refactor the tree data structure #139

Closed Cecca closed 7 years ago

Cecca commented 8 years ago

This refactoring aims to solve a couple of issues of the current implementation of alist-access.ily

  1. The function to get values from the tree has a not well defined behaviour for missing values: in case of missing values it will return #f, however #f is also a legitimate value, hence we cannot distinguish in wuich case we are into. (see #68)
  2. All the tree-related functions accept a parser and a location as arguments. This means that they can be used only in contexts where such values are in scope. This means that these values need to be passed down the call stack, leading to code that is, arguably, more cluttered.

The new tree module defines a well-specified public interface, where missing values are signaled without ambiguity (see the API averview in tree.scm above for a summary). Moreover, none of this module's functions relies on parser' andlocation' values, hence they are simpler to use in contexts where such values are unavailable.

I don't mean to sound rude towards @jpvoigt , I simply took the occasion offered by #68 to refactor his work addressing also issue (2) of the above list, which in my opinion simplifies the usage of the tree data structure :-)

uliska commented 8 years ago

Thank you for that work which looks like something I should welcome very much. I'll try to find an opportunity to look into it more closely ASAP

uliska commented 7 years ago

Well, this "ASAP" has terribly punched in my face, but now ...