-
Hi,
When this project is built and run, it prints 'Hello' and starts a REPL, but I can't run (hello) from within the REPL.
Is there a way to include a REPL in the binary and execute the project's functions within it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
How about this? (defn hello
`Evaluates to "Hello!"`
[]
"Hello!")
(def my-env (curenv))
(defn main
[& args]
(print (hello))
(repl nil nil my-env)) With that I get the following sort of result:
On a side note, I found this chapter of "Janet for Mortals" to have bits in it that helped me to understand getting this kind of thing to work. |
Beta Was this translation helpful? Give feedback.
-
@sogaiu Thanks! The method you described works perfectly. But now I've found another issue: keys like TAB, C-a, and C-k aren't working in the repl from the binary. |
Beta Was this translation helpful? Give feedback.
-
@sogaiu For reference, you're right - shell.c can't be included in the binary built with jpm and that's why key handling is missing.
And inside the janet_line_getter -> janet_line_get -> line function, I can see key handling code for keys like TAB, C-a, C-k, etc. |
Beta Was this translation helpful? Give feedback.
How about this?
With that I get the following sort of result:
On a side note, I found this chapter of "Janet for Mortals" to have bits in it that helped me to understand getting this kind of thing to work.