#clojure logs

2012-04-06

00:16unlinkHow do I write a compojure route that accesses request and captures a parameter from the route?
00:17unlinkWhat I would like: (defroutes (GET "/user/:uid" (fn [request uid] ...)))
00:17unlinker, defroutes my-routes
00:19unlinkI understand I could do (GET "/user/:uid" [uid] ((fn [uid] (fn [request] ...)) uid)), but that seems like I'm fighting the API
00:19unlink(where the innermost (fn [request] ...) stands for a defn elsewhere)
00:32yokloverr, I don't use compojure but couldn't you do (GET "/user/:uid" [uid] ((fn [request] …) uid)) ?
00:32yoklovunlink: and if that other function is elsewhere that would be (GET "/user/:uid" [uid] (otherfn uid)) which looks pretty natural to me, at least
00:33unlinkyoklov: yes, actually I meant (defn get-user [uid] (fn [request] ...)) (defroutes ... (GET "/user/:uid" [uid] (get-user uid)))
00:33unlinkyoklov: currying is not idiomatic clojure. if this was Haskell, I'd agree with you.
00:35yoklov*shrug*. i don't know how much I agree with you. the 4th parameter to GET needs to be a function?
00:36unlinkyoklov: in order to be passed the request object, it needs to be IFn or IDeref. https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj#L14
00:37yoklovokay, then i would try not to think of this as currying as much as just a function returning a function.
00:37yoklovi wouldn't think of that as currying as much at
00:38yoklovoh weird.
00:38yoklov*just the first line.
00:38unlinkyoklov: well, it's a function returning a function with the express purpose of closing over the first argument...currying.
00:39yoklovi'm not disagreeing that it's currying, i'm just saying you don't have to look at it that way
00:39unlinkah
00:40yoklovif the compojure api requires a function, thats what you have to give it.
00:40yoklovyou're taking data and building a function (which uses that data) to give to the api.
00:41unlinkmaybe #(get-user % uid) is what I should use.
00:41yoklovthats just how i'd think about that though, not necessarially the right way
00:41yoklovoh
00:41yoklovyeah
00:41yoklovthat is.
00:41unlinkbut that is more evidence that I'm doing it wrong. That couldn't be how the API was intended to be used.
00:42xeqiI think its rare to want the full request map
00:42yoklovi'd try to look at some (good) code which uses compojure in that case
00:43muhoogawd, if i'd bought clojurebook.com a month ago, i could have saved a month of asking stupid questions :-/
00:43muhoohis
00:43unlinkyoklov: Most of what I'm coming across is from an incompatible previous release of Compojure.
00:43yoklovbummer :/
00:43unlinkxeqi: I must be very special then, because I need it a lot.
00:44yoklovmuhoo: yeah? i've been going back and forth on buying it
00:44xeqiwhat do you use it for?
00:45unlinkReading the body, checking the content type, checking the content length, dispatching on accept...
00:53amalloyunlink: i don't know what you've read that makes you think you need to do this
00:56amalloyyou can literally just do (GET "/user/:uid" [uid :as request]), i think, or something close ot it
00:56amalloy*to
00:57amalloythat's discussed in the compojure wiki, which is a good resource, but i found it just now by looking at https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L81, which is used by GET
00:58muhooyoklov: it's great
00:58unlinkamalloy: ah yes you can.
00:59muhooyoklov: very practical, very focussed on real-world tasks, more like a howto or documentation. i zip around looking for examples of how to do stuff, find what i need, and move on to getting it done.
00:59unlinkamalloy: a bit creative destructuring, but sufficiently general nonetheless
00:59amalloyyeah, i don't love the asymmetry of his destructuring syntax, but i can understand it as a way to make the common case easy
01:01muhooalmost like a book-length FAQ
01:02yoklovhm, interesting
01:03yoklovyou might be convincing me, i was worried it would be like the joy of clojure. great, but not really a great reference
01:04yoklovmeaning i don't really end up read it
01:04muhooyep, i got part the way through joy of clojure and couldn't finish it
01:05yoklov*reading. i think you're convincing me
01:05muhooanyway, it worked for me. i guess someone with a deeper lisp background might enjoy other books instead. i'm mostly a sysadmin-turned-programmer, so i was totally lost until i found this book.
01:25xumingmingvi got a NPE , the stacktrace is:
01:25xumingmingv at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
01:25xumingmingv at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
01:25xumingmingv at java.lang.Thread.run(Thread.java:679)
01:25xumingmingvCaused by: java.lang.NullPointerException
01:25xumingmingv at backtype.storm.daemon.nimbus$fn__370$exec_fn__1024__auto__$reify__388$iter__429__433$fn__434.invoke(nimbus.clj:810)
01:25xumingmingv at clojure.lang.LazySeq.sval(LazySeq.java:42)
01:25xumingmingv ... 15 more
01:25muhooxumingmingv: refheap.com
01:26xumingmingvmy question is: how to diagnose this kind of exception
01:27xumingmingvi have checked (nimbus.clj:810)
01:27xumingmingvnothing is nil..
01:27xumingmingvany guidance?
01:27xumingmingvand i have also checked LazySeq.java
01:28xumingmingvseems some code in nimbus.clj used LazySeq
01:28xumingmingvhow can i determine who used the LazySeq?
01:29xumingmingvmuhoo: https://refheap.com/paste/1835
01:30bowskiHello @clojure. I was wondering how I could make my definition return a list. Right now it recursively dives into the function skip-list-keys and I'm able to print what I want, but they're backwards (i can use reverse function after this>) and in their own list (I want them all in the same list). Here's what I've got: (print (conj (skip-list-keys (last node)) (first (last node))))
01:30bowskiSorry, that's a boatload at once
01:33xumingmingvor a much simpler question
01:33xumingmingvfrom the stacktrace: at backtype.storm.daemon.nimbus$fn__370$exec_fn__1024__auto__$reify__388$iter__429__433$fn__434.invoke(nimbus.clj:810)
01:34xumingmingvcan i find the real code from the $fn_xxx$fn_yyy ?
01:34jpophello
01:35jpophow can I return something other than object from (doto object ... ) block ?
01:37xeqijpop: doto always returns the first argugment; what are you trying to return?
01:37xeqibowski: where does skip-list-keys come from? try pasting your code and an example call on refheap.com
01:38jpopxeqi I thought I could override that with (return x) inside the block or something similar
01:38jpopguess not?
01:38bowskixeqi: thanks for helping. Here it is. https://refheap.com/paste/1838
01:39amalloyjpop: no, you seem to want to do something other than what doto is for. what structure did you have in mind?
01:39bowskiI'm just trying to make the 3-17 in their own list
01:39amalloybowski: short answer: user a vector or a lazy-seq, not a list
01:39bowskiah ok
01:40amalloyi haven't looked at the code, but just caught up with your question
01:40bowskicontains? should work for that I assume
01:40jpopamalloy i am interfacing Qt's QProcess. I wanted to use doto to avoid having to assign it to a variable and repeat it's name. and I wanted to return result of readAllStandardOutput at the end
01:41amalloywut
01:42amalloyjpop: (.readAllStandardOutput (doto myObj (...) (...) ...))
01:42jpopyeah i guess that would work
01:42amalloybowski: i don't understand your question, but assuming contains? will work for anything is usually a recipe for sadness
01:43jpopa bit odd looking having all the methods in the block except that one though
01:43amalloyso shuffle it around a bit, if you like
01:43amalloy(-> my-obj (doto ...) (.readAllStandardOutput))
01:43bowskiHeh, I hear ya. I was just looking at the contains? documentation and it says "for some reason lists do not work for contains? even though they are sequences"... should have looked earlier :)
01:43amalloy"for some reason"? who wrote that, i'm gonna delete it
01:44bowskiTruely not very professional. now to make this a vector... thanks guys :)
01:44jpopis ... part of the syntax or something i should fill in?
01:44amalloyfill it in
01:45jpopI think i'll just write a doto that returns last form instead of object
01:46amalloybowski: clojuredocs is not an official clojure documentation source. i mean, a lot of good stuff is there, but it's really not "the documentation for contains?"
01:46amalloyso that line was added by some random user who didn't understand contains?
01:46bowskiAh I see. my professor was talking the other day about how the C++ official documentation took 10+ years to be released. I guess it makes sense
01:47amalloythe official clojure documentation is basically your repl, but http://clojure.github.com/ is a precompiled list of those
01:47amalloy~contains?
01:47clojurebotcontains? checks whether an indexed collection (set, map, vector) contains an object as a key. to search a sequence for a particular object, use the `some` function, which accepts a predicate. if you want to only match a certain object, you can use a set as the predicate: for example, (some #{5} (range)) finds the first occurrence of 5
01:48mjijacksonHi all
01:48mjijacksonI'm getting a java.util.IllegalFormatConversionException when I try and do a (format "%.3f" rand)
01:49bowskiwow, awesome
01:49mjijacksonThing is, that code works fine with other floating point numbers, just not rand
01:49mjijacksonAny idea why?
01:49xeqi&(format "%.3f" (rand))
01:49lazybot⇒ "0.737"
01:50mjijacksonxeqi: thanks
01:50mjijacksonjust getting into clojure, still learning the basics :)
01:56bowskiamalloy: so my list is being made like this with lazy-seq: (((((((17)14)13)12)7)4)3). Is there an "append" function like in scheme?
01:57amalloyi think you probably don't understand what i mean by "use lazy-seq", but (a) there's an append for lists, which is necessarily inefficient, and (b) conj adds to the end for vectors
02:01xeqibowski: you're function you pasted looks close to what you want, but (print ..) returns nil
02:01xeqi*your
02:02bowskiI'm really trying to understand this. I'll look at the print functions, is that maybe why? like pr or something else
02:02xeqiwhat happens when you don't print it?
02:03bowskiit looks like it's making a list for each individual item
02:03bowskiso I guess it would return the last item if the function were called
02:06bowskino I don't think that's it... hmm
02:06xeqiand the recursive call is the second argument to cons
02:06xeqisince you're returning (print ..) which is nil, this makes a new list for each call
02:06xeqibut if you just returned then it would cons and have one list
02:07amalloyyes, well spotted
02:07amalloyi kinda glazed over the print
02:07bowskihmm I've taken away the print, but My other test (contains? (skip-list-keys node0) 3) fail
02:08xeqithat gets to the ~contains
02:08xeqithe idiomatic way to search for an item in the list is (some #{3} (skip-list-keys node0))
02:11bowskiAwesome. it works. Thank you a lot for teaching me these things, dudes. I'm going to look up some right now
02:14amalloy&(doc some)
02:14lazybot⇒ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
02:14amalloybowski: lazybot also provides repl services by /msg
02:56senthili created a project with lein, and am trying to include clojure.contrib, but I'm getting java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
02:56senthil(ns clj-play.core :use [clojure.contrib])
03:01sritchiesenthil: the :use clause needs to be in its own list
03:01sritchie(ns clj-play.core (:use [clojure.contrib]))
03:01sritchieand you don't need the vector around clojure.contrib:
03:02sritchie(ns clj-play.core (:use clojure.contrib))
03:02senthilsritchie: diff. error java.lang.ClassNotFoundException: src/clj_play/core.clj
03:02senthili've contrib in my dependencies
03:03sritchiewhat file did you put that in?
03:03senthilvim src/clj_play/core.clj
03:03sritchietry saving it before compiling
03:04senthilsritchie: save what?
03:04sritchiethat text file
03:04sritchiethe source file
03:04senthilsritchie: well ofcourse, hence the diff. error
03:05sritchiewhat do you mean by diff error? thought you meant different error
03:05sritchieoh
03:05sritchieclojure.contrib isn't a library
03:05sritchieclojure.contrib.seq would work;
03:06sritchieif you want to include clojure.contrib, you do that as a dependency in project.clj
03:06sritchiefwiw, clojure.contrib is dead
03:06senthilsritchie: did that and compiled
03:06laurusIs there a way to comment out lines in Clojure mode in emacs?
03:06sritchielaurus: I used textmate-mode
03:06senthilsritchie: what replaced it?
03:06sritchiesenthil: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
03:06sritchieit's broken up into modules now
03:07sritchieanyway, you'd include [org.clojure/clojure-contrib "1.2.0"] in project.clj,
03:07sritchiethen you could do (:use clojure.contrib.macros) or whatever in ns
03:07senthilsritchie: what I want is clojure.contrib.server-socket
03:07sritchie (:use clojure.contrib.server-socket), then
03:07laurussritchie, what about the command "comment-region"
03:08sritchiesenthil: just make sure you add [org.clojure/clojure-contrib "1.2.0"] to your :dependencies in project.clj
03:08senthilsritchie: yea i did, compiled it too
03:08laurusI mean, why is it not bound to any key combination in Clojure mode?
03:08sritchielaurus: not sure
03:08senthilsritchie: but still same error
03:09sritchiesenthil: restart your nailgun server
03:09sritchieI think you have to have created the file before starting whatever process you're using for compilation
03:09laurussritchie, ok thanks!
03:09senthilsritchie: i'm using "lein run", what's nailgun?
03:09sritchiesenthil: sorry, thought you were using something w/ vim
03:10sritchiesenthil: not sure what' s up -- that error usually means you have a typo in the ns name
03:10sritchieor you placed it at the wrong spot
03:10sritchiemake sure you can see it in the fs
03:10senthilsritchie: if i remove the :use line, it works
03:10sritchiehmm
03:11sritchiewhat clojure version?
03:11sritchiepaste your project.clj
03:11senthil1.3.0
03:11sritchieserver-socket probably isn't 1.3 compatible
03:11sritchieso that ns form is failing,
03:12senthilhttp://cl.ly/1Y0p0X2P0p1b1b0A0M1z
03:12sritchiewould this help? https://github.com/clojure/tools.nrepl
03:12sritchiehow about "lein repl"
03:12sritchiethen "(use 'clojure.contrib.server-socket)"
03:13senthilsritchie: lein repl works
03:13senthilsritchie: switched to 1.2.0, still same error
03:14senthilsritchie: just to confirm, i do "lein compile && lein run" right
03:14sritchieyou don't need to compile
03:14sritchiesince you don't have any AOT stuff
03:14sritchiemeaning, there's no (:gen-class) in any namespace
03:15sritchietrying it here
03:15senthilsritchie: http://cl.ly/1V2D0f0S132f060U3V1A; I see 'hi' with 'lein run' before I get the exception
03:15senthiland since println is after the use, maybe its something else
03:16sritchiethis might be a leiningen bug, or a clojure bug
03:17sritchieI think it's a problem w/ the underscore
03:17senthilsritchie: (use 'clojure.contrib.server-socket), that doesn't work either; Exception in thread "main" java.lang.Exception: lib names inside prefix lists must not contain periods (core.clj:3)
03:17senthilha! day 0 and i run into a bug
03:17sritchiehmmmm
03:19sritchieoh!
03:19sritchieI know why
03:19sritchiefor lein run to work, you need a function called -main in the namespace
03:19sritchieotherwise, it wouldn't know what to do
03:20sritchieadd this: (defn -main [] (println "WORKING!"))
03:20sritchieto that namespace
03:20sritchieeven with the require
03:20sritchieerr, with use
03:20sritchie(ns clj-play.core (:use clojure.contrib.server-socket))
03:20sritchiesenthil: no bug, just me forgetting about what lein run does ;)
03:20sritchielein run calls the -main function of the :main namesapce
03:21senthilsritchie: awesome, it works!
03:21sritchiethat's why lein repl worked, and probably put you right into the proper ns
03:21sritchiesenthil: phew
03:21sritchiegood luck, enjoy clojure!
03:21senthilsritchie: thx dude, really appreciate your help & patience
03:21sritchiesenthil: no problem at all, the setup is the toughest part
03:22sritchiethe IRC channel was really great for me when I was learning
03:22sritchiedefinitely take full advantage
03:22sritchiesenthil: does that fix make sense?
03:22senthilsritchie: yes, i did see something about main
03:22senthilbut that error msg said class exception
03:22senthilp.s. are all errors msg this cryptic
03:23sritchiehaha, this was a particularly cryptic one
03:23sritchieI think leiningen tries to compile the :main namespace,
03:23sritchieand doing that requires a -main function
03:23sritchieso it didn't compile, and then couldn't find it
03:23sritchiesenthil: they're getting better, but they can be cryptic
03:23sritchieclojure 1.3 does a good job
03:24sritchiehttps://github.com/mmcgrana/clj-stacktrace
03:24sritchiethat will help
03:24sritchieinstructions at the bottom
03:24sritchiesenthil: good luck!
03:25senthilsritchie: thx!
03:34ggreghi all
03:35autodidaktoggreg: hi
03:37senthilWARNING: spit already refers to: #'clojure.core/spit in namespace: clj-play.core, being replaced by: #'clojure.contrib.duck-streams/spit
03:38senthil(ns clj-play.core (:use [clojure.contrib server-socket duck-streams]))
03:38senthilI get the above error with the below line
03:38senthilUsing lein
03:45autodidaktoyou need to alias (:as) duck-streams
03:46autodidaktowith :require
03:46amalloyor, better, throw duck-streams into the garbage disposal
03:47autodidaktoamalloy: What's that saying? "Code you garbage dispose, you don't have to debug" ?
03:47amalloymeh. many such sayings conveying that general intent exist
03:48amalloyi like "the fastest code is the code you never had to write"
05:31bowskiamalloy: thanks for the help. If you're interested, here's my final project - https://refheap.com/paste/1843 it's a basic skip-list in clojure. Thanks again
05:54prasaadk1I have a function that returns an element, I am calling that function in a loop and I want to create a sequence out of the return values, how should I achieve that?
05:55muhooprasaadk1: for?
05:55muhooor map maybe
05:56prasaadk1ok, I am not able to create a sequence with return values, if I print return values, it works
05:56prasaadk1how do I return the values, and make them a sequence?
05:56prasaadk1is it possible to do that using map?
05:58antares_prasaadk1: that's what map is for
06:00prasaadk1antares_, muhoo: thnks, got it, I was trying to do a doseq and calling a func for every element. map looked better and worked
06:01antares_prasaadk1: doseq is for side effects. It discards results.
06:02prasaadk1side effects? didn't get that, any link that explains that plz ?
06:03prasaadk1another question, this function is creating sequence with some numbers and some sub-sequences, is there any easy way to just flatten that out?
06:06prasaadk1how to flatten out a sequence, that has sub-sequences and numbers
06:09prasaadk1impressed to see the presence of the function "flatten"
07:17solussdwhat's the correct way to list all interfaces/protocols extended to/implemented by an object?
07:18llasramHmm. You can get interfaces through reflection, but I don't think there's a way to know all the protocols an object supports
07:19llasramThat information is kept by the book-keeping structures for the individual protocols
07:19solussdhmm… get all protocols and filter?
07:19llasramI don't think there's a way to do that either :-)
07:21llasramI suppose you could kick things off in an environment where the first thing you did was redefine defprotocol to keep a central record of all protocols defined
07:21llasramBut, why?
07:23oskarthhttp://clojars.org/search?q=clj-time This is confusing. The official one is the last one that was published, but there are plenty others with higher version numbers. What does that mean?
07:28llasramOther people forked the project, and version numbers aren't consistent across the forks?
07:30oskarthright, but the official one is still "the one to use"? As an example it would seem weird if I could form say, twitter-bootstrap, and call it version 3
07:30oskarthI was just confused about that, seeing as the project seems to have changed owner over the years
07:31oskarthif I could fork* say
07:32llasramI don't know for certain, but looking at some of the repository histories, I get the impression that the original author didn't touch it for a long time, a few other people continued development in new forks, then at some point seancorfield's fork become the "official" one
07:33oskarthyeah, that makes sense, thanks
07:34llasramGlad to make things up, any time! :-)
07:59fliebelWhere does leiningen get its classpath from when installed via apt-get? It has aal sorts of /usr/share/java on it, but not the one I want
08:14llasramThe CLASSPATH for lein itself?
10:18prasaadk1I am trying to use a forkjoin.clj , I hv got it from github and I have pasted it in my workspace, how do I import or use functions from that file?
10:22antares_prasaadk1: it depends on how you pasted it and what do you mean by "workspace" but require and use functions are probably what you need
10:25prasaadk1by workspace, I mean in the same directory as my other clj files
10:45lynaghkStyle question: What do you think about prefixing atom variable names with a bang? I'm used to seeing $element from my jQuery days, and I like that it makes "wrapped" values visually distinct.
10:51jtoyare clojars and conjars the same ting, just 2 different places to host at?
10:52TimMcNever heard of conjars
10:52S11001001jtoy: no, clojars is for clojure, conjars is for something else
10:53S11001001Conjars is a dead easy community jar repository for open source *Cascading* libraries and extensions.
10:56prasaadk1I am still struggling to include forkjoin.clj that is in the same directory as other clj files, how do I use it?
10:56llasramprasaadk1: Are you using lein?
10:56TimMcprasaadk1: What does your :require form look like?
10:56prasaadk1llasram: no I am using ccw
10:57prasaadk1(ns paralleldirsize
10:57prasaadk1 (:import java.io.File)
10:57prasaadk1 (:require fj))
10:57llasramDoesn't ccw use lein?
10:58prasaadk1llasram, dnt knw, may be not
10:58TimMcprasaadk1: That statement will only bring in fj.clj at the root of the Clojure source tree. Is that where it is? (It shouldn't!)
10:59TimMc~namespaces
10:59clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
11:00TimMcPoor chouser, always getting highlighted by that unremovable factoid.
11:00prasaadk1its in the same directory as the paralleldirsize
11:00TimMcprasaadk1: Are they both directly in src/ ?
11:01prasaadk1yes
11:01TimMcThat may cause you problems.
11:01prasaadk1TimMc, why so?
11:01TimMcI don't know if it's causing *this* problem, but you should fix it first.
11:01prasaadk1is it because, both have different namespace and are in same directory, which is the problem?
11:01TimMcI'm not actually sure. I have been told such by those who would know. :-/
11:02TimMcprasaadk1: See the clojurebot factoid I pulled up above ^
11:03devngood morning fellow clojurians
11:03fdaoudS11001001: are there any other "dead easy community jar repositories"?
11:03Cpt_HYPERFRITZdevn,
11:03llasramgood morning!
11:04TimMcfdaoud: Check for clojars forks. :-P
11:04Cpt_HYPERFRITZWhat is your opinion on ##(symbol? (symbol "I worship His Shadow"))
11:04lazybot⇒ true
11:05fdaoudTimMc: I thought maybe it was one of those things like stackoverflow that turns out to just be one of many from stackexchange
11:06goodieboywe have a leiningen plugin we're trying to test. It seems that, since we already have a previously published version installed (global plugin), lein test loads up the global plugin first, which is a problem. Anyone know a way around this?
11:07fdaoudgoodieboy: just a shot in the dark-- specify the version number? published versions should *never* be changed.
11:08goodieboyfdaoud: well we don't actually specify our plugin as a dependency to iteself, it seems that because it's a global plugin (~/.lein/plugins) it is always automatically loaded
11:09TimMcYou're trying to use it on itself?
11:09TimMcIn that case, depend on the previous version, I guess. (I think it's that simple...)
11:11goodieboyTimMc: no we're not trying to use it on itself, we want to avoid that so old code doesn't trump our development code. Leiningen appears to be loading the installed version for us though.
11:11goodieboyi'm trying to figure out how to not do that hmm
11:11TimMcWell, there's always lein2... :-)
11:13TimMcgoodieboy: OK, are you saying that you have some test project, and you have a dev-dependency on your plugin, but the .lein/plugins version is what you're getting instead?
11:14goodieboyTimMc: Sorry no. I am trying to test the actual plugin project.
11:14TimMcOh, just lein test?
11:15goodieboyTimMc: Yes. When I do this, it seems that leiningen loads my installed plugin before the same plugin project i'm trying to test. Sorry if this is confusing!
11:16TimMcgoodieboy: What happens if you do `lein trampoline test`?
11:16goodieboyTimMc: let me try that
11:16goodieboy(what does that do?)
11:17TimMcThis might be a lein bug, but trampolining may help avoid it.
11:18goodieboyTimMc: I get: Warning: trampoline has no effect with :eval-in-leiningen.
11:18TimMcOh! This may be beyond me.
11:18jayunit100hmmm
11:18TimMcgoodieboy: It starts a new JVM for the task and allows lein to exit out.
11:18jayunit100 (.toString nil)
11:18jayunit100,(.toString nil)
11:18goodieboyTimMc: OK no problem, at least I know I'm not completely missing something
11:18clojurebot#<NullPointerException java.lang.NullPointerException>
11:19jayunit100thats unfortunate... im used to using my null + operator in java... it "simulates" a to string. Is there a syntactical equivalent in clojure ?
11:19TimMc,(str nil)
11:19clojurebot""
11:19S11001001jayunit100: more importantly, &(let [x (proxy [Object] [] (toString [] nil))] [(str x) (str (str x))])
11:19jayunit100yeah... i guess so . sill question
11:20S11001001er,
11:20S11001001,(let [x (proxy [Object] [] (toString [] nil))] [(str x) (str (str x))])
11:20clojurebot[nil ""]
11:20jayunit100S11001001: huh ?
11:20S11001001you have to call str twice if you want a guarantee :)
11:20TimMcstr returns a Maybe String. :-)
11:22TimMcThis can happen in Java as well, of course.
11:23S11001001honestly I think it's a mistake, str should be a fixpoint
11:27jayunit100oh a maybe string :)
11:27jayunit100yeah that is odd.
11:28cjfriszWhat does it mean when an expression on the SLIME repl comes back with "; Evaluation aborted" but there's no stack trace?
11:28jayunit100can i filter a map function lazily ?
11:28jayunit100so that the mapper doesnt store all results, only the ones that pass a test.
11:28S11001001jayunit100: can your mapper return nil?
11:28jayunit100well - i think thats bad style.
11:28jayunit100id like to do
11:29jayunit100(map :filter (> 1 %) (+ .5) [0 .1 .4 .5 .6])
11:29jayunit100something like that
11:29S11001001first, filter is lazy, and map is lazy
11:29S11001001so chaining them is also lazy
11:30S11001001although filter is funky on chunked seqs, but you can't really count on non-weird laziness from them anyway
11:30jayunit100okay so if you put filter in the front, you get an optimal map
11:33S11001001jayunit100: depending on what your test means; in your example, your filter could go on either side, having different meanings
11:34S11001001indeed, one of the most powerful consequences of the lazy sequences is you can chain maps, filters, and other stream processors together with wild abandon
11:49jtoycan someone tell me why the use doesn't work but require works here: http://pastie.org/3739574
11:50jtoyi normally put all the dependencies in use, but it doesn't seem to work with clj-http
12:00oliverroHi there
12:00antares_jtoy: not sure what does not work, but what you want is probably https://gist.github.com/7fb0947356d09a15ac6b
12:01antares_jtoy: no need to repeat :require and your example does not benefit from deep aliasing either
12:01jtoyantares_: the only part that does not work is calling (client/get "http://google.com&quot;) , all other method calls work
12:02jtoyantares_: ok, i copied that from other people's source code, not sure what the right way is
12:02antares_jtoy: if you use clj-http.client, then get will shadow clojure.core/get
12:02antares_jtoy: define "does not work"?
12:02antares_your gist says "SUCCESS", why?
12:03jtoyantares_: I run (use :reload-all 'interests.core) ; then (client/get "http://google.com&quot;) and get java.lang.Exception: No such namespace: client (NO_SOURCE_FILE:2)
12:03oliverrois there an easy way to do "multiple" update-in at once ? For example : (multiple-update-in {:a 1 :b 2} :a :b inc)
12:03jtoyantares_: then next I do (require '[clj-http.client :as client])
12:03jtoyand then (client/get "http://google.com&quot;) and i get data back
12:04antares_jtoy: I am not sure :reload-all will pick up most recently added dependencies (that lein did not download)
12:04antares_jtoy: if you need an HTTP client example, take a look at https://github.com/michaelklishin/neocons/blob/master/src/clojure/clojurewerkz/neocons/rest.clj#L3
12:04jtoyI copied the require style from here: https://github.com/chunhk/cascalog-hope/blob/master/src/cascalog_hope/core.clj
12:06S11001001jtoy: "use" doesn't copy ns aliases from the ns you're using, you have to change to that ns if you want to use its aliases
12:06antares_jtoy: I think the issue is a missing artifact that REPL won't download, not a particular ns/require style
12:07S11001001iow, "client" is an alias valid *within* interests.core; it doesn't pollute other nses (like user) that just happen to "use" interests.core
12:07S11001001the alternative behavior would be extremely annoying
12:07jtoyS11001001: why can I use the other aliases like json/parse-string ? I require and alias the exact same way
12:08antares_jtoy: did you add clj-http just recently?
12:08antares_jtoy: after you started REPL session?
12:09jtoyno, I added it in code and then lein repl && lein compile && lein repl
12:09jtoylein deps, first
12:38dgrnbrghey technomancy, I have pushed some more code to dgrnbrg/guzheng on github. I wrote a tracer that traces which branches are taken and which are not taken, and has all of the data to generate a report on missing test branch coverage
12:42stringsIs there a difference between 'defmacro' and 'defn' in terms of how they treat arguments?
12:43jtoyis slingshot commonly used? https://github.com/scgilardi/slingshot
12:44mega, (macroexpand '(defmacro a [c b] `(+ ~c ~b)))
12:44clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
12:44drewrjtoy: yes
12:46antares_strings: if compile time vs run time evaluation counts for a difference, then yes
12:49strings'defmacro' treats the argument as a symbol, while 'defn' treats it as a data structure or whatever it's being passed
12:50dnolennice PersistentHashMaps for CLJS not far it seems: https://github.com/thomcc/persistent-hashmap/blob/master/persistent-hashmap.js
12:52technomancydgrnbrg: wow, cool
12:52dgrnbrgtechnomancy: I'm going to try to finish it into a lein plugin
12:52dgrnbrgin the next week or so
12:53technomancydgrnbrg: once you get it polished off I can point to it from the radagast readme
12:53dgrnbrgI'm not sure how to have it operate, though, since it needs to be given a list of test nses and a list of instrumented nses
12:53TimMcstrings: They both define functions that take data. They can both destructure their arguments. The real difference is what they are passed -- macros receive syntactic structures, normal fns receive runtime data.
12:54technomancydgrnbrg: should be able to construct a form to call eval-in-project on; if you have trouble I can probably set you straight
12:54dgrnbrgtechnomancy: I mean the CLI interface
12:54dgrnbrgsince I've only ever seen things like lein test nses...
12:55stringsTimMc: got it! Thanks.
12:55dgrnbrglein guzheng instr-nses… -- test-nses...
12:55dgrnbrg?
12:55dgrnbrgor maybe it just runs all the tests
12:55technomancydgrnbrg: yeah, not sure it makes sense to support a subset of the tests
12:55dgrnbrgwhat if you're developing and broke some tests
12:56dgrnbrgand don't want their stupid errors
12:56TimMcdgrnbrg: What if it chained to another task?
12:56dgrnbrgor you want to see if you cover it from 2 perspectives, since you've organized your tests to test the same code w/ different plugins or something
12:56TimMcdgrnbrg: lein guzheng instr-nses... test test-args...
12:56technomancydgrnbrg: hm; maybe so. but in that case it would make sense to read the lists from project.clj
12:56technomancysince they're unlikely to change over time
12:57dgrnbrgthat seems like a good way to do it
12:57TimMcComposability!
12:57technomancyis guzheng the instrument that guy plays in the first fight scene of the film Hero?
12:58technomancythe one where everyone is playing Go and it's raining?
12:59dgrnbrgtechnomancy: I think so
12:59dgrnbrgI haven't seen that movies in ages
13:00llasramI don't believe I've seen that, but sounds intriguing. Is it one of these? http://en.wikipedia.org/wiki/Hero_(film)#Film
13:00dgrnbrgI am seeing this error and I don't understand what could trigger it: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(REPL:101)
13:01dgrnbrgI think it's related to the way i'm rewriting a condp clause
13:01technomancyllasram: this one: http://en.wikipedia.org/wiki/Hero_(2002_film)
13:01technomancyit's pretty great
13:01megadgrnbrg: can you put the code in a gist?
13:02llasramI haven't seen a good wuxia film in forever. *queued*
13:02technomancyllasram: get the subtitled version if you can
13:02elliottwhi, day two of clojure
13:02elliottwis there a reason why .string/split can handle dashes and .string/capitalize cannot?
13:03dgrnbrgthe gist of the error: https://gist.github.com/2321318
13:04llasramelliottw: Could you provide an example of what you mean?
13:04dgrnbrgI think it's do-condp that fails
13:04elliottwthis works
13:04elliottw(clojure.string/split "scott moritz and thestreet.com’s million iphone la‑la land" #"\s")
13:04technomancydgrnbrg: might need to var-quote on line 57
13:05dgrnbrgtechnomancy: oh snap!
13:05dgrnbrgthat line is wrong
13:05elliottwbut when i do capitalize, i get this: Thestreet.com⊙s
13:05dgrnbrgit got unquote-spliced, i think
13:05elliottwLa⊑la
13:07llasramelliottw: Looks like some sort of encoding error... It works for me in my environment. How are you running the offending code?
13:07llasram&(clojure.string/capitalize "scott moritz and thestreet.com’s million iphone la‑la land")
13:07lazybot⇒ "Scott moritz and thestreet.com’s million iphone la‑la land"
13:07technomancyworks here too
13:08elliottw(defn cap-all [wordstring]
13:08elliottw (if (not (empty? wordstring))
13:08elliottw (cons (clojure.string/capitalize (first wordstring)) (cap-all (rest wordstring)))))
13:09llasramWell, I meant more what sort of interface, exception environment, etc. `lein repl` in a terminal, CCW, SLIME, etc
13:09llasrams,exception,execution,
13:11elliottwlein repl
13:12megadgrnbrg: what is this code for??
13:12lazybotmega: Definitely not.
13:12dgrnbrgmega: it's a branch coverage analyzer
13:13dgrnbrgit rewrites namespaces as they're loaded to enumerate all possible branches and lazy code paths, and then it tracks which ones are executed by the tests
13:13dgrnbrgthen it gives you a report of code paths you failed to test
13:14elliottwi just wanted to build something that turns normal text into titlecase
13:15mkwhat is function associativity?
13:16megadgrnbrg: so this is you decorating the ns guzheng.sample?
13:16dgrnbrgyes
13:16dgrnbrgi think we found the error--it's a let that wasn't wrapped in parens
13:18technomancyelliottw: are you on a mac?
13:18elliottwyup
13:18megadgrnbrg: yea thats probebly it
13:18technomancyelliottw: probably you're getting screwed by macroman encoding I guess
13:18dgrnbrgthis rewriting ASTs gets funky
13:18elliottwdamnit
13:18elliottwi've got this installed on ubuntu, maybe i should start trying it out there
13:19megadgrnbrg: instedd of outputting all the code in every path youst make a function call
13:19technomancyelliottw: or it could be jline; you could see if installing rlwrap fixes it if you haven't got that
13:19megadgrnbrg: to a function in your ns
13:19dgrnbrgmega: i'll fix it later
13:19dgrnbrg:P
13:19dgrnbrgthis is just sort a hack i want to put together
13:19dgrnbrgI actually have 2 other projects that are cooler
13:20dgrnbrgthis is my "drunk weeknights toy"
13:21megadgrnbrg: if you completly macroexpand the code insted you only probebly only need to care about if statements
13:21dgrnbrgdgrnbrg: that seems hard...
13:21dgrnbrgmega: that seems hard
13:22dgrnbrgalso, it might be harder to understand the context
13:22megadgrnbrg: theres a macroexpand-all function in clojure.walk
13:22dgrnbrgthere's only cond, condp, if, fn, and defn
13:22dgrnbrgthat I can think of
13:22megadgrnbrg: and core.match + annything i make up
13:22dgrnbrgI won't be able to help w/ that :)
13:23megadhrnbrg: you culd if it all comes down to if and fn* maybe
13:23megadgrnbrg: but im not shure about that :S
13:24dgrnbrgI don't think that the macro expand calls do a good job w/ line number tracking, iirc
13:24dgrnbrgi might be mistaken, though
13:24elliottwrlwrap?
13:24elliottwtechnomancy: rlwrap?
13:25technomancyrlwrap.
13:25technomancyit's for nicer command-line interaction
13:25technomancybut it can't be included with leiningen since it doesn't run in the jvm
13:25elliottwlooking into it now
13:25elliottwman, ramp up with this language is slow going
13:26technomancyFWIW you don't need rlwrap in lein2
13:26megaand in emacs :D
13:27elliottwi'm using sublimetext2 and lein 1.7.1
13:28technomancyleiningen 2 isn't quite finished yet, so it's probably best to stick with lein 1.7 if you're getting started
13:28technomancyjust to let you know we're working on it =)
13:28technomancycan't fix the insanity of macroman encoding unfortunately =(
13:33technomancylein 1.7 should warn you if you don't have rlwrap installed though
13:33elliottwi've gotten no warnings
13:35technomancywas there a ~/.lein/.jline-warn file created?
13:35technomancyit only emits the warning once
13:35elliottwnope
13:36megaare annyone else here using x-forwading into a virtualbox with ubuntu and emacs
13:36technomancyelliottw: ok, so you must have rlwrap installed. in that case the problem must be with macroman
13:36megamaybe a website with ready images shuld be settup for easy starting with clojure
13:36technomancymega: there's a vagrant project
13:37technomancyhttps://github.com/Seajure/emacs-clojure-vagrant
13:37technomancythat probably assumes emacs
13:37technomancyerr--assumes emacs -nw
13:38megadont think it suports -X ?
13:38technomancyif it does it's by accident
13:39technomancythe scripts were written with tmux in mind
13:40technomancyhonestly I'd just use tmux unless you need to view images or something like that
13:41megai havent used it
13:43elliottwtechnomancy: just tried it in ubuntu and it worked like a charm
13:45elliottwthanks for you help
13:46technomancycool; no problem
13:53autodidaktcemerick: listening to The Changelog podcast. Are you a fan? Might be a good format (inspiration) for some most-lazy episodes
14:06dgrnbrgtechnomancy: I added a report generator and pushed it to github. In an hour I'll write a lein task, and then it'll be useful for anyone, I think
14:07technomancyexcellent
14:08dnolenneat clojure-scheme now passing most of the CLJS tests
14:09technomancyis the clojure-scheme guy on IRC?
14:12dnolentechnomancy: sometimes, I don't see him around now.
14:13technomancywould like to pick his brain re: compiling to elisp =)
14:13dnolentechnomancy: haha! man that's a good idea :D
14:13technomancyI'm still not sure it is. =)
14:14pjstadigtechnomancy: https://twitter.com/#!/stuartsierra/status/187690421558845440
14:14technomancymost schemes make it easy to turn off mutability
14:15technomancypjstadig: ouch
14:15technomancypjstadig: that's what Steve Yegge has been saying for ages though
14:23dotemacsHey guys, I'm trying to organise a Emacs Conference. If you're interested in how it should look like or what you'd like to see, please contribute: http://emacsconf.herokuapp.com/ thanks :)
14:24megadotmacs: in sweden ? :D
14:28dotemacsmega: maybe london, uk :)
14:49antares_dakrone: you around? do you have a few minutes?
14:49dakroneantares_: what's up?
14:50antares_dakrone: I am investigating why clj-http did not handle a relative redirect. It looks like it does work great on master (as soon as I add a lein checkout). Were there fixes for it recently? should I upgrade or look into why it does not happen all the time?
14:51dakroneantares_: what version are you using?
14:52antares_dakrone: I think it is 0.3.4, via one of my REST clients
14:52antares_damn, now with 0.3.6 it works again
14:53antares_dakrone: ok, it must be that 0.3.6 for some reason does work :) thank you for your time
14:53dakroneantares_: I would be interested in knowing what's going on, there weren't any redirect fixes between 0.3.4 and 0.3.6, other than setting the max # to 20
14:54antares_dakrone: I have a gist of debug log I can PM you
14:54dakroneantares_: that would be great
15:05megais there a benifit using tmux over just using emacs?
15:11llasramI know Emacs has only grown the ability to run entirely headless vaguely recently. Last... 2 years? So possibly historical/voodoo reasons
15:12technomancyoh, no I mostly do it since it makes it easier to share the session
15:12technomancywhich you probably don't care about
15:12pipelinestill waiting for a working client/server model in emacs
15:12pipelineyou can have emcas clients issue commands to emacs
15:12llasramOh, this is something technomancy is doing! Nm :-)
15:12megai dont have freands :D
15:12pipelinebut there can only be one X11 server right now :\
15:12pipelineor rather, only one instance of the X11 libraires. you can open windows on multiple displays, from the same client location
15:13llasrampipeline: Are you sure that's true? I used to connect an Emacs session on my work workstation to my home X sever all the time
15:14llasram(which Emacs client was also talking to the workstation X server)
15:14llasramEmacs had a tendency to crash when it lost an X server connection though :-/ so I've switched to `emacsclient -t` instead
15:49ibdknoxdnolen: what's the procedure for picking GSOC proposals?
15:49dnolenibdknox: we'll have to figure that out - was going to put some thoughts together and post on the clojure-dev ML.
15:50ibdknoxdnolen: sounds good :)
15:53ibdknoxdnolen: wasn't there talk of a column preserving reader somewhere?
15:53pipelinellasram: you can't use a local emacsclient to talk to a remote emacs, and a local X server
15:53pipelinellasram: the remote emacs X client will always be the one that gets used
15:53pipelinellasram: also I've found that the non-gtk emacs behaves a lot better when it loses an X session unexpectedly
15:54pipelinesince I almost never have a use for non-bitmap fonts, not having GTK is not much of a loss to me
15:54devni get tons of reflection warnings in my `lein` output -- how can i disable those?
15:55devnkibit has a bunch via core.logic and clucy
15:55devnlein-kibit i mean
15:58dnolenibdknox: not just talk, there's a patch for Clojure - will need to wait for 1.5.0 of course.
15:59dnolenibdknox: seems like it would be useful info for any Clojure debugging tool.
16:03chouseroh. kv-reduce. huh.
16:05ibdknoxdnolen: do you have a link to the patch?
16:06dnolenibdknox: http://dev.clojure.org/jira/browse/CLJ-960
16:06ibdknoxthank you sir!
16:07dnolenibdknox: also, https://github.com/brandonbloom/clojurescript/compare/clojure:master...brandonbloom:track-pos
16:07ibdknoxI've got something exciting brewing :)
16:08dnolenibdknox: I wouldn't expect anything less at this point ;)
16:08nDuffHow can I access a public interface or enum nested in a Java class from Clojure? Simply referring to package.OuterClass.InnerObject is resulting in a ClassNotFoundException.
16:09nDuffoh, n/m
16:12prasaadk1do import and require class? I am importing a java.io.File and :require some other file
16:12prasaadk1*clash
16:16technomancychouser: yeah, so much for the feature freeze
16:16llasrampipeline: (had wandered off); oh, I see what you mean. Makes sense
16:17turbofaildoes pallet have its own irc channel or should i ask questions here?
16:20amalloytechnomancy: wow, and a checked-in (set! *warn-on-reflection* true). that's a disaster if it gets into a build
16:21technomancyamalloy: friends don't let friends, &c
16:22jimdueyturbofail: #pallet
16:22turbofailjimduey: thx
16:23jimdueyibdknox: tease. :p
16:34offby1Is there an easy way to "trace" a function -- i.e., modify the function so that it prints out its name (and perhaps its arguments) when it's entered, and prints out something else (perhaps the return value) when it exits?
16:36technomancyoffby1: two ways: slime has C-c C-t, or you can use the tools.trace library
16:36offby1*nod
16:43nDuffI'm trying to attach Java annotations to an AOT-compiled method in https://gist.github.com/422a11d822458acb2ce4 -- but calling getAnnotations() for catRev returns an empty array. Any hints on what I need to do differently?
16:44jtoyI'm learning about try/catch now, why can't I do this: (println (try (asdadsas) (catch Exception _ "test")))
16:45S11001001jtoy: because you never get inside the try, because your code doesn't compile
16:45jtoyS11001001: is there a way i can test try/catch on the repl?
16:46S11001001yes, do something other than code that can't compile
16:46prasaadk1parallel.clj is now deprecated, which is the new library now?
16:46S11001001like, (.toString nil) or something
16:47S11001001you don't need try for code that doesn't compile; if you can compile your code, you can compile your code, and there is no place for a guard
16:47daniel-renfertry is for runtime, you're not even getting to that point
16:48yoklovdoes anybody else feel like cljs needs some new interop macros? (doto …) is nice, but a lot of javascript apis require set!ing peroperties, which is… awkward.
16:49jtoyok, i think I see, wit try/catch, I should use that with let to try and set a variable and if doesn't then use the caught value , is this a normal clojure idiom?
16:49S11001001that "set a variable" stuff seems exotic to me
16:49dnolenyoklov: you mean like DOM stuff right?
16:49yoklovyeah
16:49yoklovthe dom is the biggest offender
16:49technomancyjtoy: I've always been partial to dividing by zero as my default intentional exception
16:50dnolenyoklov: hmm I don't personally have much of a problem w/ set!, what don't you like?
16:50jtoytechnomancy: cool, I'll keep that in mind
16:50jtoyS11001001: isn't let [name val] basically set variable?
16:51TimMcDoes anyone actually use the binary version of reduce? I've always found myself using the ternary version.
16:51llasramnDuff: I haven't tried it, but I *think* you need to set the metadata on the method name symbol, not the method vector
16:51technomancyclojure doesn't have variables
16:51S11001001it's bind a name to a value; name isn't a variable, and you can't set it
16:51TimMcI think (reduce + ...) is the only time I use arity 2, and that's easily replaceable with (reduce + 0 ...)
16:52yoklovdnolen: mainly that it requires breaking up dotos, so something that might have been a single statement is now 3
16:52jtoyyes, its semantics, but all i mean is have a reference
16:52jtoyie, set a variable
16:52jtoyor bind a name to a value
16:52dnolenyoklov: I'm imagine you have issue with Canvas code here.
16:53yoklovdnolen: haha, yeah
16:53S11001001"semantics" is half of what languages are all about
16:53Raynes'variable' implies the value can vary.
16:53llasramnDuff: Oh man, but ^:static is on the signature vector. Kind of confusing
16:53S11001001things that mean different things mean different things
16:54llasramHmm. Which means shady isn't handling it...
16:54dnolenyoklov: It's easy enough to write sets! or multi-set! macro here - I think Canvas is too specific to have a macro in core for it.
16:54yoklovdnolen: but other parts of the dom require set!ing things. clojure doesn't need anything like that because most java code provides setters
16:54yoklovyeah
16:54yoklovcertainly it is
16:55dnolenyoklov: other bits of the DOM require some set!, but really Canvas is a bit extreme.
16:55jtoyok, i will call it binding name to a value
16:55S11001001well, unless the calculation of that value causes an exception, said binding won't either
16:56S11001001unless you then use the resulting binding in a way that compiles, but causes an exception at runtime
16:57yoklovdnolen: hah, yeah. i guess it's just frustruating that there's no cleaner option. clojure's amazing interop has spoiled me :p
16:57jedmtnman1jtoy: might be able to call it a locally bound ref, or symbol but most would know better than I.
16:57yoklovMaybe I should just cut to the chase and investigate the goog.graphics.* package.
16:58dnolenyoklov: goog Canvas stuff really stinks.
16:58technomancyrefs and symbols are different things from locals
16:58technomancylet works in terms of locals
16:58yoklovdnolen: does it? It sort of has an excessive-OO-abstractiony bullshit smell to it.
16:59jedmtnman1technomancy: thanks for the clarifcation
16:59dnolenyoklov: yeah ... and it's slow to boot.
16:59dnolenyoklov: the low-level stuff is good I think, DOM stuff too - but the Canvas stuff - yuck.
17:00yoklovhah, damn. I won't waste my time with that then
17:05jtoyis there a way to overwrite a defonce defined symbol?
17:07antares_jtoy: a var?
17:08antares_jtoy: that's not really how you do things in clojure but the function you need is called alter-var-root
17:08antares_jtoy: (alter-var-root (var my-var) (constantly my-value))
17:12sridis there a wiki page or something that contains list of libraries known to work on clojure 1.3 (and those that do not)?
17:13sridi'm coming back to clojure after some time, and wondering if i should use 1.3 or 1.2 for my new project (web-based with cljs)
17:13daniel-renfersrid: by now, most of the good libraries are 1.3 compatible
17:13technomancyif something hasn't been updated for 1.3 it's probably abandonware
17:14sridah, good to hear. this is not like python3 at all :)
17:15jtoyantares_: so if that is not how things are normally done, what do ppl use for simple fast testing on repl
17:15technomancyjtoy: for repl stuff just change defonce to def
17:15technomancyand then change it back
17:15antares_jtoy: in the repl, definitely just redefine using def
17:15jtoyoh ok, cool
17:18jtoyany of you guys come from imperative background before clojure? I'm wondering how long it took you to get assimilated, before being productive? i've read through clojure in action and have been coding for ~ 2 weeks, things are pretty slow , although making decent progress
17:19daniel-renferLearning clojure is a series of "aha" moments
17:21jtoyit seems pretty cool so far, but a bunch of stuff i still think, "i don't see how someone could naturally want to program that way", probably bc not enough experience yet
17:24jtoyfor anyone who didn't see this yet: https://github.com/takeoutweight/clojure-scheme
17:29beffbernardLets say I have a user-model that stores a user into a persistent store.. What's proper style with dealing with the connection? Do I pass it in or use something like (with-connection …) or is it ok if I have a global connection?
17:31daniel-renferI think more often than not, something like that gets stored to a ref (or similar) and accessed that way
17:35technomancyprobably a thread-local
17:37beffbernardok
17:43dgrnbrgdoes anyone know why this lein plugin npe's in the loader (only see an NPE in line 1) of that file. Rest of source is at https://github.com/dgrnbrg/guzheng
17:44dgrnbrgtechnomancy: you probably know the answer
17:48technomancydgrnbrg: lemme see
17:48technomancywhat file?
17:48dgrnbrgthanks :)
17:48dgrnbrgthe gist has the plugin
17:48dgrnbrgit's @ src/leiningen/guzheng.clj
17:49technomancyI don't see a gist
17:49dgrnbrgI tried to follow the template in radagast
17:49dgrnbrghttps://gist.github.com/2323127 :)
17:49technomancyoh... don't follow radagast; it will only work with lein1
17:49technomancyhaven't gotten around to updating it yet
17:50dgrnbrgah
17:50technomancyin this particular case you're using leiningen 1 but calling eval-in-project using the arity from leiningen 2
17:50dgrnbrggot another template?
17:50clojurebotPardon?
17:50dgrnbrgOr is this just a 1-liner?
17:50technomancyif you have leiningen 2, just do "lein new plugin lein-guzheng"
17:50technomancyif you have lein1, you use the lein-newnew plugin
17:51dgrnbrgthat makes it part of the current project?
17:51technomancywell the thing is in lein2 you can't have in-project code in the same jar as in-leiningen code
17:51dgrnbrgi see
17:51technomancyyou need guzheng and a separate lein-guzheng jar
17:51technomancyI'd recommend doing plugin development in lein2 and testing it in lein1 once it's working
17:51dgrnbrgdo you have an example project I could refer to?
17:51dgrnbrgI've only ever used lein1
17:52technomancy"lein new plugin lein-guzheng" will spit out a sample you can work from
17:52dgrnbrgbut I don't have lein2?
17:52technomancyclojurebot: plugin guide?
17:52clojurebotHuh?
17:53technomancyok, you can install the lein-newnew plugin then if you want to keep using leiningen 1
17:53dgrnbrgI'll need to get that first, and then use the plugin system?
17:53dgrnbrgok
17:53technomancyhttps://github.com/Raynes/lein-newnew/
17:53dgrnbrgso lein newenew plugin lein-guzheng?
17:53technomancyno, just "lein new"
17:53technomancyhttps://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md <- lots of good stuff in here too
17:53dgrnbrgok
17:55jblomois there a way to generate a class with multiple fields? for java interop?
17:56jblomogen-class seems to just allow 1, defrecord doesn't let you inherit from another class
18:00sritchiejblomo: use a map for the state, then write setters and getters?
18:04jblomosritchie: hrm, yea, I would like to add javax.validation.constraints to the fields, to fit in with the java framework. sounds like it may be easier just to write this part in Java
18:06jblomohrm, maybe another way to write is with defrecord. can one provide default values for fields?
18:09megaanny one whant to try out https://github.com/megakorre/cljs-event
18:09megahave someone done annything simular?
18:50dgrnbrgtechnomancy: I've made a guzheng & lein-guzheng project on my github, but I don't understand the error in the lein-guzheng plugin
18:50dgrnbrgit seems to be unable to get guzheng
18:50dgrnbrgI've never done any of this packaging though, or really looking into lien's internals
18:51technomancydgrnbrg: you'll need to add guzheng into the project's dependencies if it's not there already; lemme find an example
18:51technomancyhttps://github.com/technomancy/swank-clojure/blob/master/lein-swank/src/leiningen/swank.clj#L59
18:53dgrnbrgI'm failing to have it run even w/in the plugin's dir itself
19:23jayunit100how can i get the values 1 through 4 in an map ? (i.e. i believe maps are ordered in clojure. right?)(
19:24technomancyjayunit100: no, maps aren't ordered
19:24jayunit100hmmm. but they are seqable ?
19:25technomancyyep
19:25jayunit100so does the seqable have a default ordering ?
19:25jayunit100I could use a java tree set
19:25antares_there is sorted-map
19:25jayunit100ah ok
19:25technomancyfor a given immutable map, every call to seq will have a deterministic order
19:25technomancybut as soon as you assoc something else in, no guarantee holds
19:26jayunit100oh ok, so its not a dynamic function implementing the ordering... its some other mechanism .
19:31yoklovdoes anybody know the reason behind the lack of complex numbers in clojure?
19:33yoklovbecause goddamn i would kill to have those built in.
19:38yoklovat least there's Ratio, but that's not nearly as useful as complex (in my opinion, at least)
19:39FrozenlockLack of complex numbers is surprising. Advantage Emacs :P
19:39mkperhaps they simply haven't been implemented
19:39offby1so ... profiling. I see there's a clojure.contrib.profile, but I was hoping for something that would periodically sample the stack, so that I wouldn't have to stick probes all in my code ... is there anything like that?
19:40yoklovi'd be extremely happy if clojure got them in the future
19:40mkwhy not add them
19:41yoklovno way to do it with any hope of efficiency and still get to use + - * / etc.
19:41yoklovalgo.generic makes those into multimethods
19:42yoklovit would have to be in the java side
19:42yoklov(probably)
19:43mkI was thinking that it would be nice to have an approx+, approx* etc., which would cast numbers to floating points
19:43mkif they were already floating point, the language wouldn't need to cast
19:45mk,[(+ (double 0.1) (double 0.2)) (+ (float 0.1) (float 0.2))]
19:45clojurebot[0.30000000000000004 0.30000000447034836]
19:46yoklov(defmacro approx+ [& forms] `(+ ~@(map #(list 'double %) forms)))
19:46mkthat can't be right. And oddly, my clojure gives 0.3 for the second one
19:47mklooks like that's due to the version
19:48mkyoklov: not sure - the idea would be to have even true numbers implemented as floats
19:49yoklov?
19:49yoklovtrue numbers?
19:50mkproper numbers. The idea is that approx+ wouldn't do type conversion
19:52yoklovhow would that be possible?
19:52mkunsure. Usually ratios are represented by two ints, but there's no reason they couldn't sometimes be represented by a float or double
19:53yokloverr
19:53yoklovyeah there is?
19:53yoklovratios?
19:53yoklovi mean
19:53mkright. Only some values
19:53yoklovthe definition of rational number
19:53yoklovfrom... math
19:53mkfor example, 1/2 can be represented by float0.5
19:54yoklovoh, i thought you said *two floats or doubles
19:54yoklovthough, that would mean there's no point to the rational numbers
19:55mkwell, it could also be represented by 1.0 and 2.0 (or 1.0 : 1.0), but I don't see why that would be an efficiency gain
19:55yoklovno it wouldn't.
19:55yoklovit would be terrible in fact
19:56yoklovthe reason (or, at least, one reason) to have rational numbers is there are algorithms that only work if you have percise fractions.
19:56mkif we're about to throw a very complicated number into a lot of approx-math, then we can essentially pretend that the number is backed by floats (or doubles)
19:58mkso the language might simply convert it to a float, do the approximate math, and then toss it back out - but, importantly, the type wouldn't change
19:58yoklovthat's probably not possible
19:59yoklovi don't know if you can go from exact -> inexact -> do some math -> exact
20:00aperiodicis it possible to create an enum type in clojure?
20:00amalloyit's trivial, if you are a wizard with a magically-enhanced FPU, yoklov
20:00mkunsure. You might compose all the steps into a single math step, check if all the math in there is approximate, and if it is, do a single typecast at the start, and a single typecast at the ned
20:00amalloybut otherwise probably not possible
20:01yoklovmk: right, lets say you can do that (composing the steps sounds hard but whatever), you still might get a wrong answer in the end
20:01amalloymk: i think you're saying a lot of things that sound to you kinda like they would be cool individually, but don't have sufficient internal consistency for someone to convince you otherwise. perhaps you should try implementing something yourself, and come back when you have something more concrete to discuss
20:03yoklovwhen you go from rational -> double, say, you lose information, and the semantics of doubles aren't such that you can really expect the answer to be right at the end, or even particularly guessable.
20:03yoklovi mean go for it :p, it will probably be nifty either way
20:04mkamalloy: if you have a solid reason against the idea, bring it up. I'm just thinking out loud and, I suppose, seeing what others think. That's a step towards having something more concrete to implement.
20:06mkyoklov: you lose information, but you'd lose it even if you used approx+ on a rational. (approx+ 1/10 1/5) would yield the fractional representation of .30..04, for example
20:06aperiodici found this old conversation in here between amalloy and seancorfield about it, but it seems that seancorfield was just reifying instances of an externally-defined enum type
20:06yoklovmk: yeah, i'm not sure if i see a need for approx+ either :p
20:08mkyoklov: because the programmer wouldn't think of numbers as being approximate, but as exact (even doubles), and the operations as being approximate
20:09amalloyaperiodic: i don't think you can create a jvm-style enum class from clojure
20:09beffbernardWhat does the convention of an asterisk suffix mean? e.g. with-bindings*, with-connection*
20:10amalloy"internal", roughly. or "helper" or whatever
20:10beffbernardamalloy: k
20:11technomancyit means "I couldn't be bothered to think of a good name for this function"
20:12beffbernardtechnomancy: lol, if that were the case, I'd have a methods like, foo********
20:12amalloyoh man. you just stole my exact joke, beffbernard
20:12amalloyexcept i was going to accuse technomancy of having projects full of such functions
20:12beffbernard:D
20:12mkyou don't even need the foo at the front
20:13aperiodicamalloy: could you explain what you mean by jvm-style? could i fake it somehow?
20:13amalloyyou can write any number of "enum-like" things in clojure
20:13aperiodicwell, i guess i need a completely jvm-style one
20:14aperiodici need to convince hadoop it's an enum type that's contained in the class i'm creating with gen-class
20:14mkaperiodic: jvm-style enums are very similar to jvm classes with a private constructor, and a few static fields such as public static MyEnum foo = new MyEnum(...)
20:15aperiodicmk: sure, but can i forge an enum that's indistinguishable from the real thing to jvm consumers of my class?
20:15yoklovaperiodic: try putting :extends java.lang.Enum in the gen-class?
20:16yoklovno clue if that will work
20:16aperiodichmm. worth a shot.
20:16beffbernardaperiodic: Why not just write that part in java?
20:16yoklovbecause writing in java sucks!
20:16beffbernard:) but it would have been done by now ;)
20:17aperiodicbeffbernard: well, no, because it needs to be an inner class/enum of the class i'm creating with gen-class
20:17yoklovthat's horrifying, why does hadoop require something so specific
20:18aperiodici suppose i could manually write a wrapper class that does essentially the same thing as the gen-class and just forwards stuff to the clojure implementation... but that sounds really boring to write
20:18aperiodicyoklov: this is how counters are implemented in hadoop. i think it's pretty dumb, too
20:18yoklovjeez
20:25aperiodicwell, i can generate a class that's named like an inner class, and extends java.lang.Enum. so, that's a start
20:28amalloyi'd be surprised to learn that you can generate enums that way. let me know if it works
20:41technomancywhy on earth is isUpperCase a static method on Character?
20:41technomancyoh jabba, you so crazy
20:42amalloytechnomancy: wait, why does that not make sense?
20:42technomancywhy isn't it just a method?
20:42amalloybecause 'x' isn't an object
20:43amalloy"because primitives"
20:43technomancywhatever.
20:43technomancydouble and long are the only primitives that matter
20:44technomancywhen are we getting tagged fixnums anyway?
20:44technomancyeven elisp has em =(
20:44amalloyi read that JDK 10, or some such imaginary-future-vision version, is hoping to get rid of primitives
20:44amalloyso you can tell your grandkids about how you had to deal with primitives
20:44technomancywell, I don't
20:44technomancypersonally
20:45technomancybut I do have to deal with Character's static methods, so indirectly I suffer
20:45amalloyright
21:48dgrnbrgtechnomancy: got any ideas on why running lein guzheng fails to load? https://github.com/dgrnbrg/lein-guzheng
22:07yoklovjesus christ, -> makes s-expressions so much less horrible for arithmetic
22:09yoklov(-> y (+ 0.5) (- y-center) (/ height)) is so much more clear than (/ (- (+ y 0.5) y-center) height)
22:12mk-> is useful whenever you are transforming a value
22:14yoklovi don't typically think of arithmetic as a transformation, but yeah that fits
22:17mksome arithmetic probably doesn't work that way, but in your example, I'd guess you're mentally moving a point around. I was trying to think of examples of this earlier, and string transformation is pretty common
22:18mkif you're writing something like (divide (toDouble (replace (trim " 99% " "%","")), 100)
22:18mk...one of the brackets is misplaced there
22:19mkanyway, I think this is a huge part of the reason people hate languages with a certain form of typing
22:20mkhalfway through that, you need to start calling the value a double, and changing the variable name
22:21mkis there a more general term for what Rich calls "identity"?
22:29yoklovi don't think so
22:29yoklovand even strongly typed languages don't care as long as that expression makes sense
22:29yoklovinput and output don't necessarially need to be the same
22:53hobbyistHi y'all. In IntelliJ Idea 10, is it possible to open a REPL instance on the current clojure file?
23:01yoklovi don't know of anybody who uses intellij. can you get any sort of repl at all?
23:03arohneris it possible to tell how many args a fn will take, ahead of time? in a way that doesn't lie (i.e. not arglist metadata)
23:04yoklovoffby1: lies. you never considered leaving emacs for a second
23:05offby1well.
23:08yoklovarohner: probably not, don't fns usually have the other arities defined and they just throw for them?
23:09arohneryoklov: yeah, all fns inherit from AFn which throws on all arities
23:09yoklovyeah, then I can't imagine it would be anywhere else but the metadata
23:10yoklovwhich could be wrong.
23:10yoklovhow often does that happen though?
23:11treehughobbyist: yes it is possible
23:20hobbyisttreehug: hint? I have La Clojure (Idea 10.5). The Tools/Clojure /Load file to REPL is disabled. I assume it shouldn't?
23:20treehughobbyist: start repl first, then load to repl should work
23:26hobbyistteehug: thanks. It appears to work as the file is now loaded. However symbols are not resolved though file compiles ok
23:27hobbyistUnable to resolve symbol: myFunc in this context, compiling:(NO_SOURCE_PATH:3);
23:27hobbyistNO_SOURCE_PATH..
23:28yoklovthat means in the repl
23:29yoklovwhat does the bit before the => say in the repl?
23:39hobbyisttreehug: things good except fully qualified names are required. Anyway around that?