#clojure log - Jan 05 2016

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

1:11 engblom: souterrain: I am using Oracle's jdk8... And Raspbian Jessie.

2:20 TEttinger: ,(def flop [f] #(apply f (reverse %&)))

2:20 clojurebot: #error {\n :cause "Too many arguments to def"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.RuntimeException\n :message "Too many arguments to def"\n :at [clojure.lang.Util runtimeException "Util.jav...

2:21 TEttinger: ,(def flop #(apply % (reverse %&)))

2:21 clojurebot: #'sandbox/flop

2:21 TEttinger: ,(flop / 2 0)

2:21 clojurebot: 0

2:21 TEttinger: ,(flop / 2 1)

2:21 clojurebot: 1/2

2:32 Kneiva: ,(flop / 2 2 1)

2:32 clojurebot: #error {\n :cause "Unable to resolve symbol: flop in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: flop in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: flop in this co...

2:40 arrdem: Silly java q... if I have a class `c` with private method `m`, can I call `m` on other instances of `c` from an instance method of `c`?

2:42 Kneiva: I don't think so.

2:42 arrdem: I think private restricts you to your own instance, but I'm not sure.

2:44 opqdonut: I think you can

2:45 Kneiva: Actually, you can.

2:45 Interesting.

2:46 arrdem: I'd kill for `auto` in Java.

2:47 opqdonut: yep, it works

2:47 as the docs say, "Access level modifiers determine whether other classes can use a particular field or invoke a particular method. "

2:47 i.e. they work per class

2:48 Kneiva: arrdem: http://pastebin.com/WhhVRLMR

2:48 arrdem: (inc Kneiva)

2:48 rip lazybot

4:52 jonathanj: re flip: tracebacks get a bit uglier since the function is no longer called "remove" but "fn--12345" and the call stack also gets a bit weird (especially if you have an async callback to a flipped function)

5:28 justin_smith: jonathanj: good point, but the weird traceback horse is pretty much out of the barn by now too

5:29 gaqwas: hi

5:31 arrdem: welcome

6:09 justin_smith: TEttinger: you might appreciate this https://twitter.com/christianbok/status/684224785501425664/photo/1

6:13 ridcully: is there a way to give that inner anon fn a name? like `~(symbol (str f "-flipped"))?

6:14 justin_smith: ridcully: with a macro of course

6:14 I don't think it's possible in a regular function call

6:25 ,(meta (fn foo []))

6:25 clojurebot: nil

7:13 ridcully: is it intentional, that yada uses o.c/core.cache, but does not end up with a dep for it?

7:20 arrdem: IMO that's a bug, you can always :exclude it downstream if you had to.

9:07 jonathanj: justin_smith: i'm still hoping that one day "weird tracebacks" will be a campfire ghost story we tell the clojure young'ns

9:08 visof: hi guys

9:08 jonathanj: ridcully: how are you finding yada?

9:08 visof: ,(read-string "032002311333110030223330")

9:08 clojurebot: 239850788873268438744N

9:08 visof: ,(== 239850788873268438744N 032002311333110030223330)

9:08 clojurebot: true

9:08 jonathanj: ridcully: the last time i tried to read the documentation, it seemed horribly out of sync with reality

9:08 justin_smith: visof: it's base 8

9:09 visof: justin_smith: how can i make it 10 ?

9:09 jonathanj: visof: zero prefixed numbers are traditionally how you write octal

9:09 visof: make it read as it's

9:09 justin_smith: visof: by not having a 0 in front?

9:10 ,(Long/parseLong "032002311333110030223330")

9:10 clojurebot: #error {\n :cause "For input string: \"032002311333110030223330\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"032002311333110030223330\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Long parseLong "Long.jav...

9:10 justin_smith: ergh

9:10 ,(Long/parseLong (subs "032002311333110030223330" 1))

9:10 clojurebot: #error {\n :cause "For input string: \"32002311333110030223330\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"32002311333110030223330\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Long parseLong "Long.java"...

9:11 ridcully: jonathanj: well the docs have huge gaps right now - so i cant tell, if something is missing or wrong. i am fooling around with it right now

9:11 pooogles: e

9:11 visof: ,(Long/parseLong "032002311333110030223330")

9:11 clojurebot: #error {\n :cause "For input string: \"032002311333110030223330\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"032002311333110030223330\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Long parseLong "Long.jav...

9:11 ridcully: jonathanj: yesterday i put schema and catacumba together, so i thought i give yada a try too, since it does that already

9:11 visof: ,(Long/parseLong "032002311333110030223330" 10)

9:11 clojurebot: #error {\n :cause "For input string: \"032002311333110030223330\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"032002311333110030223330\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Long parseLong "Long.jav...

9:11 visof: ,(Long/parseLong "32002311333110030223330" 10)

9:11 clojurebot: #error {\n :cause "For input string: \"32002311333110030223330\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"32002311333110030223330\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Long parseLong "Long.java"...

9:11 visof: ,(Long/parseLong "32002311333110030223330" 1)

9:11 clojurebot: #error {\n :cause "radix 1 less than Character.MIN_RADIX"\n :via\n [{:type java.lang.NumberFormatException\n :message "radix 1 less than Character.MIN_RADIX"\n :at [java.lang.Long parseLong "Long.java" 408]}]\n :trace\n [[java.lang.Long parseLong "Long.java" 408]\n [sandbox$eval193 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval193 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval ...

9:11 justin_smith: visof: it's too big for a long

9:12 ridcully: long long long is to long for gcc

9:12 pooogles: (ignore my typing in the wrong shell...)

9:14 visof: how can i convert octal to base 10?

9:15 ridcully: ,017

9:15 clojurebot: 15

9:15 jonathanj: ridcully: how are you finding yada?

9:15 ridcully: ,8r17

9:15 clojurebot: 15

9:15 jonathanj: ridcully: i wanted to use it for a project i started a few weeks ago, but i felt super lost reading the documentation

9:16 visof: ,10r15

9:16 clojurebot: 15

9:16 ridcully: ,(Long/parseLong "17" 8)

9:16 clojurebot: 15

9:16 jonathanj: after wrestling with liberator and all its quirks i almost regret not trying to forge ahead with yada

9:20 ridcully: jonathanj: i can't tell yet, just playing around. i also have zero experience with the clojure web stuff - used ratpack, springboot, grails

9:24 jsabeaudry: Is it possible to subscribe to all topics of a publication in core.async ?

10:15 shiranaihito: jonathanj: i was uncomfortable with Ring for some reason i don't remember now, so i made a cute little 'web framework' on top of Jetty.. configuring an app's 'routes' looks like this: https://www.refheap.com/113377 - if you like it, i can send you some pieces of code that should help you whip up a similar thing

10:17 jonathanj: the things in vectors are 'middleware' functions that get run before the actual request handler, and can intercept requests and responses a lot like Servlet "filter chains" (or some such) in Java

10:20 jonathanj: shiranaihito: i'm kind of way too invested at the moment to change things that much, but it's interesting

10:20 Ring still doesn't really have a good async story

10:20 shiranaihito: jonathanj: oh, right.

10:20 yeah, that may be a part of why i decided to make my own thing

10:21 but i seem to recall also being annoyed or feeling constrained by something in Ring

10:21 plus i wanted to define my 'routes' in a hierarchical fashion

10:22 MJB47: have you tried bidi?

10:22 (for routing)

10:22 https://github.com/juxt/bidi

10:23 jonathanj: i'm using bidi instead of compojure for routing in my app, i think it's fantastic

10:47 alive876: +

12:20 sdegutis: Is there a tool to locate unused vars in a given project?

12:20 Thanks, good day.

12:21 noncom|2: sdegutis: don't think so, since i think it is undeterminable

12:21 anything can happen at runtime

12:21 sdegutis: For sure? Hmm.

12:21 Oh true. But let's pretend super-crazy things don't happen, and the craziest thing that can happen is that the namespace is given an alias, so instead of refering foo the programmer typed a/foo.

12:22 noncom|2: yeah, even if you could try and create something that would heave through your code and see if probably some vars are used somewhere, but again, with macros this looks like not a very straightforward thing to do...

12:22 simply too much unpredetermined behavior

12:23 idk, well, for your needs maybe simply finding a mention of the var name somewhere else in the text would do...

12:23 cursive has something like that

12:26 nanuko: does anybody have any expereince using test spies in clojure?

12:28 sdegutis: noncom|2: good point, I'll just keep using grep

12:28 That said, Emacs's grep feature makes this way easier.

12:28 noncom|2: sdegutis: they say there's also some magical helm search thing, i did not use it though

12:29 nanuko: silver searcher for emacs is great for grepping through large code bases

12:29 sdegutis: noncom|2: I didn't like helm 2 years ago, too bloated for me; I stick with ido etc

12:30 Maybe helm got less bloated since then, but more likely the opposite happened.

12:30 ido-vertical-mode makes ido helm-like enough for me.

12:30 noncom|2: ah, interesting to know. i did not try helm myself, but thanks for a review of it :)

12:30 sdegutis: :)

12:30 kwladyka: for me emacs has all the same what intellij. Only one thing what is better is way how emacs select block of text. It is not normal selection when you can't move cursor. But i don't know emacs well :)

12:30 sdegutis: Oh snap, I wrote ido-vertical-mode?

12:31 noncom|2: yes, ido-vertical-mode :)

12:33 justin_smith: jsabeaudry: iirc you can do that by having a topic function that selects every message

12:33 sdegutis: man it's gotten forked a lot since then

12:38 Yay! I just deleted my only explicit use of lazy-seq and lazy-cat in this codebase!

12:50 stvo: anyone find a good replacement for prismatic to keep up on clojure news?

12:56 noncom|2: stvo: what do you mean, a blog?

12:58 stvo: prismatic used to collect all the recent blogs and such that had to do with clojure, and put it into a feed. So i could always have fun stuff to read

12:59 maybe a date-limited google search would work just as well, haven't tried that one yet.

13:00 preschema: what's the correct way to do (:require [x.y.z :as y.z])? that is, I want to do something like [x.y.z :as z] but reference it as y.z instead of z

13:00 noncom|2: stvo: well, what about planet clojure?

13:00 justin_smith: preschema: (:require [x.y.z :as y.z])

13:00 preschema: it works exactly as you suggest

13:01 preschema: justin_smith, oh haha. thanks!

13:03 stvo: noncom|2: that looks like a good resource. will bookmark it, thanks

13:03 preschema: are there any reasonably popular wiki softwares written in clojure?

13:09 noncom|2: stvo: also https://plus.google.com/u/0/communities/103410768849046117338

13:11 stvo: noncom|2: nice. thanks

13:11 sfz-: preschema: only one I know of is https://github.com/jkk/clj-wiki

13:12 preschema: though this one seems more recent/active https://github.com/simon-brooke/smeagol

13:13 preschema: thanks... neither seems very popular unfortunately

13:40 sdegutis: Hey great job.

13:49 devth: so many abandoned/incomplete clj docker api clients. why didn't someone just wrap https://github.com/spotify/docker-client instead?

13:50 time to brush up on my java interop i guess

13:50 justin_smith: devth: maybe it doesn't even need wrapping

13:50 interop is pretty easy

13:51 devth: justin_smith: yeah i think i'll attempt using it directly

13:51 TEttinger: justin_smith: did you ping me maybe? my backlog shows nothing but I have a notification

13:51 justin_smith: yeah - my first go is to always use the API, and if that becomes a pain in the ass I look for a wrapper, and if it is absent/sucky I make a wrapper

13:51 TEttinger: oh, I linked a tweet I thought you would like

13:51 devth: cool, sounds like a good plan.

13:52 TEttinger: I knew it was the smith of noise!

13:52 justin_smith: TEttinger: https://twitter.com/christianbok/status/684224785501425664

13:52 TEttinger: really just an image of some text, which kind of sucks, but it's a cool idea

13:53 TEttinger: https://twitter.com/MrsXTN/status/684397266443079680

13:53 somebody knows what's up

13:53 justin_smith: hah

14:08 sdegutis: I wrote a function in about 35 lines of code which do the majority of what I've ever used SASS/LESS for.

14:09 The only thing it can't do yet is spit out nested media-queries as a root style containing the other styles.

14:09 The point here is that Clojure is way awesome.

14:10 And it obsoletes DSLs and sub-languages like SASS/LESS extremely easily.

14:10 justin_smith: sdegutis: have you seen garden?

14:10 sdegutis: justin_smith: Yes, I tried it out for a few days and it was just awkward and hard to use, on account of trying to mimic Hiccup.

14:11 justin_smith: k

14:11 sdegutis: justin_smith: the one I wrote is much more like Sass/Less in syntax: vectors represent a level, all strings in a level represent comma-separated selectors, all maps within a level represent attributes; placement order does not matter.

14:11 And, of course, levels can be nested.

14:12 So I can do this now: ["#my-page" {:background "blue"} [".group" ".subgroup" {:color "red"}]]

14:12 The rules feel much more intuitive to me this way.

14:13 nanuko: is it possible to redef a type?

14:14 justin_smith: nanuko: you can run deftype with a new definition. But this does not change any instances of the other type - it shadows it, it does not mutate the type.

14:14 nanuko: what are you trying to do?

14:14 nanuko: justin_smith: i’m trying to mock a type’s function for testing

14:15 justin_smith: nanuko: you don't need to do anything with the type, just use reify and define the protocols / interface that the original defined

14:16 nanuko: oh, got it

14:16 justin_smith: thanks

14:16 justin_smith: nanuko: deftypes can only have methods via an interface or protocol, so the client code should be calling methods of that interface or protocol

14:19 j-pb: what is the best way to read froma lazy seq with a timeout?

14:20 I got a potentially infinite stream of messages encoded as a seq, but want to stop if there is no new realizable message in the seq

14:21 sdegutis: nanuko: is it possible for you to just use functions rather than types? that would make it easier to "mock out" functions during tests by using dependency injection

14:21 justin_smith: j-pb: and "no new realizable message" expresses itself as an indefinite delay in getting the next item in the lazy-seq?

14:21 sdegutis: btw why doesn't component just say "dependency injection framework"?

14:21 j-pb: justin_smith: yeah

14:21 sdegutis: It took me a while to realize that's pretty much all it is.

14:21 justin_smith: j-pb: this sounds like a poor match for the lazy-seq abstraction, and a better fit for a queue or channel (eg core.async)

14:22 j-pb: it's what kafka-clj does

14:22 tbh I don't find it that bad, it would be somewhat better if seq's could use deref's timeout functionality

14:22 justin_smith: j-pb: that's not the only api kafka-clj provides. And yeah, I ditched that and just used the lower level stuff myself. It's not a good use of lazy-seq.

14:23 j-pb: justin_smith: yeah but using the simple consumer is a lot slower in my tests

14:23 justin_smith: j-pb: I'm not talking about using the simple consumer

14:23 I'm talking about using the java stuff

14:23 via interop

14:23 j-pb: yeah I know

14:23 I was erefering to the other ways kafka-clj provides ^^

14:24 justin_smith: ahh, of course

14:24 I use some of their abstractions, just the lower level ones

14:24 I end up connecting the incoming messages to a core.async channel, reading from kafka inside a core.async/thread loop

14:25 (since go isn't for IO)

14:25 j-pb: yeah, that would probably also work, I'm not the biggest fan of core.async tbh ^^

14:25 justin_smith: well, you could also use a PersistentQueue inside an atom or agent

14:26 j-pb: with threads its somewhat better, but with go loops not being first class citizens I always get go loop leaks

14:26 yeah

14:26 justin_smith: I think that fits the abstraction of a network socket comm better, and allows a tiemout deref

14:26 j-pb: yeah, seqs should support timeouts though ^^

14:27 justin_smith: once you care about timeouts you care about side effects, and that's not the domain of lazy-seqs or seqs in general

14:28 j-pb: not nessecarily though, you care about a value being ready yet right? A lazy seq might take a long time to produce values but will do so without side effects.

14:33 devth: can i use lein to eval a single expression and return the result?

14:35 momerath42: devth: not sure about passing anything back through lein, but you could always call out to a shell script with your result and then exit

14:36 devth: what i'm trying to do is spin up the clojure docker image to eval an expression

14:36 maybe it'd make more sense to run a repl inside docker then send expressions to it

14:48 nanuko: sdegutis: i’m using another library, otherwise i would be using a function

15:13 j-pb: justin_smith: https://gist.github.com/anonymous/b5e83b7c75f97236dfea

15:14 I'll just have to see if it doesn't kill performance completely D:

15:14 :D

15:15 justin_smith: j-pb: couldn't that be (deref (delay ...)) and then the caller could put it in a future or another thread if they choose?

15:16 j-pb: justin_smith: verrry good point

15:16 justin_smith: oh never mind "cannot be cast to future"

15:16 j-pb: ah damn ^^

15:17 justin_smith: j-pb: but you can do it with a promise

15:18 a promise requires a let block, but it has the advantage of the caller being able to decide if it needs to be on another thread (or how to put it on a thread)

15:18 j-pb: hrm, how would that look though?

15:19 justin_smith: (let [p (promise)] (deref (deliver p (when ...)) timeout-ms ...))

15:19 j-pb: justin_smith: I think you would still have to deliver the promise in a future to not block the calling thread

15:19 justin_smith: j-pb: deliver returns the promise

15:19 hmm

15:19 j-pb: ohh interesting

15:19 justin_smith: j-pb: testing...

15:20 j-pb: no you are right, needs a thread regardless :P

15:20 j-pb: ^^ would have been tooo nice :D

15:21 justin_smith: and once you need a thread, just use a future no need to muck with the promises

15:21 j-pb: yeah

15:41 justin_smith: it's about 75 times slower on a raw (range) however, since kafka is also pretty slow it's only 50% slower ^^

15:41 justin_smith: hah

15:41 j-pb: so I'ts actually usable :D

16:56 juanjo: hi there

16:57 arrdem: welcome

16:57 juanjo: i'm trying to compile clojure localy from the sources in github

16:57 i've already installed and and maven

16:57 but when I run ant, i get this error

16:58 Error: /Users/juanjo/clojure/build.xml:44: Unable to find a javac compiler

16:58 If i run javac -v I get

16:58 Unable to locate an executable at "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/javac" (-1)

16:58 I'm using Mac OS X

16:59 do you have any suggestion?

17:00 ystael: juanjo: what jdks have you installed on your mac?

17:01 juanjo: i think 1.7

17:01 At least there is a file /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/javac

17:01 ystael: what are your JAVA_HOME and JDK_HOME set to?

17:02 juanjo: the first to/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

17:02 the second empty

17:02 ystael: that's likely the problem

17:02 juanjo: and java -version 1.8.0_66

17:02 ystael: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home

17:03 juanjo: is there a 1.8 jdk?

17:03 ystael: yes, you can get it from oracle

17:03 juanjo: anyone works for compiling clojure?

17:04 arrdem: Clojure requires JDK better than 1.6, so 1.7 or 1.8 will work, but you should use 1.8 unless you have a reason not to.

17:04 juanjo: ok, downloading now

17:04 thanks

17:13 sdegutis: Hi.

17:13 Is there a shortcut for (for [a as b bs] [a b]) ?

17:16 ystael: sdegutis: (map vector as bs)

17:16 sdegutis: ystael: Nice!

17:16 ,(map vector [:a :b] [1 2])

17:16 clojurebot: ([:a 1] [:b 2])

17:16 sdegutis: ,(for [a [:a :b] b [1 2]] [a b])

17:16 clojurebot: ([:a 1] [:a 2] [:b 1] [:b 2])

17:16 sdegutis: ystael: not quite

17:17 arrdem: sdegutis: because you're looking for the cross product of two seqs no there isn't. for is the shortcut.

17:17 ystael: sdegutis: derp

17:18 clearly all matrices in my universe are diagonal

17:18 sdegutis: arrdem: ahh, good to know.. well, it's pretty short so I guess that's great :)

17:18 ystael: :D

17:35 Trioxin: should it be easy to use DL4J in Clojure?

17:37 sdegutis: Does (map vector xs ys) only go up to the shortest of the two?

17:37 justin_smith: yes

17:37 sdegutis: Ah yep.

17:38 docstring is explicit about it this time (woo!)

18:12 amandabb: hi i'm trying to make a clojurescript project where i read in an edn file in the same directory as my source. (:require [clojure.edn :as edn]) is giving me an error No such namespace: clojure.edn does clojurescript have edn support?

18:13 justin_smith: amandabb: I think that read-string doesn't have the eval option in cljs, so you don't need clojure.edn, you can just use cljs.core/read-string

18:14 hmm, wait, one sec, that's wrong

18:14 ianhedoesit: cljs.reader/read-string

18:14 justin_smith: ^

18:14 justin_smith: aha! thanks

18:14 yeah, that's what you use instead of clojure.edn on the cljs side

18:14 ianhedoesit: yeah, the naming changes are a bit odd.

18:16 justin_smith: amandabb: typically with cljs I end up using transit, which has a json encoding, and is reliable and fast on both the clojure and cljs side

18:16 amandabb: justin_smith: really? i kinda wanted to use edn i like it better

18:16 justin_smith: but if you have a local cljs-only app, I can see cljs.reader/read-string or cljs.reader/read being useful

18:16 amandabb: transit gives you edn

18:16 it just stores it as json in between

18:17 amandabb: im trying not to use that many external libraries

18:17 or any really

18:17 ianhedoesit: why?

18:17 justin_smith: cool

18:17 clojurebot: because that's not how macros work

18:17 justin_smith: (inc clojurebot)

18:17 ianhedoesit: lol

18:17 amandabb: well this is my first clojurescript project i want to become familiar with core stuff first

18:17 ianhedoesit: hm

18:17 justin_smith: fair

18:18 amandabb: of course you can directly use json via js/JSON

18:18 interop

18:18 but yeah, edn is nice

18:18 amandabb: if this was json there'd be sooooooooooooo many commas lol

18:18 so much prettier this way

18:19 justin_smith: ,,,,,,,,,,'(,,,,,,,,clojure,,,,,,,,,,,,does,,,,,,,,,,,,not,,,,,,,,,,,,,mind,,,,,,,,,,,,,commas,,,,,,),,,,,,,,,,,,,

18:19 clojurebot: (clojure does not mind commas)

18:19 amandabb: oh i know

18:19 im saying i have a lot of comma separated values in this data file and if it were json it wouldnt be very pretty

18:20 justin_smith: right, that is a good point

18:20 amandabb: i'm still trying to read in the file

18:20 like this? (def data (cljs.reader/read-string (slurp "data.edn")))

18:20 justin_smith: that looks about right, yeah. Or you can make a PushBackReader out of the file and use reader/read

18:21 amandabb: i'm getting TypeError: Cannot read property 'read_string' of undefined

18:21 justin_smith: amandabb: also, read-string only gives you the first form in the file

18:21 amandabb: do i need to require something?

18:21 it's just a single map variable so thats fine

18:21 justin_smith: sounds like you need (require 'cljs.reader) for that to work

18:21 amandabb: ohhh ok

18:22 weird i'm still getting the same error

18:22 justin_smith: in general you should require / use / load any namespace you use - especially since require and use only actually load the first time you do it

18:22 cljs.user=> (cljs.reader/read-string "{:a 0}") => {:a 0} - works on my local cljs

18:23 amandabb: hmmm

18:23 ill paste all my code i guess

18:23 justin_smith: that's after (require 'cljs.reader) of course

18:24 amandabb: http://pastebin.com/qjSYTCyy

18:24 justin_smith: that's not how the ns form works

18:24 inside ns you want (ns game.core (:require cljs.reader))

18:25 amandabb: oh right i missed the colon oops

18:25 thanks

18:25 justin_smith: I know it's weird, but standalone require is different from require inside ns, even though they call the same code

18:25 amandabb: yeah that is weird

18:25 justin_smith: amandabb: also the ' - not used inside ns

18:28 amandabb: justin_smith: Use of undeclared Var game.core/slurp any ideas?

18:29 does cljs not have that either?

18:29 justin_smith: hmm - you might need to call something via interop

18:29 since js usually is restricted from using the file system for security reasons

18:29 is this node?

18:30 amandabb: no i just wanted to draw in the html canvas in clojurescript. this is just a figwheel template from lein

18:32 justin_smith: amandabb: OK - js doesn't let you read files

18:32 otherwise random websites would wreck you

18:33 amandabb: hmmmmm

18:33 justin_smith: usually we send files from the server

18:33 or give the user a button to push to select a file to "upload" to the js

18:33 amandabb: i really dont want these 200 lines of data config stuff in my code though

18:33 justin_smith: then slurp it in your server code and send it to the frontend

18:33 this is where transit becomes handy btw

18:34 it can still be a data file - it's just that the js side can't do the slurping

18:34 unless the end user manually clicks a button and selects the file of course

18:34 amandabb: i dont even have a server

18:34 justin_smith: that's a problem

18:35 amandabb: js is intentionally prevented from using files

18:35 amandabb: well im just writing a little client side game in cljs

18:35 i guess ill just stick it at the bottom of my code

18:35 justin_smith: OK, then either you need a server that can send it data, or you need to embed the data into the compiled js output

18:35 that would work

18:35 amandabb: is there any way to embed it

18:35 from another file?

18:36 justin_smith: with a data url or whatever I guess, but once again, this is where we would usually use a server, but I guess it can do the same thing off the file system

18:37 amandabb: can you have multiple cljs files?

18:37 justin_smith: sure, of course

18:37 amandabb: or am i stuck with just this one core.cljs

18:37 o

18:37 justin_smith: they all get compiled into on js file

18:37 amandabb: oh ok so how can i reference one from the other? more of that require stuff?

18:37 justin_smith: exactly

18:38 you can require your code the same way you would require someone else's

18:38 amandabb: ok ill try that

19:01 domgetter: "Upgrades should be done using apt rather than Leiningen itself." but if I do "sudo apt-get install leiningen" it says "leiningen is already the newest version." I'm on Linux Mint 17.2

19:02 do I have to do something other than apt-get install or lein upgrade ?

19:02 arrdem: domgetter: yeah ignore that, uninstall leiningen via the package manager and do a local install to ~/bin using lein itself.

19:02 justin_smith: domgetter: don't use apt to install lein

19:02 arrdem: domgetter: all the lein packages are woefully out of date

19:03 justin_smith: apt's idea of "newest version" is not canonical

19:03 domgetter: if you are worried about stability, it is simple to checkout any specific lein version with "lein upgrade version.i.want"

19:03 domgetter: Okay I now understand not to use apt-get to install lein, but arrdem, if I uninstall lein, how do I do a local install "using lein itself"?

19:07 I mean, how can I use lein to do anything if I've uninstalled it? It seems contradictory

19:08 Or did I misunderstand?

19:08 ianhedoesit: domgetter: http://leiningen.org/

19:08 justin_smith: domgetter: you put it in a directory that is on you path

19:08 domgetter: it's a shell script

19:10 domgetter: justin_smith: I'm trying to understand what arrdem wrote. If I've uninstalled something, how can I use it to do anything? Is leiningen different from lein?

19:11 arrdem: lein is the name used for leinigen's binary and is shorthand because nobody gets the spelling right and typing is hard :P

19:12 most of the extensions for leiningen are named lein-*

19:12 domgetter: okay so lein and leiningen are the same thing. got it

19:13 I am still confused about your phrase "using lein itself"

19:13 is that a different "lein" than the "leiningen" to which you referred earlier in your statement?

19:13 arrdem: nope.

19:13 just follow the install directions on leiningen.org

19:13 ianhedoesit: domgetter: just follow the instructions on leiningen.org

19:13 oh

19:13 domgetter: I think there's some miscommunication

19:14 when I say "different" I mean "different thing actually on my comptuer"

19:14 not "short version of the same name for a general thing"

19:14 arrdem: that'll give you a script, the file name of which is lein, and then you just run lein bootstrap to make lein set itself up.

19:16 domgetter: what danger is there in following the instructions on leiningen.org and not uninstalling whatever apt-get installed?

19:16 (since the instructions don't say to uninstall any existing thing)

19:16 justin_smith: domgetter: wrong thing being on your path

19:16 using the wrong one by mistake

19:17 arrdem: you'll have a package manager controlled copy likely at /usr/local/bin/lein and a new copy wherever you install it two. what justin_smith said.

19:17 domgetter: okay thank you

19:17 thanks for everyone's advice, I know I can get hung up on little things.

19:18 ianhedoesit: domgetter: it seems it might be helpful for you to learn a little bit more about how apt works/what it does

19:21 amandabb: ok justin_smith im back

19:21 arrdem: So before I go and write something totally evil

19:21 Are there any existing Clojure libraries for generating Java?

19:21 amandabb: got some dinner. question: can i not just have two files both with the same namespace and then reference variables without requires and imports and such?

19:22 ianhedoesit: arrdem: I'm confused

19:22 justin_smith: amandabb: files are mapped 1:1 to namespaces

19:22 amandabb: justin_smith: at the top of two files i put (ns game.core)

19:22 justin_smith: amandabb: a namespace spread over multiple files is a bad idea (though I guess maybe technically possible)

19:23 amandabb: the way require works is that it finds the right file path based on the ns you require and loads it

19:23 it only loads one file for one require (recursively)

19:23 arrdem: amandabb: justin_smith: it is possible to have multiple namespaces in a file, as well as to spread a namespace over several files, however it is _awful_ practice.

19:23 domgetter: ianhedoesit: it's just a package manager, no?

19:23 rplaca: arrdem: I think I've heard if such a thing

19:23 amandabb: well

19:23 justin_smith: arrdem: yes

19:23 ianhedoesit: domgetter: yes, but do you know what that entails?

19:23 domgetter: why it's important and much different to get lein from leiningen.org than installing it via apt?

19:23 domgetter: ianhedoesit: it will install packages and their dependencies at the versions specified?

19:24 amandabb: i have this data file and i dont want it to be in the same file as my other cljs file. would it be that bad to just have two files both in the same namespace?

19:24 arrdem: amandabb: justin_smith: Clojure may do this in places, but Clojure isn't especially good Clojure.

19:24 amandabb: it's just a single variable

19:24 rplaca: arrdem: I don't know a reference, but if it exists ztellman would know

19:24 domgetter: ianhedoesit: I know that the versions can be old. that's fine. that's not what I was confused about

19:24 justin_smith: amandabb: you are asking for a lot of pointless hassle if you do it that way

19:24 amandabb: just give each namespace a file and visa-versa, much easier

19:24 amandabb: ok i wont then

19:25 arrdem: rplaca: yeah I think alan dipert did one a while back and I think ztellman has worked with it

19:25 amandabb: should i do a subnamespace or..?

19:25 like game.core.data?

19:25 rplaca: amandabb: actually that's not that bad - just load a file directly while you're in a different namespace

19:25 arrdem: rplaca: or at least posted it at some point.

19:25 justin_smith: amandabb: there is no such thing as a subnamespace

19:25 amandabb: >.<

19:25 i dont know what to do

19:25 arrdem: amandabb: namespaces are not higherarchical

19:25 justin_smith: amandabb: foo.bar.baz is not meanignfully a child of foo.abar

19:25 rplaca: amandabb: using load-file

19:25 amandabb: i cant use load file

19:25 i think

19:25 justin_smith: amandabb: put the stuff in a file, use require

19:25 amandabb: im using cljs

19:26 justin_smith: amandabb: what's so hard about putting each thing in an ns, and requiring what you need?

19:26 amandabb: well i was wondering if they should be the same namespace or not

19:26 justin_smith: amandabb: sorry, I shouldn't have nipicked about "sub-namespace" - it isn't a thing, but right now that doesn't really matter

19:26 amandabb: looks like most people say it's bad

19:26 rplaca: amandabb: ahh - I don't have enough experience there but I bet you could do it with some interop magic

19:26 justin_smith: rplaca: you can't load files from js, it's a security issue

19:28 futuro: amandabb: hmm...probably having a ns like foo.data where you put your defs/defonces is the easiest way

19:28 rplaca: justin_smith: good point. Maybe pre-compilation

19:30 futuro: amandabb: I'd probably give it it's own file right along side the other ns's, like I'd do with a util ns

19:30 amandabb: yeah im trying now

19:30 require syntax is still kinda confusing to me

19:30 is use deprecated?

19:31 arrdem: amandabb: pretty much

19:31 (:require [foo :refer :all]) is preferred at least

19:31 amandabb: what

19:31 er

19:31 what does the default do?

19:31 (:require [foo])

19:31 that

19:32 futuro: though personally I prefer (:require [foo.data :as data])

19:32 arrdem: by default won't refer anything, it will just ensure that the other namespace has been loaded.

19:32 http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.core/refer

19:32 amandabb: that line is a no-op?

19:32 arrdem: http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.core/ns

19:32 argh I need to add beter docs for ns

19:33 amandabb: yeah namespaces really confuse me in clojure

19:33 futuro: amandabb: you have to require a namespace before you can use it, and some of the directives in a require call give you different features

19:33 amandabb: so much stuff, as, refer, require, import, use, etc.....

19:33 most languages i've used just have one

19:35 futuro: (:require [foo]) means you can get access to function/data from the foo namespace by putting 'foo/' before whatever you want to access, and you don't have to worry about name collisions

19:35 amandabb: ns, refer, require, use, import, exclude, load, refer-clojure, exclude, only, rename.. i think that's all of it

19:36 o ok ill just do that

19:37 futuro: so you could have two functions named the same thing in two different namespaces, say foo/count and baz/count, and you can require foo inside your baz namespace, then use foo's version of count with foo/count, and baz's version of count with just count

19:37 the :as part lets you define a short name for the include

19:37 so if you have (:require [datascript.core :as d])

19:37 you could use functions from datascript.core either by prepending the function name with 'datascript.core/' (minus the quote marks)

19:38 or with 'd/'

19:38 and that's about all you need to know to get started requiring things in clojurescript

19:40 there are two more directives to bring in macros; 1) :refer-macros inside of a require call, and (:use-macros), which is alongside a :require call

19:40 but when you need macros you can look those up

19:56 {blake}: OK...got a long process...want to output stuff to the screen while it's in-process. If I do a println, it comes out, but it's too much whitespace, so I want to do a print so I can put a bunch of indicators on a single line. Like a series of ".", e.g., "....". But print appears to cache its output so as to defeat the purpose and flush adds a newline. Any thoughts?

19:57 justin_smith: {blake}: flush

19:57 ,(doc flush)

19:57 clojurebot: "([]); Flushes the output stream that is the current value of *out*"

19:57 {blake}: justin_smith: flush adds a newline, as I noted.

19:57 justin_smith: {blake}: uhh...

19:58 {blake}: justin_smith: Well, it is for me. =P

19:58 In REPL and on commandline.

19:58 justin_smith: it shouldn't, it doesn't in my repl

19:58 kingfisher.core=> (do (print "a") (print "b") (flush) (print "c")(flush)) => abcnil

19:58 {blake}: Well, it does if you forget to remove the "ln" after the "print" while experimenting, smarty-pants.

19:59 justin_smith: haha

19:59 {blake}: lol, year's off to a rip-roaring start! wooo!

19:59 (thanks)

20:03 Trioxin: is CIDER in emacs more productive than intellij idea?

20:09 ianhedoesit: Trioxin: it's entirely up to your work style.

20:13 justin_smith: Trioxin: if you don't know emacs or intellij, intellij is more normal so most people would adapt to it faster

20:13 but really some people prefer an emacs or vim, some people prefer an ide, they are different ways of doing things

20:29 Trioxin: i know intellij well. never used emacs

20:31 ianhedoesit: Trioxin: then there's no real reason to learn an editor and a language.

20:31 unless you are already familiar and productive in Clojure and want to learn emacs. or just want to learn emacs in general.

20:37 ridcully: amandabb: if its fixed data, you can slurp them in a defmacro

20:37 amandabb: not sure what you mean. do u have an example?

20:38 i got it working in any case

20:44 ridcully: amandabb: put your e.g. setup.edn in resources/, add a clj file with basically a (defmacro pre-load [filename] (slurp (io/resource filename)). in your cljs call (pre-load setup.edn)

20:57 celwell: Dear Clojurians, my (funded) startup is looking for a Clojure Engineer to work onsite at our Westwood, Los Angeles office: http://www.builtinla.com/job/clojure-engineer Please email me (chris at purpledelivery dot com) with any questions.

20:58 * justin_smith starts humming "I wanna live in los angeles" by frank black.

23:25 nowprovision: I could probably test this but thinking out loud here, when doing a backup via mysqldump is the bulk of cpu usage in the client or the server?

23:25 wrong room

Logging service provided by n01se.net