[PROPOSAL] Env Defaults
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how env stanzas are parsed and how stanza defaults and ~default arguments are represented. The proposal leaves the implementation and the interaction between :standard and configured defaults unresolved, so first establish those semantics before identifying the affected code and tests. Done would mean agreed behavior for env defaults across supported stanza types, including polling mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100