You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imports a module found at the given path relative to a directory in a search path as if it were included in place. [...] The module's symbols are imported into the caller's namespace as if the module's content had been included directly.
This leads us to another question: What is a symbol in jq? The scoping section has answers:
There are two types of symbols in jq: value bindings (a.k.a., "variables"), and functions.
IMO, that means that include imports the value bindings and functions that are defined in a module, but not those that the module imports. (Unfortunately, the docs do not really specify what the "module's symbols" actually are; i.e. does that include symbols that have been included themselves? But experimentation shows that jq excludes symbols that have been included. Which somehow makes sense, because otherwise, it would become quite tricky to know where a certain symbol has been actually defined.)
It is certainly debatable whether jq's behaviour is a good choice, as I can see your prelude use case. But I think that this issue should be discussed in the jq mainstream, as I try not to diverge from jq if I do not see a very compelling reason to do so (float vs. int). And at least in this particular case, the documentation is relatively clear.
TL;DR: If you would like to see your desired behaviour implemented in jaq, I advise you to propose it to jq upstream first.
Are there any plans to improve the module loading process? Currently nested modules don't seem to work how I'd like:
~/.jq-test/env.jq
:~/.jq-test/prelude.jq
:test-script.sh
:I understand if you want to go only as far as what
jq
is capable of, but I considergojq
as the more useful implementation in this case.Or maybe I'm just holding it wrong. In any case, I'd like to hear your thoughts.
The text was updated successfully, but these errors were encountered: