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

Expose parse-string, parse-next and eval in core namespace #404

Closed
borkdude opened this issue Sep 12, 2020 · 0 comments
Closed

Expose parse-string, parse-next and eval in core namespace #404

borkdude opened this issue Sep 12, 2020 · 0 comments

Comments

@borkdude
Copy link
Collaborator

borkdude commented Sep 12, 2020

This preliminary API is already exposed and open for feedback. Should be considered undocumented until docstrings are added. This API should make writing REPLs in web applications etc easier.

user=> (require '[sci.core :as sci])
nil
user=> (def ctx (sci/init {}))
#'user/ctx
user=> (def form (sci/parse-string ctx "(+ 1 2 3)"))
#'user/form
user=> form
(+ 1 2 3)
user=> (sci/eval ctx form)
6
user=> (def multiple-forms "(+ 1 2 3) (+ 4 5 6)")
#'user/multiple-forms
user=> (def reader (sci/reader multiple-forms))
#'user/reader
user=> (def next-form (sci/parse-next ctx reader))
#'user/next-form
user=> next-form
(+ 1 2 3)
user=> (sci/eval ctx next-form)
6
user=> (def next-form (sci/parse-next ctx reader))
#'user/next-form
user=> next-form
(+ 4 5 6)
user=> (sci/eval ctx next-form)
15
user=> (def next-form (sci/parse-next ctx reader))
#'user/next-form
user=> next-form
:sci.core/eof
borkdude added a commit that referenced this issue Sep 13, 2020
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

1 participant