This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-05
Channels
- # architecture (23)
- # bangalore-clj (2)
- # beginners (93)
- # cider (27)
- # cljsjs (2)
- # clojure (66)
- # clojure-russia (9)
- # clojure-spec (28)
- # clojure-uk (3)
- # clojurescript (47)
- # cursive (2)
- # data-science (2)
- # datomic (10)
- # editors (9)
- # emacs (4)
- # figwheel (3)
- # figwheel-main (1)
- # hyperfiddle (2)
- # jobs (1)
- # nrepl (59)
- # off-topic (2)
- # onyx (10)
- # pedestal (1)
- # re-frame (13)
- # reagent (9)
- # reitit (17)
- # shadow-cljs (8)
- # tools-deps (4)
- # vim (2)
Whatcha doing with Signal? @lilactown
I've been using arrays a lot this past week, and was reminded how easy it is to shoot yourself in the foot performance-wise in Clojure when working with arrays. Make sure to always type hint your calls to aget, or your performance will plummet and you won't get any warnings to help. So be careful. To avoid these problems, I try to use core.matrix :vectorz implementation for multi-dimensional arrays of doubles, hiphip makes it more pleasant to work with primitive 1d arrays. I haven't found any decent option for multi-dimensional arrays of things other than doubles.
https://www.youtube.com/watch?v=iQwQXVM6oiY This made me understand what a tower of abstractions the clojure world is.
@ghadi they changed the way the desktop client looks yesterday and I hate it, so I decided to try and write my own 😝
I was gonna see about setting up a Clojure client first and then maybe play with a swing GUI
Yeah, seems like JavaFX doesn't have a clojure wrapper yet, or at least one that is considered mature
Honestly what I'd like is an Emacs buffer I could use to interact with it, but my elisp-fu is quite weak. So I don't know whether swing or Emacs is more unrealistic lol
I've also found that the underlying signal libs are a real PITA. So I'm going to use signal-cli, either the dbus interface or see if I can use it as a library
With the new nrepl is it possible to launch a repl and connect to an existing nrepl server?
Something like clj -Sdeps '{:deps {nrepl {:mvn/version "0.4.4"}}}' -m nrepl.cmdline --port 7888 --interactive
@thiru0130 It's considered a bit rude to @
someone who isn't already active in the channel right now. It's the middle of the night for Bozhidar.
It's Saturday evening (here on the West Coast of America) so there's probably not going to be many people around to answer your question for a while.
With clj
you can only run one set of "main options" so you can run either a -main
function in a namespace or evaluate an expression. You can't run both.
Thanks @seancorfield. I've @ 'd people several times without knowing this.
If you look at my .clojure/deps.edn
file, you'll see that starting an nREPL server can be done via the -e
main option...
I think @thiru0130 wants just a client
Ah, I read "launch a repl and connect to an existing nrepl server" to mean "and also"...
yup thx @lilactown
I wonder if you can construct a suitable -e
option to start an interactive client?
thanks @seancorfield.. I'll have to take a closer look at the code I suppose..
Looks like the run-repl
function in that namespace is private...
I suppose that has something to do with wanting to use all my favourite tools.. vim, rebel-readline, etc.
OK, so the answer is "yes, you can connect to an existing nREPL server via the client in nrepl/nrepl"... here's what I did:
seanc@DESKTOP-JMD1DBJ:~$ clj -Sdeps '{:deps {nrepl {:mvn/version "RELEASE"}}}' -e "(require,'[nrepl.cmdline,:as,c]),(#'c/run-repl,\"localhost\",7888)"
nREPL 0.4.4
Clojure 1.9.0
OpenJDK 64-Bit Server VM 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11
user=>
and that connected to an existing nREPL server running on port 7888 (which I had started in another window).Note the escaped \"
around the hostname (localhost in this case) and the commas ,
used instead of spaces (to pass through the shell script correctly).
It's relying on calling a private method nrepl.cmdline/run-repl
so it is not part of a public API.
Here's the full example... in one window:
seanc@DESKTOP-JMD1DBJ:~/clojure$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "RELEASE"} nrepl {:mvn/version "R
ELEASE"}}}' -m nrepl.cmdline --port 7888
nREPL server started on port 7888 on host 0:0:0:0:0:0:0:0 - nrepl://0:0:0:0:0:0:0:0:7888
this selects Clojure 1.10.0-alpha6; and in another window seanc@DESKTOP-JMD1DBJ:~$ clj -Sdeps '{:deps {nrepl {:mvn/version "RELEASE"}}}' -e "(require,'[nrepl.cmdline,:as,c]),(#'c/run-repl,\"localhost\",7888)"
nREPL 0.4.4
Clojure 1.9.0
OpenJDK 64-Bit Server VM 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11
user=> (clojure-version)
"1.10.0-alpha6"
user=>
so we can see the REPL client itself is running Clojure 1.9.0 but the code is run in the 1.10.0-alpha6 REPL started in the other window.@thiru0130 Is that what you're looking for?
Awesome thank you @seancorfield!!
How does one get around basic floating-point inaccuracies like (+ 10.2 0.1) => 10.29999999…
I am trying to get (10.1, 10.2, 10.3 ….) from (range 10.0 11.0 0.1), but get => (10.0 10.1 10.2 10.299999999999999 10.399999999999999 10.499999999999998 10.599999999999998 10.699999999999998 10.799999999999997 10.899999999999997 10.999999999999996)
Yes, restricting yourself to arithmetic on integers or ratios is exact.
Java also has a BigDecimal class that I believe does exact arithmetic for plus and minus, at least, although cannot of course for division.
as Andy mentioned, you can also use ratios:
=> (+ 102/10 1/10)
103/10
=> (range 10 11 1/10)
(10 101/10 51/5 103/10 52/5 21/2 53/5 107/10 54/5 109/10)
There is something that feels really wrong with getting 10.29999999 out of trying to add a single precision number though…
If you want accurate answers for bigdec, all arguments must be bigdec. Mixing arithmetic with floating point and bigdec gives approximate floating point results.
@kingcode IEEE floating point numbers store mantissa as binary number. 1/10 in decimal is easily represented exactly as 0.1, but in binary cannot be represented exactly with a finite number of digits. It is like trying to write 1/3 exactly in decimal -- you cannot.
@andy.fingerhut aw ok…I thought the larger type was infecting less precise ones, but I tried (->> (map bigdec [10 11 0.1]) (apply range)) and that worked as expected.
You can also write bigdec constants in Clojure by appending M
to the number, e.g. (+ 0.1M 0.2M)
Cool Thanks @andy.fingerhut
@thiru0130 You can also file a ticket about this and we can make it easier to connect to a running server with the built-in client. Generally the only reason why it’s not currently existing is that my assumption was that few people were using it, as it’s kind of basic compared to something like REPL-y.
What was the idea behind sync
's "transaction-flags"?
Found in the docstring: "transaction-flags => TBD, pass nil for now"
Thanks @bozhidar. The main reason I wanted this was to try and use it in conjunction with rebel-readline. Rebel doesn't work with REPL-y I guess because REPL-y needs control over manipulating the readline, just like rebel. So I thought that if I avoided REPL-y and leiningen I could use rebel. But this is not possible. I talked to Bruce and he said it won't be possible to use rebel inside an nREPL session.
So in summary I'm not going to make use of this afterall. I guess I'll still file a ticket though as it may be useful for some people? Also it seems good to have the API symmetric in this manner. I.e. we can start an nREPL server at the command-line, so we should also be able to connect to an existing one?
@thiru0130 Yeah, certainly. I was thinking of adding some --connect
flag anyways.