#clojure logs

2011-12-23

00:22GeoffSKclojure.data.json - what is the best way to included it in a project (leiningen) ?
00:31nickmbaileyfollow the instructions here: https://github.com/clojure/data.json
00:33GeoffSKthanks, but where do i find my pom.xml? I didn't realise i had one.
00:33GeoffSKoops sorry
00:33ibdknoxGeoffSK: you just need to add this to your project.clj: [org.clojure/data.json "0.1.1"]
00:34ibdknoxthen do lein deps
00:36GeoffSKshouldn't (use 'clojure.data.json) work at the repl?
00:36nickmbaileyit will work after you added it to your project.clj and then ran 'lein deps'
00:38GeoffSKyep works thanks. clooj doesn't always seem to respond after doing a lein deps.
00:38Raynesamalloy: Hi.
00:38nickmbaileyhmm haven't used clooj
00:39GeoffSKpretty limited dedicated clojure editor
02:07devnit has promise
02:07devni hope they continue to expand it
04:33tsdhHow can I fire up a SLIME REPL in clojure itself? M-x clojure-jack-in relies on an existing project.clj...
04:33sandy1986tsdh: simply start clojure.jar with java?
04:34tsdhsandy1986: That gives me a REPL at the console, but not in emacs.
04:34sandy1986ahhh okay, I do not use emacs
04:34G0SUBtsdh: you can use swank-clojure to start a swank server. emacs can then connect to it.
04:36tsdhG0SUB: How would I do so? Or the other way round, it's probably easier to create a project.clj with no deps and stuff, isn't it?
04:36G0SUBtsdh: take a look at the embedding section in here - https://github.com/technomancy/swank-clojure
04:37tsdhG0SUB: Thanks.
04:37G0SUBtsdh: you are welcome
04:41RaynesI'm not sure how useful a SLIME repl is without an associated project.
04:48tsdhRaynes: Well, the project is clojure.
04:50G0SUBRaynes: he is just not using Lein.
04:53sandy1986How to read the json string from a request? (JSON & HTTP_POST)
04:55tsdhG0SUB, Raynes: Not "he", clojure itself is just not using leiningen. ;-)
04:55G0SUBtsdh: true ;-)
05:40sandy1986Mhhh, JQuery + Json drive me insane
05:43Raynescemerick: Surely you're not up *this* early.
05:43cemerickI'm up at 5 most mornings.
05:43RaynesMan.
05:43RaynesGet off my lawn.
05:44cemerickSurely you're not *still* up *this* late.
05:44RaynesI woke up at 11PM.
05:44cemerickI don't even know what to say to that.
05:45Raynes"Get a life." is appropriate.
05:45cemerickHrm. Might be a little harsh.
05:46G0SUBcemerick
05:49cemerickG0SUB: Hi! :-)
05:49G0SUBcemerick: how's business?
05:49RaynesG0SUB: You took some amazingly unflattering pictures of me at the Conj. We are no longer friends.
05:50cemerickWe'll find out in the next month or so. Probably 50% of revenues are in January.
05:50G0SUBRaynes: oh, that was entirely unintentional :-P
05:50G0SUBcemerick: cool
05:50Raynes:p
05:50G0SUBRaynes: next time, you tell me which angle to pick. Ok?
05:51RaynesThe one where my manboobs aren't showing.
05:51cemerickG0SUB: as a corollary, selling software sucks.
05:51G0SUBRaynes: haha. I will airbrush those out if they come into the frame next time.
05:52RaynesExcellent.
05:52G0SUBcemerick: get someone else to do that.
05:54cemerickG0SUB: Can't outsource customer contact. It's the most valuable commodity.
05:54cemerickNah, I just need to flip the switch on a different business model.
05:55G0SUBcemerick: get a non-technical co-founder.
05:55G0SUBcemerick: you hack, he hustles.
05:56cemerickit'd probably be the other way around :-P
05:56G0SUB:-P
05:57Vinzentif I compile cljs file like this $ cljsc src/repl/test.cljs '{:optimizations :simple}' then I'm getting pretty long js code, but if I omitted optimizations part, get only couple of goog.addDependency calls
05:57Vinzentwhat could be the problem?
05:57cemerickG0SUB: How are you guys doing?
05:57G0SUBVinzent: that's right. there is no problem with that.
05:57G0SUBcemerick: launch imminent.
05:58VinzentG0SUB, really? So I always have to compile with optimizations?
05:58G0SUBVinzent: your production code should be compiled in advanced mode. for dev, you can leave it off.
05:59G0SUBVinzent: when in no optimization mode, remember to include goog/base.js. you don't need that in simple or advanced.
05:59G0SUBVinzent: everything else should just work
06:00cemerickG0SUB: Stellar. Go get 'em. :-)
06:00G0SUBcemerick: PM?
06:00cemericksure
06:01G0SUBapparently I can't do PM in Adium.
06:01G0SUBwtf
06:02cemerickirc through adium?
06:02G0SUBcemerick: temporary arrangement
06:02VinzentG0SUB, indeed, it works. Thank you.
06:03Blktgood day everyone
06:03G0SUBVinzent: go and hack some Cljs!
06:07VinzentG0SUB, hah, right :) but I'm still setting up my dev env, can you advise me something else what I should use?
06:08G0SUBVinzent: browser-repl.
06:08Vinzentibdknox's one?
06:09VinzentAs I understand, it's a standalone repl, and I use emacs
06:09G0SUBVinzent: no. it's in cljs core now.
06:10G0SUBVinzent: https://github.com/clojure/clojurescript/wiki/Emacs-%26-inferior-lisp-mode
06:10G0SUBVinzent: https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
06:10Vinzentah, yeah, I use it already
06:11Vinzenthttps://github.com/ibdknox/cljs-watch this one seems useful too
06:11G0SUBVinzent: yes, it's great. but it can't handle no-optimization mode. it does either simple or advanced.
06:12G0SUBVinzent: use my fork if you want to use cljs-watch with no optimizations - https://github.com/ghoseb/cljs-watch
06:13VinzentG0SUB, great, thanks, I'll check it out!
06:14G0SUBVinzent: I haven't fixed the shell script, just the code. so fix the shell script accordingly, please.
06:15Vinzentok
06:17Vinzentby the way, why there is no lein plugin for that? lein cljs install, lein cljs repl and lein cljs watch would be much nicer than a bunch of shell scripts
06:17G0SUBVinzent: those things should exist. just not right now.
06:18VinzentI see - cljs even have not been released yet
06:20tsdhOn JIRA, is there no way to get a listing of all issues where I have done something? I tried searching for Tassilo with [x] for Summary, Description, Comments, and Environment, selected "Any project" and "Any" type of issue, but I only get empty results...
06:33tsdhHm, what's the right way to close a JIRA issue that's actually a non-issue, i.e., the reported bug is no bug at all but a misunderstanding on the reporter's side?
06:34tsdhNeither Completed, Declined, nor Duplicate seem appropriate. And what should I specify as Fix versions when there's no fix. Empty, I guess?
06:35CmdrDatstsdh: it depends on what you've adopted as 'the right way', for me it would be to assign the task to the reporter with a comment, then have them resolve/close it as 'won't fix'
06:36tsdhCmdrDats: The reporter is the assembla importer. ;-)
06:39CmdrDatstsdh: ah :)
08:50elriclHello
08:51elriclIs there a way to control the heap size a clojure script?
08:51elriclSomething similar to -Xmx64m for clojure?
08:53pyrelricl: -Xmx64m
08:53pyrany option you pass to the jvm
08:53pyrwill be applied
08:54elriclI run my files as clojure xx.clj
08:54pyrok
08:54pyrclojure is probably a shell script
08:54pyrand probably knows about env variables such as JAVA_OPTS or JAVA_OPTIONS
08:59`fogusHas anyone written a node-connected REPL for ClojureScript?
09:26ambrosebshow can I get a seq of all classes defined in the java.lang.* namespace?
09:28rallie(java.lang)
09:29ralliesorry, that was meant for a repl
09:30ambrosebsI'm trying to get a seq of all the implicit imports in a clojure namespace, which I believe is just java.lang.*
09:33ambrosebsperhaps an easier problem would be to work out which classes clojure.core imports
09:42ambrosebs,(into {} (filter #(re-seq #"java.lang.*" (str (val %))) (ns-imports 'clojure.core)))
09:42clojurebot{ProcessBuilder java.lang.ProcessBuilder, Enum java.lang.Enum, SuppressWarnings java.lang.SuppressWarnings, Throwable java.lang.Throwable, InterruptedException java.lang.InterruptedException, ...}
09:42ambrosebsseems to work
10:08ambrosebsis :exclude the only valid :refer-clojure option?
10:19jodaroambrosebs: looks like refer takes :exclude, :only and :rename
10:20ambrosebsjodaro: where'd you find that out?
10:20Raynesambrosebs: Documentation, I imagine.
10:20ambrosebsoh right, refer's docs
10:21RaynesClojure has these cool docstring thingies.
11:14tmarbleO
11:14tmarbleI'm stuck with a simple routing question in Noir... keep getting "Key must be integer" from compojure...
11:15tmarbleThis is a very simple app based on noir:jar:1.2.2-SNAPSHOT
11:15tmarbleI can't seem to construct the form: (defpage user [:get "/user/:id"] {id :id}
11:16tmarblew/o getting a stack trace??
11:16lazybottmarble: Definitely not.
11:18TimMcChrist, I've got about a 5 second latency. I feel like brehaut.
11:18TimMcStupid train wireless.
11:25Raynestmarble: If there isn't a stacktrace then how are you seeing that error in the first place?
11:26tmarbleRaynes: sorry, I mean I cannot reformulate it without a stack trace => I'm getting one every time
11:26Raynestmarble: The problem is probably the 'user' bit there.
11:26Raynes(defpage "/user/:id" {id :id} ..)
11:26Raynestmarble: Try that.
11:27RaynesIt defaults to a GET request.
11:27RaynesSo no need to specify the method.
11:27tmarbleright.. tried that.. same result
11:28RaynesCan you paste the whole defpage along with the stacktrace?
11:28RaynesOn gist.github.com.
11:28tmarbleright, hold on
11:32tmarbleRaynes: please see https://gist.github.com/1514675
11:32RaynesI see the problem.
11:33Raynestmarble: That vector wont work. The defpage has to return a string. You can generate an HTML string from that [:div ..] vector using hiccup.core/html, or by creating a defpartial as explained here: http://webnoir.org/tutorials/html
11:34RaynesWell, a string or a map. In this case you just want to return a string. Compojure sees that it isn't a string and assumes it is a map, and thus when it tries to work with the map, it fails with your vague exception.
11:40tmarbleRayne: thanks! removing the hiccup stuff worked (using it within (html ...) has some ns error ... looking now)
11:40tmarbleRaynes ^
11:50tmarbleRaynes: ok, my mistake was in expanding the example on http://webnoir.org/tutorials/routes to use just hiccup (thus resulting in the behavior you describe)
11:51tmarblewhen the other tutorial examples are wrapped in (common/layout ....) or (common/site-layout ... )
11:51tmarblewhich, themselves, call (html5 ... content)
11:57triyoI'm a bit baffled as to what approach to take when introducing configuration to my clojure application.
11:58triyoMy requirements are as follows. I have an entry point -main that receives command arguments
11:59triyoThe top-level of the app is an web application (ring) that has some routes and handlers. The handlers call some namespace that contains persistence level logic that performs the db side effects.
12:01triyoQuestion is, what approach do I take, for instance, to pass environment-specific db connection info?
12:02triyoIn a simple functional approach, I could have all my functions down the abstraction take a config argument..
12:02triyoBut this of course has its own drawbacks
12:03triyoI could maybe go for some sort of a macro like with-config... But how will this work through different layers?
12:10triyoI see Chas wrote some cool post on this topic not so long ago: http://cemerick.com/2011/10/17/a-la-carte-configuration-in-clojure-apis/
12:10tolstoyIs there a handy unsigned-bit-shift-right floating around anywhere, written in Clojure?
12:10tscheibltriyo: you could create the macro "with-config" which binds the config to a thread local var using binding
12:12triyotscheibl: could you please refresh my memory. Can a `binding` be performed so that it binds over multiple namespaces in the call stack?
12:12tscheibltriyo: to "transfer" the binding to your ring handler you will have to introduce a middleware that uses bound-fn
12:13tscheibltriyo: the bound var will stay in it'S namespace
12:13tscheiblits
12:13triyoSo thats the first hurdle. Thanks. But then to transfer from handler to else where, do I have to do it explicitly with an with- type macro?
12:13triyoWell thought as much
12:14tscheibltriyo: use bound-fn
12:14triyothats the uglish part if I may say.
12:14triyoOk I'll have a loo at bound-fn
12:14tscheibli did it that way first
12:14tscheiblbut
12:15tscheiblin a single web-app there will normally be only one config for the whole app... so you can omit the with-config part
12:15tscheiblwhat I do now...
12:16tscheibl..is to read the config into an atom defiined like (def (atom nil))
12:17tscheibland read in like: (reset! config (read-string (slurp (file-or-resource (System/getProperty "backoffice.config")))))
12:18tscheiblyou see I use a Java system property to configure the config path outside .. in this case backoffice.config
12:18tscheiblfile-or resource is defined like: (defn file-or-resource [path] (or (io/resource path) (io/file path)))
12:18tscheiblso I can use it either standalone or in a Servlet context
12:19triyoHmm, if I go that route, I need to make sure it loads the file only once for when the process starts.
12:19tscheiblyes
12:20tscheibli define a function (load-config!) which is executed from the startup code
12:20triyoapp is a rest service that is gonna be under considerable fire so need to minimize loacl fs and db IO as much as possible ...
12:21tscheibl... of course you could change the config at runtime since it is an atom and use watchers to notify ore app of the change
12:21tscheibljust call (load-config) again to do that
12:21triyoThanks for that last tip on watchers... that could be useful so no surprising side effect
12:21triyo*s
12:22triyoSo you load the .conf file in to a atom right?
12:22triyoAnd atom will be bound to only a single ns right?
12:23triyoIf thats true, I'd have to call load-config in each ns where appropriate right? Would this be on each web request though?
12:24tscheiblno
12:24cemericktriyo: Note that what I describe there is *not* what I eventually settled on in clutch.
12:25tscheiblu include the config with (ns ... (:use [....config :only [config]]))
12:25tscheibland refer to it as config
12:25triyocemerick: Thanks, noted.
12:25cemerickIf you look at clutch/master, you'll see what's currently going on.
12:27triyocemerick: I'll have a look. If possible in a sentence or two maybe just to describe what route you took thats different to what you contemplated in your post?
12:28cemerickAccomplishes the same thing, but uses a slightly smarter defn-wrapping macro. Thus, pitfall #3 is avoided.
12:28cemerickhttps://github.com/ashafa/clutch/blob/0.3.0/src/com/ashafa/clutch.clj#L60
12:29tscheibl.. I do use the "with" paradigm quite often in my code... but imho it's too much boilerplate code for a global config
12:30tscheibland having the config as an atom (state) it gives you the advantage of beein easily reloadable
12:34tscheibl.. and you don't have to use bound-fn or create your own special purpose macro for that...
12:34tscheibl... but then it's an evil global ;)
12:35triyocemerick: Ok it took me a little while to figure out but I get it now and how wih-db* wraps the call and passes an implicit db arg.
12:35cemerickdoesn't seem like it took you too long :-)
12:37pandeirocemerick: is there a way to test that the clojure view server is installed and working other than just getting the couchdb config and parsing that and testing a query?
12:37triyocemerick: I'm to rusty on the Clojure front. Its been more then a year since active use, unfortunately. But I'm back, we got some great work that Clojure fits well and should keep me busy for quite some time to come. :)
12:39cemerickpandeiro: If you can get away with it, you can just clobber the view server config every time your app starts up.
12:39pandeirocemerick: k i figured as much, i will just do that
12:40cemerickIf you want to be more careful, yes, you need to access the couchdb config, and somehow make a decision as to whether it's "correct".
12:40triyotscheibl: Global vars or implicit fn arg via a smart with- fn/macro... Hmm, the choice is yours :)
12:40cemerickI've no idea how you could make that determination though.
12:40cemericktriyo: sounds good :-)
12:40pandeirocemerick: seems like a 3 step process - parse the config, throw up a test view and doc, and query it
12:40pandeirobut it's overkill for a little demo app so i will just clobber te config every time app starts
12:41tscheibltriyo: my main reason to use the statefull approach with the config was the dynamic reloadabilty
12:41tscheiblalthough it may not be that functional...
12:42cemerickpandeiro: really no reason not to. Once you *do* have a reason not to, you should probably be using a deployment process more sophisticated than the view server config fns in clutch.
12:43tscheibl... but it's quite convenient in an inherently multithreaded web-app
12:43triyotscheibl: Well thats the tradeoff I guess. In my case reloading is not desired at all so the functional route for me may very well be more suitable. I'm also thinking what the effect on composability are, if any...
12:45triyooh and testability of course.
12:46tscheibltriyo: the "with" approach doesn't keep your code from knowing where (which namespace) to get the config from....
12:46tscheiblso composability isn't tht much enhanced
12:47tscheiblsure you could write a getter function... but you will also have to refer to it via it's namespace
12:47tscheiblits
12:47tscheiblarghh... I do always mix it's with its
12:48triyoI know which you mean :)
12:48pandeirotscheibl: you and 95% of every blog post that shows up on hacker news
12:59triyoIf I take the with- + defnc (defn with conf) approach, I still have to battle with: how do I carry the cofig from -main to moustache/ring. I have to think about part like (delegate h/consumption ss ts d u) where delegate macro passes HTTP request on to the handler function h/consumption.
13:00triyoBeyond that, things do look rosier
13:00kreyHi ;)
13:02kreyhttps://gist.github.com/1514936
13:02kreyI like to write a "with-req-body" ;)
13:03kreywhich takes the code as a parameter and executes it where "parse-stream buf true" is
13:07tscheiblpandeiro: it's not that I didn't know the difference :) ... it's just that I don't write much except program code ...
13:08tscheibl.. and I type too fast with only 2-6 fingers.. never managed to learn it with all 10 during about 30 years of coding
13:08tscheibl.. but it easily leads to typing errors
13:10tscheiblI honestly never felt the need to learn it because when I code I work with my brain most oft the time and only type it in when it works inside my head
13:11tscheibl... I'm not a secretary ;)
13:11tscheibl..although the REPL changed that a bit...
13:54sbryantI'm trying out clojure with leiningen as my build + dependency management tool and I cannot for the life of my figure out how to access any dependencies. Keeps telling me things aren't in the classpath but lien classpath gives me what I'm looking for
13:54sbryantp.s. using lein swank for slime integration
13:55sbryantWhich involved going from CVS to elpa (yay) but made me turn off slime fancy (boo but understandable)
13:56sbryantThe dependency I'm trying to work with is the penumbra lwjgl wrapper library
13:59aaelonysbryant: not sure, will this help? http://clojars.org/penumbra/lwjgl
14:00sbryantIs that different from penumbra?
14:01aaelonytry it, dunno
14:01sbryantsure thing
14:12tolstoyTrying to match (in Clojure) whatever CRC16 they're using in Boost/C++: not a lot of fun. ;)
14:34KvaksWhat the best way to install Clojure and SLIME from scratch? I've spent an hour messing around, and ended up with bits and pieces from various sources such as ELPA, Git, Ubuntu repos and leinigen. I think I should just start over and find the pieces that work together better.
14:35VinzentKvaks, 1. install leiningen. 2. install clojure-mode, slime, slime-repl from the elpa
14:36KvaksAlright, thank you!
14:38sbryantJust out of curiosity should the dependencies be present in loaded-libs?
14:38jcromartieso I've had a Linode server running a Compojure web app from a REPL for a few months now, really no idea how long, but it's just kept running with no issues… so long-running Clojure processes look like they work OK :)
14:39jcromartieit's never been restarted
14:49ibdknoxcool
14:49ibdknoxmost of my sites are running off of lein run
14:57tscheibl^^
14:58pandeiroibdknox: where would you stick a noir configuration file, in the project root?
14:58ibdknoxpandeiro: usually, yeah
15:02tscheiblibdknox: would you consider to make it possible to exclude the jetty dependency via leiningen? I'm using aleph because I need asynchronous io and I have to carry these unneeded dependencies with me. I usually slove this kind of problem in my libraries by requiring the excludable dependency in code just before I need it (if I need it). This saves you from splitting up the project in multiple jars to make it modular (like ring does)
15:03tscheiblibdknox: in noir...
15:06tauntaunI'm about to write a web app. Any recommendations other than for Compojure?
15:06tscheiblnoir
15:06TharemHi, could someone help me implement assoc for a deftype? I'm trying to make a 2-d array and would like to be able to use assoc to change specific fields.
15:07tauntauntscheibl: reasons?
15:07tscheibltauntaun: it's built upon compojure but saves you a lot of boilerplate code
15:08ibdknoxtauntaun: also it has lots of stuff to get you started: http://www.webnoir.org
15:08tscheibltauntaun: ... but doesn't take away the flexibility of compojure
15:08TharemThe code I've writted so far is here: http://pastebin.com/tSZ1PF4s, but it complains about not being able to find assoc in the interfaces...
15:08bweaverTharem: Could you use `defrecord` instead of `deftype`? It supports `assoc`.
15:08tauntaunok, thanks...
15:09tscheiblibdknox: have u read my former request?
15:09ibdknoxtscheibl: is there some downside to having that dependency that I'm not aware of?
15:09TharemHmm, I could, but I'm trying to make it do the following: (assoc game-map [3 3])
15:09tscheiblibdknox: well.. it makes the standalone jar bigger
15:09Tharemand I'm not sure how to implement that on a deftype either
15:09ibdknoxtscheibl: is that actually a problem in practice?
15:10tscheiblibdknox: jetty is quite big and I like to run my stuff on small arm devices
15:10ibdknoxI see
15:10tscheiblembedded stuff
15:10bweaverTharem: Oh, sorry then. I'm new to Clojure but a defrecord would get you `(assoc game-map :xdim 3 :ydim 3)`. Dunno how to boil away the field names from that.
15:11ibdknoxtscheibl: add an issue for it on github :)
15:11tscheiblibdknox: :)
15:11TharemNah, that could work, but how do I then get it to look in the appropriate cell? I'm currently using a vector to store the data
15:12ibdknoxTharem: why are you hijacking assoc? Why not just write your own function?
15:12ibdknoxwhat you described doesn't have the semantics of assoc, it's something else really
15:12TharemThat's also an option, but I figured that I could save myself a headache if I could just have a 2-d vector behave like a 1-d one
15:14TharemAnd it does have the semantics of assoc, but instead of using a single key, it uses 2 keys contained in a vector. Or 2 keys separately, that doesn't matter.
15:14TharemI just need a way to assoc something using 2 keys
15:14bweaverTharem: After looking at the code in your pastebin I see you're trying to do something different than I thought. I can't quite tell what the `assoc` you have written now is supposed to be doing.
15:15ibdknoxyou could use a sorted map with vectors as keys
15:17TharemThe idea is rather simple: I've got an n-by-m vector, which I would like to index using an x and an y value. I'm currently using a built-in vector and translating the x and y vector by (+ x (* y y-length))
15:17TharemThat value is then used to index the vector
15:17Tharemerm, (+ x (* y x-lenght)) I mean
15:18bweaverok
15:18TharemI'm just not sure how to tell clojure to do that. I could use a separate function to index a 2-d array, but I'd prefer using assoc to keep it consistent with the rest of clojure
15:23jsnikerisHi all, I'm working on a formatter for namespace forms. Which output would you prefer for namespaces with long names: http://pastebin.com/cT2A3uWw
15:23ibdknoxjsnikeris: B
15:25jsnikerisHmm, ya the more I think about this, the problem isn't just namespaces with long names. It also applies to long ":only" lists
15:28jsnikerisI guess you'd prefer B here too: http://pastebin.com/M57F1RVL
15:28ibdknoxdefinitely
15:29tscheiblibdknox: put that on github as an issue
15:29tscheiblI've put that...
15:29tscheibl..sry I'm not native
15:30ibdknoxtscheibl: okidoke, I'll probably fix it shortly for 1.3-alpha(somenum)
15:30ibdknoxtscheibl: no worries :)
15:30tscheiblibdknox: thx would be awesome :)
15:30ibdknoxtscheibl: Sind Sie Deutsch?
15:30tscheiblibdknox: Österreich (Austria)
15:30ibdknoxah
15:30tscheiblibdknox: but we almost speek german ;)
15:31ibdknoxhaha
15:31ibdknoxtscheibl: is Clojure being used much over there?
15:32tscheiblibdknox: dunno ... I'm on no lokal IRC channels orforums...
15:32tscheibllocal..
15:32ibdknoxtscheibl: do you just use it for side projects?
15:33tscheiblibdknox: nope.. it's my main programming language since about a year
15:33tscheiblibdknox: I'm even using ClojureScript by now
15:33ibdknox:)
15:33ibdknoxtscheibl: how's that working out for you?
15:34tscheiblibdknox: It saves you quite some time when you don't have to switch programming languages all the time in a web project...
15:34tscheiblibdknox: browser differences are hard enough to handle...
15:35TharemIn case someone's still interested, I found the solution: http://pastebin.com/KQ829qua
15:35tscheiblibdknox: after solving some problems with the setup it's quite convenient to work with
15:36deechHi all, can someone point me to a resource that compares Clojure's Java interop with ABCL's?
15:36ibdknoxtscheibl: cool, are you using any CLJS libs?
15:36tscheiblibdknox: hiccups
15:36tscheiblibdknox: maybe soon "match" from dnolen
15:36tscheiblor was it matcher?
15:37ibdknoxmatch
15:37bweaverTharem: You beat me to it :) http://paste.lisp.org/display/126668
15:37tscheiblibdknox: I've integrated all the clojre and clojurescript compiling stuff with eclipse, ccw and custom builders
15:38bweaverTharem: It's interesting, I hadn't looked at protocols with deftype yet. It's pretty cool stuff.
15:38tscheiblibdknox: ..and use a slightly extended lein-clojurescript from the custom builder
15:39TharemHmm, does your code work? For me it gave errors with Associative, so I used IPresistentVector
15:39ibdknoxtscheibl: nice! You should share your workflow with the CCW guys, I bet they'd be interested in seeing how you did it
15:39bweaverTharem: Yeah, using Clojure 1.3
15:39TharemOh yeah, yours works too
15:39tscheiblibdknox: no prob... took me quite a while to figure it out .. so it could be uf use to others
15:40Tharemnow I just have to make it so that it doesn't crash the repl when it tries to print a game-map XD
15:41tscheiblibdknox: I've even managed to combine all the clojurescript stuff smoothly with jquery and jquery-mobile
15:42ibdknoxtscheibl: how'd you do that? an externs file?
15:42tscheiblibdknox: mainly because of jquery-mobile for the UI
15:42tscheiblibdknox: yep
15:42tscheiblibdknox: there are official ones for jquery
15:43tscheiblibdknox: all the other things I need I try to use from the closure library
15:44ibdknoxtscheibl: like?
15:44tscheiblibdknox: cookie stuff ... crypto hashes .etc
15:44tscheiblibdknox: but not the UI
15:44ibdknoxyeah
15:44tscheiblibdknox: that's too cumbersom in google
15:45ibdknoxfrom what I've seen the UI stuff really sucks
15:45tscheiblibdknox: you name it :)
15:46tscheiblibdknox: the google closure library seems to be quite inconsistent in a lot of places...
15:46ibdknoxtscheibl: very much so, that's why I started wrapping it :)
15:46tscheiblpinot...
15:46ibdknoxyeah
15:47tscheiblibdknox: I tried to use that too but actually couldn't utilize much of oit because of my jquery-mobile thing
15:48tscheiblibdknox: so I coded the remoting by myself.. but more resty
15:48tscheiblibdknox: I use GET and POST
15:48deechI am having trouble setting up SLIME to work with Clojure. I already have a "lein swank" running on port 4005, when I connect it immediately disconnects with a RuntimeException.
15:48ibdknoxtscheibl: how do you know which to use?
15:49deechI have a SLIME config for SBCL and ABCL, I don't want to have to hose those.
15:49dnolendeech: have you tried clojure-jack-in provided by clojure-mode ?
15:50tscheiblibdknox: I use get when I need to fetch some data .. if i need arguments for the call they get passed as url parameters.... the jquery ajax call does that automatically... works even with array and maps
15:50deechdnolen : Trying that now.
15:51tscheiblibdknox: I use POST when I INSERT or UPDATE things in a CRUD kind of thinking
15:51tscheiblibdknox: ahh yes and also DELETE .. when I delete record
15:51ibdknoxtscheibl: and what does the client-side code look like?
15:52tscheiblibdknox: the calls are not dispatched from a map like you do.. they are all separate resources..
15:52tscheiblibdknox: i'Äll set up a gist .. mom
15:53deechdnolen: I get "error "Could not start swank server: That's not a task. Use \"lein help\" to list all tasks."
15:54sbryantdeech: you need to install swank-clojure
15:55tscheiblibdknox: https://gist.github.com/1515333
15:55sbryantwhich can be done via plugin install or project dependency
15:55sbryantthen you'll be able to jack in
15:55ibdknoxtscheibl: I see, so you provide the URL.
15:55ibdknoxtscheibl: cool stuff
15:56sbryantand it looks like penumbra is clj 1.3.0 only :(
15:56tscheiblibdknox: jquery automatically encodes the data either as url parameters or form encoded depending on the request type
15:56ibdknoxyeah
15:56tscheiblibdknox: you could also send it as clojure datastructures with some jwuery ajax option
15:57tscheiblibdknox: you could possibly wrap this in some fancy macro.. but I think it wouldn't spare you much
15:57ibdknoxtscheibl: it looks like you might have a bug, line 15 should be on-error, right?
15:57deechsbryant: I'm trying that now.
15:57sbryantdeech: let me know how it goes
15:57sbryantthis is my first time with clojure
15:57sbryantand that got me too
15:57sbryantI have to keep repeating Clojure is not Common Lisp
15:57tscheiblibdknox: ahh thx... just added this 30 minutes ago or so
15:58tscheiblibdknox: error handling comes last :)
15:58ibdknox:D
15:58tscheiblibdknox: clients want to see something...
15:58sbryantI have no asdf or systems to tell me where all of this code is
15:58tscheiblibdknox: they don't pay me for error handling :)
15:58ibdknoxhaha
15:58ibdknoxtrue
15:58sbryantand I don't really know java, so it gets pretty damn confusing
15:58TharemClojure doesn't happen to have a built-in function to make a vector of a specified length?
15:59BorkdudeTharem: of what use would that be?
15:59deechsbryant : I have swank-clojure.jar installed but I think I need to include that in my .emacs file. I have other CL's configured for SLIME and I'd rather not have to hose those. How did you get SLIME to connect?
15:59sbryantAh
15:59sbryantAre you using CVS slime?
16:00TharemSay I want to make a vector containing, initialy, only zeroes, which can be used for assoc
16:00deechsbryant: Yes
16:00sbryantOkay, kill your checkout
16:00sbryantand use the elpa versions
16:00TharemI know how much space I need, just not what to put in it when the vector is created
16:00BorkdudeTharem: you can use repeat for it, to create a seq of the same elements n times
16:00sbryantI don't know why maybe technomancy can fill in the details but the clojure-swank requires a certain version of slime
16:00TharemAh thanks
16:01TharemThat's what I was looking for
16:01BorkdudeTharem: and you can use vec to make it a vec
16:01sbryantAlso remove your slime setup configuration lines
16:01Borkdude,(vec (repeat 10 0))
16:01deechsbryant: Does that mean that SLIME will quit working with SBCL etc?
16:01clojurebot[0 0 0 0 0 ...]
16:01sbryantso no (slime-setup '(fancy))
16:01sbryantNo
16:01sbryantautoloads will take care of setting up slime
16:02sbryantwhich elpa installs
16:02sbryantso install slime and slime-repl from the package list
16:03deechsbryant: Ok, I'll try that. I'll have to install ELPA first :)
16:03sbryantIf you're feeling daring try out the latest emacs 24 pretests
16:03sbryantthey have elpa already installed
16:03sbryantso you can install clojure-mode, slime, and slime-repl from the same place
16:04sbryantDo the normal thing and add the marmalade repo.
16:13TharemDoes anyone happen to know what interface a deftype needs to be printable on the repl?
16:15tscheiblTharem: have you ever had a look at https://github.com/david-mcneil/defrecord2 ?
16:17yaron-2342What exactly is the object I get when I call agent-error on an agent? It's not a throwable because I get a cast error when I try to throw it.
16:18TharemHmm, maybe I should indeed use a record instead of a deftype. I originally picked deftype because I didn't need the functionality provided by a record (or needed to overload it anyway).
16:18ibdknoxyou probably don't need either :)
16:20Tharemibdknox: True, but then I'm going to have to define a lot of functions that do conceptually the same thing as functions that are already built-in
16:21TharemAnd working with records is childishly simple if I could just find an overview of what interface does what XD
16:21joegalloTharem: pretty sure you just need to overload toString from java.lang.Object -- maybe
16:22ibdknoxdepends on how you represent your data in the beginning. What if you represented your board as a map, instead of nested vectors? Then you wouldn't need anything special at all
16:23ibdknoxthat may not be the right thing to do (I'm not sure what you're doing :) but it's something to think about
16:23TharemTrue, but every cell is going to be occupied by something
16:23yaron-2342O.k. now my head hurts. When I try to throw a value from agent-error inside of a function it fails with a cast error. But when I Try to throw it from inside the repl it's fine. ARG!
16:24Tharemand that means a map would add a huge amount of overlap. Plus, I already know how to work with maps :P
16:24Tharemoverhead*
16:25yaron-2342Oh, o.k. it is an exception. I just had a typo. Phew!
16:26yaron-2342It's at times like this I really wish Clojure had types.
16:26TharemYou can add type hints if you need them
16:28yaron-2342But they don't seem to be enforced. E.g. I will put in a type hint saying something is supposed to be a map, send in something that isn't a map and Clojure is perfectly happy. My (probably wrong) understanding is that type hints are only used to avoid reflection in Java. Am I confused?
16:29joegalloI think in that case you are using the type hints incorrectly.
16:29joegalloLet's say I call (.substring x 5) on a string -- clojure does that via reflection because it doesn't know what x might be.
16:30TimMcyaron-2342: You can put in preconditions.
16:30joegalloBut if I hinted it as a String, then it would compile into a straight up call to the right substring.
16:30joegalloClojure would not be perfectly happy if I had passed a map into either example -- but in both cases, a map has no substring method.
16:30joegalloBut that might just be my very flawed understanding of things, and I could be completely wrong.
16:31yaron-2342joegallo - Indeed, that's what I meant, but for example if I just had a normal clojure function and put in a type hint then Clojure seems to ignore the type hint. The type hint only seems to apply when Java methods are involved.
16:31joegallos/but/because/
16:31joegalloRight, the purpose of type hints there is to turn those java method calls from reflection into the actual right thing.
16:31yaron-2342TimMc - And I do but they are so… ugly. It would be beyond amazing to just up in something like ^map and call it a day rather than having to stick in pre and post and put in test functions and the rest. Too much ceremony.
16:32joegalloTagging something as a Vector before calling first on it isn't going to do anything at all, the way I understand things.
16:32yaron-2342joegallo - That was my understanding, I was just wishing out loud for them to be expanded so they would apply within Clojure
16:32joegalloIt would just be noise.
16:32joegalloOkay -- I think I understand you now.
16:37Borkdudeevery sequence has its own implementation of first, for vectors it is nth(0)
16:38Borkdudeso providing a type hint isn't needed
16:38Borkdudeit is just java polymorphism that takes care of it
16:38Borkdudeif I understand correctly
16:40mdeboardIs DOM-level JavaScript libraries like jQuery/jQuery-UI within the scope of tasks that one might undertake in ljs?
16:40mdeboardcljs*
16:40ibdknoxmdeboard: as in writing your own?
16:41Borkdudemdeboard: you can use jquery from cljs: https://gist.github.com/1096382
16:41mdeboardibdknox: No, I mean as in say I need to write some autocomplete elements in JavaScript; that would be something I'd drop in with jQuery autocomplete widgets. Is that something one would handle with cljs?
16:42ibdknoxyou certainly could, I'm not sure you'll find you gain much out of it though
16:43mdeboardright
16:46mdeboardJust looking for a reason to get involved with clojurescript
16:46ibdknoxmdeboard: you could help build the jquery for cljs: https://github.com/levand/domina
16:46ibdknoxit'd be a good way to learn I'm sure
16:49dnolenmdeboard: honestly at this point using it at all and giving feedback is "getting involved" :)
16:51mdeboarddnolen: Yeah I'm trying to fit it into my normal projects here, but I asked before you just joined the channel whether jQuery js would be a good fit for Clojure Script, since that's 99% of what we use JS for
16:51mdeboardautocomplete widgets etc
16:53dnolenmdeboard: autocomplete widgets that you build from scratch? are you already using some pre-existing auto-complete library?
16:53mdeboarddnolen: No we use the jQuery autocomplete widgets, very minimal code etc
16:53mdeboardwe have one "pure" javascript class that handles pagination
16:53dnolenmdeboard: are you planning on getting more ambitious w/ your JS?
16:54mdeboarde.g. http://lockheedmartin.jobs/ the "More"/"Less" buttons are handled by a "Pager" class
16:54ibdknoxcljs only really makes sense for really client heavy applications
16:55ibdknoxif you're trying to build an "application" instead of a website
16:55mdeboarddnolen: Doubt it, we're "committed" (*scoff*) to using Django & Python
16:55sandy1986How can I add parameters to my ~@body in a macro ?
16:55sbryantI had no idea people evened used the .jobs TLD
16:56mdeboardsbryant: Oh yes, we definitely do
16:56theconartiststeve.jobs => server not found
16:56theconartist:(
16:56mdeboardtheconartist: Research In Motion once had a .jobs domain
16:56mdeboardtheconartist: But we changed it for them
16:56mdeboardto careers.rim.com
16:56sbryanttheconartist: you can't use it for personal pages
16:56dnolenibdknox: I would argue any site that is looking at underscore.js / backbone.js should also consider cljs, seems like a lot of sites these days.
16:56mdeboardinstead of rim.jobs
16:56sbryantI'm sure no one would stop you
16:57theconartistthat's pretty damn funny mdeboard
16:57Borkdudesandy1986: what exactly do you mean
16:57sbryantmdeboard: but the double entendre is awesome.
16:58mdeboarddnolen: Actually we are implementing backbone.js, but that's not a project I Have any involvement with, and the guys that do are not keen on doing anything but js. Interestin though.
16:58sandy1986I like to write a macro that wraps something
16:58sbryantI would love to have an email at rim.jobs
16:58sbryantit's even more ridiculous than my current domain
16:58sandy1986(defmacro with-req-body [req & body] `(with-open [r# (~req :body)] (let [buf# (BufferedReader. (InputStreamReader. r#))] body)))
16:59sandy1986this works!
16:59sandy1986But not with something like: (with-req-body req (parse-stream buf true))
16:59sandy1986Cause "buf" is unknown
16:59sandy1986I need buf to be known in this context
17:00sandy1986body (missed out ~@), sorry <<
17:01amalloysandy1986: make the user call it as (with-req-body [buf] req (...)). then you can bind it to the name they specify
17:02sandy1986okay, I'll give it a try. one moment
17:02dnolenmdeboard: if you're just reusing widgets and using a couple selectors here an there - no I don't see what cljs buys you. if you need more than the I would start to consider cljs.
17:03dnolenmdeboard: I am not nor ever was a fan of jQuery. MooTools was my tool for my client projects for a long time and that was nice.
17:03sandy1986amalloy: where does [buf] came from in your example?
17:03amalloyuh
17:03amalloythe user supplies it when they call your macro?
17:04mdeboarddnolen: Noted
17:04sandy1986But I want my macro to create id
17:04andrewvc_Hi guys, I'm just getting started with macros, and I'm sugaring a common case I see. I'm wondering if my use of letfn here is considered a good idea: https://gist.github.com/af4daaf57ae9ce19d824/d4ca8d360de1cbd14c060223ba44998b34ebdab3
17:04amalloyhuh?
17:05amalloyyour macro is creating it; the user is saying what name to give it
17:05sandy1986and [buf] is a string?
17:06amalloyno, it's evidently a vector containing a symbol
17:06sandy1986(with-req-body ["buf"] req (parse-stream buf true)) << ?
17:06amalloy(with-req-body [buf] req (parse-stream buf true))
17:07amalloy(defmacro with-req-body [[binding] req & body] `(with-open [r# (~req :body)] (let [~binding (BufferedReader. (InputStreamReader. r#))] body)))
17:08sandy1986what kind of a type is binding? I try to understand...
17:08amalloyandrewvc_: i don't know anything about the part of aleph you're working with. (a) it seems like a reasonable way to wrap things, but (b) why is your wrapped-handler taking ~ch-binding if you rebind it before you let the user see it?
17:10sandy1986damn, it really works as excepted
17:10Borkdudesandy1986: excepted..?
17:10andrewvc_amalloy: My bad, still haven't run it, yeah I'm going to bind ch# to the one aleph provides, and then rebind ch# to ~ch-binding to make it available to the user. That's a bug in it
17:10andrewvc_just checking that using letfn inside a macro was an OK thing mostly
17:11sandy1986as assumed ;)
17:11Raynesamalloy is a fan of letfn in all places, big and small.
17:11andrewvc_LOL
17:11andrewvc_well, so part of my question is, letfn doesn't go in auto-generated docs
17:11andrewvc_so I guess I just need more docs in the enclosing macro then
17:11andrewvc_that worried me in particular
17:11amalloysure. it's a bit weird to introduce these "magic" names, but you seem to be making some sort of mini-dsl where you pretend those names are primitives
17:11andrewvc_cool
17:11andrewvc_great, well, then back to making it actually work
17:12andrewvc_thanks guys!
17:12sandy1986yes amalloy, this is what i like to do
17:12sandy1986but why is binding evaluated in the macro
17:13amalloysandy1986: i don't understand your question
17:14mcrittendeneny0j0p1
17:14sandy1986okay ;) I pass in the magic argument binding
17:14sandy1986it gets evaluated by ~ when the macro is created
17:14sandy1986why does it work?
17:15amalloyit's not getting evaluated
17:16sandy1986and why is ~binding used in the macro?
17:16amalloy&(let [binding x, body '(inc x)] `(let [binding 10] ~body))
17:16lazybotjava.lang.RuntimeException: Unable to resolve symbol: x in this context
17:17amalloy&(let [binding 'x, body '(inc x)] `(let [binding 10] ~body))
17:17lazybot⇒ (clojure.core/let [clojure.core/binding 10] (inc x))
17:17amalloy&(let [binding 'x, body '(inc x)] `(let [~binding 10] ~body))
17:17lazybot⇒ (clojure.core/let [x 10] (inc x))
17:17amalloythat's the difference between including the ~ and leaving it out
17:19sandy1986& = defmacro ?
17:19lazybot⇒ #<core$_EQ_ clojure.core$_EQ_@1ba28e7>
17:20amalloyhaha
17:20sandy1986;)
17:20amalloyno, just asking lazybot to eval
17:20sandy1986ahh
17:21sandy1986what's the difference between & and , for lazybot?
17:21Raynes,0
17:21Raynes&0
17:21lazybot⇒ 0
17:21clojurebot0
17:21RaynesDifferent bots.
17:21sandy1986ahh ;)
17:21Raynes:>
17:21joegalloright, & talks to lazybot, while , talks to clojurebot.
17:21joegalloiirc
17:21mdeboardI'll tell you what I could stand to write in cljs, is a browser plugin that hides stories on HN that have the string "SOPA" in them
17:21Raynesyrc
17:22Raynesmdeboard: SOPA I agree SOPA I'm getting SOPA tired of hearing SOPA about SOPA.
17:22mdeboard@kick Raynes
17:22mdeboarddamn
17:22Raynes$guards
17:22lazybotSEIZE HIM!
17:22mdeboardha
17:23sandy1986amalloy: so the ~ evaluates binding to 'x !?
17:23amalloyyes
17:24sandy1986cause [binding] stands alone in my macro definition, it simply evaluates to the passed name of binding?
17:24mcrittendenmdeboard: try http://hnapp.com/filter/d65a1cfd462aaf310bcd358d3c44f9d3
17:24mdeboardmcrittenden: brilljant
17:25mdeboardmcrittenden: That actually is awesome. Did you write?
17:25mcrittendenmdeboard: nope, I use it a good bit though. nice site.
17:26mdeboardIndeedly doo
17:29amalloysandy1986: that's another question that doesn't make sense. "stands alone" doesn't mean anything; ~binding evaluates to what was passed in because that's what always happens when you unquote anything
17:30sandy1986okay, and a vector was passed in, containing "a word" ?
17:30amalloycontaining a symbol
17:33sandy1986ahhh,... okay it makes sense
17:37jodarohrm
17:37jodarois there a one size fits all number parsing way in java?
17:38mcrittendenis there a place to go for clojure code review?
17:38jodaroi.e. Something/parseWhatever "3.14"
17:38jodaroinstead of having to know if i want a long/double/etc
17:38Raynes&(read-string "3.14")
17:38lazybot⇒ 3.14
17:38Raynes&(read-string "1")
17:38lazybot⇒ 1
17:38pandeiro_when i change a file that is already loaded in a slime REPL session, what if anything do i need to do for the changes to be reflected in the repl?
17:39Raynesjodaro: read-string will try to read any object and give you something.
17:39joegalloIf you don't know where you are going, any road will get you there.
17:39jodarooh
17:39jodarohmmm
17:39jodaroi thought i tried that
17:39jodaroand it was returning a symbol
17:39jodarobut maybe i did something else
17:39Raynes&(read-stirng "foo")
17:39lazybotjava.lang.RuntimeException: Unable to resolve symbol: read-stirng in this context
17:39Raynes&(read-string "foo")
17:39lazybot⇒ foo
17:39amalloymcrittenden: just tell hiredman you came up with a great new idea, you'll get feedback about the parts that are horrible
17:40RaynesIt can return lots of things. It just happens to do what you want as well.
17:40jodarorad
17:40jodarothats the way i like it
17:40mdeboarduh huh uh huh
17:40jodaro"it works lots of ways, one of which is the way you want it to work."
17:40amalloypandeiro_: C-c C-k the file
17:40pandeiro_amalloy: thanks
17:40Raynesjodaro: You don't want use read-string if the numbers are user input. For example, you wouldn't want to use it on a string passed as a query param on a http request.
17:41RaynesBecause they can use it to evaluate arbitrary code. Unless you bind *read-eval* to false. Or use clojail. </plug>
17:41jodaroheh
17:41jodaroi think its safe in this case
17:42jodaroits in a situation where i'm providing a decent length of rope for which one can, optionally, hang themself
17:42RaynesI'm not sure it should be optional. Why not just make them do it?
17:43lnostdal_what does "Symbol's function definition is void: define-slime-contrib" even mean? .. slime is loaded....
17:45lnostdal_not sure i want to deal with all this shit anymore .. why the heck isn't the contents of slime (a few kilobytes) simply wrapped in a namespace (does elisp even support namespaces) and included with every, single swank-backend for every single language / tool /whatever out there ....
17:45sritchielnostdal_: no namespaces in elisp
17:45lnostdal_then we need to throw emacs and/or elisp away right now
17:46lnostdal_totally fed up with it .. especially when dealing with multiple languages and tools
17:46sritchiethe initial setup can be a little harrowing, but once it's set I've loved it for clojure
17:46sritchiethat define-slime-contrib thing probably doesn't mean anything bad
17:46TharemIt means that slime won't run in his case
17:47Rayneslnostdal_: Are you trying to use SLIME for CL as well as Clojure?
17:47lnostdal_yes, it works with clojure here too .. but not when "combined" with other stuff .. sbcl, ccl, some nodejs swank backend .. etc.
17:47sritchiegot it
17:47TharemThe problem is that clojure only works with an outdated version of slime
17:47RaynesIf so, I believe technomancy's advice is "don't bother".
17:48RaynesIt is a fairly complex set up.
17:48lnostdal_yeah, i see he's trying to skip everything via that jack-in thing
17:48lnostdal_IIUC
17:49TharemClojure-jack-in assumes that slime is running properly though
17:49RaynesTharem: I think part of the problem is that the SLIME developers don't really have a concept of releasing things.
17:49lnostdal_it does? .. k
17:50RaynesI'm not sure what he is talking about.
17:50Raynesclojure-jack-in doesn't assume anything.
17:50lnostdal_yeah, it injects elisp code (slime) for emacs to eval on-the-go or something?
17:50lnostdal_that's what i thought at least
17:50Tharemclojure-jack-in does use slime though, no?
17:50RaynesIt just bootstraps a version of SLIME and runs a Leiningen command for you to start the swank server.
17:51TharemYes, but having 2 different types of slime on the ready causes problems
17:51RaynesIt is an absolute godsend for new Clojurians. 90% of the problems reported here were people who were unfamiliar with Emacs.
17:51RaynesUsing SLIME with Clojure and other languages is a whole different configuration and ball game.
17:51TharemOne way around that is to not load slime in .emacs, but provide a function that does the loading
17:51RaynesSwank backends target whatever SLIME happened to be around "at the time", in most cases.
17:51RaynesBecause, like I said, they don't do releases.
17:52TharemThat way you can do clojure-jack-in or start slime separately, but things will still break if you use clojure-jack-in after you started slime
17:52Tharemthe other way around is fine apparently
18:01sandy1986Mhhh,...
18:03sandy1986Trying to test it via repl... (def testinpt (fn [] (java.io.ByteArrayInputStream. (.getBytes "{name: Sandy}"))))
18:05sandy1986mhhh? #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$testinpt>
18:05sandy1986with (with-req-body [buf] testinpt (print "x"))
18:06TharemYou're obviously trying to call testinpt with 1 argument somewhere. Have you tried macroexpanding that call yet?
18:07sandy1986ahh Tharem, thx
18:07sandy1986(def testinpt (fn [param] (java.io.ByteArrayInputStream. (.getBytes "{name: Sandy}")))) fixed it
18:08TharemArity is just a fancy word for number if input paramters
18:08Tharemso an arity exception means there's a mismatch between what the function is getting and what it's expecting
18:08Vinzentsandy1986, why not (defn testinpt [param] ...)?
18:10sandy1986yeah Vinzent thank you very much
18:11sandy1986how can I macroexpand it to view what's getting generated?
18:12TharemIf you're using a macro (and I think with-req-body is one), you can use (macroexpand-1 '(macroname foo bar))
18:12VinzentIn emacs C-c RET, or use macroexpand-1
18:14TharemIs someone here familiar with the intricacies of painting on a JPanel?
18:15TharemIf so, can you tell me why the following code doesn't do what I'm expecting: http://pastebin.com/q3Bg2yuY
18:16sandy1986oh thank you guys very much
18:16sandy1986(clojure.core/with-open [r__798__auto__ (testinpt :body)] (clojure.core/let [buf (java.io.BufferedReader. (java.io.InputStreamReader. r__798__auto__))] (print "x"))) << yeah
18:17sandy1986Are the resources auto-garbage collected?
18:18sandy1986What is happening after the macro was run?
18:18TharemWhen the macro is run, it generates the code shown, which is then fed to the JIT-compiler, which compiles and excecutes it
18:18TharemAny garbage created is collected
18:19sandy1986Ahh, so the code does not stay in the memory?
18:19amalloyTharem: can you paste somewhere else, like gist? my computer can't resolve pastebin.com now - maybe dns issues related to sopa? :P
18:19sandy1986(code = code generated from macro)
18:20semperostried out the code in this article: http://steve.vinoski.net/pdf/IC-ClojureScript.pdf
18:20semperosworks fine when compiling the ClojureScript with {:optimizations :advanced}
18:20semperosah, nm
18:20semperosjust saw my syntax error
18:22TharemAmalloy, Sure, here is it: https://gist.github.com/1515646
18:22amalloy(.darwString "bla" 10 10)?
18:22TharemFor some reason it does manage to create a swing window with a black background, but it's not printing bla on it
18:22TharemYeah that's test code
18:23amalloydarw
18:23TharemI'm trying to get it to print some strings somewhere, but it doesn't even do that
18:23TharemXD
18:23TharemOk thanks
18:23TharemThat makes me wonder how that got past the compiler though....
18:24SergeyDHi, is it ok to share my Clojure project link here?
18:24amalloywell the compiler doesn't have the type information, i think
18:25mcrittendenwhat does & mean in the params for a function declaration? for example: (defn head [url & [req]] ...)
18:25ibdknoxmcrittenden: & essentially means the rest of the params put into a seq
18:26Tharemmcrittenden, it means that the function can be called with any number of arguments and all remaining arguments will be collected into the final parameter
18:26ibdknoxmcrittenden: in this case it's being used to make the param req optional
18:26mcrittendenahh interesting, thanks
18:27lnostdal_now jack-in doesn't even work
18:27lnostdal_*Messages* is showing "error in process filter: Symbol's function definition is void: slime-output-buffer [2 times]" no repl shows though
18:28mcrittendenibdknox: you still get any requests via i will build your prototype?
18:28ibdknoxmcrittenden: fairly often, actually
18:28mcrittendenare the clients typically pretty decent?
18:28ibdknoxit depends
18:28mcrittendenmostly startup founders w/o a tech cofounder I'd imagine?
18:29ibdknoxactually it's been all over the board
18:30ibdknoxI've gotten some requests from larger organizations and some from would-be entrepeneurs
18:30mcrittendendoes anyone ever show concern about the fact that you'd be using clojure?
18:30ibdknoxI think my offer weeds them out lol :)
18:31mcrittendeninteresting stuff. sounds like a great way to work on a bunch of different projects and get to use the tools you want
18:32mcrittendeni'm a drupal dev by day, mostly just because there's so much work, not at all because I enjoy drupal. so color me jealous
18:33ibdknoxdrupal pains me
18:33mcrittendendrupal is extremely productive once you've spent a few months with it, but it never really gets fun. it's always a bit of a grind
18:33mcrittendenat least for me
18:34mcrittendenanyways thanks for the info, just curious
18:35sandy1986what does defn- do '?
19:04lnostdal_sandy1986, it makes the function only available within the current namespace
19:05sandy1986lnostdal_: ahhh thx
19:08sandy1986what is defn-memo ?
19:16lnostdal_sandy1986, if you move the cursor over to defn-memo and press Alt-. it might lead to the definition of that, which might include some docs
19:16lnostdal_Alt-, will take you back
19:17sandy1986Does not work... which cursor? I'm using putty and vim
19:17lnostdal_ok, i assumed emacs
19:18sandy1986I googled for it... it is in clojure.contrib v1.2 which is not compatible up to clojure 1.3, right?
19:19sandy1986https://github.com/adamwynne/kestrel-client/blob/master/src/kestrel/client.clj << is the use of defn-memo default-client okay? Maybe this is not good cause the function has side-effects (connection-closed, ...) ?
19:33sandy1986lnostdal_: ?
19:53dnolen(+ 4 5)
19:53clojurebot*suffusion of yellow*
19:54dnolenoops
20:03dnolengrr, has anyone seen the issue where the SLIME REPL just doesn't seem to take any input
20:04dnolenthough interactive SLIME commands from w/in .clj files works fine
21:04mdeboardI'm seeking a quote by rhickey that said something along hte lines of, "Performance is meaningless if you don't have reliable data", anyone have a link?
21:48xcvHey guys, any news on when the screencasts from the last conj will be up on blip.tv? Really looking forward to watching them.
21:54aphyrStyle question: how should I handle kwargs?
21:56dnolenaphyr: destructuring supports kwargs
21:56dnolen
21:56aphyr(func :opt value :opt2 value), written with destructuring bind looks cleaner, but I've read that it can be slower.
21:57aphyrThe other thing is that sometimes I want to write a function that takes keyword args, provides a default for *one* of them, and passes the merged options down to some lower-level function
21:57dnolenaphyr: you can provide defaults
21:57aphyrWith (func {...}), that's easy to write as (lower-func (merge defaults opts))
21:58dnolen(defn foo [& {:keys [foo bar] :or {bar 1}}] ...)
21:59aphyrFor destructuring, I'm aware of (defn func [ & { :keys [a b c] :or [{...}]}]). Do I have to list the keys explicitly every time?
21:59aphyrIt'd be great if I could say "Take your args, provide a default for :somekey, and call the next fun"
22:00aphyr(without necessarily knowing what all the keys are)
22:01amalloyjust don't do it in the destructuring context
22:01amalloyas an aside, i think having a hierarchy with dozens of functions using kwargs is pretty gross. if you want kwargs as your top-level api, fine, but once you get into the internals accept an actual map so you don't have to do all this wrangling with & args
22:02aphyraha! That's the opinion I was starting to form.
22:02aphyrJust passing maps down seems like less code
22:02amalloyonce you're just working with maps, it's easy
22:02dnolenwhat amalloy said
22:03aphyrSo... for user-facing code, kwargs for a concise API. For internal code, use maps for brevity (and speed?)
22:03amalloy(defn foo [opts] (bar (into {:a default-a} opts)))
22:03amalloyaphyr: personally i don't usually bother with kwargs for the user-facing code either, but there's nothing wrong with it
22:03amalloyit seems to me that if i write an API that has many kwargs i've usually designed it badly
22:04aphyrMostly I need it for network configuration, etc.
22:04aphyr:host, :port, :proto, blah blah blah
22:05amalloyeh. so ask them to pass a config/options map
22:05aphyrSounds good. Thanks a bunch guys. I haven't seen anything expressing this clearly in my googling, so I'll write a short post about it.
23:55tauntaunI can't seem to use the sql API without provoking exceptions. What are the latest versions of clojure & clojure-contrib that I should specify in leiningen's dependencies (project.clj)?
23:57dnolentauntaun: don't use the sql lib from monolothic contrib. there's a new one well maintained one.
23:58dnolentauntaun: I recommend 1.3.0 + https://github.com/clojure/java.jdbc
23:58ibdknoxtauntaun: and for a higher level API, Korma: http://www.sqlkorma.com
23:59tauntaunthanks