#clojure log - Aug 06 2015

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

1:05 sdegutis: Help, I need Clojure help:

1:05 I need to figure out how to Clojure this:

1:05 ._ o o

1:05 \_`-)|_

1:05 ,"" \

1:05 ," ## | ಠ ಠ.

1:05 ," ## ,-\__ `.

1:05 clojurebot: ""

1:05 sdegutis: ," / `--._;)

1:05 clojurebot: #<RuntimeException java.lang.RuntimeException: Unsupported escape character: \_>

1:05 #<RuntimeException java.lang.RuntimeException: EOF while reading string>

1:05 sdegutis: ," ## /

1:05 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

1:05 sdegutis: ," ## /

1:05 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

1:05 #<RuntimeException java.lang.RuntimeException: EOF while reading string>

1:07 sdegutis: How can be done?

1:08 scriptor: I'm sorry, what?

1:08 Kneiva: sdegutis: put that in a file, slurp it, profit

1:08 scriptor: ^

1:09 sdegutis: Thanks I will try to store it in long_horse.txt

1:09 amalloy: how am i doing

1:10 amalloy: sdegutis: no more giant pastes of ascii art, please

1:11 sdegutis: amalloy: Phew, thanks.

1:12 Okay I think it's ready.

1:12 ,(slurp "long_horses.txt")

1:12 clojurebot: #error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkRead nil -1]\n [java.io.FileInputStream <init> "FileInp...

1:12 sdegutis: The file seems to be here, I don't understand.

1:28 Thanks, regards

4:37 tgoossens: How to create a new exception type in Clojure?

4:37 gen-class

4:37 or other wya?

4:50 Empperi: I usually just use ex-data

4:50 which doesn't provide a specific exception type but allows me to pass clojure data within the exception

4:50 which is usually what I really want

6:36 sm0ke: I am using this java api which is supposed to be used like Foo<Long> bar = foobar(0)

6:37 Which is all good, but it seems to default to Foo<Integer>

6:37 that is when used from clojure

6:37 even though i am passing foobar a long

6:38 So clojure has no generic is there a way to get around this

6:43 justin_smith: sm0ke: the jvm itself has no generics

6:43 sm0ke: that said, I am not sure how to use a polymorphic method that will take a long or int, because clojure likes to cast longs to ints if it finds an applicable int method

6:44 sm0ke: hurmm

6:44 is that true?

6:45 justin_smith: which part? the first part 100% - generics are a javac thing that has no representation in the bytecode

6:45 sm0ke: Would forcing a (foobar (long 0)) help?

6:45 justin_smith: you could try, or even a ^Long typehint

6:45 not sure

6:46 I bet Bronsa would know, if he were around

6:46 sm0ke: yes he has helped me a lot with type hints before

6:48 I had this phase where i was on a microoptimizing spree and type hinted everything in my code

6:48 got a lot of help on typehiting primitives etc

6:48 Metadata can only be applied to IMetas

6:48 why the hell am i getting that!

6:48 I am doing something like (.foobar o ^Long 0)

6:49 ,(inc ^Long 0)

6:49 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Metadata can only be applied to IMetas>

6:49 sm0ke: ,(inc ^long 0)

6:49 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Metadata can only be applied to IMetas>

6:50 clausewitch: 0 is a java.lang.Long, which cannot have the metadata you want to set on it.

6:51 type-hinting can only be done when defining variables (def, let ...)

6:51 sm0ke: not true

6:51 ,(let [^Long o 0] (inc o))

6:51 clojurebot: #error {\n :cause "Can't type hint a local with a primitive initializer"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.UnsupportedOperationException\n :message "...

6:51 sm0ke: hehe take that

6:52 lumafi: eh, that's exactly what clausewitch was talking about. defining a symbol with let

6:54 clausewitch: ,(do (def x 1) (let [^Long y x] y))

6:54 clojurebot: 1

6:54 clausewitch: When inlining a value the type-hinting seems to detect that it's superflous.

6:54 sm0ke: so what now ? how do i force a polymorphic method `foo` which takes int or long to force using long

6:55 i am going to try (long 0) now, dont make much sense to me as 0 is already long

6:55 but justin_smith says otherwise

6:55 justin_smith: sm0ke: you could use reflection to explicitly use the long method... but that is ugly af

6:55 sm0ke: justin_smith: right thats a way

6:56 justin_smith: sm0ke: no, I wasn't trying to say that (long 0) would act differently from 0... I'm actually not sure if that would make a difference or not, but would suspect not

7:11 Pupeno: I moved my source code to src/clj and adde this to my project.clj: :clj {:source-paths ["src/clj”]}, but I still get an error: Can't find ‘projectx.core' as .class or .clj for lein run: please check the spelling. What am I missing?

7:12 clausewitch: have you made a lein clean?

7:13 and is the path of the file really "src/clj/projectx/core.clj" ? @Pupeno

7:13 Pupeno: I run lein clean, but still getting the error. Yes, that path is correct.

7:15 clausewitch: @pupeno, does the core.clj-file compile when you open it and execute it expression by expression in emacs cider or similar?

7:16 Pupeno: clausewitch: yes... I didn't change anything else than move from src to src/clj (and src-cljs to src/cljs)

7:17 clausewitch: my most common problems use to be either mis-spelled namespace name (check closely!), or something broken in the file or that I'm connected to multiple JVMs with different classpaths and search in the wrong classpath...

7:18 @pupeno maybe lein check gives you some clue as well.

7:19 Pupeno: clausewitch: lein check fails with a similar error: Exception in thread "main" java.io.FileNotFoundException: Could not locate projectx/core__init.class or projectx/core.clj on classpath., compiling:(/private/var/folders/k9/pgnpg2h92bv157mw70mhznk80000gn/T/form-init206702167269887237.clj:1:124)

7:20 Clearly lein is not picking up on :clj

7:22 clausewitch: @pupeno , when I read {:source-paths ["src/clj”]} you pasted above, the last cite mark looks a bit fishy. Is it the ordinary one (") in your project.clj-file?

7:23 Pupeno: Yes, it's an ordinary double quote.

7:25 :source-paths ["src/clj"] (not inside clj) worked.

7:26 clausewitch: @pupeno well, my best bet is that there is a misspelling somewhere. could to execute the file from form by form? lein repl and cut and paste to the repl worst case...

7:27 Pupeno: There was no misspelling anywhere and yes, all my code was fine, I only moved and it was working before. The way you specify the source path in a lein project is :source-paths ["src/clj"], not :clj {:source-paths ["src/clj"]} which is what https://blog.8thlight.com/andrew-zures/2014/03/08/combining-clj-and-cljs-libraries.html recommended

7:27 clausewitch: @pupeno but hey! you should not put the source-paths in a :clj key!

7:28 Pupeno: clausewitch: yes, that's what I said.

7:28 clausewitch: @pupeno the :source-paths for ordinary clojure code is in the "root" of leiningen config...

7:28 OK :)

7:30 could you put your project.clj in a gist or something?

9:23 kwladyka: hmm which library should i use to abs?

9:23 algo.generic?

9:23 Bronsa: Math/abs

9:24 ,(Math/abs -1)

9:24 clojurebot: 1

9:25 kwladyka: Bronsa, mmm so easy answer :)

9:25 Bronsa, so i called as java function?

9:26 because i see https://clojure.github.io/clojure-contrib/math-api.html is deprecated

9:26 and i am a little confuse

9:27 Bronsa: https://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

9:27 java.lang.Math should have most of what you need, why bother using wrapper libs when you can directly interop

9:27 kwladyka: Bronsa, so directly from Java

9:28 Bronsa, to not mix languages but in this case it has sense to use Java directly

9:28 Bronsa: yes

9:28 kwladyka: "not mix languages" doesn't make much sense in clojure

9:28 kwladyka: Bronsa, ?

9:28 Bronsa: kwladyka: clojure is built on the jvm to leverage its libs

9:29 kwladyka: Bronsa, yes but i mean about code

9:33 snowell: What's conceptually different between (Math/abs -5) and (abs some/lib -5)?

9:33 In a sense, the interop is actually easier to figure out, and certainly to maintain

9:59 sveri: Hi, How do I realize lazy seqs in selmer when not using for? Is there a way to do that?

10:02 Empperi: doall

10:03 is my guess :)

10:03 don't know selmer

10:03 sveri: Empperi: yea, that works, but I have to do it in clojure then

10:11 Empperi: told you I don't know selmer :)

10:11 right, some kind of templating library

10:13 tdammers: do you have a strong use case for selmer?

10:14 'cause otherwise I'd recommend going with something more clojure-y, like hiccup or enlive

10:14 selmer is pretty limited even compared to its brethren in other languages (say jinja2 or twig)

11:07 sdegutis: Back.

15:02 kwladyka: is function like (filter-not f) instead of (filter f)? Something with oposit boolean value to filter

15:04 scriptor: ,(filter odd? (range 10))

15:04 clojurebot: (1 3 5 7 9)

15:04 scriptor: ,(remove odd? (range 10))

15:04 clojurebot: (0 2 4 6 8)

15:05 scriptor: kwladyka: is that what you want? ^

15:05 sg2002: , (select odd? (range 10))

15:05 clojurebot: #error {\n :cause "Unable to resolve symbol: select in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: select 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: select in t...

15:05 herrwolfe: using clojure trace, is there a way to tell if a transaction on a ref is being retried?

15:06 kwladyka: scriptor, ah right... i always use remove with sets, i totally miss that

15:06 thx

15:11 sveri: tdammers: not really, from my point of view it's just the go-to templating library coming from a different framework like django

15:12 tdammers: sveri: I don't know how well django fares, haven't used its templates a lot

15:13 sveri: tdammers: yea, no problem, I am just saying. I also used hiccup and enlive a lot, I just think that newcomers might recognize the templating principles from selmer more than hiccup or enlive (of course, YMMV)

15:14 tdammers: ofc

15:14 selmer is more traditional

15:14 and in fact, if your workflow involves frontend people (web designers and the like) who aren't comfortable with programming, then selmer is the better choice

15:18 {blake}: Hiccup is awfully close to HTML. My front-end peep didn't have a problem with it at all. (As another data point.)

15:18 ,clojure.core/println

15:18 clojurebot: #object[clojure.core$println 0x4735824e "clojure.core$println@4735824e"]

15:18 {blake}: ,core/println

15:18 clojurebot: #error {\n :cause "No such namespace: core"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: No such namespace: core, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "No such namespace: core"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]...

15:18 {blake}: ,println

15:19 clojurebot: #object[clojure.core$println 0x4735824e "clojure.core$println@4735824e"]

15:19 {blake}: &println

15:19 lazybot: ⇒ #<core$println clojure.core$println@bc5eb66>

15:19 {blake}: I thought that had changed.

15:41 Was there ever a good reason to not have the namespace qualified? Seems like if I had a different core, like "mylib.core" with a println, it would collide.

15:53 gfredericks: what's bothering you exactly, and what's the failure scenario?

15:55 Bronsa: {blake}: that's just how objects print

15:55 amalloy: what do you mean, {blake}? what did you think had changed?

15:55 {blake}: Just trying to get a mental model of what's going on.

15:56 Well, what's changed is that older versions would NOT display the qualifying namespace, just the last part of it.

15:56 Bronsa: I don't think so

15:56 that's the default Object toString

15:58 {blake}: I'm looking at the difference between clojurebot and lazybot. (Because I've seen it on my machines between 1.6 and 1.7)

15:58 Bronsa: ah, I thought you were talking about clojure

15:58 &*clojure-version*

15:58 lazybot: ⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}

15:58 Bronsa: ,*clojure-version*

15:58 clojurebot: {:major 1, :minor 8, :incremental 0, :qualifier "alpha3"}

15:58 {blake}: OK, between 1.7 and 1.8 there was a change.

15:59 Bronsa: yes, in how the repl prints objects and exceptions

15:59 {blake}: Is it just display related?

16:00 (OK. Cool. I'm trying to write stuff up and this invariably results in all kinds of little questions.)

16:00 swn_: I have a function foo that works, but when I call (repeatedly 5 #(foo arg1 arg2)) it doesn't get called. Why might that happen?

16:03 alex_engelberg: swn_: repeatedly returns a lazy sequence, so foo is only evaluated as you request more items from that sequence.

16:03 puredanger: It's lazy and you didn't ask for anything from it

16:09 sdegutis: Is there a performance advantage of (def foo (comp bar quux)) instead of (defn [x] (bar (quux x))) ?

16:12 Bronsa: sdegutis: written exactly like that, comp doesn't create a new class while defn does

16:12 sdegutis: Oh. Wow. Did not know.

16:12 That's impressively intimate knowledge of Clojure, Bronsa.

16:15 Good bye.

16:26 thearthur: sorry to show my ignorancs here, though when reading the docs for clj-refactor I keep seeing instructions like "1st tabstop lets you type out the namespace, the example in [example :refer [foo]]" and I'm not sure what to google for to find out how to type a tabstop. the emacs manual defined tabstops as column numbers for indenting, which I suspect is not the same thing. What is a tab stop in this context? and how do I type one?

16:28 magnars: you press tab to jump between tab stops

16:28 thearthur: hitting tab in this context does nothing I can see

16:29 magnars: sounds like yasnippet isn't working properly for you

16:30 * thearthur checks on yasnippet

16:31 magnars: I don't think digging into why is very interesting to the people in this channel, so please do open an issue on the github repo for more help if you need it. :-)

16:36 swn_: got it, thanks

16:53 thearthur: magnars: problem is already known and fixed, and yas-monor-mode must be enabled for clojure-mode

16:53 magnars: thanks very much. These little things make a huge difference, and I'm giving a talk on this at the SF meetup in about three hours, so it's nice to have it working

17:07 {blake}: in-ns has no source? =P

17:08 amalloy: {blake}: no, it is a special form

17:08 {blake}: amalloy: I'm reading the documentation and not getting what it buys you versus ns. It looks like both create empty namespaces.

17:09 amalloy: ns is built on top of in-ns

17:09 you never really have a good reason to use in-ns yourself unless you have accidentally created a broken namespace that doesn't have ns in it

17:10 TimMc: amalloy: What about switching namespaces as the REPL>

17:10 *at the REPL?

17:10 amalloy: ns is fine for that, TimMc, although in-ns works too

17:10 TimMc: ah, OK

17:10 amalloy: ,(macroexpand-1 '(ns foo))

17:10 clojurebot: (do (clojure.core/in-ns (quote foo)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core))) (if (.equals (quote foo) (quote clojure.core)) nil (do (clojure.core/dosync (clojure.core/commute (clojure.core/deref (var clojure.core/*loaded-libs*)) clojure.core/conj (quote foo))) nil)))

17:10 {blake}: clojure.org/namespaces => At the Repl it's best to use in-ns, i

17:11 amalloy: so, (ns foo) expands to (in-ns foo) followed by a bunch of useless junk that doesn't really matter

17:11 {blake}: amalloy: OK, cool.

17:11 stuartsierra: `(ns foo)` automatically refers all of clojure.core, which will break namespaces that use `:exclude-clojure`

17:12 amalloy: yes, that seems to be the difference

17:12 so like, i use in-ns in the repl too, but "most of the time" ns is fine

17:13 {blake}: I haven't had much call for using ns in the REPL. Oh...but I suppose I would if I were debugging a running one.

18:14 futuro: can anyone point me to docs related to the 'map->' macros/fns?

18:14 I'm seeing it used in the component library (and referenced elsewhere), but I can't find documentation on it

18:14 hiredman: ,(doc defrecord)

18:15 clojurebot: "([name [& fields] & opts+specs]); (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given f...

18:15 futuro: hiredman: I'll give the docs for defrecord a look, thank you

18:15 hiredman: yep

18:16 sdegutis: Why in the world does defn creaet a Jaba class¿

18:16 *create

18:16 hiredman: refering to them as `map->` functions maybe confusing to some people, they are the factory functions defrecord creates

18:16 sdegutis: hiredman: yeah Clojure doesn't really have a single consistent naming convention

18:17 Then again what language does?

18:27 futuro: ahh, ok, having that terminology is very useful

18:27 I've only ever seen them as map->"Insert some record name here", so I didn't really know what to call them

18:30 hiredman: yeah, they are "just" functions, but they happen to appear out of thin air whenever there is a defrecord

18:30 Bronsa: sdegutis: a java class is the only compilation unit the jvm understands

18:31 sdegutis: Bronsa: But (def foo (comp baz quux)) doesn't create a Java vlass?

18:31 Bronsa: sdegutis: (fn ..) creates a java class, (defn expands to def+fn, juxt doesn't

18:33 sdegutis: Bronsa: So what does (def foo 2) compile to?

18:35 amalloy: sdegutis: it adds a line to the my.ns.__init static initializer which sets the var my.ns/foo to Long.valueOf(2)

18:35 Bronsa: sdegutis: it just gets compiled in a static method f the naespace init class setting foo to 2

18:36 sdegutis: or, if compiled at the repl, it just invokes #'foo.bindRoot(2)

18:36 s/compiled/executed/

18:39 sdegutis: amalloy: AMAZING

18:39 I never knew Java was suck an unnecessarily convoluted language!

18:40 amalloy: so far nobody is talking about java

18:50 {blake}: The vector form of require...is that essentially [namespace {:key value...}], only with the curly braces sugared out?

19:08 rpaulo_: ]

19:18 sdegutis: amalloy: Long.valueOf(2)

19:19 amalloy: well, it's not java's fault that clojure stores boxed Longs instead of primitive longs

19:22 sdegutis: Oh JVM.

19:35 wickedshell: I'm reading a stream of data off a serial port and passing it into a byte array of size 256. I'm reusing the array but unfortunately do to the reuse internally it seems that I keep getting new objects returned causing a *large* number of garbage collections which is causing a problem

19:35 Is there anyway to get a mutable refernce to just the byte array without any other handling? It's a special case here where reusing the buffer is required

19:36 hiredman: you likely think you re-using the byte array, but are not actually doing that

19:36 so the best thing to do is share a small bit of code that shows you reusing the byte-array

19:37 wickedshell: the ref has stayed the same the whole time

19:37 let me paste it in somewhere

19:39 hiredman: the jvm gcs are very good too, so in order for a 256 byte byte-array to be causing lots of garbage collection you must be creating a ton of them in a very tight loop

19:39 wickedshell: hiredman, http://pastebin.com/g3H1CjHz

19:40 yeah I have a continous input stream of ~1mb/s or so

19:40 but I have to handle the messages as fast as possible

19:40 er decimal place was wrong, sorry ~100kb/s

19:41 hiredman: what makes you think that a large number of garbage collections is causing whatever problem you are seeing? (also what problem are seeing?)

19:42 wickedshell: I'm watching in jvisualvm climb up to to 750MB used then it drops down to ~100mb after GC. This is the only additional work that is being performed

19:42 basically excess amount of time being spent in the GC (particualrly on a memory constrained system which is the target)

19:43 hiredman: so that is more or less how the gc works, allocations happen until it hits a threshold then they are free'ed at once

19:43 wickedshell: right, my concern is that I really don't need to be reallocating in this case

19:44 hiredman: I don't see anything in the code that would lead me to conclude that it is doing lots of allocations, what makes you think it is?

19:45 wickedshell: a large byte[] that keeps growing in the profiler, and it's the only place I use the byte's. Although it is possible that instead some other class has a ton of internal byte[]'s

19:45 I can't figure out a good way to track down what is causing allocations

19:45 justin_smith: a byte[] doesn't grow

19:46 wickedshell: jvisualvm lumps stuff by class name

19:46 hiredman: well, you can verify if that code is causing allocations or not by disabling it and running the rest of the project

19:46 amalloy: ,(get (into-array ["test"]) 0)

19:46 clojurebot: "test"

19:46 wickedshell: so all byte arrays are under the same name

19:47 amalloy: huh. i didn't know you could use get on arrays

19:47 hiredman: if memory usage drops then either it is that code or something downstream

19:47 wickedshell: amalloy, I'm stupidly reliant on that due to other libraries :P

19:47 hiredman: amalloy: RT.get special cases arrays

19:48 so then disable things that are logically downstream of that code, if the memory usage remains constant, then it something downstream

19:48 etc etc

19:48 wickedshell: yeah, going through it now.

19:49 amalloy: this code is probably allocating a lot of Byte objects, but not byte[]s

19:49 hiredman: which jvm are you using on your target? a lot of linux distros on things like the pi install jvms that are not very good by default

19:50 oh

19:50 of course because of the get

19:50 wickedshell: openjdk

19:50 although I also deploy to jdk8

19:51 hiredman: just so long as it isn't jamvm or whatever

19:51 wickedshell: amalloy brings up a good point, are you sure you are seeing byte arrays allocated or are you seeing Byte objects?

19:52 wickedshell: Byte[] is the prmary culpriate but Byte is the 4th largest consumer atm

19:52 so yeah I'd say amalloy is right on the large number of byte's

19:52 hiredman: you are also comparing the byte array to nil, which is weird

19:52 something in a byte array cannot be nil

19:53 amalloy: wickedshell: Byte[]!? are you sure you don't mean byte[]?

19:53 wickedshell: ~543 thousand Byte's atm going up at ~50k a second, till it hc's

19:53 clojurebot: Pardon?

19:53 wickedshell: amalloy, your right

19:53 byte[] and java.lang.Byte

19:54 amalloy: anyway hiredman is right that you can't ever get a nil out of that array, so in addition to performing poorly i have to imagine your code is incorrect

19:54 wickedshell: the array has nil values in it

19:54 amalloy: no, it doesn't

19:54 hiredman: it cannot

19:54 wickedshell: oh no your right

19:54 I still need a get later though :/ stupid library wants to parse MAVLink one byte at a time

19:55 requires a byte passed in then returns a message if it got one

19:55 hiredman: use aget

19:55 and you will want to type hint the byte array

19:56 wickedshell: even though the byte array was declared with byte-array I should still retype hint it?

19:56 hiredman: declared where?

19:57 wickedshell: first line of the paste

19:57 (def buffer (byte-array 256))

19:57 hiredman: (def buffer (byte-array 256)) creates a byte array puts it in the var bound to buffer, it does not convey any typing information to the compiler

19:58 (or in another point of view it does, the compiler just ignores it)

19:58 wickedshell: can I hint it at that point or do I need to hint on the aget line? I've been somewhat unsure on the scoping of hints and generally have them in let statements

19:58 hiredman: wickedshell: I would rebind it to hinted a local

19:59 (let [^bytes buffer buffer …

20:00 you should consider setting *warn-on-relection*

20:00 wickedshell: I periodically turn it on/off. It's never been unhappy there

20:01 amalloy: well yeah, because you are using an untyped get operation

20:01 if you used aget you would see reflection warnings i think

20:01 hiredman: well, "polymorphic"

20:10 xcthulhu: Hey! I am a clojure veteran, clojurescript n00b

20:11 I am trying to write an isomorphic implementation of bitpay’s bitauth library in clojure/clojurescript

20:11 https://github.com/bitpay/bitauth

20:12 I managed to make a 100% API compatible implementation in clojure: https://github.com/xcthulhu/clj-bitauth

20:12 But I’m retarded at wrapping javascript in clojurescript and unit testing this stuff

20:12 A little hand holding for a n00b would be appreciated!

20:12 ty

20:19 BinaryResult: Love gaming & Clojure? Disco Melee is hiring remote devs to build our social streaming platform https://docs.google.com/document/d/1AZNGw7QaoN7jY8MjwpxcKcTTwqjUM7q--2W3aRM36yI/edit?usp=sharing

20:24 TEttinger: BinaryResult: I'm kinda curious if this is a mass mailing thing

20:24 (supply more info to confirm non-bot-ness?)

20:28 BinaryResult: sure what would you like to know?

20:28 see us for yourself http://beta.discomelee.com/

20:28 :)

20:29 TEttinger: just wanted to make sure it wasn't like a spambot that saw #clojure and substituted "#" with "Love gaming and "

20:29 BinaryResult: understood

20:29 TEttinger: glad you picked clojure

20:30 that site looks nice

20:30 BinaryResult: yea going very well so far :) I'm more of a founder/investor non-technical but our CTO is very selective

20:30 ty

20:30 lots in store

20:30 need the team to build it out

20:31 have to run to hockey game, hope to hear from all the clojure gamers ;)

20:31 TEttinger: I'm guessing the business angle is, "holy crap every console is adding social features, if we can make a better platform we can sell the platform for gobs of gold"

20:31 which seems solid to me

21:51 soverton: does anyone here use figwheel?

21:52 justin_smith: yup, it's the best

21:53 soverton: I'm trying to get figwheel to bind to a non-localhost ip address, but it seems to ignore the :server-ip setting in the project.clj file. It's driving me crazy.

21:53 justin_smith: wouldn't it be easier to make a tunnel with ssh?

21:53 seems like binding to a non-localhost port is just asking for trouble

21:54 soverton: well, it's not a real device. It's on a virtual network.

21:54 justin_smith: OK

21:56 soverton: the reason I avoided ssh tunneling is because I'm running MS windows 8.1 in virtualbox so I can test out my page on internet explorer. I don't know much about ms windows in the first place.

21:56 (I'm running Linux, btw)

21:57 justin_smith: can't you map the figwheel port over the vm?

21:59 soverton: yeah, I can try that. I just thought that maybe I was screwing something up in the figwheel config section, but I guess I'll just do a workaround like port mapping...

21:59 clojurebot: I don't understand.

22:02 soverton: justin_smith: thanks for the help :)

22:04 justin_smith: soverton: it might be possible, I just wouldn't know how

22:14 andrew_: hi everyone. i'm trying to write a nested lazyseq structure -- something like ((nil nil ("A" "B") nil) (nil ("C" "D "E"))) -- to csv using clojure.data.csv, but the innermost lazy seqs just don't seem to want to be evaluated. could anyone point me in the right direction?

22:15 TEttinger: andrew_: you want to evaluate ##("A" "B") ?

22:15 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

22:15 andrew_: yeah

22:15 TEttinger: I assume you don't want that classcastexception

22:16 you may want one of the dorun, doseq, doall family of macros

22:16 ,(class (map inc [1 2 3]))

22:16 clojurebot: clojure.lang.LazySeq

22:16 TEttinger: ,(doall (map inc [1 2 3]))

22:16 clojurebot: (2 3 4)

22:16 andrew_: i'm trying to write to csv and get something like ",,,A B,," but instead i'm getting ",,,clojure.lang.LazySeq@whatever,,"

22:17 TEttinger: ohh

22:17 (doc doall)

22:17 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."

22:17 TEttinger: hm I think that isn't the right one

22:18 andrew_: it feels like i might need to do some kind of recursive doall or something

22:19 TEttinger: ,(repeat 3 (repeat "A"))

22:19 clojurebot: (("A" "A" "A" "A" "A" ...) ("A" "A" "A" "A" "A" ...) ("A" "A" "A" "A" "A" ...))

22:19 TEttinger: ,(str (repeat 3 (repeat "A")))

22:19 clojurebot: "((\"A\" \"A\" \"A\" \"A\" \"A\" ...) (\"A\" \"A\" \"A\" \"A\" \"A\" ...) (\"A\" \"A\" \"A\" \"A\" \"A\" ...))"

22:19 TEttinger: damn, how to reproduce this with a bot...

22:19 &(str (repeat 3 (repeat "A")))

22:20 &(str (repeat 3 (repeat 7 "A")))

22:20 lazybot: Execution Timed Out!

22:20 ⇒ "clojure.lang.LazySeq@f960151f"

22:20 TEttinger: there we go.

22:20 &(pr (repeat 3 (repeat 7 "A")))

22:20 lazybot: ⇒ (("A" "A" "A" "A" "A" "A" "A") ("A" "A" "A" "A" "A" "A" "A") ("A" "A" "A" "A" "A" "A" "A"))nil

22:20 TEttinger: so that's one way

22:20 &(pr-str (repeat 3 (repeat 7 "A")))

22:20 lazybot: ⇒ "((\"A\" \"A\" \"A\" \"A\" \"A\" \"A\" \"A\") (\"A\" \"A\" \"A\" \"A\" \"A\" \"A\" \"A\") (\"A\" \"A\" \"A\" \"A\" \"A\" \"A\" \"A\"))"

22:21 TEttinger: &[(str (repeat 7 "A")) "," (pr-str (repeat 7 "A"))]

22:21 lazybot: ⇒ ["clojure.lang.LazySeq@48f3b8c0" "," "(\"A\" \"A\" \"A\" \"A\" \"A\" \"A\" \"A\")"]

22:21 andrew_: there it is

22:21 nice

22:22 i mean, reproducing it anyway

22:22 justin_smith: so for the readable version, us pr rather than print, pr-str rather than str

22:22 andrew_: ok, i'll give that a shot

22:22 many thanks

22:23 justin_smith: andrew_: also, with a lib like data.csv this might be handled smartly for you already

22:23 andrew_: for exampl,e, I doubt you want the , that pr-str might put into a collection

22:25 andrew_: i actually do want that comma in this case -- i wonder if data.csv is a little too fancy for me here

22:34 wickedshell: Different problem (still tracking down the memory problem) but I came across this function. I have a for loop that when called from another function (java repaint of a component) it doesn't print anythingn within the for loop, but if I manually call it from the REPL with the same agruments it prints the contents in the for loop. http://pastebin.com/8KXXCFb2 anyone ever encountered something like this?

22:34 (all the early content prints out before the for loop regardeless of where its called)

22:50 TEttinger: wickedshell: for returns a lazy sequence

22:51 wickedshell: TEttinger, ohh so you're saying its never evaulating the prints?

22:51 TEttinger: so the repl evaluates the lazy sequence, but just calling (for [x (range)] (print x)) won't do anything if you aren't in the repl

22:52 if you did that in doall, or changed 'for' to 'doseq', it would infinite loop printing numbers

22:53 and yeah, what it's printing in the repl is the evaluated lazy seq (the better term may be realized, rather than evaluated, here, not sure)

22:53 &(for [x (range 4)] (print x))

22:53 lazybot: ⇒ (0123nil nil nil nil)

22:53 TEttinger: print returns nil

22:53 the (nil nil nil nil) is the return

22:54 it printed 0123 at the same time because quirky irc bot

22:58 wickedshell: TEttinger, thanks! I'm an idiot. I had solved that before and just spent another hour on it by accident.... :( thanks!

22:59 TEttinger: heh, it's a really easy mistake to make

22:59 for is a little... misleading if you expect it to be like a java/C/C++/C# for loop

23:00 it really behaves closer to a haskell or python for comprehension, and I think haskell doesn't even call it for

23:48 magnars: thearthur: cool, glad you got it working. :) how did the talk go?

Logging service provided by n01se.net