Fork me on GitHub
#unrepl
<
2017-03-31
>
cgrand07:03:04

@pesterhazy on :exception I’d like to indicate in which phase the exception occured (`read`, eval, print and wtf)

cgrand07:03:01

I think the payload of :exception is going to be a map :phase and :ex

cgrand07:03:29

Does it seem ok to you (as the 1st consumer)

pesterhazy07:03:49

I can't see how it could hurt

pesterhazy08:03:24

what would it be useful for though?

cgrand08:03:17

quickly communicating to the user if she gets an exception because of: • syntax error • application code • other (print & wtf)

pesterhazy08:03:10

the print one is interesting 🙂

pesterhazy08:03:53

one question, can I rely on the fact that each message is newline delimited?

pesterhazy08:03:13

obviously simplifies reading from the stream

cgrand08:03:07

Hum to me it was an impl detail, how does it simplify reading?

pesterhazy08:03:02

I get a callback for each chunk of data, but a message might be larger than buffer-size

pesterhazy08:03:45

so I need to try to read and see if it doesn't throw an exception to see if the message was complete

pesterhazy08:03:07

unless I'm missing something

pesterhazy08:03:17

I do think newline-delimited EDN is a good format anyway (similar to newline-delimited JSON)

pesterhazy08:03:47

JSON doesn't allow a literal newline in string, not sure about EDN

pesterhazy08:03:42

as far as I can see the EDN spec doesn't say

pesterhazy08:03:07

>>> Strings are enclosed in "double quotes". May span multiple lines.

pesterhazy08:03:15

annoying 🙂

cgrand08:03:30

EDN is very ambiguous on strings: newline may be escaped but are not required to and, officially, most control chars are not escapable (and appears as is)

pesterhazy08:03:00

can't you use octal codes?

cgrand08:03:30

only for char lits, not for strings (according to the spec + 1 issue answered by Rich)

pesterhazy08:03:40

a more unambiguous specification for EDN would be useful

cgrand08:03:47

and edn/read being forked of clojure reader is very liberal and not validating at all

cgrand08:03:01

the reader used in CLJS is tools.reader?

pesterhazy08:03:03

that complicates things of course, because complete-form? for EDN needs to actually read the string, I think

cgrand08:03:50

Accumulate chunks until read succeeds (or fail for a reason other than EOF) is currently your best approach.

pesterhazy08:03:06

yeah, will do that

pesterhazy08:03:02

which unfortunately involves catching an exception and regex'ing the Exception text 😞

cgrand08:03:03

If PushbackReader/read-char could be extended to return a special value to signify temporary end then the reader could return a continuation

cgrand08:03:11

so you would get from read (with the appropriate options), either an exception, a value or a continuation (a function expecting more input)

pesterhazy11:03:29

New version now correctly implements reading from an EDN stream

pesterhazy11:03:46

It's almost usable now!

cgrand11:03:32

@pesterhazy interrupt & bg work (with 2 connections)

cgrand12:03:49

@pesterhazy how do you intent to make elisions expand in a CLI repl client?

pesterhazy12:03:43

I was thinking of adding a client command like \cont

cgrand13:03:02

what if you have several elisions? you would expand them all? \moar

cgrand13:03:32

like (repeat (range)) 🙂

cgrand13:03:30

> (repeat (range))
< [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session238 1), :background (unrepl.repl/background! :session238 1)}} 1]
< [:eval ((0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__242)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__243)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__244)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__245)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__246)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__247)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__248)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__249)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__250)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__251)}) <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__241)}) 1]

pesterhazy13:03:39

good point... not sure how to handle this

pesterhazy13:03:00

come to think of it, a nice interface for this would be to start an ad hoc webserver from unravel and open a browser with [+] expandable elisions

cgrand13:03:35

once you are in the browser, throw a textarea in

pesterhazy13:03:37

to replace the terminal prompt?

pesterhazy13:03:59

so many possibilities...

cgrand13:03:06

so little time

pesterhazy13:03:24

one simple thing I though of was a unravel special \pprint

pesterhazy13:03:35

to pprint the last result

cgrand13:03:28

why not always pprint?

pesterhazy13:03:23

I sometimes prefer pp over pprint

pesterhazy13:03:35

it really depends on the information shown

pesterhazy13:03:44

also cloure.pprint/print-table is also a nice display format

cgrand13:03:57

what I meant is that since with unrepl you get data (and not almost readable representation), the client can pprint at will — in a GUI it could be expanded, collapsed, partialy displayed as a table etc.

pesterhazy13:03:18

right that's what I meant as well

pesterhazy13:03:24

you can even make it interactive

pesterhazy13:03:08

I have to admit, working with node (lumo) is actually quite a lot of fun

dominicm14:03:00

@pesterhazy is your client built on lumo?

richiardiandrea17:03:09

the only thing I am missing from the lumo experience is good rock solid completion, I am tempted to create a bounty

pesterhazy17:03:03

both tab completion and cljs support are on the todo list for unrepl

cgrand20:03:05

well completion is touchy because there’s no agreement on the algorithm, but in the end given the new “multiple connections” model it will just resolve to a fn call.

richiardiandrea17:03:07

@pesterhazy Just an impl detail..I would advise against tab completion only. In inf-clojure for instance it is very nice that I can call (lumo.repl/get-completions) to get them.

pesterhazy17:03:27

you mean it should be possible to directly call the fn determining possible completions?

richiardiandrea17:03:20

also, emacs can read json, but inf-clojure does not implement that at the moment

richiardiandrea17:03:56

that is why I actually call (doall (map str (lumo.repl/get-completions \"%s\"))) for lumo

pesterhazy18:03:36

Unravel now shows docs for the symbol under the cursor when you type Control-O

pesterhazy18:03:13

If you have a minute, give it a try and let me know if it works for you

richiardiandrea19:03:04

@pesterhazy sooooo, you convinced me to be your alpha tester...is the client connecting to an nrepl?

richiardiandrea19:03:31

oh sorry never mind...read the doc ! 🙂

cfleming23:03:30

WRT exception phase, isn’t that potentially confusing when an exception is thrown during printing a lazy sequence? That will probably have happened in code that the user thinks of as :eval.