This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-09
Channels
- # beginners (121)
- # boot (28)
- # cider (106)
- # clara (57)
- # cljs-dev (70)
- # cljsrn (6)
- # clojure (145)
- # clojure-dev (7)
- # clojure-italy (36)
- # clojure-russia (42)
- # clojure-spec (26)
- # clojure-uk (127)
- # clojurescript (103)
- # core-async (10)
- # cursive (56)
- # datascript (66)
- # datomic (16)
- # defnpodcast (1)
- # emacs (18)
- # events (6)
- # figwheel (1)
- # jobs (1)
- # luminus (1)
- # lumo (44)
- # off-topic (58)
- # om (17)
- # onyx (2)
- # parinfer (75)
- # pedestal (4)
- # re-frame (18)
- # ring (4)
- # ring-swagger (8)
- # rum (7)
- # spacemacs (7)
- # specter (2)
- # sql (4)
- # unrepl (39)
- # untangled (17)
- # vim (3)
- # yada (21)
cool, seems clearer to me
I like that it's explicit - it gives you a window into how unrepl works behind the scenes (with distinct read, eval, print phases)
A sample
> "hello";comment
< [:read {:from [1 1], :to [1 8], :offset 0, :len 7} 1]
< [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session337 1), :background (unrepl.repl/background! :session337 1)}} 1]
< [:eval "hello" 1]
< [:read {:from [1 8], :to [2 1], :offset 7, :len 9} nil]
< [:prompt {:file "unrepl-session", :line 2, :column 1, :offset 16, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]
Actually repl is a bit of misnomer. It should be PREPL: prompt, read, eval, print, loop 🙂
Now, how to prevent commands from messing with *1 and friends?
• tag them with some meta e.g. ^:unrepl (....)
• have commands impl set a flag
• return special value/throw specal exception
after read, before evaluating the form, look whether the meta is present, if yes don’t update \*[123e]
there could also be a macro,
(unrepl/incognito (set-source ...))
not sure how easy tagged elements are to implement in cljs
I think (?!) the normal reader doesn't support tagged literals
registering custom tags I mean
maybe I'm wrong?
that's not a custom tag, it's built in
cljs.user=> (binding [cljs.reader/*default-data-reader-fn* (atom tagged-literal)] (cljs.reader/read-string “<#C4C63FWP5|unrepl>/do bidoo”))
<#C4C63FWP5|unrepl>/do bidoo
hm true, although that doesn't affect the reader that reads .cljs source files
I'm talking about jvm-based cljs here, so I imaging self-hosted works differently
hehe that could work too 🙂
lisps are great
@pesterhazy thanks it removed a complex piece (:pre-prompt queue)
>66
< [:read {:from [1 1], :to [2 1], :offset 0, :len 3} 1]
< [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session339 1), :background (unrepl.repl/background! :session339 1)}} 1]
< [:eval 66 1]
< [:prompt {:file “unrepl-session”, :line 2, :column 1, :offset 3, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]
>(unrepl/do (unrepl.repl/set-file-line-col :session339 “foo.clj” 42 63))
< [:read {:from [2 1], :to [3 1], :offset 3, :len 72} 2]
< [:prompt {:file “foo.clj”, :line 42, :column 63, :offset 75, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]
>*1
< [:read {:from [42 63], :to [43 1], :offset 75, :len 3} 3]
< [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session339 3), :background (unrepl.repl/background! :session339 3)}} 3]
< [:eval 66 3]
< [:prompt {:file “foo.clj”, :line 43, :column 1, :offset 78, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]