Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ER: ignore module directive (for the time being) #156

Open
pkoppstein opened this issue Jan 28, 2024 · 5 comments
Open

ER: ignore module directive (for the time being) #156

pkoppstein opened this issue Jan 28, 2024 · 5 comments

Comments

@pkoppstein
Copy link

Perhaps one day jaq will support modules in some shape or form.
In the meantime, it would be very helpful if jaq could at least ignore a valid jq "module" directive
to facilitate the use of otherwise-compatible jq modules.

Thanks!

@01mf02
Copy link
Owner

01mf02 commented May 21, 2024

Hi @pkoppstein, I have also planned module support for 2.0. I'm not sure, though, about whether it's worth to support the module directive, because it is only useful together with metadata, but is this actually used in the wild?

@01mf02
Copy link
Owner

01mf02 commented May 21, 2024

By the way, you might perhaps know this: If we import some JSON data in a module mod.jq, then we can use it inside this module, e.g.:

# mod.jq
import "bench" as $bench; 
def x: $bench::bench;

If we import this module, can we refer to variables such as $bench from there?

import "mod" as mod;

mod::x, # <--- this works
$mod::bench::bench # <--- this does not compile

I suppose that this is not possible, but I guessed that I'd better ask. :)

@pkoppstein
Copy link
Author

@01mf02 asked:

is this actually used in the wild?

Yes. See e.g.

@pkoppstein
Copy link
Author

@01mf02 wrote:

$mod::bench::bench

I would not expect that to work, because "mod" has been imported as a jq module, not as data.

Given your setup, however, one might reasonably expect mod::$bench::bench to work, but it doesn't (at least not yet :-)

As far as I can tell, not much thought was given to the importation of "data" (i.e. using the import directive) so I wouldn't read too much into the way things actually work. (In this regard, it's noteworthy that one can write $bench as well as the documented and somewhat mysterious $bench::bench.)

Should we request mod::$bench::bench as an "enhancement request"?

@01mf02
Copy link
Owner

01mf02 commented May 24, 2024

Thanks for giving some examples of module in the wild, @pkoppstein. I'm convinced now that I want to support this.

Also thanks for pointing out that $bench alone works as well. I thought that I had tried that and it didn't work, but I checked again just now, and it worked just fine. In that case, I think that I'd rather not support $bench::bench, but just the shorter (and more logical, IMO) $bench.

No, let's not request mod::$bench::bench; it will be enough work for me to get jaq on the same level as jq module-wise without this feature. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants