jank-lang / jank

The native Clojure dialect hosted on LLVM
https://jank-lang.org
Mozilla Public License 2.0
1.69k stars 50 forks source link

Add CLI REPL history persistence #85

Open jeaye opened 3 months ago

jeaye commented 3 months ago

We're using readline for the jank and native CLI REPLs. This gives us history within a session, but persisting that would be super helpful for iteration. Since we have two CLI REPLs, we should have two history files.

From what I can tell, the correct docs are here: https://tiswww.case.edu/php/chet/readline/history.html

If there's a more modern library for this, I'm open to us using that instead.


EDIT: LLVM has a LineEditor which uses libedit (Editline) behind the scenes. Example usage is here: https://github.com/llvm/llvm-project/blob/main/clang/tools/clang-repl/ClangRepl.cpp#L228-L232

If this works, we should stick with it. Otherwise, we can consider: https://github.com/antirez/linenoise

neoeleatic commented 2 months ago

I hate to be this guy, but it appears to me that there might be a licensing issue when using GNU readline in Jank. readline is GPL and in Jank's license file you state it's MPL2 and incompatible with secondary licenses. The MPL FAQ (https://www.mozilla.org/en-US/MPL/2.0/FAQ/) states in Q14 that you can't combine code in this case.

I might very well be wrong since I'm thankfully not a license expert. It's just something I noticed while browsing issues.

Some people like to use Editline (https://www.thrysoee.dk/editline/) as an alternative.

raoulmillais commented 2 months ago

The MPL v2 is GPL compatible provided the software is dual-licensed.

jeaye commented 1 month ago

I hate to be this guy, but it appears to me that there might be a licensing issue when using GNU readline in Jank. readline is GPL and in Jank's license file you state it's MPL2 and incompatible with secondary licenses. The MPL FAQ (https://www.mozilla.org/en-US/MPL/2.0/FAQ/) states in Q14 that you can't combine code in this case.

I might very well be wrong since I'm thankfully not a license expert. It's just something I noticed while browsing issues.

Some people like to use Editline (https://www.thrysoee.dk/editline/) as an alternative.

Super cool of you to call this out! Nothing to hate. Rather than changing any licensing, we can replace readline for a more flexibly licensed alternative. Thanks, also, for pointing out Editline.

I believe that LLVM has line editing functionality and we're already embedding it, so I think it makes sense to move in that direction first.

ValorZard commented 1 month ago

@jeaye what do you mean by two CLIs and two history files? all i see is the jank CLI

jeaye commented 1 month ago

We have a cpp-repl command and a repl command. The former takes in C++ code, the later takes in jank code. We can actually skip the cpp-repl command now and just do the repl command.

On October 9, 2024 10:32:26 AM PDT, Srayan Jana @.***> wrote:

@jeaye what do you mean by two CLIs and two history files? all i see is the jank CLI

-- Reply to this email directly or view it on GitHub: https://github.com/jank-lang/jank/issues/85#issuecomment-2402904717 You are receiving this because you were mentioned.

Message ID: @.***>