#clojure logs

2011-07-28

00:32jcromartieOK so I'm a little confused
00:32jcromartieis it: (defn name "doc string" {:stuff :map} [arg list] body)
00:32jcromartieor
00:32jcromartie(defn name "doc string" [arg list] {:stuff :map} body)
00:32jcromartieboth work?
00:35amalloyjcromartie: the latter certainly won't
00:35amalloyit'll compile, but won't do what you want
00:36jcromartiehm
00:36jcromartieso then...
00:36amalloy&(macroexpand '(fn {:doc "whatever"} [] 1))
00:36lazybotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
00:37amalloyhm. not the result i expected, but i rarely use the map syntax
00:37amalloy&(doc defn
00:37lazybot⇒ Macro ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata ; Adjusted to (doc defn)
00:38jcromartiebut attr-map can't reference params if it comes first
00:38jcromartieah
00:38jcromartiehttp://clojure.org/special_forms
00:39jcromartiecondition-map is separate from the attr map
00:39jcromartieso it's REALLY ([name doc-string? attr-map? [params*] condition-map? exprs*)
00:40amalloymmm, not really. exprs* is passed along to fn; it's fn that has the magic for condition-map
00:42amalloyi mean, it's arguing about something fairly meaningless, but exprs* subsumes the arguments to fn, including condition-map
00:44jcromartieah ha
00:44jcromartieOK good point
00:53jcromartiehooray for pre-conditions
01:04jcromartiezone achieved
01:40Pupenorequire loads the lib and use loads the lib and makes it possible to call functions without the lib prefix, is that it?
01:49ibdknox_anyone from the clojurescript team still up?
01:51kumarshantanuPupeno: yes
01:52kumarshantanuBe wary of name clashes in the case of "use" though
01:52replacatechnomancy (or anyone else) know why clojure-jack-in would be failing with "error in process filter: Assertion failed: (keywordp module)"
01:52PupenoThanks.
02:18kjeldahlwreplaca: Haven't seen it myself, but make sure you do not have any other *swank* buffers open, and that you're not using older emacs packages..
02:21replacakjeldahlw: I don't, but I think it may be glomming on to some swank-contrib stuff I had from an older version. Dunno why it used to work, though
02:38ibdknox_BWAHAHA
02:38ibdknox_I have a fully functional browser repl
02:41replacaibdknox_: congrats! Now what? :)
02:42ibdknox_replaca: haha clean it up so that other people can party on it :)
02:42ibdknox_replaca: and then it's time for the clojurescript client-side framework
02:43replacaibdknox_: there you go. that should be a fun project.
03:31danbellanyone know of a markdown parser for clojure?
03:33amalloydanbell: surely there's one for java
03:33danbellyeah
03:33danbellI know there is
03:34danbelljust wondering if one had somehow escaped my googling
03:40tsdhHi. Can someone explain me these 2 reflection warnings? http://pastebin.com/xFuzbsFz
03:42raektsdh: replace "i ^Image (.getImage img)" with "^Image i (.getImage img)"
03:44tsdhraek: That doesn't make a difference.
03:45tsdhraek: Even hinting the calls directly, e.g., (int (* @scale (.getWidth ^Image i))), won't get rid of the warnings...
03:46tsdhClojure 1.3, if that matters...
03:48tsdhWell, that's no big deal anyway.
03:50tsdhThe more pressing issue which nearly made me running mad yesterday is that proxy silently discards exceptions thrown in the method implementations. Is that intended? At least, the docs don't indicate that...
03:52tsdhHm, oh well, probably that's not proxy, but the backtraces simply don't hit the slime repl...
03:52amalloytsdh: that's not true
03:52amalloyit's possibly something to do with the async event processing you're doing
03:53amalloybut in my slime repl, eg: (.size (proxy [java.util.ArrayList] [] (size [] (throw (Exception. "test"))))) ; throws correctly
03:54tsdhamalloy: Throws correctly means what? You see the backtrace at the repl? Or are you even put in the debugger?
03:54amalloythe usual slime debug dialog appears
03:54amalloy0 to abort to slime top-level, etc
03:54tsdhYep, here, too.
03:55amalloylike i said, it's probably because you're doing async programming
03:55amalloythe exception isn't occurring on the swank thread, so it isn't easily trapped
03:56tsdhamalloy: Yes, you are right. But if I did this in Java, at least I'd see the backtraces on System.err. With clojure and slime, I don't see anything.
03:56amalloyit's probably on the lein-swank console
03:56amalloy(not my fault if phil's hiding that from you)
03:56amalloybut you could try setting the defaultUncaughtExceptionHandler
03:57amalloy$google defaultUncaughtExceptionHandler
03:57lazybot[Thread (Java Platform SE 6)] http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html
03:58tsdhWhat's the buffer name? I remember, with older slime/clojure-mode releases, I could jump to the *inferior-lisp* buffer, and that contained anything I'd see on System.out and System.err. But with the current version of clojure-mode and clojure-jack-in, that buffer doesn't even exist...
03:58amalloy*shrug*
03:58amalloyi use lein/cake swank and slime-connect by hand
03:59amalloythen it's either in the lein-swank process's stderr, or cake.log
04:00amalloyit's not like you have to use jack-in if it's causing you problems
04:01tsdhamalloy: Well, except from that issue, it works perfectly without having to setup anything.
04:03tsdhOk, one other thing: Is case intended to work for public static int constants in java?
04:04raektsdh: I think the buffer is called *swank*
04:04tsdhraek: That buffer is full of elisp.
04:05raektsdh: look at the top
04:05raekyes, that's from the swank bootstrapping process
04:05tsdhraek: Oh, yeah!
04:06raektsdh: when I'm working on a swing app, I use this 'safety-net' macro to get stack traces of unhandled exceptions as popups: https://gist.github.com/1098366
04:07amalloytsdh: no it's not, but that might be in 1.3
04:07raekso all callback method bodies has a (safety-net ...) form at the outermost level
04:08tsdhraek: Neat, thanks.
04:09tsdhamalloy: I'm on 1.3, and there it does't work, too. (case 45 java.awt.KeyEvent/VK_MINUS true false) ==> false
04:09amalloywell, there was a fair bit of discussion about it on jira and the ML, which i didn't really follow
04:09amalloyif you're interested in how it was resolved, that's where to look
04:10raekI think the case expression ends upp using the _symbol_ java.awt.KeyEvent/VK_MINUS
04:10raeksince the cases must be compile time constants
04:11raekbut in this case it's not very logical, since java.awt.KeyEvent/VK_MINUS is available at compile time
04:11tsdhexactly
04:12raekbut there is nothing in clojure that is constant at compile time like that
04:13raekyou could probably work around this with a macro
04:13amalloyraek: indeed, chouser wrote such a macro
04:13amalloysomewhere
04:14tsdhraek: No, I'll stick with cond and keep that in mind. It just felt natural to use case in that place.
04:14raekah, here's an old variant of case I made once to dispatch on classes: https://gist.github.com/997652
04:15tsdhamalloy: He had a macro to make even enum constants work (somehow), right? Or was it Chas Emerick?
04:15amalloyi think cemerick patched case
04:15amalloychouser just pasted a quick macro into #clojure
04:15amalloy(useless bugger)
04:15tsdhamalloy: Yes, case* or something.
04:16raekreplacing 'resolve' with 'eval' would problably work...
04:16amalloyi'd be rather surprised if it were called case*
04:17tsdhamalloy: Right, it's case+. http://cemerick.com/2010/08/03/enhancing-clojures-case-to-evaluate-dispatch-values/
04:57harblcatis there a way to turn a whole bunch of static method calls on a class into something like a (doto ...)?
04:58harblcatlike, (Foo/a) (Foo/b) to (something Foo (.a) (.b))?
05:05raek,(macroexpand-1 '(doto SomeClass (. foo "arg") (. bar "arg")))
05:05clojurebot(clojure.core/let [G__1705 SomeClass] (. G__1705 foo "arg") (. G__1705 bar "arg") G__1705)
05:05raekharblcat: it looks like the let form is in the way for doing that
05:06raekso you probably have to roll your own "doto-class" macro
05:06harblcatI've tried that, but it seems to throw an error, saying "no matching method found: foo for class java.lang.Class"
05:07raekwhich had you tried?
05:07harblcatbeen looking at what (Foo/bar) expands to, and it's supposedly expanding to (. Foo bar)?
05:08harblcatand if doto puts x as the first argument to each form, it should come out just right, but it doesn't apparently
05:10raekusing doto here fails since you get (. G__1705 foo "arg") instead of (. SomeClass foo "arg")
05:11raek. is a special form and its arguments are not evaluated
05:12raekyes, it expands to (. Foo bar). this syntax is easier to generate by macros
05:12harblcatAh, so you're saying that doto somehow loses the class along the way?
05:13raeklook at this macro expansion:
05:13raek,(macroexpand-1 '(doto SomeClass (. foo "arg") (. bar "arg")))
05:13clojurebot(clojure.core/let [G__1733 SomeClass] (. G__1733 foo "arg") (. G__1733 bar "arg") G__1733)
05:13raekthis is the code that the doto form is replaced by
05:14raekfor the interop to work, the *code* has to say (. SomeClass foo "arg"), i.e. the name of the class must be there in the code as a symbol
05:15raek(. x foo "arg") is also the syntax for a instance method call
05:16raekthe compiler checks if the name represents a class ("SomeClass" does, but the is no class called "G__1733") and emits code for an instance or class method call based on that decision
05:17harblcatI think I understand now... It's treating the doto expansion as an instance-method call, and I want a static method call
05:17raekif you use doto here, it will generate code for calling an instance method called "foo" on the class object for the class "SomeClass", which is not the same as calling a class method called "foo" on the class
05:17raekexaactly
05:17harblcatI see. Thanks a bunch!
05:17kumarshantanucan set! be used with protected inherited fields from a base class?
05:32triyoWhat version of clojure-contrib, if any, matches the current clojure 1.3.0-master-SNAPSHOT?
05:32triyoI want to include it in my project.clj.
05:32triyoOr even better question, how do I determine this myself?
06:16triyoOk so I get error: java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var from the clojure.contrib.sql when using the clojure1.3 master snapshot
06:16triyoCan someone explain why this would be the case?
06:17triyoMy guess is that the contrib is not compatible with the latest clojure 1.3.
06:17ambrosebsaren't master snapshots out of date?
06:17ambrosebsor is that the latest build?
06:23triyoambrosebs: Not to sure, I have this in project.clj file: org.clojure/clojure "1.3.0-master-SNAPSHOT"
06:24triyoits looking for getRoot method that doesn't seem to be there
06:24ambrosebstry "1.3.0-beta1" (I think)
06:24triyojava.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var
06:25triyoOk I'm giving the beta1 a try, thanks
06:29triyoI still get the error: java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var :(
06:30triyoOk, I have an idea
06:30triyoI have ClojureScript on my classpath too and need to run the it build in dev via my emacs session.
06:31triyoThe ClojureScript/lib has a clojure.jar, any idea what version that is?
06:31triyoIs it compatible with 1.2.x?
06:31ambrosebsno idea
06:31triyoif so, then I don't really need reference to 1.3 at all
06:31triyohmm
06:32triyoOk, I'll have to take a look
06:45danbell,("asdjklfsdfds" 0)
06:45clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
06:46Pupeno_I just ordered The Joy of Clojure! :)
06:47Pupeno_Anyone using La Clojure?
06:51kjeldahlwtriyo: I think clojurescript is clojure 1.3 beta 1 .
07:18ohwow_Clojure doesnt have call/cc, does it?
07:26pepijnfliebel from italy here. does anyone know if Clutch supports document update handlers?
07:29pepijnit'd also be funny to write queries in ClojureScript, but Clutch already has a Clojure view server.
07:31ilyakHi *
07:31ilyakI did a (deftype Something [] Runnable (run [this] ...code...))
07:32ilyakbut if I try to instantiate Something from java code and run() it, I get the exception that variable I use in that code isn't bound
07:32ilyakIt is present in that namespaces (given that code compiles)
07:32ilyakWhy?
07:32clojurebothttp://clojure.org/rationale
07:33ilyakIs deftype not standalone and I need gen-class for that?
07:40voltonWhat's the name of the paper on pattern matching by Maranget everyone's talking about?
07:57cemerickvolton: this is what dnolen linked to yesterday… http://moscova.inria.fr/~maranget/papers/ml05e-maranget.pdf
07:57voltoncemerick: thanks
08:27tsdhIs it expected that apply-ing a function takes at least twice the time than calling it directly?
08:28tsdh(time (dotimes [i 1000000] (+ ([i] 0)))) ==> ~40ms
08:28tsdh(time (dotimes [i 1000000] (apply + [i]))) ==> ~130ms
08:32triyoDoes anyone have an example that demonstraits how to create a postgresql "sequence" for auto-incrementing pk ids?
08:36triyoFound the answer on clojure group
08:37ohwow_tsdh: hm, that's interesting
08:37Chousuketsdh: apply does quite a lot more than a plain function call. In addition, + gets inlined
08:38Scriptortsdh: wouldn't it be (+ i 0) ?
08:38Chousukeit seems for some reason he wanted to put i in a vector and then extract it
08:39tsdhScriptor: Yes, (+ i) is the same as (+ i 0), cause 0 is the neutral element of additien.
08:39Chousukeprobably to simulate apply but that's not what apply does.
08:39tsdhChousuke: Exactly, because apply gets the last args as seq.
08:40Chousukeat any rate, your example is not very good
08:41Chousukeapply is obviously going to be slower than a direct function call, but when measuring the difference you should use some code where it actually matters instead of something trivial like that
08:42Chousukein other words, your benchmark is not representative of any real-world scenario
08:50tsdhChousuke: Well, right. I'm just looking for some performance bottleneck in my code and realized that I apply very often, like for iteratively executing a function and passing the results along. However, if 10 million applications make only 90ms more, that's not where my seconds are left.
08:52Scriptorthere should be a java profiling tool that can be used with clojure
08:52cemerickThere are many
08:52cemerickVisualVM, NetBeans (roughly the same), Eclipse, Yourkit, probably more
08:54tsdhcemerick: I'll try out one of those. Any suggestion what to take?
08:55cemerickYourkit is probably the best; visualvm is also very nice, free, and you probably already have it (it ships with the JDK)
08:57tsdhcemerick: But not with OpenJDK/IcedTea on x86_64...
08:57Chousukeit might be in a separate package?
08:59cemericktsdh: good luck in general, then. ;-) sun-java6-jdk (or whatever it's called) is worth the install IMO.
09:00cemerickOh, the *days* I spent trying to get Java2D font rendering working properly using openjdk/icedtea… :-(
09:01tsdhcemerick: I want it *fast* not *pretty*. ;-)
09:02cemericktsdh: Last time I benchmarked the two, the sun VM was also faster *shrug*
09:03cemerickHopefully that's less the case now. Theoretically, there shouldn't be a difference between the two starting with JDK 7 IIRC — but I remain wary.
09:06tsdhHm, visualvm instantly crashes due to some Qt stuff...
09:33Vinzent,map-indexed
09:33clojurebot#<core$map_indexed clojure.core$map_indexed@136055d>
09:54tsdhI don't get visualvm to work. When I run "lein test", two Clojure applications will show up. I guess one is leiningen, the other my app. No matter which I choose and select CPU in the Profiler tab, the results do not contain a single class/method of mine. Any hints?
10:04cemericktsdh: yours is probably the one with the higher pid. Are you having your app do work while you're profiling?
10:07tsdhcemerick: Yes, I use the one with the higher pid. And yes, my test cases are plenty of cpu-brning work.
10:08tsdhcemerick: When I delete anything from the "start profiling from classes", "do not profile classes" textfields, I get at least quite a few "Redefining 100 classes at idx 0, out of total 493" messages.
10:09tsdhAnd some of my classes show up. However, that happens not before my tests are nearly done...
10:16cemericktsdh: If you're just looking at the unaltered real-time hotspot view, then you may not see your functions/classes, especially if the hotspots aren't there. You can filter the classes shown via the text field at the bottom. If you take a snapshot after you've done a fair bit of work, then you can switch to the "combined" view, find a class/function of yours, and it'll show the entire stack above and below your class/function, along w
10:16cemericktotal time, invocation count, etc.
10:25tsdhcemerick: Now I get results. But why do I get these "Redefining 100 classes at idx 0" messages and my classes showing up in the profiler tab so late? Actually, that happens not before the last few deftests of the last of 5 test namespaces run...
10:26Poet_Hi .Can anyone give me link to real world project in clojure ?
10:30cemericktsdh: the profiler has to instrument the classes it's going to track. I'm not sure about the delay/timing — I get data flowing within ~5s. If you fiddled with classname filters, perhaps they're set too strictly?
10:34tsdhcemerick: I had to remove all filters to get at least the current behavior...
10:35joegalloPoet_: What's qualifies as real world?
10:37wjlroePoet_: this is Clojure (on the App Engine): https://the-deadline.appspot.com/
10:38wjlroetechnomancy: I'm having problems running leiningen on Linux (through Jenkins) - it just hangs when `lein jar` or `lein compile`... any ideas what's going on there?
10:39VinzentPoet_, http://www.uswitch.com/, flightcaster, etc, you can find some projects on clojure dev site under success stories
10:46jcromartieI'm working on a (albeit simple) real world app
10:46jcromartieand I'm using it in-house to put a shiny new layer on an old database system
10:47ipostelnikis there an existing function in clojure.core that will a apply a function to map's values?
10:47wjlroe(map fun (values this-map))
10:47wjlroewell not really
10:48kumarshantanuipostelnik: (map (fn [[k v]] ...) {:a 10 :b 20})
10:48ipostelniksomething like (fn mm [m f] (into {} (map (fn [[k v]] [k (f v)]) (seq m)))
10:52jcromartieI'm struggling with some design decisions when it comes to how to implement an API for a general "repository" of model objects
10:52jcromartieshould I deal with refs?
10:52jcromartieor with the underlying value of the ref?
10:53jcromartielike, should I say a repo is (ref {}) or just {}
10:54jcromartieI think I'm having a hard time describing it well
10:56ejacksonafter setting the clojurescript environment, is it intended that cljsc works from anywhere in the filesystem but repl and repljs do not ?
10:59jcromartiehere's what I have right now, with no refs in sight at this level: https://gist.github.com/1111698
10:59jcromartieI use refs for my actual domain layer
11:06gtrakworking on a lein project that has tests in another lein project, is there a way to deploy the build of the first so the second will pick it up, or must I use the remote repo?
11:10wjlroegtrak: https://github.com/technomancy/leiningen <- have a look for "checkout dependencies" in the FAQ
11:10replacagtrak: you can just do a "lein install" on the dependency and it will put it in your local ~/.m2
11:11gtrakah, perfect
11:12gtrakyou guys have thought of everything
11:14charliekilostupid question: why can't I do (def m {:name String}) (new (:name m)) ?
11:17Vinzentcharliekilo, i guess it's because new does not evaluates its argument
11:17cemerickcharliekilo: new is a special form, not a function
11:18kumarshantanucharliekilo: (.newInstance (:name m))
11:18kumarshantanuwhich uses reflection
11:25gtrakdoes 'new' not use reflection?
11:27kumarshantanugtrak: no, new uses the Class instance without looking up the runtime information
11:27gtrakah, it's a compile-time binding
11:40charliekilocemerick: thanks, thats works for me (not that I doubted you ;))
11:44manuttercan I pull in the Spring Security jars by adding some dependency lines to my project.clj (and if so does anyone know what lines to add)?
11:49Vinzentmanutter, I use http://www.mvnbrowser.com/ for searching right deps
11:50manutterVinzent: cool, thanks much!
11:54gtrakmanutter, there's also this: http://mvnrepository.com/
11:54gtrakhttp://mvnrepository.com/artifact/org.springframework.security/spring-security-parent
11:55manutterCool again, (and thanks again)
11:56mrBlissI use http://jarvana.com
11:57gtrakdoes lein have provided and excludes?
12:07manutterOk, I got spring-security-core and spring-security-web, and I *think* that's all I need for basic auth & auth. Now to figure out how to make it all work.
12:07manutter(PHP programmer here, venturing into uncharted territory...)
12:08PupenoJava 7 has been released?
12:08dakronegtrak: it has excludes, not sure about 'provided'
12:10manutterls
12:11manutterdoh, wrong window
12:18edoloughlinAnyone used 'rand' to initialise values with clj-record/create? I'm seeing different values to what's in the DB if I do this. I posted some of the code I'm using to http://stackoverflow.com/questions/6862066
12:24nowhere_manhi all
12:24nowhere_manI'm a happy Common Lisp and Scheme hacker, and I'd like to add Clojure to dialects
12:24nowhere_manI recently tried installing swank through leiningen and it failed miserably
12:25nowhere_manwhat is the current weapon of choice to have Clojure within SLIME?
12:25ohwow_I just did that tomorrow and everything went fine :(
12:25dakronenowhere_man: how did the swank installation fail?
12:26Vinzentnowhere_man, I have :dev-dependencies [[swank-clojure "1.3.2"] in project.clj
12:26kephalenowhere_man: :dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]]
12:26dnolennowhere_man: note that getting Clojure to work an existing Common Lisp SLIME setup is difficult
12:27nowhere_mandnolen: I still need to work with Common Lisp each day...
12:27technomancydnolen: actually now it works OK as long as you don't need them to coexist in the same instance
12:28nowhere_mandnolen: but I'm okay to launch swank manually and then connect to it with slime-connect, that shouldn't be a problem, should it?
12:28dnolennowhere_man: technomancy is the man to speak to :)
12:28technomancyif you use a fresh emacs instance with M-x clojure-jack-in, the CL-compatible slime should not interfere
12:30ohwow_clojure-jack-in works only on projects?
12:30ohwow_or can i use it with ordinary .clj files
12:31technomancyordinary .clj files are in projects =)
12:31nowhere_manVinzent/kephale: thanks, I just did it wrong, I did `lein install swank-clojure`
12:31technomancyohwow_: for stand-alone files you can use ~/.lein/bin/swank-clojure and M-x slime-connect
12:32Vinzentbtw, technomancy, why lein tasks must be run from the project root now?
12:33technomancyVinzent: I think that snuck in as a bug briefly; fixed in the latest release
12:34Vinzentoh, great! Thank you :)
12:40nowhere_manok, thanks all
12:40mrBlissnowhere_man: my solution: https://gist.github.com/1111898
12:41nowhere_mantechnomancy: swank-closure is correctly documented, this is rare enough that it warrants my gratitude
12:41jcromartienowhere_man: docs FTW, eh
12:41nowhere_man:-D
12:41jcromartieI'm kind of proud of the way clojure projects are documented
12:42Cozeyis it possible to run leiningen repl without using lein script? I'd like to run it inside Intellij Idea 'La clojure' plugin, which just lets one specify arguments to a clojure.jar file...
12:42jcromartiepart of my automated tests report any undocumented public fns
12:43nowhere_manjcromartie: nice QA·
12:43raekCozey: well, you can use "lein classpath" to get the -cp option lein uses
12:44raekCozey: are you looking for a certain lein feature or just the clojure repl?
12:45Cozeyrepl would be best
12:46Cozeybecause i need to debug an app which uses some java classes
12:46Cozeyi jsut can't go on with emacs and slime and cdt. I'm unhappy about it, but I must admit it is a productivity killer
12:48Cozeyhmm it seems leoiningen plugin for idea does wonders and it just works !
12:49gtrakoh wow, didn't know idea had one of those
12:50raekCozey: the most basic way to start a repl manually in a lein project would be to do something like java -cp <output from lein classpath> clojure.main
12:51raekassuming idea adds line editing and history
12:54kumarshantanugtrak: yes
12:54kumarshantanuprovided is dev-dependencies
12:54kumarshantanuand excludes is exclusions
12:55Cozeyok
12:55Cozeyjust one problem more- it seems lein generates a pom.xml without excludes
12:55Cozeyand now i have contrib for 1.3 and 1.2 ( i try to run 1.3)
13:00hvyay for java.net.URLClassLoader/close
13:00jcromartiecan I "clean up" a namespace and reload it?
13:01hvjcromartie: As far as I know, not easily. yet. the unloading of a class loader, and gc'ing it in JDK7 is in that direction.
13:02jcromartiethere's remove-ns
13:02jcromartieworked OK for me
13:02hiredmanjust reload the namespace
13:03hiredmanuse (and also I believe require) takes :reload or :reload-all
13:04hvjust keep in mind that :reload does not magically take care of everything the ns did.
13:06jcromartiehiredman: reloading is fine, but I'm concerned with changing defs
13:06jcromartielike a (defn foo) goes away, and reloading leaves the old one
13:08hvjcromartie: in that case you remove-ns. (notice some libraries have ;; (remove-ns 'THEIR-NS) at the top. the developers eval them before reload).
13:10hvif you did something to other namespaces, you may have to remove-ns them, too.
13:32leonid_hello people
13:32leonid_I started playing with clojure yesterday
13:32leonid_4clojure is helping me greatly
13:33manutteryeah, 4clojure is awesome
13:33leonid_i've got a question
13:34hvyou should just ask ;)
13:34leonid_is there any ways to know the actual number of letters in the shortest 4clojure entries?
13:34manutterYou might also want to google "clojure koans" for some good introductory material, btw
13:34leonid_all I'm seeing is a histogram
13:35manutterwhere are you seeing the histogram?
13:36leonid_when you submit a code and it passes all tests, it lets me click the "view chart" link
13:36leonid_(I've joined the golf league btw)
13:36manutterHeh, I feel dumb now, I never noticed that link before.
13:37manutterHmm, in fact I'm still not seeing it.
13:37leonid_you should join the golf league to see the chart
13:38leonid_http://4clojure.com/league
13:38manutterThat must be it, I never joined a league.
13:39leonid_it would be great if I could see the code sizes of the best entries and my own solutions next to the problem titles in the list
13:39leonid_because as of now I just need to re-submit my solution to check the chart
13:40manutterYeah that would be cool
13:40manutterThe code is open source, you could submit a patch :)
13:43leonid_when I get better at clojure, I migh
13:43leonid_t
13:55jweissis there a way to get 'lein swank' to bind to all interfaces, not just local?
13:55jweissfor connecting to remote project
13:57technomancyjweiss: there is a way, but you shouldn't do it. tunnel over SSH.
13:58jweisstechnomancy: k
14:13imadein 4clojure can I see other people solutions, would be nice to compare with mine
14:17imadek actually it makes sense not to show other solutions, otherwise the clojure gold loses it's point
14:18imadeI am wondering if #(reduce (fn [coll x] (cons x coll)) [] %) is idiomatic solution for http://www.4clojure.com/problem/23
14:18mattmitchelli'm trying to build a function called one-of? which accepts a value, and a list of predicate functions. I want it to return true if one of the predicates returns true... Is there anything like this already?
14:18imadethe shortness is not important for me, more important is that it's easy to read
14:19kumarshantanumattmitchell: (some #(% value) predicates)
14:19mattmitchellkumarshantanu: ahh perfect :)
14:27ibdknox_As promised
14:27ibdknox_I have my browser-based ClojureScript repl:
14:27ibdknox_https://github.com/ibdknox/brepl
14:28triyoIs there currently a solution to include ClojureScript in to existing projects? More specifically, leiningen based project and emacs with slime / swank.
14:28gtrakooo nice
14:28thearthurWho should I politely nudge to get my range patch merged?
14:28ibdknox_2 requirements: you need clojurescript on your machine, and rlwrap for a prettier REPL :)
14:28triyoReason I ask, is that I have a project that is based on clojure 1.2.1 and it seems that ClojureScript requires clojure 1.3.
14:29ibdknox_triyo: that's going to be a pain
14:29jcromartieimade: I think I've got a better one
14:29triyonot going, it is ;)
14:29gtrakibdknox_, I was just looking at your socketio library a couple of days ago, very cool
14:29ibdknox_gtrak: I actually didn't want to use it here
14:30ibdknox_gtrak: it's like using a nuclear bomb to kill a mosquito
14:30ibdknox_gtrak: but aleph wouldn't work with 1.3.0
14:30gtrakah
14:30jcromartieimade: #(reduce conj nil %)
14:30ibdknox_also, changes in 1.3 killed the way the clj-socketio stuff worked :(
14:31gtrakisnt it just a wrapper for the java one?
14:31ibdknox_yeah, but it reify's an interface
14:31triyoibdknox_: I could try to go the other route and that is upgrade my project to clojure 1.3, however that brings me to different problem. Is there a compatible version of clojure-contrib for 1.3?
14:31ibdknox_triyo: the contrib libraries have all been broken apart and become new things
14:32triyoibdknox_: yup, I gather as much on attempting to do so anyway
14:32triyoit hell broke loose
14:32ibdknox_triyo: which ones are you looking for?
14:32triyo*it=all
14:32jcromartieIt's easy to cheat on a lot of these 4clojure problem
14:32ibdknox_gtrak: before in that reify'd class I would call anonymous functions stored in an atom
14:33triyowell just org.clojure/clojure-contrib
14:33ibdknox_gtrak: for some reason it wouldn't let me do that anymore
14:33ibdknox_triyo: there's no way you're using *all* of contrib :-p
14:33triyoOf course I am ;-)
14:33triyo*just kidding*
14:34triyoIf I have -> in project.clj is that all libs? [org.clojure/clojure-contrib "1.2.0"]
14:34triyocause fact of the matter is I only need contrib/sql as far as I recall
14:35triyoI think its a long shot that just my fall short of the mark...
14:36triyoI need to stick to 1.2.x of clojure and contrib
14:36technomancytriyo: have you tried clojure.java.jdbc? it should work with 1.2 or 1.3
14:36imadejcromartie: thank you, I will meditade about this a little bit
14:37triyohere are all the libraries I need for my exiting project -> https://gist.github.com/1112209
14:38triyotechnomancy: I haven't tried with 1.3. I am utilizing the clojure.java.jdbc with 1.2
14:38seancorfieldclojure.java.jdbc is tested against both 1.2.1 and 1.3.0
14:38technomancytriyo: I meant that jdbc should replace contrib/sql
14:39technomancytriyo: what's more relevant is what nses you use inside contrib
14:39triyotechnomancy: Oh right I see what you mean
14:39seancorfieldyes, it's better to move to the new contrib libraries as soon as you can so your transition to clojure 1.3.0 will be easier
14:39seancorfieldalso means you don't get a "kitchen sink" of 60 modules when you only want one or two :)
14:40ibdknox_seancorfield: that transition has been surprisingly complicated so far :(
14:40triyook, I have a plan. I'll drop my use of clojure/contrib quick and see if there is any dependencies.
14:40cemerickit's the price one pays to be a bleeding edge library author, I think
14:41jcromartiewow, I just discovered "reductions"
14:41triyoits a small price to pay cemerick
14:41triyo;)
14:42seancorfieldibdknox_: not for me - i moved to 1.3.0 snapshots before alpha builds i think :)
14:42seancorfieldbut, yeah, if you have a bunch of existing 1.2-compatible code, it can be painful
14:43ibdknox_my problem has largely been with the fact that most of the ecosystem is still on 1.2 code that won't even run in 1.3 lol
14:45technomancywell as long as people report the compatibility issues they find and/or submit patches fixing them things should be better by the time the release lands
14:46technomancymost of the changes needed are trivial, there are just a lot of them
14:46triyotechnomancy: so far so good. thanks for your assistance. only reason I had the clojure/contrib was because my project originally depended on the sql lib. But since I switched to clojure.java.jdbc, no need for it any more.
14:47hiredman^{:dynamic true} this and ^{:dynamic true} that
14:47thearthurim trying to follow the patch submiting process from clojure.org, and it mentions taging the patch for testing. how do I do that
14:47hiredmanhugod: do you have a list things you need from monolithic contrib?
14:47technomancyhugod: what's happening with alioth?
14:48dnolenhugod: why, contrib was always community driven, seems like a bad use of limited resources IMO. they don't even have time for alioth.
14:49hiredmanthearthur: the instructions are written for pre-jira process, I think jira has some workflow drop down or something
14:49triyotechnomancy: now for a question regarding clojure-swank that you might know a thing or two about pls. Does the clojure-swank lib need to have the matching clojure version? In other words, whats in the prj/lib dir andprj/lib/dev?
14:50hugodhiredman: I'm just about covered now, but it has been a long process
14:50dnolentechnomancy: core wants the community to step up and write 1.3 alioth code to show that Clojure perf has made a significant jump (probably be as good or best OCaml now)
14:50technomancytriyo: I think swank is backwards-compatible as far as clojure 1.1
14:50hugodtechnomancy: just a comment from the mailing list
14:50technomancyhugod: oh, the benchmarks
14:50technomancyyeah, waste of time
14:50thearthurhiredman: looking... any idea what this looks like?
14:50technomancythose guys are well-documented to have a prejudice against the JVM
14:50hugoddnolen: most of the new contribs don't have bug trackers set up for instance
14:51dnolenhugod: whose fault is that? the contrib authors.
14:51technomancyI thought you meant the alioth git repo
14:51raekwhat is this alioth?
14:51technomancydnolen: someone has to give the authors the permissions in the first place
14:51hiredmanthearthur: I forget, I go through this same dance everytime I try to submit a patch, which is not often enough to remember the steps
14:51dnolentechnomancy: prejudice does help much since it's basically ATS, C, C++, Java -server dominating the benchmarks.
14:51hugoddnolen: and some of the authors are from core
14:52triyoDoes one have to use clojureScript/lib/clojure.jar file or can I just getting via leiningen?
14:52dnolentechnomancy: someone has to ask for it, that's like one email.
14:52triyoIts not a magical ver that works specially with cljs right?
14:53technomancyraek: alioth is a debian-specific gforge instance that also hosts some benchmarks
14:54dnolenhugod: ah yeah, that's true. it would be nicer if clojure/core was clear about what *they* no longer want to maintain.
14:54leonid_[11:18:39] <imade> I am wondering if #(reduce (fn [coll x] (cons x coll)) [] %) is idiomatic solution for http://www.4clojure.com/problem/23
14:54dnolenbut again, people could just ask.
14:54triyook, I see its not as per the bootstrap script
14:55leonid_the more optimal (?) solution uses less than ten letters
14:56leonid_if you want, I can pm you the solution
14:58triyoOnly problem I have is that I had to manually hack over the compiler.jar+goog.jar and the src/ in to my project. No package management for clojurescript at the moment sucks a bit.
14:58ibdknox_speaking of
14:58ibdknox_is anyone working on a package management solution for CLJS?
14:59leonid_clj crashes due to a whitespace in my home directory name
14:59leonid_so I need to use it on its parent directories
14:59triyobtw, whats the deal with ^:dynamic in clj 1.3?
15:00hiredmanvars are no longer dynamically rebindabled by default, if you want them to be you have to mark them as such
15:03triyohiredman: interesting move. More functional.
15:03triyolike maths let x = 3 -> x always 3 right?
15:04hiredmanno
15:04triyook could you explain just a bit?
15:05triyoreasoning that is behind no dynamic rebind.
15:05grumpytoadso... i'm reading a lot about a good emacs environment - since I'm mainly a vim user, is it worth my while to switch to emacs for clojure ev ?
15:05grumpytoad*dev
15:06dnolentriyo: it's a performance optimization. 1.3.0 is mostly about that, unifying numerics, with a couple other goodies here and there.
15:07triyoOh I see, hence there is a manual override in case you need the dynamicity of Vars
15:07dnolentriyo: yup.
15:14raekah, cool. some implemented the idea: https://github.com/ibdknox/brepl
15:14mattmitchellhow can i get the difference between 2 vectors?
15:14peterise1insmattmitchell: how would you define it?
15:16mattmitchelleheh, well i know there is set/difference, but i haven't been able to get it to work with vectors...
15:17mattmitchellok so let me convert to set... hmm.
15:17dnolen,(set [1 2 3])
15:17clojurebot#{1 2 3}
15:17dnolen,set/difference
15:17clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0)>
15:17dnolen,clojure.set/difference
15:17clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>
15:17dnolenoh well
15:18technomancymattmitchell: clojure.data/diff in 1.3 maybe
15:18peterise1ins,clojure.set/set-difference
15:18clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>
15:18mattmitchellok cool, this is giving me enough to play with
15:19dnolenmattmitchell: (set/difference (set [...]) (set [...])) should work as long as the vectors don't have duplicate items and order is not a consideration.
15:19mattmitchelldnolen: ok excellent thanks!
15:24tsdhIf I have a function (defn foo [x] (let [a ... b ...] (foo a) (foo b))) where the recursion is for side-effects only, how do I write it to not consume stack?
15:25gtrakwhat is this syntax #'symbol?
15:26chousergtrak: that's shortcut for (var symbol)
15:27chouserIt evaluates to the Var object named "symbol"
15:27gtrakI see
15:28gtrakwhat would be the purpose of that?
15:28chouserYou can deref it to see the current value of that var
15:28gtrakit adds an indirection to symbol resolution?
15:29Netfeedhow can i "unpack" a list? (take 2 (range 10)) returns (0 1), but how can i use that for say +? (+ (take 2 (range 10)))
15:29Chousukeapply
15:29Chousuke(doc apply)
15:29clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
15:29Netfeedah, yeah, that's true, thank you
15:29dnolen,(reduce + (take 2 (range 10)))
15:29clojurebot1
15:33raekgtrak: it is useful when you, for instance, want to store a callback function in a data structure somewhere
15:33gtrakaren't named functions all vars anyway?
15:34raek(defn foo ...) (def callbacks {:f foo}) ; <-- here the current value of foo is stored. if foo is redefined, 'callbacks' won't be updated
15:34raek(def callbacks {:f #'foo}) solves that problem
15:34gtrakso a var to a var
15:36gtrakI see, the root binding is early-bound, this makes it late?
15:36raekgtrak: when a function is refered to in a piece of code, the var will be dereference each time the code is executed.
15:36raekgtrak: no, a var to a function
15:36raekinstead of just the function
15:37gtrakright, i think we're saying the same thing
15:37raekin (def a x), x is dereferenced once. in (defn b [] x), x is dereference each time b is called.
15:37gtrakearly vs late binding
15:38raek(assuming x is a var here)
15:44gtrakraek, ah, if you use that var as a function it is automatically dereferenced, sneaky!
15:45hiredmanno
15:45hiredmannames that are free in an expression are always resolved to the dereferencing of a var
15:47gtrakwhat's it mean to be free in an expression? I notice the leftmost is dereferenced and the arg is not
15:48hiredmangtrak: http://en.wikipedia.org/wiki/Lambda_calculus#Free_variables
15:49gtrakhiredman, this may be helpful to me someday :-), but right now it makes no sense
15:51hiredman(def x 1) (fn [] (+ x x)) is compiled as somethinglike (def x 1) (fn [] ((deref (resolve 'clojure.core/+)) (deref (resolve `x)) (deref (resolve `x))))
15:51raek(fn [x] (let [y 1] (list x y z))) ; <-- here z is a free variable, but not x and y
15:52gtrakah, not a lexically scoped one
15:52hiredmanin the code the compile emits vars are actually only resolved when the fn loads, and just loaded from the fn's var cache and derefed, instead of calling resolve every time
15:53gtrakah, unless you explicitly tell it to be a var?
15:53gtrakwith #' or (var ..)?
15:54hiredman#' and (var ...) are actually the same thing
15:55hiredmanthe reader changes one into the other
15:55hiredmanbut yes, explicitly referencing the var gets you the var, not the value of the var
15:56hiredmanbut if I recall it still loads the var into the var cache for the fn
15:56gtrakis it implemented as a var to a var? like a double pointer?
15:56raekthis would be a var-to-a-var: (def x 1) (def y #'x)
15:57gtrakright
15:58raekvars are like pointers, but the reference they contain could also be seen as a kind of pointer
15:58gtrakright, so try (y nil)
15:58gtrakyou get "java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)"
15:59raekI never said anything about functions... :)
15:59gtrakso it's deref'ing the var, that's what I was referring to :-)
15:59raekif x would contain a function, that would have worked
15:59gtrakah right, I'm not worried about the exception, obviously an int isn't a fxn, but y was a var
16:00raekbut afaik, the compiler won't generate any var-to-var code unless you explicitly write something like the above
16:07gtrakhiredman, so, when you call a function the argument isn't considered to be a free variable to be resolved? doing (print y) gives you #'user/x
16:07mefestogtrak: anything can be called like a function if it implements clojure.lang.IFn
16:08gtrakdoes var implement IFn?
16:08mefestogtrak: clojure.lang.Var implements IFn
16:08gtrakha
16:08gtrakdoubly sneaky
16:08mefestogtrak: so do Keywords which is why (:fname amap) works
16:08gtrakso var just delegates to its value
16:09hiredmangtrak: y is a free variable, it is resolved to the var #'y, and deref'ed which gives you #'x
16:10mefestogtrak: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L377
16:10mefestogtrak: calls to invoke delegate to fn which derefs itself
16:10gtrakbam, well there it is
16:11mefestogtrak: pretty cool setup :) pretty cool when using deftype
16:13Netfeedis it possible to write tests for private functions? or is it better to just write for the public ones?
16:13Netfeedwith clojure.test
16:15mefestoNetfeed: i can't comment on what's better but if you require a lib you can call a private function in it with something like (#'my.lib/f)
16:15gtrakmefesto, what's cool about it with deftype?
16:16mefestogtrak: it's just more the same but applied to your own types
16:16Netfeedmefesto: alright, i'll start from there, thank you
16:20mefestogtrak: https://gist.github.com/1112451
16:21gtrakthe invoke is the special sauce?
16:21mefestoyeah IFn.invoke
16:21gtrakah you're extending IFn
16:22gtrakthat one: invoke(Object arg1, Object arg2)
16:23mefestoIFn.invoke(Object arg1)
16:24mefestoin deftype, the first arg is the target object
16:24mefestolike how in python the "this" reference is made explicit
16:24gtrakah
16:25gtrakbut when you run it it actually uses the java model, and doesn't pass in the 'this' as the first arg
16:25mefestoyup
16:27imadecan anyone offer me feedback for 4clojure problem http://www.4clojure.com/problem/26, my solution is at https://gist.github.com/1112440
16:30amalloyimade: instead of using reduce/loop to eagerly create a list of N fibonacci numbers, try lazily creating a list of infinite fibonacci numbers and then just take'ing from that. it can come out a lot simpler that way
16:31imadeamalloy: yeah that would definitley be a better alorithm
16:32imadeI will meditate about this now
16:33amalloyalso in general if you find yourself building a list and then reversing it, you probably meant to use a vector instead (doesn't really apply if you want to take the first bit of advice)
16:34imadeI used list so I could access the previous calculation
16:35amalloyright. you couldn't (shouldn't, anyway) do that with a lazy-seq, but with a vector it would be at least as easy
16:36amalloyoh, but you couldn't destructure it
16:36imadeyes
16:36imadein list the previous calculation was in the first position
16:37amalloy&(let [prev [0 1 2 3 4]] ((fn last-two [v] [(peek v) (peek (pop v))]) prev))
16:37lazybot⇒ [4 3]
16:38imadeI see, very cool
16:39imadebtw, the correct solution in 4clojure starts with 1 1 ..., in wiki it's 0 1 1 ..., why's that?
16:39amalloygood question
16:40amalloyi hadn't noticed we did that. kinda silly
16:40amalloybut you can compensate for our failing by making your base case [1 1] instead of [0 1]
16:41imadeyeah
17:23triyoI have a ClojureScript function that attempts to generate a slug uri based on input string and automatically set the input text field with the value. https://gist.github.com/1112594
17:24zoldarhello, I'm trying to setup ritz (formerly swank-clj). I'm able to run swank server through 'lein ritz' and connect to it, but when I pass a form with error I don't get any stacktrace: http://paste.lisp.org/display/123620 . Any ideas what could I've missed?
17:24triyoProblem is I don't really know how to set a value "property", instead it attempts to call it as a function instead a property of HTMLInputElement
17:26triyohmm, set! I guess *blush*
17:27hugodtriyo: ritz still needs to have some work done on filtering which exceptions break into the debugger
17:27triyowrong person ;)
17:28hugodoops, sorry
17:28triyonp
17:28hugodzoldar ^^
17:30leonid_has anyone gotten less than 28 points on http://4clojure.com/problem/29 ?
17:30zoldarhugod, hmm but that exact simple example was taken from presentation - is there anything I can do to make it break into debugger in such cases?
17:31triyoHoly smokes, where have I bean for the past year, http://4clojure.com/
17:32triyo*bean=been
17:32triyothis looks awesome.
17:32leonid_yes it is!
17:33hugodzoldar: you could patch ritz… ritz.jpda.debug/break-for-exception?
17:33Raynesamalloy: You've got fanboys ^
17:34hugodzoldar I'm currently working on fixing it -but not managing to devote much time to it
17:34triyoI see that the 4clojure numbers haven't hit even close to the number of foreclosures in the US ;-)
17:35triyo23,451 only
17:35zoldarhugod, ok, thanks for your efforts so far
17:36amalloyleonid_: two people have 25
17:36leonid_wonder how they managed to do it
17:36hugodzoldar: np, I get annoyed by the same issue - so it's likely to get fixed
17:36leonid_amalloy: how does one know the size of the smallest entry?
17:37amalloyleonid_: i log into the server and query the database :P
17:37leonid_you should make it visible
17:37leonid_please !
17:37scottjibdknox: why have CLOJURESCRIPT_HOME in brepl when already set for clojurescript? also maybe print index.html url in terminal so user can just click on it
17:37amalloypatches welcome :)
17:37leonid_after I get more familiar at clojure..
17:37leonid_(started only a day ago)
17:38amalloyah
17:41amalloyleonid_: mind gisting your 28-character solution somewhere? there might be a way to trim three characters off it while using the same general approach
17:41leonid_mind if I just post it here?
17:41amalloyhah, sure. i guess it's short enough
17:41leonid_#(apply str (re-seq #"[A-Z]" %))
17:42leonid_i'm suspecting that I can reduce 3b from the regex
17:42mattmitchellanyone know of a lib i can use to get the distance between to x/y coordinates?
17:43amalloymattmitchell: i think it's called Math.sqrt :P
17:43gtrakjesus... pythagoreanlib
17:46raek(defn distance [p1 p2] (->> (map - p1 p1) (map square) (reduce +) (Math/sqrt)))
17:46raek(defn square [x] (* x x))
17:46raekworks on any number of dimensions!
17:49leonid_looks like regex is not the problem
17:54dnolenclojurebot: max people
17:54clojurebotmax people is 317
17:54technomancyclojurebot: lies
17:54clojurebotexcusez-moi
18:12leonid_hell yeah got 25 chars
18:56technomancyinteresting; debian is considering dropping java for mips, which would mean most -gcj packages would go away across the board.
18:57technomancyFSVO interesting
19:08frouI posted a socket-REPL-related question on StackExchange. Can any shell scripters tell me if it's a fool's errand? http://unix.stackexchange.com/questions/17562
19:10technomancyyou want rep!
19:10technomancyclojurebot: rep?
19:11clojurebotyou mean clojure.main
19:11technomancy...
19:12technomancyI'm not sure if you can do it with that contrib lib. you could try calling (.close *in*) or something
19:15frouooh, that does work it seems
19:16frouI was coming at it from the wrong angle, shell hackery. thank you technomancy
19:17technomancyno problem
19:19amalloyfrou: C-c is kinda rude there anyway. use C-d to close repls, most of the time
19:20amalloy(which amounts to basically the same thing as closing the socket)
19:21amalloywait, but you only want to kill the netcat process, not the long-lived clj process. i see. so does technomancy's solution really work?
19:23frouamalloy → ^D doesn't appear to do much when using netcat as a client of the socket REPL
19:23frouit does, I run `lein repl` then in the code sent via netcat, have (.close *in*) appended
19:24amalloyfrou: right, but can you then reconnect and send another command?
19:24ihodesnetcat can die. gnu's doesn't compile on osx, and osx's isn't compatible with gnu's. :(
19:24amalloydur, never mind. you must be opening a new socket on each connectgion
19:25frouihodes → i installed gnu 0.7.1 no sweat via homebrew
19:25ihodesfrou: might have to try that. don't remember if i did. i just gave up pretty quickly to be honest.
19:26pmbauerI've seen the following idiom several times, what is the motivation? (defn somefunc [x] (let [x x] (...)))
19:27technomancypmbauer: trying to use up _exactly_ 140 characters in a tweet maybe?
19:27pmbauerHa! I can't understand the need for the local alias
19:27pmbauer...saw it in some of dnolen's code today.
19:28dnolenpmbauer: eh?
19:28pmbauerAh! Hi. https://gist.github.com/888733 see lines 40, 44, and 48
19:28dnolenpmbauer: are you ignoring the type hints?
19:29pmbauerThe type hint can't be put on the parameter?
19:30dnolenpmbauer: not in this case no, at least not when I wrote that code.
19:30pmbauerAh. Thanks for the explanation, thought I was missing something.
19:30dnolenpmbauer: those aren't regular fns
19:31pmbauerprotocol implementations ...
19:34pmbauerdnolen: One other q, on line 21 (compute [_] (.compute task)), I get a reflection warning for 'compute', yet all the other RecursiveTask methods resolve. Any idea why?
19:35pmbauerI double checked the signature in jdk7 just to check my sanity ...
19:35dnolenpmbauer: it's a protected method I think.
19:35pmbauer*sigh* staring me in the face. Thanks.
19:36dnolenpmbauer: didn't seem to matter in the end performance wise.
19:36pmbauer...trying to port a fork/join java algorithm to clojure. This was a great help. Thank you for the gist
19:36dnolenpmbauer: no problem! look forward to seeing that. haven't messed much with fork/join beyond that gist.
19:57seancorfieldi try *really* hard not to respond to ken wesson... i really should know better... :(
20:00dnolenseancorfield: not … worth … it
20:01seancorfieldin my defense, i'd just got back from the dentist and was unusually grumpy :)
20:04technomancyseancorfield: killfiles dude
20:04ndimiduktechnomancy: have a moment?
20:05seancorfieldthat's a bit brutal - ken also posts some really interesting answers to questions :)
20:05technomancyndimiduk: what's up?
20:05technomancyseancorfield: well actually I just have a filter that marks all his posts as already read
20:06technomancybut that's only because I don't know of a killfile implementation that's portable across emacs and android =\
20:06ndimiduktechnomancy: i have a swank hook for adding cdt debugging jvm options to my project. it works when i invoke `lein swank` from the cli but when i use emacs clojure-jack-in i get an exception for passing 6 arguments to my hook fn. any ideas?
20:07technomancyndimiduk: curious; can you gist the hook?
20:08ndimiduktechnomancy: https://gist.github.com/1112864
20:09hiredmanI imagine you need a & args in your hook
20:09technomancyndimiduk: yeah, hiredman is right. you need to apply f to the project and args
20:09technomancysince swank takes optional args as well
20:10ndimidukso, (defn swank-hook [f project & args] ...) ?
20:10technomancyaye
20:11technomancyand (apply f (assoc project [...]) args)
20:12ndimidukah!
20:12ndimiduknice, that works.
20:12ndimidukthanks guys
20:12technomancynp
20:21ndimiduktechnomancy: do i need to do something special to have the lein process started by clojure-jack-in respect my $JAVA_HOME?
20:21ndimiduk(use 'swank.cdt) throws because it can't find tools.ja
20:21ndimidukr
20:22ndimidukwhich is in the lib in my $JAVA_HOME
20:22clojurebotRoger.
20:24technomancyndimiduk: try setting JAVA_CMD to point to the right executable instead
20:25amalloyclojurebot: forget which
20:25clojurebotPardon?
20:27technomancyndimiduk: do you think it would be wise to search for the java executable using JAVA_HOME if JAVA_CMD is not set?
20:27devnibdknox: cool.
20:27devnibdknox: I like this REPL
20:27ndimidukthat sounds reasonable.
20:28ndimiduktry $JAVA_HOME/bin/java
20:28ndimidukwhich is what i just set my $JAVA_CMD to
20:28devnibdknox: I especially like the fancy-shmancy tab-completion. I think my next project is to try and get (doc) hooked up to gClosure in ClojureScript
20:28technomancyI'm a big fan of software that doesn't require JAVA_HOME to be set, but I guess if it is set, it's usually set for a reason
20:28technomancyndimiduk: feel free to open an issue
20:28ndimidukwhy would you prefer JAVA_CMD?
20:29ndimidukthis is the first time i've encountered that one
20:29ndimidukalso, i'm not sure why that should resolve my classpath correctly
20:29technomancyI think JAVA_CMD came from some autogenerated shell scripts from a maven plugin or something
20:30ndimidukand it doesn't
20:30technomancyhm. I had that same issue of missing tools.jar, and it was from using a JRE instead of a JDK
20:30technomancyonce I switched JAVA_CMD to point to java from a JDK, it worked fine
20:31ndimiduknot so for me.
20:31ndimidukcan i query the current classpath from within a repl?
20:32ndimiduksomething off of System perhaps?
20:32technomancy(System/getProperty "java.class.path")
20:32technomancyor lein classpath
20:34ndimidukinteresting. i have nothing in my classpath which is not defined by my project
20:34ndimidukso says (System/getProperty "java.class.path")
20:35ndimidukit must be omitting some assumed entries. or the runtime appends to this list
20:35technomancyyou may also want sun.boot.class.path?
20:35ndimidukah, there we have some system libs
20:35ndimidukit's using a jre path
20:35technomancythat's the stuff that doesn't go through bytecode verification, etc
20:36ndimidukhaha.
20:36ndimidukokay. $JAVA_HOME/bin/java is a symlink to ../jre/bin/java
20:38ndimidukthis is a full jdk; i have javac in $JAVA_HOME/bin
20:41ndimiduk`$ $JAVA_CMD -verbose:class | grep tools` returns no results
20:42ndimidukare you using openjdk? does that version of the java bin load additional libs?
20:44technomancyopenjdk on ubuntu has it, yeah
20:44choffsteinHey all. I have a question for you -- I am doing some data set-up in a let statement and half-way through the statement I want to determine whether there is enough data to proceed or not. If not, I want to throw an error -- if there is, I want to proceed computing the data. What is the "clojure way" of doing this?
20:46technomancy,(let [x 2, _ (when (neg? x) (throw (Exception. "Positive numbers only plz"))) y (Math/sqrt x)] y)
20:46clojurebot1.4142135623730951
20:46technomancyyou can do that; it's not great
20:46amalloyoften you can just create the lazy seqs representing the processing of your data unconditionally, and then later only force it if the condition is met
20:47choffsteintechnomancy: yeah, I really don't like the use of _ for creating side-effects and what-not.
20:47choffsteinamalloy: can you expand on that a bit?
20:48choffsteinoh, wait, nope. re-read … I think I understand.
20:48choffsteinhow can I be sure that my process will be lazy?
20:52amalloyuhhh. only use lazy functions to operate on it? not very helpful, but there's not a lot of specific things to say
20:54hugodndimiduk: it is my understanding that openjdk automatically adds tools.jar, while sun jdk does not - see "Sun/Oracle JDK" in https://github.com/pallet/ritz
21:28tmountainis this the preferred (and fastest?) way to convert an ArrayList to a vector? (into [] array-list)
21:29amalloypreferred is probably: "are you sure you need to do it?"
21:30tmountainwell, I'm calling some Java code that returns an ArrayList, so I don't have much choice in that regard
21:30amalloytmountain: but is there a reason you need a vector, is my point. java's collections can be worked with as seqs
21:31amalloy&(seq (java.util.ArrayList. [1 2 3 4]))
21:31lazybot⇒ (1 2 3 4)
21:31tmountainoh, I see
21:31tmountainthat makes life easier, thanks!
21:31amalloyi mean, the seq isn't random-accessible anymore
21:33tmountainwhat you're saying is it acts like a seq, not a vec, right?
21:33amalloyright
21:33tmountainI gotcha, thanks for the help
21:39scottjhugod: ndimiduk: I thought it was openjdk that didn'thave tools.jar on cp by default, at least on ubuntu
21:42ndimidukthis is sun's java
21:42scottjmaybe it's both
21:45scottjritz with openjdk source is pretty sweet, you can step through not only your code, the clojure code, but the jvm code too
21:45jcromartiewow, I just realized exactly how powerful a remote slime REPL is
21:45jcromartie:P
21:45scottjmars lander?
21:46scottjbe sure to do it over ssh
21:46jcromartieyes
21:46jcromartiewhat about a mars lander?
21:46jcromartieI've heard NASA uses some similar kind of technology
21:46scottjthere wassome famous lisp project like that that had a repl jpl or someone used to debug something far away
21:46jcromartieyeah
21:47jcromartiebut I like the idea that I can have the files on my local machine, and hit C-c C-k and fix a problem live
21:47jcromartieif I absolutely have to cowboy code it
22:01nowhere_manscottj: just saw your closing of my issue with SLIME disconnecting, would it be a daunting task to make swank-clojure play nice with recent SLIME?
22:02scottjnowhere_man: I don't think so, just no one's done it
22:03scottjnowhere_man: hugod's fork ritz works with a more recent version
22:03scottjnowhere_man: I would be really happy to have swank-clojure work with latest slime, but technomancy had a bad experience following master on slime in the past
22:04hugodstill nowhere near current, but my aim was always to get it up to date,
22:04hugodritz works with slime-autodoc
22:04scottjswank-clojure does too (for me)
22:05scottjbut I use a different slime version than the recommended one
22:06scottjI think it would be cool to have a auto-complete mode for dependencies in project.clj so where it completes the name and version based on clojars
22:06tomojthere's an index you can download, right?
22:07hugodI believe lein already downloads it
22:07hugod~/.lein/clojars
22:07clojurebotHuh?
22:08scottjhugod: nice didn't know about that
22:08tomojhttp://clojars.org/repo/feed.clj.gz
22:08tomojI don't have ~/.lein/clojars
22:08tomojoh, lein-search writes it
22:09scottjif anyone writes a mode like that please post it to ml, otherwise I'll probably take a stab at that soon now that I know about ~/.lein/clojars
22:09tomojwhoa
22:10tomojscm repos in that index
22:10nowhere_manhugod: I did lein install plugin and added dev-deps to my project, but on lein ritz, I get java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine
22:10nowhere_manis it something leiningen doesn't check for?
22:11hugodit is require by the jpda debugger - see the Sun/Oracle JDK section of the readme
22:11tomojscottj: need a primitive clojure reader in elisp? or rely on running slime?
22:12scottjhugod: note I have that issue with openjdk
22:12hugodnowhere_man: it is tools.jar that you have to get on the classpath
22:12hugodscottj maybe they both need it then…
22:14scottjtomoj: yeah i was thinking of using slime and basing it on ac-slime.el, but not using slime would be better
22:18nowhere_manhugod: added /usr/lib/jvm/java-6-openjdk/lib/tools.jar to .lein-classpath to no avail...
22:20nowhere_manhugod: nevermind, I didn't find anything else in lein's online help but I just stumbled on `lein help sample`
22:20hugodnowhere_man: maybe try :dev-resources-path
22:20scottjnowhere_man: see ritz readme
22:23scottjI'm still amazed no one seems to care about clojure-refactoring
22:23hugodbtw, still looking for any input on https://github.com/pallet/ritz/issues/14 - how to filter/manage which exceptions break into the debugger
22:24nowhere_manha, shit, I thought these sections were exclusive, I only read the one for lein
22:25hugodkeep meaning to try clojure-refactoring, but never did…
22:26scottjit's awesome
22:26scottjbut there are some bugs. I really like the thread-first, thread-last, unthread refactorings
22:26nowhere_manooOOooOo, it works!
22:26nowhere_manI'll finally be able to play with Clojure, great!
22:27nowhere_manthanks a lot, you all
22:28hugodnowhere_man: ritz still has some rough edges…issues welcome
22:28scottjhugod: did you ever get a response to your -dev locals clearing request?
22:28hugodscottj: not from core
22:29nowhere_manhugod: one of the greatest pleasures in using free software is seeing bugs fixed, so I'll happily file issues...
22:29hiredmanI thought rhickey replied
22:29hiredmansomething like "I dunno what the best way to do this is"
22:29hugodhiredman: earlier on in the year
22:30hugoda dynamic var controlling the locals clearing would be fine with me
22:32hugodthat could be set by emacs using a prefix for C-c C-c or C-c C-k
22:33hiredmanmore hooks for the compiler would be nice in general
22:59jcromartiehm... form validation in sandbar look complicated
23:23scottjjcromartie: maybe look at valip or noir
23:23jcromartieI just wrote this https://gist.github.com/1113067
23:24jcromartieI achieved my goals :)
23:24jcromartieseems to be sufficient for a decoupled validation lib
23:24jcromartiethe results can be passed to the view layer
23:25jcromartieand the view doesn't need to know anything about validation itself
23:26alandipertjcromartie: neato
23:26alandipertjcromartie: lines 18/19 could be (when-let [x (get m k)]...)
23:26jcromartieyes
23:27jcromartieactually
23:27jcromartieno
23:27jcromartiebecause if the form was not submitted, then there will be no key in the params map
23:27jcromartiethis only validates when the form was actually submitted
23:27alandipertthat's ok, get returns nil on not found (by default)
23:28jcromartieno, I mean when the key is not present I don't want to validate at all
23:28alandipertoh i gotcha
23:28jcromartiebut when it's present and nil, then it's an error
23:28jcromartiealthough... hm
23:29jcromartieI'm not sure if that's secure
23:46kephalehopefully an easy leiningen question: how does one refer to files in the resources directory in a portable way (so it works in an uberjar)?
23:49hiredmankephale: clojure.java.io/resource
23:50kephalehiredman: hoorah, thank you
23:55jcromartienow with infinity% more tests!
23:55jcromartiehttps://gist.github.com/1113067