Conversation
|
Nice to see work on this! have you felt the urge yet to implement most of it in jq? 😬 it was very satisfying to more or less be able to do |
It sounds tempting ... I already wondered whether there is an There is a pretty nasty restriction in jaq that makes implementing TL;DR: I currently do not know how to implement a lazy |
|
P.S.: Even if I was able to store the |
|
In any case, having |
Yesterday, I was able to create a little prototype after all that uses this approach, see #304. |
|
Nice work, i'm trying to follow along about the lifetime reasoning, think i see what the problem but my internal borrow checker is not that good :) would be great to later discuss how a more competent eval function could work, binding, isolation, provide input etc PS there is an old jq PR jqlang/jq#1843 that adds eval as part of adding more IO and co-routines support. Might be an interesting read. PS2 realised that a basic |
Yeah I know, this stuff is pretty hard to understand, and it took me several days/weeks to figure out why my pointer approach is not working. But, in a nutshell, in jaq, the output of a filter has the type
This is quite impressive! Even if I'm somewhat skeptical about the I/O features, because I like to think of jq as a (mostly) pure functional programming language after all. ;)
🤯 (about the video) I also thought about the |
This PR implements a REPL akin to fq's REPL, namely as a filter called
repl.REPL usage can be nested, as demonstrated below:
Unlike
fq, jaq does not require a--replflag, and thereplfilter can be used anywhere, not just "last in pipeline".Due to depending on
rustylinefor implementing the REPL, this requires bumping MSRV to 1.66.Limitations
fq).The indentation does not increase for nested REPLs.This has been implemented in 1e35912.def f: 1;, hit ENTER, then usefin another term. However, you can writedef f: 1; f + f. (This could be overcome by a simple heuristic that checks whether the line ends with ';' and treats this as intermediate command.) fq also has this limitation.The REPL cannot be used with inputs read from stdin. This is due to an issue with the underlying rustyline library.This has been resolved in 9cb4384.Ideas for how to overcome these limitations are welcome.
Acknowledgements
Thanks to @wader for having implemented
replin fq, which has served as primary inspiration for me.