#clojure logs

2011-01-28

00:16_mstRaynes: this might not help at all, but you could try 'A z' or 'A k' from the group buffer. I remember in the dim dark past having groups default to being "zombie" or "killed" and not showing up by default...
02:11brehautis there anyone online who has seen my site and wanted to punch me for the choice of colors?
02:13zvrbawhat is your site?
02:14brehautbrehaut.net
02:14brehautit was eye searingly yellow
02:14zvrbawas?
02:14brehautyes
02:14zvrbai still want to punch you in the face
02:14zvrbaWAS?
02:14zvrbait still is!
02:14zvrbait looks like a cartoon commercial for a film from 1950s
02:15zvrbaesp. because of heading fonts
02:15zvrbathe text contrast is bad, it's hard to read
02:15zvrbaorange on yellow... bad combo
02:15brehautok so you havent got the new version of the css thats for certain
02:16zvrbaand yellowis shadow around the biggest headings is rather corny
02:17zvrbahttp://media.brehaut.net/style/wendigo-base.css
02:17zvrbathat's the CSS referenced from the page html
02:18brehautyou may be surprised to learn that that file is subject to change
02:18brehautand i get the latest version here
02:23zvrbawell, this is the first time i loaded this page, so it is not some strange caching problem
02:23brehautwell then
02:23brehautyou would have detested the previous version if you think the current version is too yellow
02:23zvrbahehe
02:23zvrbait's not "too"yellow. it just looks like a cartoon commercial
04:32Dranikhi all!
04:33Dranikis it possible to define several classes in one clojure file using gen-class?
04:34clgvwould that mean using multiple ns-statements? then it's considered bad style as far as I heard.
04:35ejacksonyup.
04:35Dranikhow about the macro (gen-class ) ?
04:36Dranikwhat's wrong with that code:
04:36Dranik(gen-class
04:36Dranik :name My1
04:37Dranik :methods [[myMethod [] String]])
04:37Dranik(defn -myMethod [this] (println "myMethod called") "")
04:37Dranik(.myMethod (My1.))
04:39clgvdo you get an error with that?
04:40Dranikyep. It can't find My1
04:40Dranikbut I don't compile it
04:40DranikI run it interactively from command-line
04:41Dranikguess, that's the point, it should be compiled...
04:51Dranikejackson, ok, I see that creating multiple ns-statements in one file is a bad style. But is it technically possible?
04:51ejacksonI've never tried ;)
04:51Dranik:-(
04:54fliebelDranik: Why would you want it?
04:55Dranikfliebel, I want to create macros for several architectural patterns
04:55Dranikfor now I'm trying to implement Factory
04:57fliebelDranik: Have you tried singleton? :) I thought design patters where not very useful in functional programming.
04:57clgvuuuuh sounds a bit far from clojure.
04:57clgvDranik: why do you want to do that?
04:58clgvin clojure you can simply use factory-methods which are nothing special at all: normal functions that return objects ;)
04:58Dranikclgv, fliebel, that's not for functional programming. I try use clojure as a meta-language implementing another language on top of it
04:59DranikI want to use it from java
04:59DranikI hate writing copy-pasted code for patterns. I want clojure macros which will do all the job
05:07clgvDranik: I don't know if that will work. But you should let us know when you tried and gathered some experience,
05:08Dranikclgv, interesting, hugh? :-)
05:23ejacksonoooh redis-clojure.....
05:24bobooh, is it more updated perhaps?
05:25boboit claims to be 1.2.7 but links to ragnard's github where latest is 1.0.4
05:26boboor 1.2.4 in the 1.2 branch
05:28ejacksonyes, I'm looking at the forks now.... I suspect it starts with ghoseb
05:28ejacksondunno though
05:32TobiasRaedermorning
05:32boboejackson: let me know if you get any clarity in it :-) and whats different in 1.2.7
05:33ejacksonbobo: yeah, I've written a simple thing around jedis for myself, but this looks good.
05:33ejacksonmorning TobiasRaeder
05:34TobiasRaederanyone tried to do something with clojure + servlet api 3.0 yet?
05:38boboejackson: does jedis support pubsub? or blocking stuff
05:38ejacksonbobo: no idea, i'm just using the basics
05:38ejacksonbut i imagine it does
05:38bobook, il take a look later then =)
05:45LauJensenMorn'
05:46ejacksonbobo: yup jedis does pubsub
05:46ejacksonLauJensen: morning
05:49boboejackson: awesome
05:52LauJensenuser=> (project (table :t1) [:id (case :status (>= :wage 500) "High" (< :wage 500) "Low" :else "Weird")]))
05:52LauJensenSELECT t1.id,CASE WHEN (wage >= 500) THEN High WHEN (wage < 500) THEN Low ELSE Weird END AS status FROM t1
05:56TobiasRaeder@LauJensen morning
05:56LauJensenMorning TobiasRaeder
06:52shortlordis there a way to get the line number that caused a RunTime Exception? ust .getMessage and .getStacktrace is not very helpful
06:55shortlordor at least print the whole exception inclusive complete stacktrace. .getStacktrace only has one line as output
07:01clgvshortlord: (use 'clojure.stacktrace) and (print-stack-trace *e) or more often better choice: (print-stack-trace (.getCause *e))
07:08edoloughlinHow can I test if something is a map?
07:08shortlordclgv: that sounds great, but I need the stacktrace as a string to display it in a processing window. Is there anything comparable to print-stack-trace that returns the string or would I have to rebind *out* or something like that?
07:09edoloughlinSorry, just found map?
07:21Fossishortlord: look at the implementation. should be somewhere in there ;)
07:51bartj, (+ 1 1)
07:51clojurebot2
08:10robonobog'day
08:10clojurebotclojure-maven-plugin is http://github.com/talios/clojure-maven-plugin
08:11robonobois there a way to kill all threads except for the one i'm one at the repl?
08:51edwAh, yes, hello.
08:51edwWrong window. Again.
09:00AWizzArdrobonobo: http://download.oracle.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html
09:02robonoboAWizzArd: what if I don't have the "references" to the thread anymore? I have a bunch of threads started with (future) that run forever in my app, but that I have to restart from time to time during development.
09:02robonoboAnother way would be to just restart my slime. Is there a way to do this from emacs?
09:03tomoj,i + sayoo + TAB + RET + start it again
09:03clojurebotjava.lang.Exception: Unable to resolve symbol: i in this context
09:03tomoj:/
09:04robonobotomoj: was that for me?
09:06AWizzArdrobonobo: You can construct your futures in a way that they check on a var *run* from time to time and quit running if *run* = false.
09:06raekrobonobo: the Future object that is returned by 'future' can be used to shut the thread down. just keep a reference to each Future object
09:07raekif you want to be able to start new threads again, it can be a good idea to give each "generation" of threads an atom that contains a boolean for whether that generation should still run
09:08raekthus you avoid the problem when a thread misses the false value if you set *run* to false and then to true again
09:12robonobook, thanks guys
09:15raekyou could perhaps let the threads have an outer loop like (future-call (fn [] (do-stuff) (recur)))
09:15raekthat would let you redefine do-stuff and it the new version will automatically be used
09:19robonobojava.lang.ThreadDeath doesn't sound very good
09:20raekI also recommend looking into thread interruption. it is a bit more to read, but it is good to know about
09:20robonoboraek: i'll do that
09:21raekthe book "Java Concurrency in Practice" is really good
09:24robonobocan anyone search clojuredocs.org? i get a 500 error.
09:25mrBlissrobonobo: same here
09:25robonobodammit
09:25chouserthere's find-doc at the REPL
09:26robonobochouser: yeah, i know, but it doesn't have the nice examples and relevant functions, etc
09:28chouseryes, but if it's only the search on clojuredocs that's broken... anyway, just making sure you were aware
09:30robonoboshutting a future down = cancelling it?
09:36raekyes. that was what I meant before. (although, I did not say it)
09:37raekcancelling a future causes its executing thread to be interrupted
09:55robonoboholy hell the repl knows my name
09:55robonobo"Connected. Robin, this could be the start of a beautiful program."
09:55tonylwoow
09:56ejacksonrobonobo: yes, and when you make embarrasing coding errors its emails them to the googlegroup....
09:57robonoboall heil the allmighty slime
10:05edwIs it normal for a "jar t ..." of a jar made with "lein uberjar" to take, like, forever to run?
10:07hoeckedw: yes, the jar tool is horribly slow
10:07edwSome O(n^2) stuff going on in there?
10:07edwOr maybe O(x^n)...
10:08hoeckedw: exactly, they screwed sth. up there
10:09edwThank God Sun didn't just use tar... :/
10:09hoeckedw: but unzip -l ueber.jar works too and just as fast as you would expect
10:09stuartsierraJAR is actually just ZIP with some extensions.
10:10stuartsierraZIP utilities can usually unpack JAR files.
10:11edwRight, of course! I should have thought of that. Thankfully jar is still running, so I can take satisfaction in C-c-ing it.
10:12edwBoom! Done in less than a second. Jar elapsed time: at least five minutes.
10:14edwI put (:gen-class) in my ns form, but the output jar doesn't have a java class for the namespace. Any ideas?
10:16stuartsierraedw: you need to explicitly AOT-compile the namespace.
10:17edwI did "lein compile; lein uberjar"; should that have worked?
10:17mefestoedw: did you specify a :main or :aot in your project.clj?
10:17raekedw: you have to explicitly list that namespace in our project.clj
10:17raek*your
10:18mefestoedw: https://github.com/technomancy/leiningen/blob/stable/sample.project.clj
10:18edwAh, let me look into that. Thanks!
10:19smnirvenyoohoo
10:21zoldarhello, I'm trying to port hiccup to clojure-clr. I've hit a weird build error: http://dpaste.com/362811/ . The source is available here: https://github.com/zoldar/hiccup-clr . What may be the cause of that wrong namespace resolution?
10:27stuartsierrazoldar: that kind of error usually indicates a mismatch between the name of the file and the name of the namespace it loads.
10:28zoldarthat's weird, I've just double checked if there are any typos
10:28zoldarI just put contents of every
10:28zoldaroops
10:28stuartsierraIt appears to be expecting a namespace "hiccup.form_helpers" with an underscore.
10:29zoldarI've just put contents of every file into repl
10:29zoldarand all except one evaluated ok
10:29stuartsierraBut Clojure will expect "hiccup/form_helpers.clj" to contain "hiccup.form-helpers" with a dash.
10:29zoldarit does
10:30zoldarI mean I know
10:30stuartsierraSomething is trying to find the namespace 'hiccup.form_helpers' with an underscore.
10:30zoldarI also get this error for hiccup.core
10:30stuartsierraMaybe ClojureCLR is not munging file names correctly?
10:30zoldarI suppose
10:31zoldardoes the author hang out here any time
10:31zoldar?
10:31zoldarI mean I rather think that I'm doing something wrong
10:31zoldaror maybe that's some side effect of other issue
10:32stuartsierraSorry, I don't know.
10:38abedrastuartsierra, did you get a chance to review CLJ-689?
10:38stuartsierrano
10:39abedraNow that hudson is doing maven releases we should make sure it gets reviewed and completed
10:39stuartsierraok, added to my TODOs
10:39abedracool
10:39abedraI'm happy to work with you on it if you would like
10:39abedraI just want to make sure it gets attention and you have been inside hudson the most recently
10:39stuartsierraok
10:40stuartsierraabedra: in the middle of stuff right now, I'll ping you later to go over it.
10:41chouserWe've just invented a convention for our codebase
10:41chousermemoized version of functions end in a pencil
10:41chouserso, (defn myfunc✎ (memoize myfunc))
10:41abedrastuartsierra, no hurry
10:42abedrastuartsierra, there's plenty of things to do :)
10:42stuartsierrachouser: how do you type that?
10:42chouserCTRL-V
10:42chouseryou don't have a pencil key on your keyboard?
10:43stuartsierraI have an old Kinesis with PS/2 plugs.
10:43abedrachouser, well the cool kids with the kinesis keyboards do
10:43chouserdo they really?
10:43abedrachouser, damn skippy
10:43abedrachouser, they even have pencil macros
10:44edwOkay, so is `lein uberjar' supposed to take forever once I've included :aot and :main clauses to my project.clj?
10:45stuartsierrachouser: you're one of those nuts who redefines fn as the lambda character, aren't you?
10:45abedrastuartsierra, be careful now...
10:45chouserno, really not. This is my first excursion into unicode-in-my-clj land.
10:46chouserand I'm inordinately amused
10:46abedra:)
10:46stuartsierrachouser: all right, but watch out for the slippery slope towards Snowman.
10:46abedrastuartsierra, hey i've got snowmen
10:46abedrastuartsierra, in my git dirty tracking
10:47stuartsierraWhere's the unicode character for a steaming pile of s***?
10:47abedrastuartsierra, it's the eclipse icon
10:48stuartsierraah, of course
10:48chouserCtrl-Shift-U 270e Enter
10:49abedrachouser, nice
10:49abedrait's now a macro on my keyboard
10:49chouserha!
10:49abedra270e
10:49tonylɰe
10:49chouserfail
10:50abedra270e
10:50chouserabedra: I think that's a gnome key sequence
10:50abedra
10:50abedra✎✎✎✎✎✎✎✎✎
10:50chouserheh
10:50abedrathere
10:50tonylɰ that is the s#$t symbol
10:50tonylmm
10:51abedrachouser yeah gnome isn't all too happy with that
10:52abedraI want a metal fingers character
10:52abedrabesides the standard \m/
10:55testis there a Clojure/Java library which converts three-digit country codes to two-digit country codes ?
10:55raeklike U+2603 SIGN OF THE HORNS ?
10:55sritchiehey all, one quick question -- if I have a function that returns a sequence of arguments (in this case, a vector with x and y coordinates) is there an idiomatic way to pass the contents of that vector in as arguments to another function (rather than the vector itself?
10:55raek(fictional)
10:55testraek, to me ?
10:55abedraraek, exactly!
10:55stuartsierrasritchie: apply
10:56sritchieah, got it, that's great
10:56sritchiethanks!
10:57raekchouser: I had no idea about that keyboard shortcut. awesome!
10:57chouserraek: just learned it myself
10:57raek
10:58raek$title http://☃.net/
10:58sexpbotPage has no title.
11:01raektest: no :-) maybe there is something in java.util.Locale http://download.oracle.com/javase/1.4.2/docs/api/java/util/Locale.html
11:02stuartsierratest: If it's a direct mapping, you could just copy-and-paste the list into code as a literal map.
11:07DranikI have a macro with a list (a b c) which is bound to some binding lst. how to return a b c from the macro using lst? `~@lst throws an error, and `(~@lst) returns (a b c)
11:08raekDranik: a macro can only expand into one thing. maybe you could expand into a (do ...)?
11:08stuartsierraYou can't do that without symbol macros, which clojure does not (yet) support.
11:08edwjoin #lein
11:08edwD'oh.
11:08raekwhat are symbol macros?
11:08Dranikraek, good idea, I'll check it out!
11:09raek(assuming a, b and c are only executed for side-effects)
11:09Dranikhell no, that doesn't work..... :-(
11:10edwDoes anyone have lein uberjar invocations that last a very long time? I don't know if it's hung or just doing something very slowly e.g. reaing a jar file.
11:10qbgI don't see how symbol macros would help here
11:10stuartsierraqbg: you're right, any macro, symbol or othrewise, can only expand to one expression.
11:10qbgDranik: Why do you need such a macro?
11:11Dranikqbg, I make my own version of gen-interface on top of the standard gen-interface
11:11Dranikthe only difference is that i analyze it's arguments and return two things
11:11Dranikthe first one is usual gen-interface
11:12Dranikand the second -- a binding which contains the results of analysiz
11:12Dranik*sorry for spelling
11:12qbgWhere do you use the results of analysis?
11:13Dranikqbg, I'm trying to create a macro for a pattern "decorator"
11:13Dranikso I save the list of methods in some binding
11:13qbgSo you are using this macro in another macro?
11:13Dranikand use this binding when generate decorated class
11:13Draniknope
11:13raekDranik: I think it's easier to split up macro functionality into functions rather than macros
11:13DranikI use the binding in another class
11:14Dranikraek, may be
11:14raek(but I'm not quite sure I understood your problem)
11:14qbgSounds like you want a function
11:15raekmacros are just the icing...
11:18edwDranik: It's a bit of a cliche, but patterns are considered an adaptation to the brain-damaged nature of OOP by Lisp types. How hard is it to just define a procedure that just calls a procedure, doing something to the input or output?
11:19Dranikedw, yep, you're right
11:19clgvedw: lol I wouldn't let that stand as definition for patterns in general ;)
11:19Dranikedw, what I'm doing -- is practicing. I'm just having fun.
11:20edwDranik: Okay; I've done that sort of thing just for fun.
11:20edwclgv: I agree with you, but it's not a bad 1st order approximation of a definition.
11:25sritchiehey all -- is there a clean way to multiply all elements in a sequence by a factor, other than (map #(* factor %) my-seq)
11:25qbg(map (partial * factor) my-seq) ;)
11:26qbgMore seriously, what is wrong with the map approach?
11:26sritchieoh, nothing, I was just wondering if there was a "scale" function or something
11:27pdkfailing map you could do a for loop
11:27qbgNot built in
11:27qbgpdk: Yeah, for would be nice too
11:28sritchieI'm working for a group that formerly used a mess of python code -- the conversion to clojure is going to be something like 10% of the lines, and I'm becoming addicted to cutting lines
11:28qbg&(for [x (range 10)] (* x 3))
11:28sexpbot⟹ (0 3 6 9 12 15 18 21 24 27)
11:29sritchiethat's cleaner, I think
11:30qbgIt makes it harder to use with ->, ->> though
11:30sritchie(defn scale[seq fact]
11:30sritchie (for [x seq] (* x fact)))
11:30sritchieqbg: haven't seen those forms yet, I'll check out the docs now
11:31tomojshould probably be [fact seq] ?
11:32sritchietomoj: yup, that looks better
11:33tomojfor ->> compat
11:33tomoj(->> (range) (take 10) (scale 0.5))
11:34tomojit makes me happy that python->clojure is losing you a lot of code
11:35sritchietomoj: it's an application to run a pretty involved analysis NASA MODIS tiles -- I'm switching us over to clojure and cascalog, so the process can run on Hadoop
11:36sritchiehadoop's data shuffling sheds quite a bit of code, but clojure is doing its part
11:36pdki recall reading the docstrings for -> and ->>
11:36tomojso are you developing hive queries?
11:36pdkgoing "wtf do these even do"
11:36pdkthen i saw a code example and went OHHHHH
11:36tomojbetter question: are you using stuartsierra's clojure-hadoop?
11:37ejacksonpdk: you and me both.
11:37ohpauleezsritchie: Any reason why you just didn't use Hadoop Streaming and keep the current codebase?
11:37wolverianon our clojure course we're not even recommending reading docstrings since they're pretty much completely unusable for learning. might work as a reference.
11:37ohpauleezwolverian: Really? I think they're pretty good
11:37sritchieohpauleez: the code base was in need of some serious, serious cleanup -- each step has to be triggered manually
11:38ohpauleezahh
11:38ohpauleezcool! sounds like a fun project
11:38edwwolverian: I learned `sed' from the manpage. I know what you mean about docstrings...
11:38sritchieohpauleez: so, the options were, revamp the python code, or go to clojure!
11:38sritchietomoj: not using clojure-hadoop, though it looked great -- cascalog is a layer on top of cascading
11:38ejacksonand you told the serpent to GTFO !
11:39wolverianohpauleez: some people will be able to learn from them, but mostly they're written for people who already understand most of the concepts of clojure. learning a new language and a new idiom is ... different.
11:39sritchieso, essentially hive queries
11:39sritchiehttp://bit.ly/9ATc7B
11:39ohpauleezhaha, if you're job entails having to pick between (or work in) Clojure and Python, you have yourself a pretty sweet job
11:39ohpauleezhaha
11:39edwOkay this is odd, `lein uberjar' hangs but interactively, the uberjar command works fine. WTF?
11:40sritchieohpauleez: I'm being careful not to ruin it! My side job is iPhone stuff in objective C, where the thought / typing ratio is inverse to clojure's
11:47chouserwhat does it mean when proxy says "Incompatible return types"?
11:49ohpauleezsritchie: I don't mind obj-c, I kind of like it, but I've never used it to dev OSX stuff, only used GNUStep and C-libs
11:50sritchieohpauleez: I actually do like coding in it -- it's just that it can be quite verbose. I notice that I type quite a bit more to realize an idea -- in clojure,I find myself sitting for ten minutes, then writing down a short function that does the job
11:51sritchieohpauleez: I'm partial to the second way, I suppose, but objective-C's really not bad
11:51ohpauleezfor sure. Clojure has total zen appeal
11:51ohpauleezI am as well
11:52dnolensritchie: I like Objective-C as well. XCode makes typing it out fairly pleasant. The only thing that drives me *insane* is not literal support for NSDictionary NSArray
11:52dnolens/not/no
11:52sexpbot<dnolen> sritchie: I like Objective-C as well. XCode makes typing it out fairly pleasant. The only thing that drives me *insane* is no literal support for NSDictionary NSArray
11:53sritchieyeah! I needed to do a set operation for a piece of code that clustered points on a map, and had to break out NSMutableSets
11:54sritchiefelt like a heavy datastructure for the operation involved, but of course that's just because sets aren't primitive
11:56sritchiebtw, what's the difference between -> and ->>?
11:56sritchieI'm having real trouble googling the second, and the doc strings are the same
11:56ohpauleezsritchie: One dumps the result as the first arg, the other dumps it as the tail arg
11:56Dranikwhy aren't macros arguments evaluated? I've looked into the macros source, it is just a function
11:57Dranik(defdefmacro (fn [&form &env name & args] ...
11:57Dranik(def defmacro (fn [&form &env name & args] ...
11:57chouserDranik: do you mean "why is it designed that way" or "by what mechanism are the differentiated"?
11:57Dranikthe second
11:57sritchieohpauleez: got it
11:58chouserDranik: The metadata of the var
11:58chouser,(:macro (meta #'defn))
11:58clojurebottrue
11:58Dranikchouser, could you explain a bit more?
11:58chouser,(:macro (meta #'filter))
11:58clojurebotnil
11:58ohpauleezsritchie: Cool, if you need some examples ping me. Also, Clojure Docs usually has good examples: http://clojuredocs.org/quickref/Clojure%20Core
11:59chouserDranik: does that make sense?
11:59Dranikchouser, well, I'm near to it :-)
11:59Dranikchouser, what metadata should I set in order not to evaluate the function arguments?
12:00chouserDranik: you should define a macro instead of a function
12:00sritchieohpauleez: this looks really good! What's trying to do is shorten up the function here: https://gist.github.com/2a15289d7bf3b2e64f49
12:01Dranikchouser, I see. But I dig into the defmacro source and see a pure function
12:01Dranikhow is it done that way?
12:01sritchiejust as practice. It feels like there's a pattern here... I want to write (map -> dist [(+ ul-x) (- ul-y)]), or something like that, but one can't map a macro
12:01qbgDranik: Macros are functions at their core
12:02sritchieohpauleez: also, not very clear!
12:02ohpauleezsritchie: Yeah, threading is really only used when it helps readability
12:02Dranikqbg, yeah, I know, because I look in the source of defmacro. What I can't get is how that function is implemented that it does not evaluate its arguments
12:02chouserDranik: When Clojure is compiling your code and it sees (foo ...), it finds the var foo, checks to see if it's metadata claims it's a macro, and if so calls the function *right then*, with undocumented arguments that are subject to change.
12:03qbg&(meta #'for)
12:03sexpbot⟹ {:macro true, :ns #<Namespace clojure.core>, :name for, :file "clojure/core.clj", :line 3582, :arglists ([seq-exprs body-expr]), :added "1.0", :doc "List comprehension. Takes a vector of one or more\n binding-form/collection-expr pairs, each followed by zero or mor... http://gist.github.com/800556
12:03qbgSee the :macro true part?
12:03qbgThat is how
12:03Dranik:-)
12:03qbgYou should define your macros with defmacro though
12:04Dranikqbg, ok, then where is the definition of that meta :macro true in the source of defmacro?
12:04qbgCheck out the .setMacro call after the definition defmacro
12:05Dranikqbg, I got it, thanks!
12:06qbgsritchie: (map + dist [ul-x (- ul-y)])
12:07sritchieqbg: oh, great
12:09AWizzArdI have (defmacro foo ([a] (foo a 2 3)) ([a b] (foo a b 3)) ([a b c] `(+ ~a ~b ~c)))
12:09AWizzArdWhy do the calls (foo 10) and (foo 10 20) lead to a stack overflow?
12:09AWizzArd(foo 10 20 30) works nicely.
12:10qbgQuote the output!
12:10ohpauleezyeah
12:10ohpauleeznice catch
12:11AWizzArdI am aware how to fix it. I just would think that the version I just pasted here should work too.
12:12AWizzArd(defn bar ([a] (foo a 2 3)) ([a b] (foo a b 3)) ([a b c] (+ a b c))) also works fine.
12:12AWizzArduuhm, replace the 'foo's with 'bar's.
12:13qbgI can imagine a macro calling itself going bad
12:13Dranikis it possible to add private properties to a class generated by the gen-class facility?
12:13pdkuh
12:13pdkwouldn't -> and ->> be defined recursively for example
12:13qbgpdk: They don't call themselves from their definition though
12:13AWizzArdWell, a macro can call itself in its expansion.
12:14qbgThey are used in the expansion, not the definition
12:14AWizzArdBut it seems it can't do that outside of the expansion, during the "outer macroexpansion time".
12:14qbgTo be able to compile itself, it needs to compile itself first...
12:17sritchieqbg: actually, that almost works -- the weird part of mine was that I need (- ul-y (second dist))
12:17sritchieqbg: so, the ul-y has to be positive, and - has to be applied to it
12:18qbgYour gist must be wrong then
12:18ohpauleezsritchie: If you find yourself needing positional pieces of a seq a lot, consider making heavy use of destructuring in your let blocks
12:19qbgNo..
12:19ohpauleezlet forms*
12:19sritchieqbg: yeah, you're right, the gist with threading is wrong
12:19qbgYeah, you wanted ->>
12:20qbgComplete overkill: (map #(%1 %2 %3) [+ -] [ul-x ul-y] dist)
12:21sritchieoverkill, but that's what I'm trying to do! it's sort of silly for an example this small
12:23sritchiemapping the threading macro would get it done, but that's not possible
12:24qbgUnless you wanted to do it at compile time
12:26qbgYou could write an anonymous macro macro, but that would be extreme overkill
12:28sritchieqbg: I'll think more about what the function is doing, I think -- I have an upper left point, and I to get the coordinates in a coordinate system that moves right in x, down in y
12:28sritchieqbg: I think the answer is to write another function that makes that clear
12:29sritchieI get my ul-x and ul-y by doing the same thing that I do in the body of the function
12:59mefestoclojuredocs down?
13:01sritchieqbg: I ended up using your overkill solution -- I defined that anonymous function as "distance", with args [dir start magnitude]
13:01sritchieqbg: so now it's clear what the map is doing
13:01tonylmefesto: not for me
13:01sritchiehere's the final code :
13:01sritchiehttps://gist.github.com/799942
13:01mefestotonyl: searching fails for me
13:02tonylmefesto: it seems that the search functionality is not functioning
13:05chousermaybe because it's not functional
13:07hiredmanshould have used a monad, then it would certainly be functional
13:13mattmitchellhow can i save the name of a function as a string/keyword in a var, then call it later?
13:13mattmitchelleval works, but well... that doesn't seem right
13:14mefestomattmitchell: resolve ?
13:14mefesto,(resolve 'clojure.core/inc)
13:14clojurebot#'clojure.core/inc
13:14mefesto,((resolve 'clojure.core/inc) 5)
13:14clojurebot6
13:14mattmitchellmefesto: ok cool, so then how can i execute it?
13:15semperosfunctions are first-class citizens
13:15semperoswhy can't you just pass the function itself?
13:15mattmitchellsemperos: well because there are a number of different things i want to do based on the name
13:15mefestomattmitchell: i believe that a var in function position of a form will execute
13:26mefestodoes c.c.command-line/with-command-line now allow overriding -h? it seems to always trigger the help output
13:29chousermefesto: hasn't it always?
13:30mefestochouser: dunno this is my first time using it. i have an entry for [host h "Hostname" "localhost"] and was hope that would override -h
13:30mefestochouser: just curious, i can use --host no problem
13:31chouserah
13:31raekmattmitchell: if you want the function itself, you can deref/@ the var. though, as mefesto said, using a var as a function will invoke what's in it
13:31chouserI don't see a way after a quick glance. Yet another example of my only-slightly-better-than-nothing contributions to contrib.
13:32mefestochouser: c.c.command-line is a great contrib! :)
13:33mefestoi can tell it'll be very handy for some of the things i currently have on my plate
13:42chousermefesto: well, that's nice, thanks. :-)
13:43mefestochouser: is there a way to force a print-help? for example, if a user doesn't provide one or more file names i'd like to print an error plus the usage.
13:46AWizzArdIs there a way as in CL to find out that a file/ns is in the process of being loaded, but not compiled?
13:47AWizzArdI would like to build a closure that sets newline to (java.lang.System/getProperty "line.separator") while a module is being loaded.
13:48AWizzArdI could do (let [newline (java.lang.System/getProperty "line.separator")] (defn foo ...)) but think this would put MY line.separator into an ATOed .jar
13:48AWizzArdThis could be \r\n for Win, but I would like foos newline to be \n on Linux
13:48AWizzArdBut without having to look it up every time.
13:49mefestowhat's the clojure way to print to the error stream? (.println System/err "...") or is there something like (println *err* "...")?
13:54AWizzArdBest would be: (eval-when :load (defconstant nl (java.lang.System/getProperty "line.separator")))
14:00raekhrm, my combination of having lein in ~/.bin/, using emacs-starter-kit and durendal
14:01raek...somehow causes emacs to not be able to launch "lein swank"
14:05technomancyraek: there's a bug in OS X where $PATH settings in .profile are not picked up by GUI apps; could be that
14:05raekI'm running ubuntu
14:06ldhtechnomancy: they acknowledge that as a bug? ;)
14:06raekin the C-x m shell, lein does not work, but in the C-x M-m shell it does
14:06technomancyldh: no, but that doesn't mean it's not a bug
14:06ldhtechnomancy: agreed
14:08edwldh: Isn't there a way to create a properties file that contains PATH elements that get added at login in OS X? I once went to the trouble of doing that, and it solved that problem.
14:08technomancyyou have to create an XML file, which is a solution I can't recommend in good conscience
14:09technomancy(mostly for DRY violations)
14:09edwYou *can* use the plist editing app, if you don't want to get too much blood on your hands.
14:09ldhedw: the way which works for me is to add them to /etc/launchd.conf, but you're still repeating yourself
14:10edwWell ldh, we're talking about .bashrc vs .profile vs .login. There's a pre-existing problem...
14:28chouserstuartsierra: is there a way to get lazytest:watch to load files with *warn-on-reflection* on?
14:29stuartsierrahmm
14:29stuartsierranot that I can think of
14:29chouserhm, ok.
14:29stuartsierraYou can set! it in a source file, temporarily.
14:29chouserthere's no root binding established
14:30stuartsierraalter-var-root, maybe?
14:30chouserah, maybe.
14:33chouserstuartsierra: yep, that did it, thanks.
14:34stuartsierrawelcome
14:34raektechnomancy: robert.hooke question: what happens if I reevaluate an add-hook expression?
14:34raekI see in the code that there is an add-unless-present function
14:35raekif I reevaluate the hook function too, will it think it's a distinct one?
14:36technomancyraek: you can pass a var in if you need to preserve equality across recompiles
14:36technomancyI think
14:39raektechnomancy: ok, thank
14:39raeks
14:39technomancylemme know if that doesn't work
14:39technomancyelse you can just put a conditional remove-hook before the redefinition, but that's sorta lame
14:40stuartsierraabedra: ping
14:40technomancyit's a great way to get around defmulti defonce-annoyance though
14:40raekI found an interesting usage of robert.hooke
14:40technomancy(def mymulti nil) (defmulti mymulti [...]) ;; and magically it's no longer annoying
14:40raekI have a namespace that defines operations on data stored as maps
14:41raekit includes an "adorn" function that by default does nothing
14:41raekother namespaces can hook that function to add their own keys to the map when that function is called
14:42technomancyhrm; why not just an atom of fns?
14:42raekbasically, I use this as an alternative to memoize
14:42stuartsierrafogus: ping
14:42raekother namespaces can tell what data they will need later
14:43technomancyraek: oh, I see; so it's important the hook args get passed all the way through.
14:43technomancyI thought it was just for side-effects
14:43technomancycool
14:43raekI use it to "compile" lists of points into java Path2D objects
14:45raekthe graphics code can add its bookkeeping data in the datastructure itself, and the first namespace does not need no know any details
14:45technomancycomposable.
14:46raek(I'm coding a clone of the board game "Carcassonne")
14:46technomancyoh, fun.
14:48raekmaybe I should call this approach the "Christmas Tree Pattern" - you have a map and let other namespaces adorn it with whatever data they need
14:49raek(namespace qualified keywords suddenly become very handy)
14:50edwIs there a way to get lein to be a little more verbose? I have a `lein compile' that's taking forever and I'd like to see what's going on.
14:51stuartsierrameow
14:51stuartsierrawrong window
14:54tonyllol
14:56Raynesstuartsierra: That's horrifying. Should I ask what window that belonged to?
14:57brehautmorning
14:59fliebelraek: I'm very curious to see your game. my curiosity is aimed at the code, playing is of secundair importance. Is it plain java 2d?
15:00raekyes
15:00raekhttps://github.com/raek/thiudinassus
15:00raekmy friend and I have just got started with it
15:02fliebelraek: cool, I found it on your web days ago, but without the link.
15:02raekfliebel: more readable form: http://raek.se/thiudinassus.html
15:02fliebelI see squares...
15:03raekthat's gothic.
15:04fliebelwhat is the robert/hooke for, you wher talking bout earier?
15:04raekit's used for thiudinassus.tile/adorn-tile
15:04raekand for thiudinassus.graphics/adorn-tile
15:04fliebel(sorry, typing with one hand because cat ocupies chair.
15:04raekit's not on github yet
15:04fliebelokay
15:05raekthe html you see is fresh from my working directory
15:05fliebelcool, thanks, i'll keep an eye onit :)|
15:25Raynescemerick: hi
15:26cemerickRaynes: hello :-)
15:56AWizzArdAnyone here with a very recent Clojure?
15:57AWizzArdI found something in 1.2 that looks like a bug and would like to know if 1.3alpha still has this and if it is a bug :)
15:57chouseroh, I have 1.3alpha3 or so
15:57AWizzArdgood
15:58chousergotta go in a couple minutes though
15:58AWizzArdchouser: it is a very small example, 5 lines or so
15:59AWizzArdchouser: first start with an atom (def my-atom (atom nil)). Now add a closure (let [lalala 1] (defn foo [a b c] (println a b c))) which does not access the value it closes over. Then please add the macro (defmacro bar [x y z] `(~(deref my-atom) ~x ~y ~z))
16:00AWizzArdIf you now (bar 10 20 30) it will most likely print them out. Should work as expected.
16:00AWizzArdCan you confirm that so far?
16:00AWizzArdooh, I forgot one step: (reset! my-atom foo)
16:00AWizzArdbefore calling bar
16:00chouserCompilerException java.lang.IllegalArgumentException: Can't call nil
16:00chouserah
16:01chouseryes, works.
16:01AWizzArdchouser: now please update your closure to access its val: (let [lalala 1] (defn foo [a b c] (println a b c lalala))). Then again (reset! my-atom foo)
16:01AWizzArdAnd now please call (bar 10 20 30) again. I would expect it to print 10 20 30 1. But in my Clojure it fails.
16:02AWizzArd"No matching ctor found for class [...]"
16:02chouserprints 10 20 30 here
16:02AWizzArddid you (reset! my-atom foo)
16:02AWizzArdSo that my-atom will see the new version?
16:03chouseroh, no.
16:03chouserIllegalArgumentException No matching ctor found for class user$eval69$foo__70 clojure.lang.Reflector.invokeConstructor
16:03AWizzArdyes, same here
16:03AWizzArdI tend to say this is a bug. But perhaps it is a feature? ;)
16:04tonylI don't think let is meant to make a closure over a def/defn
16:04tonylI can't remember well, but I might be wrong
16:04chouserAWizzArd: interesting -- I'll have to ponder this another time. gotta go.
16:04AWizzArdtonyl: that is what closures are for
16:04AWizzArdchouser: thanks for confirming it
16:05raekI guess you could as well write it as (def foo (let [lalala 1] (fn foo [a b c] (println a b c lalala))))
16:05raektonyl: ^
16:06AWizzArdtonyl: it allows to add static final fields with fastest possible access
16:06raekbut I don't think there's any difference
16:06tonylraek: you beat me to the example
16:06tonyloh then it is something else then
16:06AWizzArdraek: this also throws the same exception
16:06AWizzArdclosures are the equivalent to objects in the world of functional programming
16:07tonylclose enough comparison
16:07AWizzArdAlthough I mainly used this as a replacement for the non-existing defconstant
16:08AWizzArdhiredman: ping
16:08hiredmanhmm?
16:09AWizzArd(defn foo [a] (let [x (SimpleDateFormat. "yyyy-mm-dd HH:mm:ss")] <body>)) <-- will the compiler optimize this?
16:09AWizzArdSo that not in each invokation of foo a fresh SimpleDateFormat is created?
16:09hiredmanno
16:10AWizzArdIs there any way to have this object instantiated once as a constant, without the need for lookups other than with a closure?
16:10hiredmandef it, but date formats are not thread safe
16:10AWizzArd(let [x (SimpleDateFormat. "yyyy-mm-dd HH:mm:ss")] (defn foo [a] body)) <-- here x is a static field and known to be final.
16:11hiredmanthat doesn't deal with non-thread-safeness
16:11AWizzArdA defed var also requires a lookup.
16:11AWizzArdThread safety is in my case no problem.
16:14dnolenAWizzArd: in 1.3.0 the vars are no longer default to dynamic, so is this really an issue anymore?
16:14AWizzArddnolen: The "problem" is: you can do: (def x 1) ... (def x 2)
16:14AWizzArdClojure must not assume that x is constant.
16:15AWizzArdSo it needs at least some kind of indirection, some lookup.
16:15AWizzArdIt may be faster for 1.3 when dynamics are gone by default. But still needs some lookup.
16:16mattmitchellwould someone mind taking a look at this macro? i'm attempting to learn how they work, but not getting past this: https://gist.github.com/800959
16:16mattmitchellline 2, attempting to use a keyword for defn
16:17bartj_how can I access enums in Clojure
16:17bartj_I tried:
16:17AWizzArdbartj_: enumeration-seq
16:18bartj_(enum-name/option) without success
16:18AWizzArddnolen: something like (defconstant sym val) could be nice. It would create a final static field to access the val.
16:19raekAWizzArd: what class would that field belong to?
16:20AWizzArdraek: NS maybe
16:20mrBlissJust generated a random string with java.security.SecureRandom: "pdickava". Almost dick and java in the same random string ;-)
16:20raekmattmitchell: (defmacro solr-doc [type args] `(defn ~(symbol (name type)) [~args] (prn "test")))
16:21AWizzArdraek: and one really could not change the name without full recompilation
16:22bartj_for eg: http://www.google.com/codesearch/p?hl=en#5xpftBF0e98/trunk/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java&amp;q=INTERNATIONAL%20package:http://libphonenumber%5C.googlecode%5C.com&amp;sa=N&amp;cd=3&amp;ct=rc
16:22raekAWizzArd: iirc, classes for namespaces are only emitted when doing AOT.
16:22bartj_has an enumeration on line 304
16:23raek(please correct me if I'm wrong)
16:23AWizzArdraek: I don't know enough about the internals of the JVM. There might be a way to implement defconstants.
16:23mattmitchellraek: ok i get it. thank you.
16:23AWizzArdraek: but perhaps the bug I mentioned above can simply be fixed :)
16:25raek,java.util.concurrent.TimeUnit/SECONDS
16:25clojurebot#< SECONDS>
16:25raekbartj_: ^
16:25raekenum values are stored in static fields, iirc
16:25bartj_oh!
16:27raekThey're a bit strange, since they're an invention of Java and are regular classes in the JVM.
16:27raekhrm, maybe they had a special attribute in the class definition too.
16:28bartj_raek: if you could look at the example URL
16:28bartj_I am trying to access the PhoneNumberFormat enum as follows:
16:28bartj_PhoneNumberUtil/PhoneNumberFormat
16:28bartj_without success
16:29raekah, is it a nested class?
16:29raek(an enum type defined inside another class, in this case)
16:30bartj_from what I can see, there is only one class?
16:30bartj_PhoneNumberUtil
16:30raekcom.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat/INTERNATIONAL
16:30bartj_may I ask why the $ ?
16:30RaynesInner class.
16:31raekit is the way the JVM names inner classes
16:31bartj_forgive my ignorance, but enums are classes ?
16:31raekyes... :)
16:32bartj_arggh, Java!
16:32raekJava and backwards compability
16:32pdkmaps with keyword symbols as keys
16:32pdkfeels good man
16:32bartj_thanks a lot
16:33raeknp
16:33raekalso, import-static in contrib could be worth checking out
16:43bartj_raek: thanks for the tip on import-static; no more XL size variable names
16:57stuartsierraimport-static is kind of a hack.
18:04lazy1clojurebot: help
18:04clojurebothttp://www.khanacademy.org/
18:04lazy1:) Forgot about that
19:50bdeshamhi all... is there a defmulti- that acts like defn- to make a non-public multimethod?
20:00tonylnot as far as i know, but why would you want a non-public multimethod
20:08chouserbdesham: you can make any var private by setting :private in it's metadata to true
20:08bdeshamchouser: ok, thanks
20:09bdeshamtonyl: I was under the impression that if I'm writing e.g. a library, I should make all of the "utility functions" private... is that right?
20:11tonylbdesham: I guess, I just never do. trying to keep everything open. It makes me think a lot if my function to be of general use
20:11tonylI didn't know about manually making private vars though, good to know.
20:12bdeshamtonyl: ok, gotcha
20:16bdeshamI'm writing a small library that others might find useful... any examples of other libraries I should look at to see how to package it, etc.? (I'm more or less a Clojure newbie)
20:17lazy1bdesham: You can take https://github.com/weavejester/hiccup for example (1'st that came to mind)
20:18bdeshamlazy1: that looks like it'll work, thanks
20:19lazy1I think it's a pretty standard structure. For packaging - I think http://clojars.org/ is the widely used method
20:19lazy1And think about your namespace, I got burned with fs :)
20:20Rayneslazy1: https://github.com/Raynes/fs-revolution
20:20Rayneslazy1: Miki is annoying. :p
20:21RaynesNote that that fork is mostly a joke. Not sure I actually want to maintain that.
20:21bdeshamlazy1: heh, ok thanks :-)
20:32lazy1Raynes: I'm honored :)
20:35lazy1Raynes: BTW - http://www.catb.org/~esr/writings/anarchist.html was some inspiration
20:35Raynes:)
20:37Rayneslazy1: Seriously though, it's totally a joke and I intend to update the README to reflect that. I took a chance on this one, knowing I'd come off as a huge asshole. :p
20:38RaynesI got to try out the git-hg plugin in the process. Works fairly well.
20:39lazy1Don't worry, I like the joke
20:40lazy1You might even switch to hg before you know it
20:40lazy1GTG, TTYL
20:41RaynesI might decide to write code in COBOL as well. Highly unlikely.
21:33brehautis there a method to test if something is an isntance of a class?
21:33brehauts/method/function/
21:33sexpbot<brehaut> is there a function to test if something is an isntance of a class?
21:34tonyl&(doc instance?)
21:34sexpbot⟹ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
21:35brehauttonyl: thanks
21:46qbgI just realized that being able to do (extend-type nil ...) means that you don't need the Null Object pattern...
22:06dnolenqbg: yeah there are two useful things with protocols which I didn't understand until recently. Extending nil, and extending Object to provide default implementation.
22:07qbgI mention this because some students next to me in a software development class have to implement a BST in Java; it is so much better in Clojure...
22:42hiredmanAWizzArd: I don't know if you are aware of the change in 1.3 to assume that vars are not dynamic unless declared to be
22:43hiredmanit apparently makes vars much cheaper
22:43hiredmansince unless the var is declared to be dynamic you don't have to pay the price of checking to see if the var is rebound
22:45hiredmanif I recall, at the conj, rich said something like "I've never seen hotspot inline away the dynamic lookup check" but with non-dynamic vars hotspot will inline var lookups apparently
23:55semperosI've never done database connections with Java, I see that I'm supposed to put the driver on my classpath; I know Leiningen automatically puts stuff in its default folders on the class path
23:56semperosbut do folks just put it somewhere globally? if so, any convention?
23:56mefestosemperos: which database are you working with?
23:56semperosjust learning with mysql
23:57semperosgoing to play around with clojureql abit
23:57mefestoi been wanting to play with that as well :)
23:57mefestowhat do you mean 'globally'?
23:57semperosI imagine folks use the mysql driver for more than one project
23:57semperosand Leiningen cleans out lib for certain actions
23:58semperoswasn't sure where folks stuck it, or if they just copy it into the lib of each project they need it for
23:58mefestoyeah but it uses maven's dependency management so it'll get cached in your $HOME/.m2/repository automatically
23:58semperosah
23:59semperosI was approaching it manually
23:59semperosso this would be the Leiningen directive: [mysql/mysql-connector-java "5.1.6"]
23:59semperos?
23:59mefestoso just declare the dependency in your project.clj and it'll download just the first time ... afterwards other projects will just copy it from your local repo
23:59semperosyeah, I use Leiningen
23:59mefestoyeah, looks like 5.1.14 is the latest
23:59semperosdidn't think about the database connector being available that way, but as it's a jar, it makes perfect sense
23:59mefestoat least the latest in the maven repo
23:59semperosright
23:59semperosthat's one thing I've noticed, as I've started using more Java libs