-
Notifications
You must be signed in to change notification settings - Fork 445
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
Add a REPL #17
Comments
Ideally we would use libreadline, but would need an #ifdef for windows, and I'm not sure whether it'd work out-of-the-box on OSX. On the plus side, this doesn't affect libjsonnet.so. |
Thinking more about this, the only thing I know how to provide is the ability to execute complete programs on each line, i.e. the only benefit over using jsonnet -i 'foo' is avoiding typing jsonnet -i '' Imperative languages like Scala have an easier time because they have this notion of intermediate state. And in contrast with Haskell, Jsonnet does not have the notion of top-level declarations, it is not possible to parse just "local x = 4"; So given all that, do you still think it's worth it? |
Jsonnet REPL should be more featureful than the standard language itself, because it would make it more useful for experimentation and learning the language. I believe both Scala and Haskell REPLs allow you to do more than what the languages themselves provide. I agree, however, that it's a non-trivial project. As a first step, providing the same functionality as Later on, allowing the addition of top-level bindings would be an additional useful feature; I suspect as soon as there's a REPL, this will be the first feature request. :-) |
hmm... perhaps instead of REPL for exploration we can recommend that they edit a file and have it automatically executed?
In the simplest version it can be achieved with a one liner:
This is actually better in many ways than a REPL, especially a primitive one, especially for a language like jsonnet. It can be more fancy of course. You can watch for actual file changes instead of running it every 0.5 second for example (it's a bit tricky: some editors modify a file multiple times (vs code) or actually replace it with a new inode (vim), so there are some special cases). And we could use tmux to provide integrated experience, i.e. open editor pane and result pane for the user. |
Since the new website has these interactive Javascript panels, do we think a REPL or watch-based solution is still necessary? |
Upvote this issue. I would like my dev env to have a REPL, just like any other language development environment. I shouldn't need to resort to an external program (browser) if I have the language's environment set up on my device. |
Also consider the case of using the REPL to load local libsonnet files in a given dev project and playing around with an internal objects and so forth. |
The main issue with repl is that, because Jsonnet is a functional, expression-oriented language, so your every entry in repl would basically need to be a separate program. I think that an editable buffer which is evaluated as you edit it (i.e. "live preview"), is a more suitable approach to experimenting with Jsonnet than a traditional repl. So I imagine a bit more sophisticated version of the watch solution would be the best option. I mean stuff like automatically creating a temporary file and setting up "windows" for evaluation and for the input (maybe using tmux or something) and updating the output whenever the file is saved. This would allow you to experiment locally and to use any libraries and existing code you have available. What do you think @shaiguitar? |
Sure, that sounds good. As long as it's possible to load local libsonnet files and play with the REPL and the syntax alongside the project's objects. I would expect this sort of tooling to be part of the development environment. |
Fix local bind body not being desugared
For exploring Jsonnet, it would be nice to have a REPL, e.g., via
jsonnet -i
. For inspiration, I would look to Scala's REPL as an example.The text was updated successfully, but these errors were encountered: