unrepl

discussing specification of an edn-based repl and its implementations.
cgrand 2017-06-09T10:05:57.368422Z

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

pesterhazy 2017-06-09T10:49:43.884155Z

cool, seems clearer to me

pesterhazy 2017-06-09T10:50:34.894162Z

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

cgrand 2017-06-09T10:52:34.916237Z

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]
&lt; [:prompt {:file "unrepl-session", :line 2, :column 1, :offset 16, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]

cgrand 2017-06-09T10:53:16.924059Z

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

dominicm 2017-06-09T10:58:28.981521Z

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

pesterhazy 2017-06-09T11:01:03.012247Z

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

cgrand 2017-06-09T12:14:06.841451Z

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

cgrand 2017-06-09T12:15:53.864139Z

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

cgrand 2017-06-09T12:18:51.901589Z

like set-source

cgrand 2017-06-09T12:58:57.480183Z

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

cgrand 2017-06-09T12:59:18.486032Z

I prefer the 1st one because it’s declarative

dominicm 2017-06-09T13:01:55.533189Z

how does the meta work?

cgrand 2017-06-09T13:10:49.684821Z

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

cgrand 2017-06-09T13:11:17.692902Z

but metadata is not canon edn

cgrand 2017-06-09T13:12:45.718078Z

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

pesterhazy 2017-06-09T13:18:11.814276Z

there could also be a macro,

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

cgrand 2017-06-09T13:18:36.822202Z

true

pesterhazy 2017-06-09T13:18:37.822392Z

not sure how easy tagged elements are to implement in cljs

cgrand 2017-06-09T13:18:51.826478Z

easy

pesterhazy 2017-06-09T13:19:03.830205Z

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

pesterhazy 2017-06-09T13:19:20.835372Z

registering custom tags I mean

pesterhazy 2017-06-09T13:19:22.835922Z

maybe I'm wrong?

cgrand 2017-06-09T13:19:45.842998Z

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

pesterhazy 2017-06-09T13:20:01.847712Z

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

cgrand 2017-06-09T13:23:23.910528Z

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

pesterhazy 2017-06-09T13:24:52.937583Z

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

cgrand 2017-06-09T13:24:57.939374Z

(or *tag-table* for specific tags)

pesterhazy 2017-06-09T13:25:24.947661Z

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

cgrand 2017-06-09T13:25:25.947979Z

this one we are in control of

cgrand 2017-06-09T13:25:41.952814Z

ah

cgrand 2017-06-09T13:28:31.005456Z

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

pesterhazy 2017-06-09T13:30:36.046673Z

hehe that could work too 🙂

pesterhazy 2017-06-09T13:31:03.055840Z

lisps are great

cgrand 2017-06-09T13:54:28.529009Z

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

cgrand 2017-06-09T13:59:27.634892Z

&gt;66
&lt; [:read {:from [1 1], :to [2 1], :offset 0, :len 3} 1]
&lt; [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session339 1), :background (unrepl.repl/background! :session339 1)}} 1]
&lt; [:eval 66 1]
&lt; [:prompt {:file “unrepl-session”, :line 2, :column 1, :offset 3, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]
&gt;(unrepl/do (unrepl.repl/set-file-line-col :session339 “foo.clj” 42 63))
&lt; [:read {:from [2 1], :to [3 1], :offset 3, :len 72} 2]
&lt; [:prompt {:file “foo.clj”, :line 42, :column 63, :offset 75, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]
&gt;*1
&lt; [:read {:from [42 63], :to [43 1], :offset 75, :len 3} 3]
&lt; [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session339 3), :background (unrepl.repl/background! :session339 3)}} 3]
&lt; [:eval 66 3]
&lt; [:prompt {:file “foo.clj”, :line 43, :column 1, :offset 78, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns user}]

dominicm 2017-06-09T14:08:29.837232Z

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

cgrand 2017-06-09T14:10:07.873432Z

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

dominicm 2017-06-09T15:03:06.091207Z

ah