#clojure logs

2012-09-26

00:15lnostdalthere's no "break" facility in nrepl.el?
00:16lnostdalor abort or whatever .. to get out of loops started in the REPL
00:16technomancythere's a way to do it; the binding isn't obvious
00:22Sgeo_How difficult is it to make menus in elisp?
00:22Sgeo_I might just end up writing menus or something for these things
00:39nuclearsandwichtechnomancy: sup?
00:43kwertiiAnyone 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.
00:44mpanwho's the purple haired guy doing introduction in the clojure conj videos?
00:48nuclearsandwichmpan: that'd be stuart sierra
00:48nuclearsandwich(probably)
00:52mpannuclearsandwich: thanks!
00:54leonardoborgeskwertii: 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
00:54kwertiileonardoborges: yeah, I'm trying to make a 2d Java array of PersistentVectors
01:14technomancynuclearsandwich: just wondering if you were interested in my laptop
01:14technomancypm
01:14technomancy?
01:39mpanwhat determines when a macro is evaluated to produce the expansion? when the expansion is evaluated to produce the result?
01:40hiredmanmpan: macro epansion happens before compilation , it is basically the first step of the analysis the compiler does
01:41mpanin that case, is it possible for the value of the expansion to be conditional on some of the arguments?
01:44mpanI'm trying to make a contrived example and I'm getting errors
01:45Sgeo_mpan, the arguments to a macro are code
01:46Sgeo_(defmacro mymacro [arg1 arg2] ...)
01:46mpanthis is a contrived example I have trouble understanding: (defmacro foo [x] (if x '1 '0))
01:46Sgeo_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
01:47mpanif I try to evaluate (foo true) vs (foo false), what is the process that happens?
01:48Sgeo_The code (if true '1 '0) is run and the result is placed in place, in this case '1
01:48Sgeo_(For true)
01:48mpanwhat if I then make
01:49mpan(defn bar [x] (foo x))
01:49mpanis it that when bar is called, foo gets compiled??
01:49lazybotmpan: Definitely not.
01:49Sgeo_Note that (foo (== 3 (+ 1 1))) '1 will get placed in because foo sees the expression, not the result
01:49amalloyhigh five, lazybot. keep those right answers coming
01:50amalloympan: no. when bar is compiled, foo is called with the argument 'x
01:50mpanI'm a little worried; how does the bot know what I asked?
01:50amalloythen its result is placed "inline" into the definition of bar
01:50mpanuh oh
01:50Raynesmpan: His hair was blue.
01:50mpandoes bar not do what I think it does, then?
01:50Raynesmpan: It was dark blue and faded slightly so it looked purple in certain lights.
01:51amalloympan: he doesn't. i just taught him that people who ask questions ending with ?? are usually wrong
01:51Raynesmpan: My hair was also blue, but really bright blue.
01:51mpanRaynes: ah cool
01:51Sgeo_lazybot, will you response with an answer effectively meaning "no" to this question??
01:51lazybotSgeo_: What are you, crazy? Of course not!
01:51lazybotSgeo_: Very doubtful.
01:51mpanlolheuristic
01:51mpanman, this is like the time I was convinced elizabot was a real person
01:52mpanwait so, if macros don't conditionally expand at runtime, what does?
01:52amalloynothing. don't do it
01:52mpannot that I can imagine why one would want that
01:53amalloy(eval does, sorta, but don't do it)
01:53Sgeo_amalloy, even if I'm building a REPL???
01:53lazybotSgeo_: Oh, absolutely.
01:53mpan"I don't want to go there" type deal?
01:53amalloySgeo_: if you were building a repl for clojure, eval would make sense. but plenty of lovely repls already exist
01:55mpanso anything that determines a conditional expansion needs to be known at compile time?
01:55Sgeo_But you can expand into code that will do stuff at runtime
01:56mpanI suppose if I keep delaying the expansion/evaluation to the logical extreme, then I have a repl
01:56mpanthanks guys! that cleared up a major misunderstanding I was having before
01:57mpanI had seen some macros that I had believed did run-time expansion
01:59SrPxWhat is the difference between '(this) and [this]
01:59amalloy&(let [this 10] (list '(this) [this]))
01:59lazybot⇒ ((this) [10])
02:00Sgeo_'(this) is a list. [this] is a vector.
02:00Sgeo_Although, I guess '[this] more closely corresponds with '(this)
02:00Sgeo_'[blah] weirds me out a bi
02:00Sgeo_bit
02:01SrPxBut how is a list different form a vector? '(this) and '[this] now
02:03Sgeo_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
02:04SrPxSgeo_: I could be using lists or vectors for the same thing without really noticing a difference, then ?
02:05Sgeo_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.
02:08SrPxOK, thanks
02:08amalloySgeo_: lists and vectors are both excellent stacks
02:09amalloytbh i'd prefer a list unless i had some need to do something other than conj/pop
02:11hiredmanhttps://github.com/hiredman/ed25519/blob/master/src/ed25519/replacements.clj#L5 sweet conditional macro expansion
02:14Sgeo_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
02:15SrPx(:a {:a 1}) works. Is :a a function?
02:16Sgeo_All keywords are (conceptually, if not physically) functions that take a map
02:16Sgeo_,(ifn? :a)
02:16clojurebottrue
02:16hiredmanSrPx: in most of the ways you would ever care about, yes
02:17Sgeo_,(:a {})
02:17clojurebotnil
02:17Sgeo_,(:a {:a nil})
02:17clojurebotnil
02:17Sgeo_This makes me sad.
02:17SrPxWhy?
02:17clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
02:18Sgeo_Does clojurebot use Bucket code o.O
02:18SrPxAlso 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)
02:18Sgeo_Hmm.
02:18Sgeo_,(type 'a)
02:18clojurebotclojure.lang.Symbol
02:18Sgeo_,(type "a")
02:18clojurebotjava.lang.String
02:18Sgeo_,(doc juxt)
02:18hiredmanSrPx: http://clojure.org/data_structures
02:18clojurebot"([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)]"
02:18SrPx,(type? 'a)
02:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: type? in this context, compiling:(NO_SOURCE_PATH:0)>
02:19SrPxwaht
02:19Sgeo_,(map type ['a "a"])
02:19clojurebot(clojure.lang.Symbol java.lang.String)
02:20SrPx((juxt type) ['a "a"])
02:20SrPx,((juxt type) ['a "a"])
02:20clojurebot[clojure.lang.PersistentVector]
02:20hiredmanSrPx: read http://clojure.org/data_structures
02:20SrPx,(print ((juxt type) ['a "a"]))
02:20clojurebot[clojure.lang.PersistentVector]
02:20SrPx):
02:20SrPxoh I get it
02:20SrPx((juxt #(+ 1 %1) #(* 2 %1)) 3)
02:20SrPx,((juxt #(+ 1 %1) #(* 2 %1)) 3)
02:20clojurebot[4 6]
02:20SrPx:D
02:21SrPxNot sure why you told me that but I like it
02:21Sgeo_SrPx, I misthought when wanting to illustrate the types of 'a and "a" in one line
02:21SrPxI see
02:22Sgeo_So I checked the juxt doc to see if that's what I wanted. Not sure why, I am familiar with map.
02:22SrPxmaybe you just learn what juxt is and it was stuck in your head?
02:22SrPxwhere it is anyway? I guess there are more cool things there
02:23SrPx,((map inc) [1 2 3])
02:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$map>
02:23SrPx:(
02:23Sgeo_SrPx, map needs both a function and a seq
02:23SrPxhiredman: I will read it now, thanks
02:24Sgeo_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
02:24Sgeo_,((partial map inc) [1 2 3])
02:24clojurebot(2 3 4)
02:24Sgeo_,(map inc [1 2 3])
02:24clojurebot(2 3 4)
02:29amalloySgeo_: ##(for [coll [{}, {:a nil}]] (:a coll 'not-here))
02:29lazybot⇒ (not-here nil)
02:30amalloyand if you want an if-form that has an explicit else, just use cond instead of if: (cond test then :else else)
02:31Sgeo_,(doc contains?)
02:31clojurebot"([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'."
02:31Sgeo_,(contains? {:a nil} :a)
02:31clojurebottrue
02:32Sgeo_,((fn [key map] (if (contains? map key) [key map] nil)) :a {:a nil})
02:32clojurebot[:a {:a nil}]
02:33Sgeo_,((fn [key map] (if (contains? map key) [(key map)] nil)) :a {:a nil})
02:33clojurebot[nil]
02:33Sgeo_,((fn [key map] (if (contains? map key) [(key map)] nil)) :a {})
02:33clojurebotnil
02:33amalloy&(doc find)
02:33lazybot⇒ "([map key]); Returns the map entry for key, or nil if key not present."
02:34Sgeo_,(find {:a nil} :a)
02:34clojurebot[:a nil]
02:34Sgeo_Cool
02:49SrPx(map #(%1) [1 2 3]) why this does not work? I want it to return the list itself
02:49SrPx,(map #(%1) [1 2 3])
02:49clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
02:50SrPx,(map #(+ %1 0) [1 2 3])
02:50clojurebot(1 2 3)
02:50SrPxUsing + it works but only for numbers
02:50amalloy&'#(%1)
02:50lazybot⇒ (fn* [p1__11272#] (p1__11272#))
02:50SrPx?
02:51SrPx,(map (fn [a] a) [1 2 3])
02:51clojurebot(1 2 3)
02:51SrPxThat is OK.
02:51amalloy&(map (fn [a] (a)) [1 2 3])
02:51lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
02:51SrPxYes I see, Thanks
02:53Sgeo_,(map identity [1 2 3])
02:53clojurebot(1 2 3)
02:54SrPx(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?
02:56Sgeo_,(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
02:56clojurebot({:name "foo", :hp 20} {:name "moo", :hp 30} {:name "boo", :hp 40})
02:58RaynesWhy would he want a seq of maps vs a seq of vectors?
02:59Sgeo_He wrote a function that returns a vector rather than a map
02:59RaynesIt looks like he is working on building a map later.
02:59RaynesSo it makes sense for it to be a vector of vectors.
02:59RaynesEr, seq of vectors.
02:59Sgeo_Oh
02:59Raynes&(into {} '([1 2] [3 4]))
02:59lazybot⇒ {1 2, 3 4}
03:00Sgeo_So then:
03:00RaynesSrPx: Your code doesn't work unless a is a function.
03:00Sgeo_,(map (fn [[name hp]] [:name name :hp hp]) [["foo" 20] ["moo" 30] ["boo" 40]])
03:00clojurebot([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 40])
03:01Sgeo_Raynes, vectors are functions, the goal appears to be to get the 0th and 1st elements
03:01RaynesOh, right, ew.
03:01SrPx?
03:01RaynesI was thinking of the first element of each vector rather than the vector itself as a for some reason.
03:01SrPx,(map (fn [a] [:name (a 0) :hp (a 1)]) [["foo" 20] ["moo" 30] ["boo" 20]])
03:01clojurebot([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 20])
03:02Sgeo_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
03:03lazybot⇒ [100 "Sgeo"]
03:03lazybot⇒ [100 "Sgeo"]
03:03amalloy&(map #(zipmap [:name :hp] %) [["foo" 20] ["moo" 30] ["boo" 20]])
03:03lazybot⇒ ({:hp 20, :name "foo"} {:hp 30, :name "moo"} {:hp 20, :name "boo"})
03:03Raynes(map #(zipmap [:name :hp] ((juxt first second) %)) [["foo" 20] ["moo" 30] ["boo" 20]])
03:03SrPxSgeo_: I did not learn destructuring yet but seems allright, thanks
03:03RaynesI used juxt cuz juxt.
03:03Raynesamalloy: How could you not use juxt?
03:04RaynesI wrap all my vectors in juxt.
03:04Sgeo_,(doc zipmap)
03:04clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
03:05Raynes&(for [[k v] [["foo" 20] ["moo" 30] ["boo" 20]]] [:name k :hp v])
03:05lazybot⇒ ([:name "foo" :hp 20] [:name "moo" :hp 30] [:name "boo" :hp 20])
03:05SrPx(: love that learning
03:06Raynesamalloy: Dude, check it out. Exact same length.
03:06Rayneso/
03:06SrPxfor is very similar to map, is not i
03:06SrPxit*
03:07RaynesYes, but generally better when your function to map is long or needs to destructure its argument.
03:07RaynesEither of our examples are acceptable.
03:07Sgeo_Or when you have multiple sequences?
03:08RaynesSgeo_: Well, they do entirely different things with multiple sequences.
03:08Raynes&(map vector [1 2 3] [4 5 6])
03:08lazybot⇒ ([1 4] [2 5] [3 6])
03:08Sgeo_Oh, I usually think in terms of what for does
03:08Sgeo_List monad etc
03:08Raynes&(for [x [1 2 3] y [4 5 6]] [k v])
03:08lazybotjava.lang.RuntimeException: Unable to resolve symbol: k in this context
03:08Raynes&(for [x [1 2 3] y [4 5 6]] [x y])
03:08lazybot⇒ ([1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6])
03:22Sgeo_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
03:31SrPxhmm
03:31SrPxthanks (:
03:32SrPxthis is something I always wanted in other languages and is so simple on clojure
03:32Sgeo_What, in particular?
03:33SrPxtoo many things actually, but I was talking about (for [x (range 10) y (range 10)] ...)
03:34Sgeo_Ah. Several languages have things like that, they're called list comprehensions usually
03:34Sgeo_Python and Haskell also have them
03:34SrPxI'm not sure you could do this exactly on python
03:35Sgeo_[(x, y) for x in range(10) for y in range(10)]
03:35SrPxsomething like [(x,y) for x in range(10) for y in range(10)]
03:35SrPx... yes, that. But I remember it not working for some reason, not sure though
03:36Sgeo_That's weird, it should
03:36SrPxI think I was trying to do it with a block of code or something
03:36SrPxSo I needed to use the for loops, not the comprehension
03:37Sgeo_Oh, trying to do an action?
03:37SrPxand 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
03:37SrPxdo not remember well though
03:37amalloythat's because of the pointless statement/expression dichotomy :P
03:37SrPxSgeo_: maybe
03:38Sgeo_If Python didn't hate lambdas so much, could do an anonymous function, and then loop through the result and call each function
03:38Sgeo_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
03:39SrPxfor (x,y) in [(x,y) for x in range(3) for y in range(2)]: do_something(x,y)
03:40SrPxSgeo_: this! What is wrong with python's lambda!?
03:40SrPxI mean, why they made it like that? It is horrible and I thought I was the only one who thought so
03:40Sgeo_(doseq [x (range 3) y (range 2)] (do-somethign x y))
03:41SrPxSgeo_: way shorter
03:42Sgeo_sequence_ [do_something x y | x <- [0...2], y <- [0..1]]
03:42Sgeo_iirc
03:43SrPxRuby?
03:43clojurebotChunky bacon!
03:43Sgeo_Haskell
03:43SrPxOr haskell
03:43SrPx(:
03:43SrPxI'm afraid of Haskell
03:43SrPxMight be my next language
03:45Sgeo_It's rather beautiful, although I'm coming to Clojure from Haskell
03:45Sgeo_Mostly because I really like macros, and the idea of changing code while it runs
03:46Sgeo_Both exist in Haskell, both are not especially convenient or liked in Haskell
03:47Sgeo_Oh, and the idea of structuring large programs with monad transformers kind of scares me
03:47SrPxSgeo_: someone pointed you don't need macros in haskell because their functions can already do anything, or something on those lines
03:48SrPxSgeo_: monads is what scares me, I have no idea what it is and I have read a few articles already
03:49SrPxgtg sleep, good night you all
03:50Sgeo_Haskell functions can do _some_ of the use-cases of macros in Lisp.
03:50Sgeo_Good night
04:22clgvI want to coinstruct a java object by calling different constructors depending on a flag without repeating the proxy statement
04:23clgvcan I do it simpler than writing another macro for that?
04:35augustlwhat'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.
04:35augustlI suppose I should fetch the files from the file system and not from the classpath
04:37augustlI'm thinking an environment variable that contains the path to the folder where the keys can be found should work.
04:38clgvaugustl: oh you can fetch them from the classpath. just add the path where you stor them to the classpath
04:39clgvaugustl: you could add the path to production or development keys to the classpath depending on what mode you are in.
04:39augustlclgv: does that mean my project.clj will contain this path?
04:39clgvaugustl: depends on your deployment scenario. when you deploy such that you start with leiningen then you could do it like that
04:40augustlah I see
04:40augustlthe thing that launches my app gets to set the classpath, I guess
04:40clgvaugustl: yeah. or you can also set it in your main-method, e.g. via pomegranate
05:08augustlclgv: good stuff, thanks
05:40zoldar_#quit
07:04Sgeo_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.
07:05Sgeo_And yes, what I just said does in fact make sense to me, if to no one else
07:27abadrBeginner 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?
07:30Sgeo_abadr, are you using require, or the ns form?
07:30Sgeo_Require looks like (require 'clojure.math.combinatorics)
07:30abadrSgeo_: the ns form (:require)
07:30Sgeo_If you don't use the ', then it will look for a var with that name in the current namespace
07:30Sgeo_Oh
07:30hyPiRionabadr: are you using leiningen, or just raw clojure?
07:31abadrhyPiRion: using leiningen
07:31abadrand the library is added to my project.clj
07:31abadras [org.clojure/math.combinatorics "0.0.3"]
07:32hyPiRionand the (ns ... (:require clojure.math.combinatorics)) is the ns-import?
07:34abadroh jeez, I just had a stray paren. sorry guys.
07:34abadrthis is my first project
07:59bonegaI am trying to get started with Clojurescript - Currently following the piggieback guide
08:00bonegaBut I have a probem loading it
08:00bonega"<script type="text/javascript" src="out/goog/base.js"></script>"
08:00bonegaShould goog/base.js automatically get created? I can surely take goog.jar from clojurescript dir and insert it
08:01bonegabut it seems kind of wrong
08:48HodappHuh, 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.
08:48HodappConsidering that's from 1978, that hurts a little.
09:06awestholmQuick 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
09:06awestholmsome 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...
09:10augustlI 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?
09:11augustlawestholm: sounds a bit weird to use namespaces for joins, but I guess Korma is an ORM that requires it?
09:13augustlawestholm: 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.
09:14augustlawestholm: disclaimer: I'm not an expert, basing this on http://news.ycombinator.com/item?id=2467809
09:16nsxtawestholm: sounds like you need to forward declare the entities
09:16awestholmaugustl: 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.
09:17nsxtawestholm: 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
09:19augustlhttps://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/def.clj#L122 seems to be what I'm looking for
09:19augustlnot built-in though..
09:20S11001001augustl: it's useless now
09:20augustlS11001001: is there something newer and betterer? :)
09:20S11001001,((fn [x y & {:keys [z]}] [x y z]) 1 2 :z 3)
09:20clojurebot[1 2 3]
09:21samratif I have raw video file(like this: https://www.refheap.com/paste/5297) how do I convert(or write) it to a video file?
09:21augustldoes it error if the :z key is not present, and does it work without x and y?
09:21augustlS11001001: ^^
09:21awestholmnsxt: 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
09:21awestholmas the entities). I'm not really sure why, but I feel a little weird with two different decompositions...
09:22augustlsamrat: how exactly do you "have it"?
09:22S11001001augustl: it's destructuring syntax; x and y are required in that example because I listed them as required parameters
09:22samrataugustl: dropbox API
09:22S11001001augustl: combining optional and keyword params does not make sense
09:22augustlsamrat: looks like something you might put in a string literal, or the output of a print
09:22augustlsamrat: from the API, do you get a string? Or a byte stream of some sort?
09:23augustlS11001001: this is what I have now (defn make-app-handler [{:keys [db lucene-dir-factory api-url]}] ...)
09:23samrataugustl: i'm trying to download a file from the API using a GET request(https://www.dropbox.com/developers/reference/api#files-GET)
09:23augustlS11001001: works fine, but it won't throw an error if any of the listed keys are missing
09:24samratbut I get the raw thing when I do clj-http.client/get to the api
09:24augustlsamrat: if you have a stream, you just write it to a file
09:24augustlsamrat: clj-http probably gives you a byte stream of some sort
09:24nsxtawestholm: 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.
09:24augustlsamrat: slurp/spit is good for easy mode io
09:24samratI tried the example here: http://clojuredocs.org/clojure_core/clojure.java.io/writer but didn't work
09:25augustlsamrat: (spit "out.mov" the-stream-or-string-or-whatever)
09:25S11001001augustl: and you forgot the &
09:25samrataugustl: is spit good for large files though?
09:25augustlS11001001: I thought that made the map optional
09:25S11001001there is no optional arg syntax in destructuring
09:25augustlsamrat: why wouldn't it be?
09:26augustlsamrat: clj-http probably puts the entire thing in memory anyways unless you tell it not to
09:26S11001001similarly, there is no keyword arg syntax in destructuring; the change that was made was to make destructuring available on the tail
09:26S11001001augustl: try to remove the & from the example I wrote earlier and see the difference
09:27augustlS11001001: 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.
09:28S11001001augustl: yes
09:28augustlso it still doesn't do what I want :)
09:29S11001001it's not "keyword arguments" without the &
09:29S11001001so if you just want map destructuring, you just want map destructuring
09:29augustlas I said, I want a method that takes a map and errors if certain required keys aren't present
09:29samrataugustl: I tried spit, but seems like the content didn't get written properly. VLC gives me an erro
09:29S11001001if you want that, why not just make those "required" args positional?
09:29samrataugustl: " no suitable decoder module for fourcc `undf'" Any ideas?
09:30augustlsamrat: what kind of object do you pass to spit?
09:30augustlsamrat: (class the-obj)
09:30augustlsamrat: feel free to paste your code somewhere
09:30S11001001the point of keyword args is to provide many options, where the user will typically want to provide few of them
09:30awestholmnsxt: appreciate the help. sorry for the delayed reply - sorting out some server issues.
09:30S11001001if an arg is always required, then the keyword is boilerplate, and therefore makes the function more annoying to use
09:31augustlS11001001: I'll do it by hand (or use the thingie from contrib)
09:31samrataugustl: java.lang.String
09:31S11001001contrib is deprecated; do not use it
09:31augustlsamrat: that might be a problem. Strings interpret the bytes with an encoding
09:31augustlsamrat: you want to pass the raw bytes you get from the http request into the file system
09:32augustlS11001001: writing my own it is, then :)
09:33nsxtawestholm: 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})
09:33nsxthike.models.hike=>
09:33nsxtoh dear.
09:34nsxthttps://groups.google.com/d/msg/sqlkorma/Byaclz3dJJY/c80IFnilzLcJ
09:38awestholmnsxt: thanks for the link. love the disclaimer by the guy who asked the question :)
09:39nsxttrying to avoid any potential flames, i guess :)
09:46samrataugustl: can't seem to figure out how to do that? (:body (http/get request-url)) seems to give me a string
09:50augustlsamrat: not sure how to make it into something other than a string
10:14holohi
10:28Cheironholo: hi
10:37dhofstetwhy do I get a warning "replace already refers to #'clojure.core/replace" when I include clojure.string with (:use [clojure.string :as string])?
10:37dhofstetshouldn't ":as string" prevent such warnings?
10:41jkkramerdhofstet: (:require [clojure.string :as string])
10:43dhofstetjkkramer: thanks, that works
10:49antares_Elastisch 1.0 is out, 10 months in the works :) http://blog.clojurewerkz.org/blog/2012/09/26/elastisch-1-dot-0-0/
10:55Hodappwha-
10:58Cheironantares_: congrats!
11:02antares_Cheiron: thank you
11:06rjois this thread-safe code: https://gist.github.com/3788541
11:07nDuffrjo: You should use a ref and put it in dosync
11:07nDuffrjo: ...since there isn't a guarantee that nothing else will change @inverted-index between get-val and insert-term's uses
11:08nDuffrjo: ...whereas a ref will restart the transaction in that case.
11:10gtuckerkelloggdoes recur have problems with restructured named arguments?
11:10gtuckerkelloggdestructured
11:52Frozenlo`How would this be written in clojurescript? "location=this.getElementsByTagName('a')[0]"
11:52danenaniahi 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:54Frozenlo`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:59antares_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:00antares_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:00pandeirocould someone explain or point me to help on the difference between reify and proxy?
12:01danenaniaantares_: ok, i just found the section of the leinegen tutorial that explains the uberjar deployment. that looks like it should work.
12:01antares_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:01chouserpandeiro: 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:01technomancydanenania: clojars uses upstart; there's a post to the mailing list describing it. fairly simple.
12:01danenaniaantares: yeah, problem with heroku is it doesn't allow websockets.
12:02antares_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:02danenaniaand 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:03pandeirochouser: antares_: thanks, trying to process that in my head
12:04danenaniatechnomancy: thanks, i'll look at upstart
12:04antares_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:06pandeirochouser: 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:06danenaniaantares_: 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:06antares_danenania: yes
12:08chouserpandeiro: 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:08chouserOn the other hand, it really doesn't matter unless you're concerned about performance. USe whatever's more convenient.
12:08pandeirook gotcha
12:09pandeiroone 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:10pandeiroi am wondering how best to abstract the handler into something like ring uses...
12:27antares_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:51pandeiroantares_: 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:53ToBeReplacedhi everyone; newbie here... how come I can do: (Character/isUpperCase \A) , but not (filter Character/isUpperCase "Hi!") ?
12:53Bronsajava methods are not first class
12:53Bronsayou have to wrap them in functions
12:54Bronsa,(filter #(Character/isUppercase %) "Hi!")
12:54clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: isUppercase, compiling:(NO_SOURCE_PATH:0)>
12:54Bronsa,(filter #(Character/isUpperCase %) "Hi!")
12:54clojurebot(\H)
12:54ToBeReplacedah, got it... thank you!
12:59jroI'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:00jrowhen I print the params, there is only :tag "tag2" entry
13:02antares_jro: what library do you use? clj-http?
13:03antares_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:06jroring.middleware/wrap-params
13:10pandeirosounds like he means on the server side?
13:10pandeirobeen 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:12TimMcjro: What happens if your key is named tag[] instead of tag?
13:12antares_pandeiro: yes, clj-http kinda mimics the Ring API
13:20jroTimMc, with a key :tag[] I still get the last one
13:21TimMcHmm, OK. Worth a try -- some libs treat that specially.
13:34berdarioHello, I have 2 questions:
13:35mikehoyI did a sudo apt-get install clojure I've tried loadig my simple script with clojure script.clj but it fails
13:36mikehoyis it best to install from a jar?
13:36TimMcmikehoy: It's best to not install Clojure -- it works as a lib.
13:37berdarioI 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:37TimMcmikehoy: You'll want to use the Leiningen build tool to pull in the right Clojure version (along with other dependencies).
13:38berdariohere is the code btw: http://bpaste.net/show/SmCmDusaBgFkH9P0N8hp/
13:38mikehoyshould I purge this old 'isntall' of clojure first?
13:38TimMcberdario: It's probably your read-string, then.
13:39TimMcmikehoy: Yes. It is probably an old version, too.
13:39berdariomikehoy: I think you can keep it, leiningen will download the new clojure version on its own btw
13:39TimMcThere are a lot of bad/outdated tutorials out there about getting started with Clojure...
13:39mikehoyTimMc: I'm noticing that myself
13:41TimMcberdario: I'd *personally* recommend replacing read-string there with #(Long/parseLong %) -- but that's something people argue about. :-)
13:42berdarioTimMc: uhm... that'll fail with BigIntegers, doesn't it?
13:43berdariobtw, yes... it was read-string... I actually already got that error
13:44berdarioso, maybe... it's still better to use parseLong, at least I'd have a better error message
13:45ejacksonanybody know the syntax to extend a protocol to a java primitive array ?
13:45berdariowell, thanks :)
13:49berdarioTimMc: 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:49TimMcberdario: 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:50berdarioI 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:51berdarioin fact, there's the (do ) form in clojure, to isolate imperative blocks of code
13:52berdariobut then I realized... that (do) and ((fn [] )) seem to do the same thing
13:52berdariosince you can have as many forms as you want, as expressions in the fn "body"
13:53TimMcYes. 'fn has an implicit 'do form.
13:53TimMcI believe 'do is called 'progn in CL.
13:54berdarioso, 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:54emezeskeberdario: 'abuse'?
13:54hfaafbhttp://houseonthehill.net/images/products/cp801.jpg
13:54hfaafbsorry
13:54hfaafbwrong channel!
13:54berdarioyeah... "abuse" is a little bit loaded
13:55berdarioI meant, that I thought that idiomatic clojure was strictly functional
13:55berdariowas I under the wrong impression?
13:55emezeskeI think most people try to write code as functional as possible
13:56berdariook, thanks :)
13:57TimMcClojure does not try to be anything near pure-functional, but it does highly encourage it. :-)
13:57TimMcfunctional-style, that is
14:02jkkramerberdario: 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:02chrisircHello. 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:03scriptorchrisirc: ->
14:03scriptor,(doc ->)
14:03clojurebot"([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:03chrisircThanks!
14:04berdarioChanServ: 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:04berdarios/ChanServ/jkkramer
14:27mpenetejackson: you need to use Class/forName
14:28mpenetejackson: something like (Class/forName "[Lorg.apache.cassandra.thrift.KeySlice;") , if I understood your question correctly
14:32mpenetejackson: actually no, primitive have special type hints I think something like ^ints etc
14:33mpenetso I guess it would be similar when used from protocols?
14:34ejacksonmpenet: thanks.
14:36ejacksonmpenet: 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:36ejacksonI'll try Class/forName now and see
14:38pandeiroi 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:39ejacksonmpenet: you can do it this way round too: (extend-type (type (int-array [])) ...) but it seems a bit gross
14:39ejacksoni mean, what's the literal ?
14:39mpenetejackson: yeah I saw that somewhere
14:39antares_ejackson: there is no literal and it is not gross
14:39pandeiroit 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:39mpenetejackson: you can use (Class/forName "[I")
14:39antares_that's how it also works for byte arrays
14:41antares_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:42pandeiroantares_: do i need to 'just know' the core protocols though?
14:42pandeiro(i don't)
14:42pandeiro(yet)
14:42antares_pandeiro: most of the core does not use protocols but Java interfaces
14:42ejacksonantares_, mpenet : thanks.
14:43ejacksonClass/forName seems the nicest.
14:44mpenetThat would also be my choice
14:45pandeiroantares_: the stuff in clojure.lang.* seems like what i am after
14:45pandeirojust wondering how i might inspect that at the REPL (if possible)
14:46pandeiroah i take it those are implemented as interfaces, not protocols
14:48LesZedCBhello guys
14:49LesZedCB(+ 2 3 4)
14:49clojurebot*suffusion of yellow*
14:49antares_pandeiro: yes, clojure.lang.IPersistentMap, clojure.lang.Indexed and so on are what you are looking for
14:49antares_,(+ 2 3 4)
14:49clojurebot9
14:50antares_&(+ 2 3 4)
14:50lazybot⇒ 9
14:50Sgeo....How does clojurebot know what a suffusion of yellow is?
14:50SgeoOr that's probably a term that that nomic took from elsewhere
14:52mpenetpandeiro: there is also a nice trick to figure this stuff: https://gist.github.com/2053633
14:52mpenetpandeiro: I think that is from cgrand originally
14:53mpenetex: https://www.refheap.com/paste/5305
14:59pandeirompenet: thanks, that is helpful indeed
15:01pandeiroso for instance clojure.lang.IPersistentCollection is what something that I want to use (count ...) on has to implement?
15:02pandeiroand can I just implement (count [this] ...), and not the other functions?
15:07mpenetpandeiro: 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:09TimMcclojurebot: +
15:09clojurebotforget (+ 2 3) is 42
15:10gfredericksclojurebot: forget?
15:10clojurebotyou need to put the verb in pipes
15:10TimMcBot, you need to give your factoid DB a good scrubbing.
15:10TimMchaha
15:16berdarioUhm, by looking here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go it seems that
15:16berdarioclojure.contrib.repl-utils has been migrated to clojure.repl and clojure.java.javadoc
15:17berdarioI looked here: http://dev.clojure.org/display/doc/Clojure+Contrib but I can't find any mention of these 2 packages
15:20xeqiberdario: those part of clojure, not a seperate "contrib" library
15:20xeqi*are part of
15:20berdarioxeqi: ok, but if I try (require 'clojure.contrib.repl) it fails with
15:21berdarioCould not locate clojure/contrib/repl__init.class or clojure/contrib/repl.clj on classpath
15:21xeqi(require 'clojure.repl)
15:21berdariouh, duh... but it seems it doesn't have the same functions that contrib.repl (supposedly, since I never used it) contained
15:22pandeiroi think i am confused from looking at clojurescript stuff
15:23pandeirowhere i think many jvm-clojure interfaces are protocols
15:25pandeiroi 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:26bonegaAnyone know what to do about this?
15:26bonega"GET http://localhost:9000/out/goog/base.js 404 (Not Found)"
15:26bonegaI am following the browser-repl part of this: https://github.com/cemerick/piggieback
15:26bonegagoog/base.js doesn't exist in that path, but am I really expected to extract it from goog.jar?
15:26bonega
15:27pandeirobonega: no that should've been output as part of some compilation process probably?
15:29abaloneis there a built-in or idiomatic/conventional two way map?
15:30pingtimeoutHi clojurians
15:30xeqibonega: I think cljsc will spit that file out
15:31xeqiabalone: nope, I've seen recommendations just to use two maps
15:34augustlwhat'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:35augustlhmm, perhaps slurp takes a classpath:// url
15:35hiredmanthere is no classpath:// url
15:35hiredmanthere is jar://
15:35hiredmanfile://
15:35augustlah
15:36hiredmanbut yes, most clojure.java.io files can take java.net.URL
15:36augustlit'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:37paultagis using .*java.* advised? What about clojurescript or the clojure-py thing, how does that port?
15:37augustlhmm, I need a byte[], not a string
15:37paultagwouldn't one much prefer not using language-local things?
15:38hiredmanpaultag: my advice is to embrace the platform you are on
15:38paultaginteresting.
15:38hiredmanclojure is designed to be symbiotic with existing platforms, which means easy interop
15:38xeqipaultag: it doesn't port; it might be possible to use some form of crossover files and have platform specific files where necissary
15:39paultaghiredman: 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:39hiredmanmy understanding is clojure-py isn't really clojure these days? the guy decided to ignore some clojure semantics
15:39paultagxeqi: interesting.
15:40hiredmanpaultag: http://clojure.org/rationale
15:40emezeskepaultag: Pretty much no non-trivial codebase will port between Clojure platforms without work.
15:40paultag(I'm still new, and spoiled by jython, pypy and cpython)
15:41antares_I can't help but post it here: https://groups.google.com/forum/?fromgroups=#!topic/clojure/sTptS7VmCM0
15:41paultaghiredman: reading that now, thank you
15:41paultagemezeske: interesting.
15:41emezeskepaultag: 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:41emezeskepaultag: I assume other platforms have equally glaring differences
15:42paultagyeah, 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:42paultagbut I can see the point
15:43abalonexeqi: thanks
15:43hiredmanembrace existing platforms, don't build your own
15:44duck11231The problem is that lowest common denominator will keep getting lower as new host platforms are added that don't support X
15:44augustlpaultag: I think at least 25% of my code is Java interop for what it's worth
15:44uvtcpaultag: 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:44augustlusing the Lucene Java APIs directly
15:44augustluvtc: does clojure-py use jython?
15:45paultaguvtc: I think I will! (but I hate to do something un-idiomatic to most clojure folks)
15:45paultagaugustl: hurm, I'll have to learn more.
15:45scriptoraugustl: nope, it runs on cpython
15:45uvtcpaultag: No, it doesn't use Jython. It compiles to CPython bytecode.
15:45scriptorit's a from-scratch implementation that's separate from the jvm
15:45augustlscriptor: so it creates external python processes?
15:45paultagwrong person, uvtc :)
15:45augustlI see
15:46scriptoraugustl: it compiles down to python bytecode which you can then run with: $ python from-clj-py.pyc
15:46uvtcpaultag: oops! :) augustl ^^ (re. does clojure-py use jython)
15:46paultaguvtc: :)
15:49uvtcantares_: "fine crafted 16th century process" . Hah. :)
15:59Frozenlo`Is there some special steps to use macro in cljs, or is it only when using them in another namespace?
16:00emezeskeFrozenlo`: You have to put them in a .clj file, and use (:use-macros ...) or (:require-macros ...)
16:00emezeskeFrozenlo`: ClojureScript macros are written in Clojure.
16:01Frozenlo`Oh I see!
16:01Frozenlo`This just got more complicated :p
16:02scriptorFrozenlo`: 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:10bonegaxeqi: thanks, not sure what I missed in the process
16:12Frozenlo`I feel like Alice. The more I play with JS, the more I go down in the rabbit hole...
16:14pandeiroi 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:16grettkeQuestion: Why doesn't this evaluate to 'foo? (#(%) 'foo)
16:17amalloy&'(#(%) 'foo)
16:17lazybot⇒ ((fn* [p1__11692#] (p1__11692#)) (quote foo))
16:18grettkeamalloy: thank you
16:31gtrakanyone ever made an if-not-let?
16:37scriptorgtrak: wouldn't the binding always be bound to false or nil?
16:37gtrakmaybe, well, it would act like an if-let only the not-condition would come first?
16:37amalloyscriptor: that is one of the two fairly-useless implementations
16:38amalloygtrak just nailed the other :)
16:38gtrakamalloy: yes, I think my final solution is to just make a function :-)
16:38gtrakbecause there was way to much code in there to figure out where the other branch started
16:39gtraktoo*
16:40gtrakif-not seems similarly useless, then
16:40gtrakif you end up having two non-trivial branches
16:41scriptorit comes to readability, I guess
17:03Raynesibdknox: I'm being told you don't know what abstraction is. This can't be so! http://news.ycombinator.com/item?id=4577835
17:03RaynesYour whole idea must be flawed!
17:03RaynesQuick, cash out and head to Bermuda.
17:08grettkeQuestion. unquote only works when used inside of syntax-quote, right?
17:08dnolengrettke: yes
17:09grettkednolen: THanks I just tested it in the repl too but wanted to double check.
18:20FrozenlockI'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:23nDuffFrozenlock: ...where's goog.require being called for unreferenced code, anyhow?
18:23nDuffFrozenlock: I'd start by tracking down the invocation point and fixing it there.
18:23nDuff...making "all the files" something that doesn't really apply.
18:23FrozenlockI'm looking at the generated JS and it seems that there's still the 'provide' for a file I no longer require.
18:28FrozenlockI 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:28FrozenlockIs there some temp file I should be removing?
18:29nDuffUsing cljsbuild?
18:29Frozenlockyup
18:29FrozenlockI've done cljsbuild clean, but alas, I still have the same problem.
18:29emezeskeFrozenlock: What's the problem?
18:29emezeskeFrozenlock: You aren't using optimizations, so all the code is there
18:30emezeskeFrozenlock: If you turn on optimizations, and totally unused goog namespaces are still there, that's weird
18:31FrozenlockOk, so I take that I can't have random files in my directory, even if I'm not requiring them.
18:32FrozenlockAt least the browser repl is still working, so I guess it's not that big of a deal when in dev.
18:32emezeskeThe compiler searches recursively in :source-path for *.cljs files, and compiles them
18:33emezeskeIf they're not actually used, advanced optimization will probably eliminate their effects on the final JS output
20:04paultaggiven a clojure.lang.PersistentStructMap, how might I get a key by name?
20:04gtuckerkelloggI'm not understanding something about either destructuring or recur. in particular, how they work together
20:05gtuckerkelloggI've made a short example of what surprised me https://www.refheap.com/paste/5298
20:09antares_paultag: in Java or Clojure?
20:10paultagantares_: Clojure :)
20:11antares_paultag: does clojure.core/get not work?
20:11paultagI saw key and val, but I couldn't get either to hack
20:11paultagah, I missed get. Thanks, antares_!
20:11paultag(still new)
20:11amalloypaultag: don't touch structmaps at all
20:11amalloyjust use a regular map; structs are old and deprecated
20:11paultagamalloy: it was returned from clojure.xml/pars
20:11paultagI just checked it's type
20:11amalloyhaha ew. okay, you're forgiven
20:11paultagerm, parse*
20:12paultagI figured I should research the problem before I asked :)
20:12ChongLia lot about clojure is so refreshing
20:12emezeskegtuckerkellogg: 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:12ChongLiI love the idea that you don't have to spend time declaring one-off data structures
20:12emezeskegtuckerkellogg: http://clojure.org/special_forms#Special%20Forms--(recur%20exprs*)
20:12ChongLior building schemas
20:12antares_paultag: clojure.core/get is what you need, it works for all implementations of maps as well as records
20:12ChongLijust use a map or a set or a vector
20:13paultagantares_: ^5, thanks!
20:13ChongLiactually creating a data structure with defrecord or deftype should be reserved as an optimization step
20:13gtuckerkelloggemezeske, thank you.
20:15emezeskegtuckerkellogg: It happens. :)
20:16arohnerhas anyone successfully used https://github.com/martintrojer/frinj ?
20:16arohnerI'm getting stupid errors trying to follow the examples
20:56holohi
20:56Frozenlockhello
21:36weavejester&(do (deftype T [x]) (->T 1))
21:36lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
21:37weavejester,(do (deftype T [x]) (->T 1))
21:37clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:37weavejesterHum.
21:37Raynesweavejester: Have you seen https://github.com/pliant/lein-war ?
21:38weavejesterRaynes: Nope
21:38RaynesI 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:38RaynesJust thought I'd point it out to you since I noticed it a few days ago.
21:39weavejesterRaynes: Hm… the plugin looks like it's designed to work around bugs in Lein-Ring...
21:39RaynesThat's my point.
21:40weavejesterThere haven't been any issues opened about it...
21:40weavejesterUsually when there's a bug, people open issues rather than writing plugins to work around it :)
21:41RaynesWell, it's not really a bug.
21:41Rayneslein-ring just dumps a bunch of stuff that isn't necessary into wars, like jetty, etc.
21:41RaynesIt doesn't actually hurt anything, but it makes the jar larger than necessary.
21:41weavejesterI think I'd view that as an issue though
21:42weavejesterEven if it doesn't hurt
21:42weavejesterIt's not exactly optimum
21:46TimMc"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:47TimMchttp://common-lisp.net/~frideau/lil-ilc2012/lil-ilc2012.html
21:47TimMcThat's... kind of wonderful.
21:51weavejesterIt looks like the Leiningen REPL uses a different reader version to the code its executing.
21:52weavejesterI'd better get to sleep :)
22:00SgeoM-( in paredit is pretty cool
22:01ChongLibarf & slurp
22:01ChongLiare great stuff
22:02ChongLiI just need to get around to removing all the rxvt keybindings that clash with these commands
22:15ivan`I have learned the secret of VisualVM: it cannot find processes running in a different tmp directory
22:18paultaganyone know anything about Overtone? Anyone know how I can install instruments? I'm getting a *** ERROR: SynthDef piano not found
22:21paultagit was "installed" by lein via project.clj -- [overtone "0.7.1"]
22:24aperiodicmy understanding is it should come with everything it needs (it wraps a whole SuperCollider installation)
22:24paultaghurm.
22:25paultagI wonder why it's misbehaving
22:25aperiodicyou could try setting it up with an external SuperCollider and install instruments into that
22:26paultaghurm.
22:26paultagI can't help but feel like I somehow did this wrong :)
22:29aperiodicheh, 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:29aperiodicalthough if you can get any sound out of it that's probably not your problem
22:29paultagyeah, I can do sine waves
22:29paultagI'm about 1 day into clojure, so i'm sure it's my fault
22:31aperiodici dunno, this sounds like it might be an overtone bug to me.
22:31aperiodiccan you use any other instruments?
22:31paultagnack
22:35aperiodicnack?
22:35clojurebotscoobysnack is botsnack
22:37paultagaperiodic: negative ack, sorry, we use that often in debian land.
22:37paultagaperiodic: none of the others work either
22:39paultagaperiodic: after I issue a (use 'overtone.live) (and it's good) - (use 'overtone.live)
22:39paultagerm, http://paste.debian.net/193411/
22:39paultagsorry, wrong paste.
22:39aperiodicyeah, there's nothing in the docs about needing to do anything special to use the instruments. i'd open up an issue
22:39paultaglibs - http://paste.debian.net/193412/
22:39paultagaperiodic: hey, thanks!
22:40paultagaperiodic: I'm @paultag on github if you'd like to tag me there too
22:40paultagOh -EPARSE
22:40paultagopening an issue now
22:41aperiodicpaultag: my github nick is also the same as here, if you want to blame me :)
22:41paultagI will :)
22:41paultagthanks :)
22:46Sgeoclojurebot, literal scoobysnack
22:46clojurebotscoobysnack is botsnack
22:46Sgeoclojurebot, literal[*] scoobysnack
22:46clojurebotscoobysnack is botsnack
22:46Sgeo:/
22:47john2xis there a library for parsing CSS?
22:47Sgeoclojurebot, bucket
22:47clojurebotbucket is http://wiki.xkcd.com/irc/Bucket#Docs
22:50TimMcSgeo: clojurebot's factoid engine is random access, with emphasis on the random
22:51TimMc~scoobysnack
22:51clojurebotscoobysnack is botsnack
22:51TimMcHmm, it hasn't inferred that one yet.
22:56SgeoTimMc, it looks like Bucket
22:57amalloySgeo: it's not
22:58Sgeoo.O
22:59amalloyi don't understand your hypothesis. you're speculating that clojurebot is an instance of bucket, or using some bucket irc lib, or what?
23:00SgeoUsing Bucket's source code
23:01amalloyhe'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:01amalloy~source
23:01clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
23:05arrdem~gourds
23:05clojurebotSQUEEZE HIM!
23:35arrdemclojurebot, litA is clojurebot, litB
23:35clojurebotAck. Ack.
23:35arrdemclojurebot, litB is clojurebot, litA
23:35clojurebotRoger.
23:35arrdemclojurebot, litA
23:35clojurebotlitA is clojurebot, litB
23:35arrdemshoot.
23:36arrdemanother bot troll foiled.
23:36SgeoThe loop won't work, but you probably want
23:36Sgeoclojurebot, lit2A <reply> clojurebot, lit2B
23:36clojurebotclojurebot is not a benchmarking platform
23:36Sgeoclojurebot, lit2B <reply> clojurebot, lit2A
23:36clojurebotclojurebot is a multimap
23:36Sgeoclojurebot, lit2A
23:36clojurebotI don't understand.
23:37Sgeooh, hmm
23:37arrdem(inc sego) ; just for joining in
23:37lazybot⇒ 1
23:37SgeoIt's Sgeo not sego
23:37arrdem(inc Sego)
23:37lazybot⇒ 2
23:37arrdem(dec sego)
23:37lazybotYou want me to leave karma the same? Fine, I will.
23:38SgeoS. followed by g. followed by e. followed by o.
23:38arrdem(inc Sgeo)
23:38lazybot⇒ 1
23:38arrdemI'm a nub. tab exists for a reason.
23:38arrdem(doseq [nic ["sego" "Sego"]] (println "(dec" nic ")"))
23:39arrdem,(doseq [nic ["sego" "Sego"]] (println "(dec" nic ")"))
23:39clojurebot(dec sego )
23:39lazybot⇒ -1
23:39clojurebot(dec Sego )
23:39lazybot⇒ -2
23:39arrdemKARMA OBLIVION FOR YOU
23:39arrdem,(set! arrdem -1)
23:39clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: arrdem in this context, compiling:(NO_SOURCE_PATH:0)>
23:39arrdem(set! arrdem -1)