@arnetheduck @ juancarlospaco
To misquote Jamie Zawinski's Law, "every declarative config language attempts
to expand until it can read mail. Those which cannot are replaced by ones which
can."
Joking aside, declarative config style may be fine for the simplest projects,
but in more complex cases **invariably leads to DRY violations** , hacks (eg
**auto-generating them from a program** ) or **other limitations** (see
top-post: "I think it's impossible to do that in nim.cfg. Sorry.")
it essentially leads to a mini-language that keeps running into its own
limitations or has to grow new foreign syntaxes (
@if
Run
,
@end
Run
etc).
* The same debate was happening in D for dub config format, leading to
extensions, eg
[https://github.com/dlang/dub/wiki/DEP4#synopsis](https://github.com/dlang/dub/wiki/DEP4#synopsis)
(because indeed, people run into limitations)
eg:
if os="windows" compiler="dmd" {
libs "winmm"
}
else {
libs "jsw"
}
for "file" files="templates/*.tmpl" {
preBuildCommand "process-template $file"
}
Run
* likewise with tmux.cfg format, which uses a number of ugly tmux-config
specific syntax for handling conditionals and environment differences, eg:
if-shell "uname | grep -q Darwin" "set -g default-command
\"reattach-to-user-namespace -l ${SHELL}\"" " "
Run
* likewise with limitations with gitconfig which doesn't support environment
variable expansion, but only limited type conversion and path expansion, see
[https://stackoverflow.com/questions/11262010/shell-variable-expansion-in-git-config](https://stackoverflow.com/questions/11262010/shell-variable-expansion-in-git-config)
* plus so many other examples with other config formats
if you don't want complex things in your config.nims, disallow them in your
project; but usually the complexity is there for a good reason (which would be
hard to do in a nim.cfg declarative way).
# Last resort option
(note: i don't think we'd need this though) for the "corporate environments"
(whatever that means) that require declarative only, one option might be to add
a new mode to ScriptMode: `Declarative`
type
ScriptMode* {.pure.} = enum ## Controls the behaviour of the script.
Silent, ## Be silent.
Verbose, ## Be verbose.
Whatif ## Do not run commands, instead just echo
what would have been done.
Declarative ## gives error if any construct is considered
non declarative
Run