Métriques du dépôt
- Stars
- (1 882 étoiles)
- Métriques de merge PR
- (Merge moyen 1j 20h) (345 PRs mergées en 30 j)
Description
Problem
This proposal is coming out of my general annoyance of having to work harder than necessary to allow to customization of the same option at the stanza and the environment level. Clearly, both mechanisms are useful (see flags for example), and ideally this mechanism would work for pretty much every option as well: no_dynlink, preprocess, modes, etc.
Solution
Allow for defining all optional fields inside inside the env stanza. For example:
(env
(_
(libraries foo bar)
(no_dynlink)))
To specify the defaults for a particular stanza, we can:
(env
(_
(test
(enabled_if (= %{foo} foo)))))
Where the stanza could be test, executable, library, alias, and possibly things like buildable as well. We could also entertain setting defaults for multiple stanzas at once but that isn't necessary for a first version.
Implementation
This is the most difficult part, and I haven't yet thought about this too much in the hopes that others might suggest productive ideas. But here are some points that I'd like to mention:
-
Easiest way to implement this feature would be the parse the defaults when parsing the stanzas and inserting them into the correct
~defaultargs. But this is also wrong and will make implementing polling mode harder. -
All fields that have a default value today will basically need to be options. This is unfortunate as we'll need a layer of indirection to access the values of things once the default values have been set. I wonder if we could save ourselves from this massive refactoring by parameterizing the types appropriately - by using a functor for example.
-
The interaction of
:standardwith the default value. Should we make it official that:standardwill henceforth refer to the current default. Perhaps it should be renamed to:defaultthen? (with a deprecation cycle of course).