unrepl

discussing specification of an edn-based repl and its implementations.
cgrand 2017-11-10T10:21:28.000089Z

@pesterhazy please have a look at this WIP and tell me your opinion

pesterhazy 2017-11-10T10:26:19.000065Z

looks good to me

pesterhazy 2017-11-10T10:27:37.000329Z

kind of like a connection factory

pesterhazy 2017-11-10T10:28:02.000132Z

why is it called state-machine though?

cgrand 2017-11-10T10:37:02.000212Z

I should have split the refactoring in two, got carried away

cgrand 2017-11-10T10:37:31.000176Z

so I first introduced socket-connector

cgrand 2017-11-10T10:37:52.000183Z

which is the factory stuff to create pairs

cgrand 2017-11-10T10:38:16.000089Z

oops

cgrand 2017-11-10T10:39:28.000032Z

I did split the refactoring in two but forgot the second part...

pesterhazy 2017-11-10T10:40:48.000277Z

btw there's a simple "smoke test" in scripts/tests (you need to start scripts/server in another tab)

cgrand 2017-11-10T10:41:10.000123Z

cool

cgrand 2017-11-10T10:42:47.000236Z

so the latest commit is the state machine

cgrand 2017-11-10T10:45:34.000165Z

Basically I introduce a state machine to remove the nested handlers

cgrand 2017-11-10T10:45:52.000093Z

(side effect: “started” event is not used anymore)

cgrand 2017-11-10T10:46:15.000319Z

there’s a case that should be merged with process

pesterhazy 2017-11-10T11:40:28.000142Z

could you create a WIP PR? It's easier to comment that way

cgrand 2017-11-10T12:48:10.000340Z

@pesterhazy here you go

cgrand 2017-11-10T14:22:30.000064Z

The last one is interesting because it sets the print limit for strings on the aux connection to 2^32-1.

cgrand 2017-11-10T14:23:05.000397Z

and doing so it’s possible to use completion and doc anew

cgrand 2017-11-10T14:24:08.000174Z

moreover it’s the first use of a parametrized message template

cgrand 2017-11-10T14:35:04.000277Z

@volrath and @pesterhazy so no need to piece together elided strings anymore

volrath 2017-11-10T14:39:03.000419Z

looks good

volrath 2017-11-10T14:45:49.000587Z

although I kept thinking on the tag readers for a bit after one of the questions in the talk. Someone asked if unrepl, as a protocol, could be used to work with any other language other than clj. So the answer is that basically the thing that would have to change would be these action templates, that should accomodate to the particular target language. In that case, transforming those templates to strings instead of code would make sense. For the case of edn readers it's the same: right now a reader would consume the whole message and transform it into a data structure, including the templates. If templates were to be strings, they could be then read again with the proper tag reader substitutions. This would make clients easier to implement, in the sense that they would have to rely only on edn readers instead of implementing tree traversal operations

volrath 2017-11-10T14:46:05.000563Z

which, again, i don't think is super bad, but just a thought...

volrath 2017-11-10T14:46:55.000663Z

for clj/cljs, there's already core.walk and core.zip, but for other languages, the client author might have to figure out how to traverse

volrath 2017-11-10T14:47:29.000155Z

(luckily I already made a library to traverse tree like data structures in elisp 😉 https://github.com/volrath/treepy.el)

🍀 1
dominicm 2017-11-10T14:49:30.000133Z

nrepl was intended as cross-platform too. It didn't really happen though.

cgrand 2017-11-10T14:51:05.000115Z

I tried to not close doors for xplatform but it’s not a priority, we’ll sort out details with it when/if it happens

dominicm 2017-11-10T14:51:46.000299Z

It's probably not horrible to have x-platform use edn.

volrath 2017-11-10T14:52:10.000218Z

as long as we take elisp into account, I'm good 🙂

dominicm 2017-11-10T14:53:13.000127Z

elisp server you mean?

cgrand 2017-11-10T14:53:34.000513Z

You are presuming that the edn reader would work like Clojure one and allow to specify a map of readers for read-time resolution.

volrath 2017-11-10T14:55:15.000418Z

Yes, I'm assuming edn readers should implement that feature, as being part of the specification

volrath 2017-11-10T14:55:40.000421Z

"It is envisioned that a reader implementation will allow clients to register handlers for specific tags." https://github.com/edn-format/edn#tagged-elements

cgrand 2017-11-10T14:55:45.000118Z

@dominicm if x-platform emits EDN then it can’t do that on the main connection (as it’s not EDN or Clojure) but only on tooling connections, and it requires to have a edn reader on the server

cgrand 2017-11-10T14:57:59.000617Z

A reader that would resolve no tag but preserve them all is also a possibility (see last paragraph)

volrath 2017-11-10T15:01:51.000039Z

yes. imo, that would be the second best option, to have an edn reader that won't report errors on unhandled tags and then the client's author would have to walk and replace

volrath 2017-11-10T15:02:53.000174Z

@dominicm I mean in general, as a client implementation written in elisp is of great importance for the project

1
cgrand 2017-11-10T15:03:39.000063Z

in loanguages with an impoverished data model it could even be the best option

cgrand 2017-11-10T15:05:06.000305Z

so my current idea would be to tag templates (no tag = EDN), eg #unrepl.template/brainfuck edn-as-usual and then specify how to serialize the instanciated msg to brainfuck.

volrath 2017-11-10T15:07:54.000128Z

in this case, where you put edn-as-usual, would that be a string?

volrath 2017-11-10T15:09:12.000463Z

I mean, kind of like this: [:eval {... :actions {:interrupt #unrepl.template/brainfuck "some brainfuck code"} ...}] ?

cgrand 2017-11-10T15:12:24.000461Z

if you work at the string level you need to know how to 1/ find parameters (with an escape sequence specific to each lang), 2/ escape values (and that may depend on context)

dominicm 2017-11-10T15:12:32.000296Z

vimscript one is more important :troll:

1
1
cgrand 2017-11-10T15:15:18.000405Z

edn-as-usual would be whatever makes sense

cgrand 2017-11-10T15:15:40.000123Z

substitution and serialization strategies being dependent on the template type

cgrand 2017-11-10T15:16:44.000019Z

if string interpolation (beware of accidental injection) works for your lang, go

volrath 2017-11-10T15:18:51.000163Z

Hmm what I was thinking was more of the form of: [:eval {... :actions {:interrupt "(some-more-edn #unrepl/param etc)"} ...}], so when I client edn-reads a message, the actions are still not entirely transformed to data structure, the client would have to edn-read them again with the correct tag readers (the one that would do the actual parametrization) and they would be ready to use. In case of using a reader that won't accept tag readers, client would have to traverse the action data structure and replace params

volrath 2017-11-10T15:20:00.000117Z

now if some one would want to transform an action from edn to, let's say brainfuck, I say they just edn-read the action with the correct tag readers, get their data structure, and then transform from that data structure to brainfuck

cgrand 2017-11-10T15:20:33.000152Z

I find this approach hacky and won’t change the default for it.

volrath 2017-11-10T15:21:01.000690Z

fair enough 🙂

cgrand 2017-11-10T15:22:56.000349Z

actions may be called multiple times (eg autocomplete), so parsing once, finding paths to params and then using the paths (rather walking each time) is a possibility too. Parsing and reparsing to get the benefit of a free walk is a bit wasteful imo

volrath 2017-11-10T15:24:22.000270Z

yeah good point, didn't think of that