unrepl

discussing specification of an edn-based repl and its implementations.
dominicm 2017-04-06T09:03:40.616825Z

@pesterhazy how do you handle multiple ?

pesterhazy 2017-04-06T09:35:58.092314Z

@dominicm ^^

cgrand 2017-04-06T09:49:03.276351Z

map elisions returns seq of pairs, that put the burden of maintaining context on the client... I should change that

cgrand 2017-04-06T09:49:53.287998Z

either return another map or #unrepl/map-entries ([k v] ...)

pesterhazy 2017-04-06T10:04:55.500979Z

True haven't looked at kv pairs yet

cgrand 2017-04-06T11:36:32.625718Z

Something bothers me about hash maps/sets. It’s kind of a detail but it’s very easy to mess their ordering. If the client parses map into its own maps then the print order depends on hash order of the client and not of the order (and if the map was elided it’s a bit of both).

cgrand 2017-04-06T11:42:22.695165Z

So: is asking client repls author to use a custom edn reader ok or... should maps and sets be rendered as #unrepl/map entries ?

thheller 2017-04-06T11:43:57.713606Z

@cgrand FWIW in my customFormatters I even attempt to sort the keys of a map

thheller 2017-04-06T11:44:24.718971Z

since when inspecting a map I hated the random ordering of keys

thheller 2017-04-06T11:44:42.722433Z

which is especially annoying when just looking for a specific key

cgrand 2017-04-06T11:45:26.731445Z

example problem: the user evals (into (sorted-set) (range 100)), it renders to #{0 ... 99} but the client reads that and prints #{0 32 64 96 1 33 65 ... 95}

thheller 2017-04-06T11:46:30.743873Z

yeah that is why I print the type of the collection as well, sometimes it is useful to know which collection was used

cgrand 2017-04-06T11:53:04.822411Z

print-dup territory

thheller 2017-04-06T12:00:01.908503Z

no such thing in CLJS

pesterhazy 2017-04-06T13:46:02.737883Z

yeah I ran into the fact that printing works differently in cljs than clj

pesterhazy 2017-04-06T13:46:44.753228Z

currently I extend IPrintWithWriter, which works

pesterhazy 2017-04-06T13:47:05.761218Z

are there alternative printers? maybe I should look into fipp?

cgrand 2017-04-06T14:02:49.127807Z

Printing is messy :-(

pesterhazy 2017-04-06T14:04:54.178410Z

seems like this could be implemented well in a library

pesterhazy 2017-04-06T14:05:25.190682Z

I wouldn't necessarily want to write my own printer but not sure how else to do it for map ellisions

cgrand 2017-04-06T14:06:53.224895Z

There are two things that are too often completed: walking and printing.

pesterhazy 2017-04-06T14:08:47.269029Z

>>> To achieve success in philosophy would be, to use a contemporary turn of phrase, to 'know one's way around' with respect to all these things, not in that unreflective way in which the centipede of the story knew its way around before it faced the question, 'how do I walk?', but in that reflective way which means that no intellectual holds are barred.

pesterhazy 2017-04-06T14:29:56.779251Z

@cgrand, when I close the input stream, unrepl doesn't seem to send a [:fin] message

pesterhazy 2017-04-06T14:30:19.789895Z

that would be very useful I think

pesterhazy 2017-04-06T14:30:58.806821Z

because after unrepl/start terminates, I get a regular clojure prompt again, user=>

cgrand 2017-04-06T15:04:19.663533Z

@pesterhazy can you describe steps to reproduce? I'm confused by your last sentence.

pesterhazy 2017-04-06T15:05:06.683501Z

sure

pesterhazy 2017-04-06T15:05:50.703048Z

if I run this:

cat src/unrepl/{print.clj,repl.clj} <(echo '(unrepl.repl/start)') - | nc localhost 50505

pesterhazy 2017-04-06T15:06:08.710178Z

the last lines of output are

[:unrepl/hello {:session :session330, :actions {:exit (unrepl.repl/exit! :session330), :log-eval (clojure.core/some-&gt; :session330 unrepl.repl/session :log-eval), :log-all (clojure.core/some-&gt; :session330 unrepl.repl/session :log-all), :set-source (unrepl.repl/set-file-line-col :session330 <#C4C63FWP5|unrepl>/param :unrepl/sourcename <#C4C63FWP5|unrepl>/param :unrepl/line <#C4C63FWP5|unrepl>/param :unrepl/column)}}]
[:prompt {:file "unrepl-session", :line 1, clojure.core/*warn-on-reflection* false, clojure.core/*ns* <#C4C63FWP5|unrepl>/ns unrepl.repl}]
nil
unrepl.repl=&gt;

pesterhazy 2017-04-06T15:06:26.718436Z

(I just typed ^D in nc)

pesterhazy 2017-04-06T15:06:52.729238Z

after unrepl/start finishes, the original repl takes over

pesterhazy 2017-04-06T15:07:05.734993Z

then my code tries to interpret that as EDN, which it obviously can't

pesterhazy 2017-04-06T15:08:29.771343Z

if I append (write [:fin]) to the end of unrepl.repl/start, I get a signal so I know when the EDN stream ends

pesterhazy 2017-04-06T15:10:47.829745Z

i.e. the EDN stream starts with [:unrepl/hello] and ends with [:fin]

cgrand 2017-04-06T15:23:10.147854Z

Ok got it: the original repl takes over and prints user=> as its final word before exiting too. Correct?

cgrand 2017-04-06T15:23:32.157327Z

Then yes there should be a :bye message.

pesterhazy 2017-04-06T15:38:15.531626Z

correct