Skip to content

Commit

Permalink
Simplify the REPL eval, we don't need to split the string, just add a…
Browse files Browse the repository at this point in the history
… newline!
  • Loading branch information
Olical committed Sep 13, 2024
1 parent c8a4e42 commit d56113a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
9 changes: 1 addition & 8 deletions fnl/nfnl/repl.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
(coroutine.resume co)

(fn [input]
;; Split the input into single characters and evaluate each, one at a time.
;; This is to ensure evaluating ":foo :bar" returns both values.
(if (core.string? input)
(core.run!
(fn [char]
(coroutine.resume co char))
(core.seq (.. input "\n")))
(coroutine.resume co input))
(coroutine.resume co input)

(let [prev-eval-values results-to-return]
(set results-to-return nil)
Expand Down
2 changes: 1 addition & 1 deletion fnl/spec/nfnl/repl_spec.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(local r (repl.new))
(assert.are.same [[10 20]] (r "[10 20]"))

(assert.are.same [:foo :bar] (r ":foo :bar"))
(assert.are.same [:foo :bar] (r ":foo :bar\n"))
(assert.are.same [:foo :bar] (r "(values :foo :bar)"))

;; A nil closes the REPL and returns nil.
Expand Down
9 changes: 1 addition & 8 deletions lua/nfnl/repl.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lua/spec/nfnl/repl_spec.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d56113a

Please sign in to comment.