Fork me on GitHub
#clojure
<
2018-08-04
>
benzap01:08:46

@emccue I have a project, fair game to anyone to try and tackle

benzap01:08:32

I've been working on a project called eden, and I need to provide better error-messages. Typically when you provide an error message, you also provide a line number where the error occured, etc.

benzap01:08:05

Only problem is, the edn parser doesn't seem to have facilities for tagging lines numbers from the output

benzap01:08:06

So a good project would be to extend tools.reader.edn to allow you to read in an edn string, but return it in a form that includes this information

benzap01:08:49

I'm not 100% sure what the scope of this project is, it might be useful to make an EDN linter first

benzap01:08:20

better yet, if you could make an EDN linter, this would be a good starting point

emccue01:08:50

hmm interesting

emccue01:08:41

so basically you would just need "started form at line ..." as metadata on each form

emccue01:08:48

i dont know of any ordering guarentees on persistent maps, so it probably cant be done in post

benzap02:08:12

yeah, I definitely can't be done in post, unless the tools.reader already includes that information

ampersanda10:08:00

Is there's a way to read-line for password in command line with Clojure?

ampersanda12:08:01

@scriptor: I tried using it, but it always return JavaNullPointer

puzzler12:08:37

Is there a way to place a primitive return type on a protocol function? This doesn't work:

(defprotocol Tp
  (get-x ^long [this]))

(defrecord T1 [x]
  Tp
  (get-x [this] x))

bronsa12:08:53

there isn't

jgh15:08:42

hey guys, im running into a weird issue with a future in a unit test. I'm making doing this (roughly)

(let [fx (future (myfunc some params))
       ms (t/in-millis (t/interval (t/now) deadline))]
  (deref fx ms (timeout fx req)))
for the unit test I have deadline set to 10 minutes in the future (so it's roughly 600000 ms, and I've confirmed that). However deref is almost immediately timing out and calling the timeout function. The future is not realized at this point (checked via realized?). Anyone have any thoughts on why deref might not be blocking / is waking up too early?

jgh15:08:17

or is deref calling my timeout function before it begins waiting?

jgh15:08:47

hm, it doesnt look like timeout-val should be getting evaluated before timing out: https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L2290

jgh15:08:34

ok well using a token like :timeout and then checking for that token afterward seems to work ok....i dunno.

jgh15:08:51

should probably be documented if it's evaluating the timeout value up front, that seems unexpected.

jgh15:08:24

ah, no, im an idiot

jgh15:08:28

that's what my problem is

jgh15:08:13

i figured out what i screwed up...disregard all this, the world is ok still (other than my ego)

andy.fingerhut19:08:00

@jgh I guess you already realized that deref, being a Clojure function, eagerly evaluates all of its arguments before the function is called? If you want your expression (timeout fx req) only to be evaluated after the deref timeout has expired, you could perhaps wrap it in a (delay ...) form, for example, which would then require forcing it after deref returns, if deref returned the timeout value.

jgh19:08:31

yeah.. i sat back and used my brain a little and realized that haha

lilactown23:08:05

why doesn’t this work?

(doto (make-array SignalServiceUrl 1)
    (.push (SignalServiceUrl. ""
                              trust-store)))

lilactown23:08:18

I get

No matching method found: push for class
   [Lorg.whispersystems.signalservice.internal.configuration.SignalServiceUrl;

lilactown23:08:30

it should be calling .push on the array?

andy.fingerhut23:08:22

The [L before org. etc. is a way that the JVM uses to indicate that it is an array where the elements are of the type after the [L

andy.fingerhut23:08:51

Example: `user=> (type (make-array Object 1)) [Ljava.lang.Object;`

lilactown23:08:31

whatever, it turns out into-array is a lot easier to type