Fork me on GitHub
#clojure
<
2017-07-01
>
Alex Miller (Clojure team)01:07:34

It's ok to validate things outside of spec too

seancorfield02:07:21

@hmaurer Clojure 1.9 is stable enough for production use as far as I’m concerned — my company has Clojure 1.9 Alpha 17 in heavy production usage right now.

pc12305:07:07

does anyone have recommendations on a good job scheduling library for Clojure? checked out Quartzite earlier, but had some difficulty getting it to play nicely with my loading of env vars from mount

jumar08:07:35

Should I follow kibit's recommendations?

Consider using:
  (vec costs)
instead of:
  (into [] costs)
Is there any real difference between vec and into []? vec is a bit shorter and maybe more explicit but I've also seen into [] being used a lot. I've found following question on SO: https://stackoverflow.com/questions/12044181/into-or-vec-converting-sequence-back-to-vector-in-clojure but I don't think the different behavior for small arrays mentioned in answer is true

jumar08:07:28

I did following experiment:

(def my-a (int-array [1 2 3]))

(def my-v (vec my-a))
my-v
;=> [1 2 3]

(aset my-a 1 10))
(java.util.Arrays/toString my-a)
;=> "[1, 10, 3]"

;=> my-v
[1 2 3]

noisesmith08:07:50

@jumar it can't alias an int-array

noisesmith08:07:55

+user=> (def a (into-array [1 2 3]))
#'user/a
+user=> (def v (vec a))
#'user/v
+user=> a
#object["[Ljava.lang.Long;" 0x5c089b2f "[Ljava.lang.Long;@5c089b2f"]
+user=> (seq a)
(1 2 3)
+user=> v
[1 2 3]
+user=> (aset a 1 42)
42
+user=> v
[1 42 3]

noisesmith09:07:39

as you see, it can alias a Long array

jumar09:07:11

I see, any thoughts on my original question? 😉

noisesmith09:07:49

if the collection might in some cases already be a vector, or it's an array that won't be aliased, use vec

noisesmith09:07:21

if you already have a vector and need to add to it, or if you need to do some transformation like mapping or filtering as you add things, use into

noisesmith09:07:47

if none of those conditions apply, it doesn't matter which you use

noisesmith09:07:32

when I mention transforms here, I'm talking about using the transducing arg to into btw

jumar09:07:03

Wonderful, thank you very much for this piece of advice.

diginomad16:07:56

Hello,I am new here and to Clojure too,Is it okay if I post some code here to resolve an issue?

joshjones16:07:03

yes @diginomad, you can ask it here -- there is also a #beginners channel that you may find helpful if your issue is not resolved here

diginomad16:07:10

Hi @joshjones, thank you for the response

diginomad16:07:36

I have been exploring core.async

diginomad16:07:31

the gophers daisy chain whispering

diginomad16:07:44

and am stuck someplace

diginomad16:07:50

help would be appreciated

joshjones16:07:46

i would recommend you ask in #core-async -- providing some details as to how specifically you are stuck

isaac17:07:13

How to make class self as type hint for field of deftype?

(deftype Foo [^some.ns.Foo parent])

PB22:07:00

Has anyone see this error when trying to start your repl: Exception in thread "main" java.net.SocketException: Protocol family unavailable, compiling:?

noisesmith22:07:25

is this something that happens in every project, or only when loading a specific project's code?

noisesmith22:07:09

sometimes I find that if I don't use lein's init-ns or main features, and just call require from user, the error is more informative

noisesmith22:07:51

for example

$ lein run -m clojure.main
user=> (require 'my.ns)

noisesmith22:07:09

then I get a better idea of what code is blowing up

kingcode23:07:56

Does anyone know how to create a parameterized type instance (java interop)? E.g. new MyPType<Integer>

noisesmith23:07:48

@kingcode that doesn't actually exist

kingcode23:07:10

OK…because param types are only compile time, correct?

noisesmith23:07:12

it's a thing the java compiler pretends is there, but isn't actually a thing in the relevant bytecode

noisesmith23:07:01

@kingcode right, type erasure (with the exception that you can use reflection to find the generic type - but that's not actually as relevant as one might think)

noisesmith23:07:25

the important thing is the code just works without it

kingcode23:07:56

True..I should have known 🙂 thx