#clojure log - Sep 26 2012

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

0:15 lnostdal: there's no "break" facility in nrepl.el?

0:16 or abort or whatever .. to get out of loops started in the REPL

0:16 technomancy: there's a way to do it; the binding isn't obvious

0:22 Sgeo_: How difficult is it to make menus in elisp?

0:22 I might just end up writing menus or something for these things

0:39 nuclearsandwich: technomancy: sup?

0:43 kwertii: Anyone have information on what is currently (1.4) the most performant way to store a 2d grid of arbitrary objects, such as for a video game board? I'm getting terrible performance with nested arrays of vectors.

0:44 mpan: who's the purple haired guy doing introduction in the clojure conj videos?

0:48 nuclearsandwich: mpan: that'd be stuart sierra

0:48 (probably)

0:52 mpan: nuclearsandwich: thanks!

0:54 leonardoborges: kwertii: don't really know what could be tripping your performance but if you really need to, it's possible to drop to raw arrays instead of vectors: http://clojure.org/java_interop#Java%20Interop-Arrays

0:54 kwertii: leonardoborges: yeah, I'm trying to make a 2d Java array of PersistentVectors

1:14 technomancy: nuclearsandwich: just wondering if you were interested in my laptop

1:14 pm

1:14 ?

1:39 mpan: what determines when a macro is evaluated to produce the expansion? when the expansion is evaluated to produce the result?

1:40 hiredman: mpan: macro epansion happens before compilation , it is basically the first step of the analysis the compiler does

1:41 mpan: in that case, is it possible for the value of the expansion to be conditional on some of the arguments?

1:44 I'm trying to make a contrived example and I'm getting errors

1:45 Sgeo_: mpan, the arguments to a macro are code

1:46 (defmacro mymacro [arg1 arg2] ...)

1:46 mpan: this is a contrived example I have trouble understanding: (defmacro foo [x] (if x '1 '0))

1:46 Sgeo_: If I do (mymacro 1 2) mymacro will see 1 and 2, but if I do (def a 1) (def b 2) (mymacro a b) mymacro will see a and b, not 1 and 2

1:47 mpan: if I try to evaluate (foo true) vs (foo false), what is the process that happens?

1:48 Sgeo_: The code (if true '1 '0) is run and the result is placed in place, in this case '1

1:48 (For true)

1:48 mpan: what if I then make

1:49 (defn bar [x] (foo x))

1:49 is it that when bar is called, foo gets compiled??

1:49 lazybot: mpan: Definitely not.

1:49 Sgeo_: Note that (foo (== 3 (+ 1 1))) '1 will get placed in because foo sees the expression, not the result

1:49 amalloy: high five, lazybot. keep those right answers coming

1:50 mpan: no. when bar is compiled, foo is called with the argument 'x

1:50 mpan: I'm a little worried; how does the bot know what I asked?

1:50 amalloy: then its result is placed "inline" into the definition of bar

1:50 mpan: uh oh

1:50 Raynes: mpan: His hair was blue.

1:50 mpan: does bar not do what I think it does, then?

1:50 Raynes: mpan: It was dark blue and faded slightly so it looked purple in certain lights.

1:51 amalloy: mpan: he doesn't. i just taught him that people who ask questions ending with ?? are usually wrong

1:51 Raynes: mpan: My hair was also blue, but really bright blue.

1:51 mpan: Raynes: ah cool

1:51 Sgeo_: lazybot, will you response with an answer effectively meaning "no" to this question??

1:51 lazybot: Sgeo_: What are you, crazy? Of course not!

1:51 Sgeo_: Very doubtful.

1:51 mpan: lolheuristic

1:51 man, this is like the time I was convinced elizabot was a real person

1:52 wait so, if macros don't conditionally expand at runtime, what does?

1:52 amalloy: nothing. don't do it

1:52 mpan: not that I can imagine why one would want that

1:53 amalloy: (eval does, sorta, but don't do it)

1:53 Sgeo_: amalloy, even if I'm building a REPL???

1:53 lazybot: Sgeo_: Oh, absolutely.

1:53 mpan: "I don't want to go there" type deal?

1:53 amalloy: Sgeo_: if you were building a repl for clojure, eval would make sense. but plenty of lovely repls already exist

1:55 mpan: so anything that determines a conditional expansion needs to be known at compile time?

1:55 Sgeo_: But you can expand into code that will do stuff at runtime

1:56 mpan: I suppose if I keep delaying the expansion/evaluation to the logical extreme, then I have a repl

1:56 thanks guys! that cleared up a major misunderstanding I was having before

1:57 I had seen some macros that I had believed did run-time expansion

1:59 SrPx: What is the difference between '(this) and [this]

1:59 amalloy: &(let [this 10] (list '(this) [this]))

1:59 lazybot: ⇒ ((this) [10])

2:00 Sgeo_: '(this) is a list. [this] is a vector.

2:00 Although, I guess '[this] more closely corresponds with '(this)

2:00 '[blah] weirds me out a bi

2:00 bit

2:01 SrPx: But how is a list different form a vector? '(this) and '[this] now

2:03 Sgeo_: Lists are conceptually made up of an element and another list. O(1) time prepend and access to front, O(n) to append to end and to retrieve arbitrary value. Vectors are O(log n) time complexity in various things (append/prepend I think, not sure about arbitrary retrieval) but from what I understand it's a small amount in practice

2:04 SrPx: Sgeo_: I could be using lists or vectors for the same thing without really noticing a difference, then ?

2:05 Sgeo_: Well, for large collections of items, unless you're using the collection as a stack, vectors will usually be faster in practice. I should note that I'm still unfamiliar with Clojure in practice.

2:08 SrPx: OK, thanks

2:08 amalloy: Sgeo_: lists and vectors are both excellent stacks

2:09 tbh i'd prefer a list unless i had some need to do something other than conj/pop

2:11 hiredman: https://github.com/hiredman/ed25519/blob/master/src/ed25519/replacements.clj#L5 sweet conditional macro expansion

2:14 Sgeo_: Code like this does kind of make me wish that if forms did a sort of else nested inside them a/la try/catch rather than go the traditional Lisp route

2:15 SrPx: (:a {:a 1}) works. Is :a a function?

2:16 Sgeo_: All keywords are (conceptually, if not physically) functions that take a map

2:16 ,(ifn? :a)

2:16 clojurebot: true

2:16 hiredman: SrPx: in most of the ways you would ever care about, yes

2:17 Sgeo_: ,(:a {})

2:17 clojurebot: nil

2:17 Sgeo_: ,(:a {:a nil})

2:17 clojurebot: nil

2:17 Sgeo_: This makes me sad.

2:17 SrPx: Why?

2:17 clojurebot: why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone

2:18 Sgeo_: Does clojurebot use Bucket code o.O

2:18 SrPx: Also how do I get a type of something? (I would ask if 'a and "a" were just strings but I guess this is a better question)

2:18 Sgeo_: Hmm.

2:18 ,(type 'a)

2:18 clojurebot: clojure.lang.Symbol

2:18 Sgeo_: ,(type "a")

2:18 clojurebot: java.lang.String

2:18 Sgeo_: ,(doc juxt)

2:18 hiredman: SrPx: http://clojure.org/data_structures

2:18 clojurebot: "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"

2:18 SrPx: ,(type? 'a)

2:18 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: type? in this context, compiling:(NO_SOURCE_PATH:0)>

2:19 SrPx: waht

2:19 Sgeo_: ,(map type ['a "a"])

2:19 clojurebot: (clojure.lang.Symbol java.lang.String)

2:20 SrPx: ((juxt type) ['a "a"])

2:20 ,((juxt type) ['a "a"])

2:20 clojurebot: [clojure.lang.PersistentVector]

2:20 hiredman: SrPx: read http://clojure.org/data_structures

2:20 SrPx: ,(print ((juxt type) ['a "a"]))

2:20 clojurebot: [clojure.lang.PersistentVector]

2:20 SrPx: ):

2:20 oh I get it

2:20 ((juxt #(+ 1 %1) #(* 2 %1)) 3)

2:20 ,((juxt #(+ 1 %1) #(* 2 %1)) 3)

2:20 clojurebot: [4 6]

2:20 SrPx: :D

2:21 Not sure why you told me that but I like it

2:21 Sgeo_: SrPx, I misthought when wanting to illustrate the types of 'a and "a" in one line

2:21 SrPx: I see

2:22 Sgeo_: So I checked the juxt doc to see if that's what I wanted. Not sure why, I am familiar with map.

2:22 SrPx: maybe you just learn what juxt is and it was stuck in your head?

2:22 where it is anyway? I guess there are more cool things there

2:23 ,((map inc) [1 2 3])

2:23 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$map>

2:23 SrPx: :(

2:23 Sgeo_: SrPx, map needs both a function and a seq

2:23 SrPx: hiredman: I will read it now, thanks

2:24 Sgeo_: Although it's different in Haskell, where there's no difference between a function that takes a function and returns another function that acts on its arguments, and a function that takes two arguments

2:24 ,((partial map inc) [1 2 3])

2:24 clojurebot: (2 3 4)

2:24 Sgeo_: ,(map inc [1 2 3])

2:24 clojurebot: (2 3 4)

2:29 amalloy: Sgeo_: ##(for [coll [{}, {:a nil}]] (:a coll 'not-here))

2:29 lazybot: ⇒ (not-here nil)

2:30 amalloy: and if you want an if-form that has an explicit else, just use cond instead of if: (cond test then :else else)

2:31 Sgeo_: ,(doc contains?)

2:31 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."

2:31 Sgeo_: ,(contains? {:a nil} :a)

2:31 clojurebot: true

2:32 Sgeo_: ,((fn [key map] (if (contains? map key) [key map] nil)) :a {:a nil})

2:32 clojurebot: [:a {:a nil}]

2:33 Sgeo_: ,((fn [key map] (if (contains? map key) [(key map)] nil)) :a {:a nil})

2:33 clojurebot: [nil]

2:33 Sgeo_: ,((fn [key map] (if (contains? map key) [(key map)] nil)) :a {})

2:33 clojurebot: nil

2:33 amalloy: &(doc find)

2:33 lazybot: ⇒ "([map key]); Returns the map entry for key, or nil if key not present."

2:34 Sgeo_: ,(find {:a nil} :a)

2:34 clojurebot: [:a nil]

2:34 Sgeo_: Cool

2:49 SrPx: (map #(%1) [1 2 3]) why this does not work? I want it to return the list itself

2:49 ,(map #(%1) [1 2 3])

2:49 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

2:50 SrPx: ,(map #(+ %1 0) [1 2 3])

2:50 clojurebot: (1 2 3)

2:50 SrPx: Using + it works but only for numbers

2:50 amalloy: &'#(%1)

2:50 lazybot: ⇒ (fn* [p1__11272#] (p1__11272#))

2:50 SrPx: ?

2:51 ,(map (fn [a] a) [1 2 3])

2:51 clojurebot: (1 2 3)

2:51 SrPx: That is OK.

2:51 amalloy: &(map (fn [a] (a)) [1 2 3])

2:51 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

2:51 SrPx: Yes I see, Thanks

2:53 Sgeo_: ,(map identity [1 2 3])

2:53 clojurebot: (1 2 3)

2:54 SrPx: (map (fn [a] [:name (a 0) :hp (a 1)]) [["foo" 20] ["moo" 30] ["boo" 40]]) - so, this works and is awesome. Is there a way to write it shorter?

2:56 Sgeo_: ,(map (fn [[name hp]] {:name name :hp hp}) [["foo" 20] ["moo" 30] ["boo" 40]]) ; returns a seq of maps, not a seq of vectors like your original. if you really want it your way, that's fine

2:56 clojurebot: ({:name "foo", :hp 20} {:name "moo", :hp 30} {:name "boo", :hp 40})

2:58 Raynes: Why would he want a seq of maps vs a seq of vectors?

2:59 Sgeo_: He wrote a function that returns a vector rather than a map

2:59 Raynes: It looks like he is working on building a map later.

2:59 So it makes sense for it to be a vector of vectors.

2:59 Er, seq of vectors.

2:59 Sgeo_: Oh

2:59 Raynes: &(into {} '([1 2] [3 4]))

2:59 lazybot: ⇒ {1 2, 3 4}

3:00 Sgeo_: So then:

3:00 Raynes: SrPx: Your code doesn't work unless a is a function.

3:00 Sgeo_: ,(map (fn [[name hp]] [:name name :hp hp]) [["foo" 20] ["moo" 30] ["boo" 40]])

3:00 clojurebot: ([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 40])

3:01 Sgeo_: Raynes, vectors are functions, the goal appears to be to get the 0th and 1st elements

3:01 Raynes: Oh, right, ew.

3:01 SrPx: ?

3:01 Raynes: I was thinking of the first element of each vector rather than the vector itself as a for some reason.

3:01 SrPx: ,(map (fn [a] [:name (a 0) :hp (a 1)]) [["foo" 20] ["moo" 30] ["boo" 20]])

3:01 clojurebot: ([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 20])

3:02 Sgeo_: SrPx, look at my code. Instead of taking an argument a, I'm taking it as [name hp], which destructures the vector into local variables named name and hp

3:03 * Sgeo_ wonders... ##(let [[name hp] ["Sgeo" 100 :foo]] [hp name])

3:03 lazybot: ⇒ [100 "Sgeo"]

3:03 * Sgeo_ wonders... ##(let [[name hp whatever bluh] ["Sgeo" 100 :foo]] [hp name])

3:03 lazybot: ⇒ [100 "Sgeo"]

3:03 amalloy: &(map #(zipmap [:name :hp] %) [["foo" 20] ["moo" 30] ["boo" 20]])

3:03 lazybot: ⇒ ({:hp 20, :name "foo"} {:hp 30, :name "moo"} {:hp 20, :name "boo"})

3:03 Raynes: (map #(zipmap [:name :hp] ((juxt first second) %)) [["foo" 20] ["moo" 30] ["boo" 20]])

3:03 SrPx: Sgeo_: I did not learn destructuring yet but seems allright, thanks

3:03 Raynes: I used juxt cuz juxt.

3:03 amalloy: How could you not use juxt?

3:04 I wrap all my vectors in juxt.

3:04 Sgeo_: ,(doc zipmap)

3:04 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

3:05 Raynes: &(for [[k v] [["foo" 20] ["moo" 30] ["boo" 20]]] [:name k :hp v])

3:05 lazybot: ⇒ ([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 20])

3:05 SrPx: (: love that learning

3:06 Raynes: amalloy: Dude, check it out. Exact same length.

3:06 o/

3:06 SrPx: for is very similar to map, is not i

3:06 it*

3:07 Raynes: Yes, but generally better when your function to map is long or needs to destructure its argument.

3:07 Either of our examples are acceptable.

3:07 Sgeo_: Or when you have multiple sequences?

3:08 Raynes: Sgeo_: Well, they do entirely different things with multiple sequences.

3:08 &(map vector [1 2 3] [4 5 6])

3:08 lazybot: ⇒ ([1 4] [2 5] [3 6])

3:08 Sgeo_: Oh, I usually think in terms of what for does

3:08 List monad etc

3:08 Raynes: &(for [x [1 2 3] y [4 5 6]] [k v])

3:08 lazybot: java.lang.RuntimeException: Unable to resolve symbol: k in this context

3:08 Raynes: &(for [x [1 2 3] y [4 5 6]] [x y])

3:08 lazybot: ⇒ ([1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6])

3:22 Sgeo_: If ordinary Clojure code could conceptually be said to be in the IO monad, I wonder if a code-walker could transform normal-looking (as in, no need for domonad) Clojure code into monadic code

3:31 SrPx: hmm

3:31 thanks (:

3:32 this is something I always wanted in other languages and is so simple on clojure

3:32 Sgeo_: What, in particular?

3:33 SrPx: too many things actually, but I was talking about (for [x (range 10) y (range 10)] ...)

3:34 Sgeo_: Ah. Several languages have things like that, they're called list comprehensions usually

3:34 Python and Haskell also have them

3:34 SrPx: I'm not sure you could do this exactly on python

3:35 Sgeo_: [(x, y) for x in range(10) for y in range(10)]

3:35 SrPx: something like [(x,y) for x in range(10) for y in range(10)]

3:35 ... yes, that. But I remember it not working for some reason, not sure though

3:36 Sgeo_: That's weird, it should

3:36 SrPx: I think I was trying to do it with a block of code or something

3:36 So I needed to use the for loops, not the comprehension

3:37 Sgeo_: Oh, trying to do an action?

3:37 SrPx: and I couldnt in any way do it without 2 for loops or without calling it.cartesian or something like that to generate a list of x y pairs

3:37 do not remember well though

3:37 amalloy: that's because of the pointless statement/expression dichotomy :P

3:37 SrPx: Sgeo_: maybe

3:38 Sgeo_: If Python didn't hate lambdas so much, could do an anonymous function, and then loop through the result and call each function

3:38 I should note that in Clojure, if you want to do side-effects, you should probably either use doseq, or, if you also want the results, doall and for

3:39 SrPx: for (x,y) in [(x,y) for x in range(3) for y in range(2)]: do_something(x,y)

3:40 Sgeo_: this! What is wrong with python's lambda!?

3:40 I mean, why they made it like that? It is horrible and I thought I was the only one who thought so

3:40 Sgeo_: (doseq [x (range 3) y (range 2)] (do-somethign x y))

3:41 SrPx: Sgeo_: way shorter

3:42 Sgeo_: sequence_ [do_something x y | x <- [0...2], y <- [0..1]]

3:42 iirc

3:43 SrPx: Ruby?

3:43 clojurebot: Chunky bacon!

3:43 Sgeo_: Haskell

3:43 SrPx: Or haskell

3:43 (:

3:43 I'm afraid of Haskell

3:43 Might be my next language

3:45 Sgeo_: It's rather beautiful, although I'm coming to Clojure from Haskell

3:45 Mostly because I really like macros, and the idea of changing code while it runs

3:46 Both exist in Haskell, both are not especially convenient or liked in Haskell

3:47 Oh, and the idea of structuring large programs with monad transformers kind of scares me

3:47 SrPx: Sgeo_: someone pointed you don't need macros in haskell because their functions can already do anything, or something on those lines

3:48 Sgeo_: monads is what scares me, I have no idea what it is and I have read a few articles already

3:49 gtg sleep, good night you all

3:50 Sgeo_: Haskell functions can do _some_ of the use-cases of macros in Lisp.

3:50 Good night

4:22 clgv: I want to coinstruct a java object by calling different constructors depending on a flag without repeating the proxy statement

4:23 can I do it simpler than writing another macro for that?

4:35 augustl: what's a good way to use a certain rsa keypair in dev and another in prod, without having access to the prod keypair on my dev box? Seems like you typically embed the files you need your .jar to use in the .jar itself, but I don't want to need to have access to the prod keys in dev.

4:35 I suppose I should fetch the files from the file system and not from the classpath

4:37 I'm thinking an environment variable that contains the path to the folder where the keys can be found should work.

4:38 clgv: augustl: oh you can fetch them from the classpath. just add the path where you stor them to the classpath

4:39 augustl: you could add the path to production or development keys to the classpath depending on what mode you are in.

4:39 augustl: clgv: does that mean my project.clj will contain this path?

4:39 clgv: augustl: depends on your deployment scenario. when you deploy such that you start with leiningen then you could do it like that

4:40 augustl: ah I see

4:40 the thing that launches my app gets to set the classpath, I guess

4:40 clgv: augustl: yeah. or you can also set it in your main-method, e.g. via pomegranate

5:08 augustl: clgv: good stuff, thanks

5:40 zoldar_: #quit

7:04 Sgeo_: comp is my canary. I can't let it break. If I break it, and decide that it's better off special-cased, I can't guarantee that functions that do similar things won't gum up the works.

7:05 And yes, what I just said does in fact make sense to me, if to no one else

7:07 * clgv throws MissingContextException

7:27 abadr: Beginner question: I'm trying to 'require' clojure.math.combinatorics, but I get the runtime error "No such var: clojure.core/clojure.math.combinatorics" when trying to compile. What's wrong?

7:30 Sgeo_: abadr, are you using require, or the ns form?

7:30 Require looks like (require 'clojure.math.combinatorics)

7:30 abadr: Sgeo_: the ns form (:require)

7:30 Sgeo_: If you don't use the ', then it will look for a var with that name in the current namespace

7:30 Oh

7:30 hyPiRion: abadr: are you using leiningen, or just raw clojure?

7:31 abadr: hyPiRion: using leiningen

7:31 and the library is added to my project.clj

7:31 as [org.clojure/math.combinatorics "0.0.3"]

7:32 hyPiRion: and the (ns ... (:require clojure.math.combinatorics)) is the ns-import?

7:34 abadr: oh jeez, I just had a stray paren. sorry guys.

7:34 this is my first project

7:59 bonega: I am trying to get started with Clojurescript - Currently following the piggieback guide

8:00 But I have a probem loading it

8:00 "<script type="text/javascript" src="out/goog/base.js"></script>"

8:00 Should goog/base.js automatically get created? I can surely take goog.jar from clojurescript dir and insert it

8:01 but it seems kind of wrong

8:48 Hodapp: Huh, this paper from 1978 by Backus spoke of the von Neumann languages - which appear largely to be imperative, state-oriented ones - as using a model of the computer that was decades out of date.

8:48 Considering that's from 1978, that hurts a little.

9:06 awestholm: Quick question - can someone enlighten me about Clojure's reasoning on circular dependencies? I'm using Korma to access a few Postgres tables, with a namespace for each table and the methods that manipulate its data. The cyclic dependencies come in when I'm referencing the different tables to allow for joins. This seems like a reasonable thing to do... why does clojure prohibit this? Also, what are

9:06 some opinions on restructuring things so that all the entities are in a single namespace and the data manipulation occurs in different namespaces which refer back to the entities namespace? That seems a little ugly to me, in that I think the logical grouping of a table and related methods rather than all tables makes more sense...

9:10 augustl: I want my method to throw an exception if a map is passed that doesn't have exactly the keys I specify. Any built-in way to do this, perhaps via destructuring?

9:11 awestholm: sounds a bit weird to use namespaces for joins, but I guess Korma is an ORM that requires it?

9:13 awestholm: the reason for why clojure prohibits it is probably because Clojure doesn't really have a concept of files, it's just a sequence of lisp code being evaluated, via files.

9:14 awestholm: disclaimer: I'm not an expert, basing this on http://news.ycombinator.com/item?id=2467809

9:16 nsxt: awestholm: sounds like you need to forward declare the entities

9:16 awestholm: augustl: Korma doesn't require it, I'd just like to separate the logic around each table into its own namespace. So each namespace contains a defentity call, which I believe is a macro which sets up a var/ref that contains whatever Korma's concept of a table happens to be. I'm then using these namespaces in and amongst one another so I've got access to the table entities for joins.

9:17 nsxt: awestholm: i ran into the same issue when i started with korma... i set up a general "entities" file, wherein i defined each of the entities, but then created a "model" namespace for each of the entities so that the logic could be self-contained and separate from those of the other entities

9:19 augustl: https://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/def.clj#L122 seems to be what I'm looking for

9:19 not built-in though..

9:20 S11001001: augustl: it's useless now

9:20 augustl: S11001001: is there something newer and betterer? :)

9:20 S11001001: ,((fn [x y & {:keys [z]}] [x y z]) 1 2 :z 3)

9:20 clojurebot: [1 2 3]

9:21 samrat: if I have raw video file(like this: https://www.refheap.com/paste/5297) how do I convert(or write) it to a video file?

9:21 augustl: does it error if the :z key is not present, and does it work without x and y?

9:21 S11001001: ^^

9:21 awestholm: nsxt: yeah, that's what I was thinking of as an alternative. That said, it feels a little weird to be forced into structuring things that way. Seems like it's causing us to take one large bundle of functionality (the database interactions) and break it up in two different ways (by the specifics of the problem domain, such as separating the different models, and by the nuts and bolts of the app, such

9:21 as the entities). I'm not really sure why, but I feel a little weird with two different decompositions...

9:22 augustl: samrat: how exactly do you "have it"?

9:22 S11001001: augustl: it's destructuring syntax; x and y are required in that example because I listed them as required parameters

9:22 samrat: augustl: dropbox API

9:22 S11001001: augustl: combining optional and keyword params does not make sense

9:22 augustl: samrat: looks like something you might put in a string literal, or the output of a print

9:22 samrat: from the API, do you get a string? Or a byte stream of some sort?

9:23 S11001001: this is what I have now (defn make-app-handler [{:keys [db lucene-dir-factory api-url]}] ...)

9:23 samrat: augustl: i'm trying to download a file from the API using a GET request(https://www.dropbox.com/developers/reference/api#files-GET)

9:23 augustl: S11001001: works fine, but it won't throw an error if any of the listed keys are missing

9:24 samrat: but I get the raw thing when I do clj-http.client/get to the api

9:24 augustl: samrat: if you have a stream, you just write it to a file

9:24 samrat: clj-http probably gives you a byte stream of some sort

9:24 nsxt: awestholm: completely agree. but so long as you have relations, i'm not sure there's any way around it. i'll check the mailing list to see if anyone's come up with any alternatives.

9:24 augustl: samrat: slurp/spit is good for easy mode io

9:24 samrat: I tried the example here: http://clojuredocs.org/clojure_core/clojure.java.io/writer but didn't work

9:25 augustl: samrat: (spit "out.mov" the-stream-or-string-or-whatever)

9:25 S11001001: augustl: and you forgot the &

9:25 samrat: augustl: is spit good for large files though?

9:25 augustl: S11001001: I thought that made the map optional

9:25 S11001001: there is no optional arg syntax in destructuring

9:25 augustl: samrat: why wouldn't it be?

9:26 samrat: clj-http probably puts the entire thing in memory anyways unless you tell it not to

9:26 S11001001: similarly, there is no keyword arg syntax in destructuring; the change that was made was to make destructuring available on the tail

9:26 augustl: try to remove the & from the example I wrote earlier and see the difference

9:27 augustl: S11001001: I added an &, (defn make-app-handler [& {:keys [db lucene-dir-factory api-url]}] (println api-url)). It errors when I give it a map.

9:28 S11001001: augustl: yes

9:28 augustl: so it still doesn't do what I want :)

9:29 S11001001: it's not "keyword arguments" without the &

9:29 so if you just want map destructuring, you just want map destructuring

9:29 augustl: as I said, I want a method that takes a map and errors if certain required keys aren't present

9:29 samrat: augustl: I tried spit, but seems like the content didn't get written properly. VLC gives me an erro

9:29 S11001001: if you want that, why not just make those "required" args positional?

9:29 samrat: augustl: " no suitable decoder module for fourcc `undf'" Any ideas?

9:30 augustl: samrat: what kind of object do you pass to spit?

9:30 samrat: (class the-obj)

9:30 samrat: feel free to paste your code somewhere

9:30 S11001001: the point of keyword args is to provide many options, where the user will typically want to provide few of them

9:30 awestholm: nsxt: appreciate the help. sorry for the delayed reply - sorting out some server issues.

9:30 S11001001: if an arg is always required, then the keyword is boilerplate, and therefore makes the function more annoying to use

9:31 augustl: S11001001: I'll do it by hand (or use the thingie from contrib)

9:31 samrat: augustl: java.lang.String

9:31 S11001001: contrib is deprecated; do not use it

9:31 augustl: samrat: that might be a problem. Strings interpret the bytes with an encoding

9:31 samrat: you want to pass the raw bytes you get from the http request into the file system

9:32 S11001001: writing my own it is, then :)

9:33 nsxt: awestholm: the only thing i could find was this, which just confirms what you've said: ({:Stop [], :updated_on nil, :created_on #inst "2012-09-25T19:32:47.686000000-00:00", :user_id nil, :hike_id 19})

9:33 hike.models.hike=>

9:33 oh dear.

9:34 https://groups.google.com/d/msg/sqlkorma/Byaclz3dJJY/c80IFnilzLcJ

9:38 awestholm: nsxt: thanks for the link. love the disclaimer by the guy who asked the question :)

9:39 nsxt: trying to avoid any potential flames, i guess :)

9:46 samrat: augustl: can't seem to figure out how to do that? (:body (http/get request-url)) seems to give me a string

9:50 augustl: samrat: not sure how to make it into something other than a string

10:14 holo: hi

10:28 Cheiron: holo: hi

10:37 dhofstet: why do I get a warning "replace already refers to #'clojure.core/replace" when I include clojure.string with (:use [clojure.string :as string])?

10:37 shouldn't ":as string" prevent such warnings?

10:41 jkkramer: dhofstet: (:require [clojure.string :as string])

10:43 dhofstet: jkkramer: thanks, that works

10:49 antares_: Elastisch 1.0 is out, 10 months in the works :) http://blog.clojurewerkz.org/blog/2012/09/26/elastisch-1-dot-0-0/

10:55 Hodapp: wha-

10:58 Cheiron: antares_: congrats!

11:02 antares_: Cheiron: thank you

11:06 rjo: is this thread-safe code: https://gist.github.com/3788541

11:07 nDuff: rjo: You should use a ref and put it in dosync

11:07 rjo: ...since there isn't a guarantee that nothing else will change @inverted-index between get-val and insert-term's uses

11:08 rjo: ...whereas a ref will restart the transaction in that case.

11:10 gtuckerkellogg: does recur have problems with restructured named arguments?

11:10 destructured

11:52 Frozenlo`: How would this be written in clojurescript? "location=this.getElementsByTagName('a')[0]"

11:52 danenania: hi clojurians, i have a small noir/aleph websockets app running that i'd like to deploy to an ec2 micro instance, but not having much background in java or sys admin, i'm not really sure where to start. can anyone recommend a tutorial or give me a general idea of the simplest path to get it up?

11:54 Frozenlo`: I end up with "(this-as my-this (set! location (first (.getElementsByTagName my-this 'a'))))" but it's much longer than JS, which I find odd.

11:59 antares_: danenania: I don't think there is a single document that covers it all but it is not difficult. You can either start your Web server in the main fn and build a single jar with lein uberjar, or provision leiningen on the instance and use lein run

12:00 danenania: maybe deploying to heroku would work for you? It's free and for small apps will be sufficient. Not sure if they allow web sockets, though.

12:00 pandeiro: could someone explain or point me to help on the difference between reify and proxy?

12:01 danenania: antares_: ok, i just found the section of the leinegen tutorial that explains the uberjar deployment. that looks like it should work.

12:01 antares_: danenania: the all-in-one jar then can be launched with nohup java -jar [path/to.jar]. A small shell script and something like start-stop-daemon would be sufficient.

12:01 chouser: pandeiro: the important difference in deciding which to use is that reify is faster, but can only implement interfaces. proxy can inherit from concrete classes.

12:01 technomancy: danenania: clojars uses upstart; there's a post to the mailing list describing it. fairly simple.

12:01 danenania: antares: yeah, problem with heroku is it doesn't allow websockets.

12:02 antares_: pandeiro: reify dynamically creates a class that uses provided functions directly. Proxy creates a class that wraps your functions and can be dynamically adjusted at runtime. Reify only works for interfaces, proxy is for extending classes.

12:02 danenania: and how about routing? do i need nginx or some kind of proxy to route incoming traffic to the noir port, or does netty handle that by default?

12:03 pandeiro: chouser: antares_: thanks, trying to process that in my head

12:04 danenania: technomancy: thanks, i'll look at upstart

12:04 antares_: danenania: noir uses jetty, not netty. Jetty is a Web server that can be used w/o Nginx but it is rarely exposed on port 80. It is not as efficient at serving static files. So yes, you generally need Nginx for proxying.

12:06 pandeiro: chouser: do you remember the subethasmtp example i was working on monday? it has a server that wants you to pass it a MessageHandlerFactory instead of a handler itself... reify is working fine but as i try to abstract my code out to a wrapper, i am using ring's jetty adapter as a blueprint, and i noticed it uses proxy to produce an AbstractHandler class for Jetty

12:06 danenania: antares_: i'm using noir with noir-async (https://github.com/andrewvc/noir-async) which puts noir on top of netty. i imagine it's the same deal with netty though?

12:06 antares_: danenania: yes

12:08 chouser: pandeiro: the syntax between proxy and reify is unfortunately a bit different, but if you're not inheriting from a concrete class, it would be better to use reify.

12:08 On the other hand, it really doesn't matter unless you're concerned about performance. USe whatever's more convenient.

12:08 pandeiro: ok gotcha

12:09 one of the differences between subethasmtp and the ring protocol is that subetha expects an interface with 4 discrete functions, whereas ring/jetty uses one handler

12:10 i am wondering how best to abstract the handler into something like ring uses...

12:27 antares_: pandeiro: maybe https://github.com/michaelklishin/langohr/blob/master/src/clojure/langohr/consumers.clj#L22 can serve as an example. You can always add a function that create Java instances you need from a bunch of fns.

12:51 pandeiro: antares_: thanks for that, yeah, i was thinking of just handling either a map explicitly naming the fns with maybe a syntactic shortcut to the most common handler if a fn is provided instead of a map

12:53 ToBeReplaced: hi everyone; newbie here... how come I can do: (Character/isUpperCase \A) , but not (filter Character/isUpperCase "Hi!") ?

12:53 Bronsa: java methods are not first class

12:53 you have to wrap them in functions

12:54 ,(filter #(Character/isUppercase %) "Hi!")

12:54 clojurebot: #<CompilerException java.lang.IllegalArgumentException: No matching method: isUppercase, compiling:(NO_SOURCE_PATH:0)>

12:54 Bronsa: ,(filter #(Character/isUpperCase %) "Hi!")

12:54 clojurebot: (\H)

12:54 ToBeReplaced: ah, got it... thank you!

12:59 jro: I've POST form which posts form data using tag=tag1&tag=tag2, but a route (POST "/r {params :params}) sees only one value in params map. Is there easy workaround for this, or should I change the form instead?

13:00 when I print the params, there is only :tag "tag2" entry

13:02 antares_: jro: what library do you use? clj-http?

13:03 jro: if so, use :form-params: (client/post "http//site.com" {:form-params {:foo "bar"}}). It's in the README: https://github.com/dakrone/clj-http

13:06 jro: ring.middleware/wrap-params

13:10 pandeiro: sounds like he means on the server side?

13:10 been a while since i used the array format on an html form but i don't think that is how it gets serialized in the query string

13:12 TimMc: jro: What happens if your key is named tag[] instead of tag?

13:12 antares_: pandeiro: yes, clj-http kinda mimics the Ring API

13:20 jro: TimMc, with a key :tag[] I still get the last one

13:21 TimMc: Hmm, OK. Worth a try -- some libs treat that specially.

13:34 berdario: Hello, I have 2 questions:

13:35 mikehoy: I did a sudo apt-get install clojure I've tried loadig my simple script with clojure script.clj but it fails

13:36 is it best to install from a jar?

13:36 TimMc: mikehoy: It's best to not install Clojure -- it works as a lib.

13:37 berdario: I have a "RuntimeException EOF while reading", I checked all the parens (I have paredit) and it's still failing... anything else I should pay attention to?

13:37 TimMc: mikehoy: You'll want to use the Leiningen build tool to pull in the right Clojure version (along with other dependencies).

13:38 berdario: here is the code btw: http://bpaste.net/show/SmCmDusaBgFkH9P0N8hp/

13:38 mikehoy: should I purge this old 'isntall' of clojure first?

13:38 TimMc: berdario: It's probably your read-string, then.

13:39 mikehoy: Yes. It is probably an old version, too.

13:39 berdario: mikehoy: I think you can keep it, leiningen will download the new clojure version on its own btw

13:39 TimMc: There are a lot of bad/outdated tutorials out there about getting started with Clojure...

13:39 mikehoy: TimMc: I'm noticing that myself

13:41 TimMc: berdario: I'd *personally* recommend replacing read-string there with #(Long/parseLong %) -- but that's something people argue about. :-)

13:42 berdario: TimMc: uhm... that'll fail with BigIntegers, doesn't it?

13:43 btw, yes... it was read-string... I actually already got that error

13:44 so, maybe... it's still better to use parseLong, at least I'd have a better error message

13:45 ejackson: anybody know the syntax to extend a protocol to a java primitive array ?

13:45 berdario: well, thanks :)

13:49 TimMc: I have another doubt... slightly more philosophical: I already have some experience with other FP languages (haskell, F#, scala)... but aside from the emacs configuration file, I've seldom seen any lisp code

13:49 TimMc: berdario: Yes, that would fail on bignums. But if you use read-string, you need to think about more things: 1) clojure.core/*read-eval*, 2) octal literals

13:50 berdario: I was under the impression, that lisps (and clojure itself) favor quite a bit the FP side (unlike scala, which is ok with mixing imperative and functional style)

13:51 in fact, there's the (do ) form in clojure, to isolate imperative blocks of code

13:52 but then I realized... that (do) and ((fn [] )) seem to do the same thing

13:52 since you can have as many forms as you want, as expressions in the fn "body"

13:53 TimMc: Yes. 'fn has an implicit 'do form.

13:53 I believe 'do is called 'progn in CL.

13:54 berdario: so, what is the consensus? should I refrain from abusing the implicit 'do form? or is it ok to mix and match the two styles?

13:54 emezeske: berdario: 'abuse'?

13:54 hfaafb: http://houseonthehill.net/images/products/cp801.jpg

13:54 sorry

13:54 wrong channel!

13:54 berdario: yeah... "abuse" is a little bit loaded

13:55 I meant, that I thought that idiomatic clojure was strictly functional

13:55 was I under the wrong impression?

13:55 emezeske: I think most people try to write code as functional as possible

13:56 berdario: ok, thanks :)

13:57 TimMc: Clojure does not try to be anything near pure-functional, but it does highly encourage it. :-)

13:57 functional-style, that is

14:02 jkkramer: berdario: btw, your multimethod definition is broken. you want (defmulti add identity), not (defmulti add (fn [s] identity)). the latter dispatches on identity function itself, regardless of argument

14:02 chrisirc: Hello. I forgot the name of the macro that chains functional calculations (passes the result of a form as the first argument in the function call in the next form).

14:03 scriptor: chrisirc: ->

14:03 ,(doc ->)

14:03 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

14:03 chrisirc: Thanks!

14:04 berdario: ChanServ: yes, you're right :) it originally was #(split % #",")... I used this library: https://github.com/clojure/core.match/wiki/Overview but I was now trying to rewrite the same snippet with multimethods... then I realized that the parameter for the method is still the original one, and not the result of the multimethod dispatch function... and I messed up :)

14:04 s/ChanServ/jkkramer

14:27 mpenet: ejackson: you need to use Class/forName

14:28 ejackson: something like (Class/forName "[Lorg.apache.cassandra.thrift.KeySlice;") , if I understood your question correctly

14:32 ejackson: actually no, primitive have special type hints I think something like ^ints etc

14:33 so I guess it would be similar when used from protocols?

14:34 ejackson: mpenet: thanks.

14:36 mpenet: I ended up changing the code to dispatch on the primitive type alone, rather than array-of such. So Integer/type & friends worked out

14:36 I'll try Class/forName now and see

14:38 pandeiro: i want to extend a MimeMultipart class to behave more or less like a seq (count ...) (doseq ...), where can i see which protocols i need to implement?

14:39 ejackson: mpenet: you can do it this way round too: (extend-type (type (int-array [])) ...) but it seems a bit gross

14:39 i mean, what's the literal ?

14:39 mpenet: ejackson: yeah I saw that somewhere

14:39 antares_: ejackson: there is no literal and it is not gross

14:39 pandeiro: it would be nice if i could somehow create a clojure data structure at the repl and inspect which protocols it implements - is that possible?

14:39 mpenet: ejackson: you can use (Class/forName "[I")

14:39 antares_: that's how it also works for byte arrays

14:41 pandeiro: http://clojuredocs.org/clojure_core/clojure.core/satisfies_q, http://clojuredocs.org/clojure_core/clojure.core/extends_q, http://clojuredocs.org/clojure_core/clojure.core/extenders

14:42 pandeiro: antares_: do i need to 'just know' the core protocols though?

14:42 (i don't)

14:42 (yet)

14:42 antares_: pandeiro: most of the core does not use protocols but Java interfaces

14:42 ejackson: antares_, mpenet : thanks.

14:43 Class/forName seems the nicest.

14:44 mpenet: That would also be my choice

14:45 pandeiro: antares_: the stuff in clojure.lang.* seems like what i am after

14:45 just wondering how i might inspect that at the REPL (if possible)

14:46 ah i take it those are implemented as interfaces, not protocols

14:48 LesZedCB: hello guys

14:49 (+ 2 3 4)

14:49 clojurebot: *suffusion of yellow*

14:49 antares_: pandeiro: yes, clojure.lang.IPersistentMap, clojure.lang.Indexed and so on are what you are looking for

14:49 ,(+ 2 3 4)

14:49 clojurebot: 9

14:50 antares_: &(+ 2 3 4)

14:50 lazybot: ⇒ 9

14:50 Sgeo: ....How does clojurebot know what a suffusion of yellow is?

14:50 Or that's probably a term that that nomic took from elsewhere

14:52 mpenet: pandeiro: there is also a nice trick to figure this stuff: https://gist.github.com/2053633

14:52 pandeiro: I think that is from cgrand originally

14:53 ex: https://www.refheap.com/paste/5305

14:59 pandeiro: mpenet: thanks, that is helpful indeed

15:01 so for instance clojure.lang.IPersistentCollection is what something that I want to use (count ...) on has to implement?

15:02 and can I just implement (count [this] ...), and not the other functions?

15:07 mpenet: pandeiro: It was just an example with IPersistentCollection, because it is short :) but depending on what you want to inspect, pass it the clojure type you are interested in

15:09 TimMc: clojurebot: +

15:09 clojurebot: forget (+ 2 3) is 42

15:10 gfredericks: clojurebot: forget?

15:10 clojurebot: you need to put the verb in pipes

15:10 TimMc: Bot, you need to give your factoid DB a good scrubbing.

15:10 haha

15:16 berdario: Uhm, by looking here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go it seems that

15:16 clojure.contrib.repl-utils has been migrated to clojure.repl and clojure.java.javadoc

15:17 I looked here: http://dev.clojure.org/display/doc/Clojure+Contrib but I can't find any mention of these 2 packages

15:20 xeqi: berdario: those part of clojure, not a seperate "contrib" library

15:20 *are part of

15:20 berdario: xeqi: ok, but if I try (require 'clojure.contrib.repl) it fails with

15:21 Could not locate clojure/contrib/repl__init.class or clojure/contrib/repl.clj on classpath

15:21 xeqi: (require 'clojure.repl)

15:21 berdario: uh, duh... but it seems it doesn't have the same functions that contrib.repl (supposedly, since I never used it) contained

15:22 pandeiro: i think i am confused from looking at clojurescript stuff

15:23 where i think many jvm-clojure interfaces are protocols

15:25 i just want to be able to do (count (javax.mail.internet.MimeMultipart. ...)) ;=> 3 or whatever -- so should I just invent my own Multipart protocol and implement (count ...) etc for that MimeMultipart type?

15:26 bonega: Anyone know what to do about this?

15:26 "GET http://localhost:9000/out/goog/base.js 404 (Not Found)"

15:26 I am following the browser-repl part of this: https://github.com/cemerick/piggieback

15:26 goog/base.js doesn't exist in that path, but am I really expected to extract it from goog.jar?


15:27 pandeiro: bonega: no that should've been output as part of some compilation process probably?

15:29 abalone: is there a built-in or idiomatic/conventional two way map?

15:30 pingtimeout: Hi clojurians

15:30 xeqi: bonega: I think cljsc will spit that file out

15:31 abalone: nope, I've seen recommendations just to use two maps

15:34 augustl: what's a good way to read a file from the classpath? Currently have a java.net.URL via `(clojure.java.io/resource "my-file.txt")`

15:35 hmm, perhaps slurp takes a classpath:// url

15:35 hiredman: there is no classpath:// url

15:35 there is jar://

15:35 file://

15:35 augustl: ah

15:36 hiredman: but yes, most clojure.java.io files can take java.net.URL

15:36 augustl: it's a file:// when my project isn't a jar but a checked out git repo. I suppose it'll be a jar:// when it's packaged as a jar

15:37 paultag: is using .*java.* advised? What about clojurescript or the clojure-py thing, how does that port?

15:37 augustl: hmm, I need a byte[], not a string

15:37 paultag: wouldn't one much prefer not using language-local things?

15:38 hiredman: paultag: my advice is to embrace the platform you are on

15:38 paultag: interesting.

15:38 hiredman: clojure is designed to be symbiotic with existing platforms, which means easy interop

15:38 xeqi: paultag: it doesn't port; it might be possible to use some form of crossover files and have platform specific files where necissary

15:39 paultag: hiredman: sure, but that should be the exception, not the rule, no? I just don't like tying myself down if something language-local to foo looks shiny

15:39 hiredman: my understanding is clojure-py isn't really clojure these days? the guy decided to ignore some clojure semantics

15:39 paultag: xeqi: interesting.

15:40 hiredman: paultag: http://clojure.org/rationale

15:40 emezeske: paultag: Pretty much no non-trivial codebase will port between Clojure platforms without work.

15:40 paultag: (I'm still new, and spoiled by jython, pypy and cpython)

15:41 antares_: I can't help but post it here: https://groups.google.com/forum/?fromgroups=#!topic/clojure/sTptS7VmCM0

15:41 paultag: hiredman: reading that now, thank you

15:41 emezeske: interesting.

15:41 emezeske: paultag: Consider, for example, the fact that JavaScript does not have a concept of a "character". That's a pretty fundamental schism between ClojureScript and Clojure.

15:41 paultag: I assume other platforms have equally glaring differences

15:42 paultag: yeah, granted. I'm just suprised the basics (file i/o, net i/o) aren't dumbed down and implemented as part of the clojure runtime

15:42 but I can see the point

15:43 abalone: xeqi: thanks

15:43 hiredman: embrace existing platforms, don't build your own

15:44 duck11231: The problem is that lowest common denominator will keep getting lower as new host platforms are added that don't support X

15:44 augustl: paultag: I think at least 25% of my code is Java interop for what it's worth

15:44 uvtc: paultag: if you like Python, and like the idea of easy interop with (and reliance on) Python, then maybe check out clojure-py (and let us know how it goes!). :)

15:44 augustl: using the Lucene Java APIs directly

15:44 uvtc: does clojure-py use jython?

15:45 paultag: uvtc: I think I will! (but I hate to do something un-idiomatic to most clojure folks)

15:45 augustl: hurm, I'll have to learn more.

15:45 scriptor: augustl: nope, it runs on cpython

15:45 uvtc: paultag: No, it doesn't use Jython. It compiles to CPython bytecode.

15:45 scriptor: it's a from-scratch implementation that's separate from the jvm

15:45 augustl: scriptor: so it creates external python processes?

15:45 paultag: wrong person, uvtc :)

15:45 augustl: I see

15:46 scriptor: augustl: it compiles down to python bytecode which you can then run with: $ python from-clj-py.pyc

15:46 uvtc: paultag: oops! :) augustl ^^ (re. does clojure-py use jython)

15:46 paultag: uvtc: :)

15:49 uvtc: antares_: "fine crafted 16th century process" . Hah. :)

15:59 Frozenlo`: Is there some special steps to use macro in cljs, or is it only when using them in another namespace?

16:00 emezeske: Frozenlo`: You have to put them in a .clj file, and use (:use-macros ...) or (:require-macros ...)

16:00 Frozenlo`: ClojureScript macros are written in Clojure.

16:01 Frozenlo`: Oh I see!

16:01 This just got more complicated :p

16:02 scriptor: Frozenlo`: yep, cljs itself is written in straight clojure, so since macros run in compile time it makes sense you'd have to use clojure instead of cljs

16:10 bonega: xeqi: thanks, not sure what I missed in the process

16:12 Frozenlo`: I feel like Alice. The more I play with JS, the more I go down in the rabbit hole...

16:14 pandeiro: i still don't see how to extend random Java classes to implement eg (count ...) - is this possible in jvm clojure like it is in cljs?

16:16 grettke: Question: Why doesn't this evaluate to 'foo? (#(%) 'foo)

16:17 amalloy: &'(#(%) 'foo)

16:17 lazybot: ⇒ ((fn* [p1__11692#] (p1__11692#)) (quote foo))

16:18 grettke: amalloy: thank you

16:31 gtrak: anyone ever made an if-not-let?

16:37 scriptor: gtrak: wouldn't the binding always be bound to false or nil?

16:37 gtrak: maybe, well, it would act like an if-let only the not-condition would come first?

16:37 amalloy: scriptor: that is one of the two fairly-useless implementations

16:38 gtrak just nailed the other :)

16:38 gtrak: amalloy: yes, I think my final solution is to just make a function :-)

16:38 because there was way to much code in there to figure out where the other branch started

16:39 too*

16:40 if-not seems similarly useless, then

16:40 if you end up having two non-trivial branches

16:41 scriptor: it comes to readability, I guess

17:03 Raynes: ibdknox: I'm being told you don't know what abstraction is. This can't be so! http://news.ycombinator.com/item?id=4577835

17:03 Your whole idea must be flawed!

17:03 Quick, cash out and head to Bermuda.

17:08 grettke: Question. unquote only works when used inside of syntax-quote, right?

17:08 dnolen: grettke: yes

17:09 grettke: dnolen: THanks I just tested it in the repl too but wanted to double check.

18:20 Frozenlock: I've removed every 'require' for files using a particular library, but goog.require still says it can't find it. Does cljs load all the files, regardless or not they are required?

18:22 * nDuff hasn't seen that.

18:23 nDuff: Frozenlock: ...where's goog.require being called for unreferenced code, anyhow?

18:23 Frozenlock: I'd start by tracking down the invocation point and fixing it there.

18:23 * nDuff usually uses cljsbuild compiling to a single file.

18:23 nDuff: ...making "all the files" something that doesn't really apply.

18:23 Frozenlock: I'm looking at the generated JS and it seems that there's still the 'provide' for a file I no longer require.

18:28 I have a main.cljs where I require other cljs in the same folder (for example helperfn.cljs, load.cljs...). In my main, I've removed the require to helperfn.cljs, but when I compile it (without optimization), there's still the code from helperfn.cljs in the exported file.

18:28 Is there some temp file I should be removing?

18:29 nDuff: Using cljsbuild?

18:29 Frozenlock: yup

18:29 I've done cljsbuild clean, but alas, I still have the same problem.

18:29 emezeske: Frozenlock: What's the problem?

18:29 Frozenlock: You aren't using optimizations, so all the code is there

18:30 Frozenlock: If you turn on optimizations, and totally unused goog namespaces are still there, that's weird

18:31 Frozenlock: Ok, so I take that I can't have random files in my directory, even if I'm not requiring them.

18:32 At least the browser repl is still working, so I guess it's not that big of a deal when in dev.

18:32 emezeske: The compiler searches recursively in :source-path for *.cljs files, and compiles them

18:33 If they're not actually used, advanced optimization will probably eliminate their effects on the final JS output

20:04 paultag: given a clojure.lang.PersistentStructMap, how might I get a key by name?

20:04 gtuckerkellogg: I'm not understanding something about either destructuring or recur. in particular, how they work together

20:05 I've made a short example of what surprised me https://www.refheap.com/paste/5298

20:09 antares_: paultag: in Java or Clojure?

20:10 paultag: antares_: Clojure :)

20:11 antares_: paultag: does clojure.core/get not work?

20:11 paultag: I saw key and val, but I couldn't get either to hack

20:11 ah, I missed get. Thanks, antares_!

20:11 (still new)

20:11 amalloy: paultag: don't touch structmaps at all

20:11 just use a regular map; structs are old and deprecated

20:11 paultag: amalloy: it was returned from clojure.xml/pars

20:11 I just checked it's type

20:11 amalloy: haha ew. okay, you're forgiven

20:11 paultag: erm, parse*

20:12 I figured I should research the problem before I asked :)

20:12 ChongLi: a lot about clojure is so refreshing

20:12 emezeske: gtuckerkellogg: The docs for recur say: "The recur expression must match the arity of the recursion point exactly. In particular, if the recursion point was the top of a variadic fn method, there is no gathering of rest args - a single seq (or null) should be passed."

20:12 ChongLi: I love the idea that you don't have to spend time declaring one-off data structures

20:12 emezeske: gtuckerkellogg: http://clojure.org/special_forms#Special%20Forms--(recur%20exprs*)

20:12 ChongLi: or building schemas

20:12 antares_: paultag: clojure.core/get is what you need, it works for all implementations of maps as well as records

20:12 ChongLi: just use a map or a set or a vector

20:13 paultag: antares_: ^5, thanks!

20:13 ChongLi: actually creating a data structure with defrecord or deftype should be reserved as an optimization step

20:13 gtuckerkellogg: emezeske, thank you.

20:15 * gtuckerkellogg hates asking a question that is answered in the docs :-(

20:15 emezeske: gtuckerkellogg: It happens. :)

20:16 arohner: has anyone successfully used https://github.com/martintrojer/frinj ?

20:16 I'm getting stupid errors trying to follow the examples

20:56 holo: hi

20:56 Frozenlock: hello

21:36 weavejester: &(do (deftype T [x]) (->T 1))

21:36 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

21:37 weavejester: ,(do (deftype T [x]) (->T 1))

21:37 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

21:37 weavejester: Hum.

21:37 Raynes: weavejester: Have you seen https://github.com/pliant/lein-war ?

21:38 weavejester: Raynes: Nope

21:38 Raynes: I haven't looked at the code at all, but if it does what it says well it should probably be a patch to lein-ring and not a separate project.

21:38 Just thought I'd point it out to you since I noticed it a few days ago.

21:39 weavejester: Raynes: Hm… the plugin looks like it's designed to work around bugs in Lein-Ring...

21:39 Raynes: That's my point.

21:40 weavejester: There haven't been any issues opened about it...

21:40 Usually when there's a bug, people open issues rather than writing plugins to work around it :)

21:41 Raynes: Well, it's not really a bug.

21:41 lein-ring just dumps a bunch of stuff that isn't necessary into wars, like jetty, etc.

21:41 It doesn't actually hurt anything, but it makes the jar larger than necessary.

21:41 weavejester: I think I'd view that as an issue though

21:42 Even if it doesn't hurt

21:42 It's not exactly optimum

21:46 TimMc: "It was suggested we name our two packages church and state rather than pure and stateful, to insist on the need to keep them separate."

21:47 http://common-lisp.net/~frideau/lil-ilc2012/lil-ilc2012.html

21:47 That's... kind of wonderful.

21:51 weavejester: It looks like the Leiningen REPL uses a different reader version to the code its executing.

21:52 I'd better get to sleep :)

22:00 Sgeo: M-( in paredit is pretty cool

22:01 ChongLi: barf & slurp

22:01 are great stuff

22:02 I just need to get around to removing all the rxvt keybindings that clash with these commands

22:15 ivan`: I have learned the secret of VisualVM: it cannot find processes running in a different tmp directory

22:18 paultag: anyone know anything about Overtone? Anyone know how I can install instruments? I'm getting a *** ERROR: SynthDef piano not found

22:21 it was "installed" by lein via project.clj -- [overtone "0.7.1"]

22:24 aperiodic: my understanding is it should come with everything it needs (it wraps a whole SuperCollider installation)

22:24 paultag: hurm.

22:25 I wonder why it's misbehaving

22:25 aperiodic: you could try setting it up with an external SuperCollider and install instruments into that

22:26 paultag: hurm.

22:26 I can't help but feel like I somehow did this wrong :)

22:29 aperiodic: heh, on the overtone wiki they say that using the internal server isn't supported everywhere, but fail to provide any sort of whitelist or blacklist

22:29 although if you can get any sound out of it that's probably not your problem

22:29 paultag: yeah, I can do sine waves

22:29 I'm about 1 day into clojure, so i'm sure it's my fault

22:31 aperiodic: i dunno, this sounds like it might be an overtone bug to me.

22:31 can you use any other instruments?

22:31 paultag: nack

22:35 aperiodic: nack?

22:35 clojurebot: scoobysnack is botsnack

22:37 paultag: aperiodic: negative ack, sorry, we use that often in debian land.

22:37 aperiodic: none of the others work either

22:39 aperiodic: after I issue a (use 'overtone.live) (and it's good) - (use 'overtone.live)

22:39 erm, http://paste.debian.net/193411/

22:39 sorry, wrong paste.

22:39 aperiodic: yeah, there's nothing in the docs about needing to do anything special to use the instruments. i'd open up an issue

22:39 paultag: libs - http://paste.debian.net/193412/

22:39 aperiodic: hey, thanks!

22:40 aperiodic: I'm @paultag on github if you'd like to tag me there too

22:40 Oh -EPARSE

22:40 opening an issue now

22:41 aperiodic: paultag: my github nick is also the same as here, if you want to blame me :)

22:41 paultag: I will :)

22:41 thanks :)

22:46 Sgeo: clojurebot, literal scoobysnack

22:46 clojurebot: scoobysnack is botsnack

22:46 Sgeo: clojurebot, literal[*] scoobysnack

22:46 clojurebot: scoobysnack is botsnack

22:46 Sgeo: :/

22:47 john2x: is there a library for parsing CSS?

22:47 Sgeo: clojurebot, bucket

22:47 clojurebot: bucket is http://wiki.xkcd.com/irc/Bucket#Docs

22:50 TimMc: Sgeo: clojurebot's factoid engine is random access, with emphasis on the random

22:51 ~scoobysnack

22:51 clojurebot: scoobysnack is botsnack

22:51 TimMc: Hmm, it hasn't inferred that one yet.

22:56 Sgeo: TimMc, it looks like Bucket

22:57 amalloy: Sgeo: it's not

22:58 Sgeo: o.O

22:59 amalloy: i don't understand your hypothesis. you're speculating that clojurebot is an instance of bucket, or using some bucket irc lib, or what?

23:00 Sgeo: Using Bucket's source code

23:01 amalloy: he's not. i can't imagine why that would be so surprising as to merit o.O - i mean, bucket isn't written in clojure, and clojurebot is. that should be basically sufficient to stop worrying about it

23:01 ~source

23:01 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

23:05 arrdem: ~gourds

23:05 clojurebot: SQUEEZE HIM!

23:35 arrdem: clojurebot, litA is clojurebot, litB

23:35 clojurebot: Ack. Ack.

23:35 arrdem: clojurebot, litB is clojurebot, litA

23:35 clojurebot: Roger.

23:35 arrdem: clojurebot, litA

23:35 clojurebot: litA is clojurebot, litB

23:35 arrdem: shoot.

23:36 another bot troll foiled.

23:36 Sgeo: The loop won't work, but you probably want

23:36 clojurebot, lit2A <reply> clojurebot, lit2B

23:36 clojurebot: clojurebot is not a benchmarking platform

23:36 Sgeo: clojurebot, lit2B <reply> clojurebot, lit2A

23:36 clojurebot: clojurebot is a multimap

23:36 Sgeo: clojurebot, lit2A

23:36 clojurebot: I don't understand.

23:37 Sgeo: oh, hmm

23:37 arrdem: (inc sego) ; just for joining in

23:37 lazybot: ⇒ 1

23:37 Sgeo: It's Sgeo not sego

23:37 arrdem: (inc Sego)

23:37 lazybot: ⇒ 2

23:37 arrdem: (dec sego)

23:37 lazybot: You want me to leave karma the same? Fine, I will.

23:38 Sgeo: S. followed by g. followed by e. followed by o.

23:38 arrdem: (inc Sgeo)

23:38 lazybot: ⇒ 1

23:38 arrdem: I'm a nub. tab exists for a reason.

23:38 (doseq [nic ["sego" "Sego"]] (println "(dec" nic ")"))

23:39 ,(doseq [nic ["sego" "Sego"]] (println "(dec" nic ")"))

23:39 clojurebot: (dec sego )

23:39 lazybot: ⇒ -1

23:39 clojurebot: (dec Sego )

23:39 lazybot: ⇒ -2


23:39 ,(set! arrdem -1)

23:39 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: arrdem in this context, compiling:(NO_SOURCE_PATH:0)>

23:39 arrdem: (set! arrdem -1)

23:40 * arrdem will stop playing with the bots now

Logging service provided by n01se.net