Fork me on GitHub
#unrepl
<
2017-06-09
>
cgrand10:06:57

So, :echo is dead, long live :read!

pesterhazy10:06:43

cool, seems clearer to me

pesterhazy10:06:34

I like that it's explicit - it gives you a window into how unrepl works behind the scenes (with distinct read, eval, print phases)

cgrand10:06:34

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}]

cgrand10:06:16

two reads (one for which the id is nil: it’s the comment)

dominicm10:06:28

I love the idea of displaying inline results for a whole buffer using this system.

pesterhazy11:06:03

Actually repl is a bit of misnomer. It should be PREPL: prompt, read, eval, print, loop 🙂

cgrand12:06:06

With pervasive offset reporting a client may determine if it is up-to-date

cgrand12:06:53

so it can determine when it is safe to send “meta commands” on the main channel

cgrand12:06:51

like set-source

cgrand12:06:57

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

cgrand12:06:18

I prefer the 1st one because it’s declarative

dominicm13:06:55

how does the meta work?

cgrand13:06:49

after read, before evaluating the form, look whether the meta is present, if yes don’t update \*[123e]

cgrand13:06:17

but metadata is not canon edn

cgrand13:06:45

so a tagged element rather #unrepl/do (set-source ...)

pesterhazy13:06:11

there could also be a macro,

(unrepl/incognito (set-source ...))

pesterhazy13:06:37

not sure how easy tagged elements are to implement in cljs

pesterhazy13:06:03

I think (?!) the normal reader doesn't support tagged literals

pesterhazy13:06:20

registering custom tags I mean

pesterhazy13:06:22

maybe I'm wrong?

cgrand13:06:45

cljs.user=> #inst “2017-04-01”
#inst “2017-04-01T00:00:00.000-00:00"

pesterhazy13:06:01

that's not a custom tag, it's built in

cgrand13:06:23

cljs.user=> (binding [cljs.reader/*default-data-reader-fn* (atom tagged-literal)] (cljs.reader/read-string “<#C4C63FWP5|unrepl>/do bidoo”))
<#C4C63FWP5|unrepl>/do bidoo

pesterhazy13:06:52

hm true, although that doesn't affect the reader that reads .cljs source files

cgrand13:06:57

(or *tag-table* for specific tags)

pesterhazy13:06:24

I'm talking about jvm-based cljs here, so I imaging self-hosted works differently

cgrand13:06:25

this one we are in control of

cgrand13:06:31

so simply wrapping in (unrepl/do ...) and it’s not even a macro, it doesn’t exist

pesterhazy13:06:36

hehe that could work too 🙂

pesterhazy13:06:03

lisps are great

cgrand13:06:28

@pesterhazy thanks it removed a complex piece (:pre-prompt queue)

cgrand13:06:27

>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}]

dominicm14:06:29

Does *1 trigger re-evaluation? I thought it grabbed the result only

cgrand14:06:07

it grabs the result, the eval you see is the evaluation of “grab the value of *1”