#clojure logs

2011-09-15

00:08sridamalloy_: why doesn't 4clojure accept `def`?
01:19nickmbaileywhy would '(type (int 1))' return java.lang.Long?
01:29nickmbaileyseems like a bug
01:32quotemstrWhy doesn't ClojureScript have refs?
01:35brehautquotemstr: because there is no shared state concurrency in javascript
01:37brehautnickmbailey: in clj 1.2, type either returns the :type meta data for its argument, or the class. if in returns a primative its not going to have meta, so it will be boxed into an object (in this case a long apparently) for class
01:38nickmbaileybrehaut: its actually a 1.3 thing
01:38nickmbaileyit returns java.lang.Integer on 1.2
01:38brehautnickmbailey: then i have no idea
01:38nickmbaileybut java.lang.Long on 1.3rc0
01:39nickmbaileyi assume its due to the fact that function arguments are auto boxed into actual objects so you can't really pass primitives
01:39nickmbaileybut it seems like an int primitive should be boxed into Integer
01:39brehautin 1.2 that would be the case
01:40nickmbaileyi think its the case in 1.3 if you don't add primitive type hints
01:41nickmbaileyoh you can only type hint longs and doubles
01:42nickmbaileyi wonder if int even returns an integer primitive in 1.3
02:20nickmbaileyyeah looks like in 1.3 all primitives are boxed to either long or float, i guess that makes sense
03:59tsdhHi
04:01tsdhI've just read something (book, blog, whatever) that demonstrated clojure's java interop by creating some AWT frame that translated a given function's value to RGB and printed it in some canvas. But I can't remember where I've read that. Do you?
05:09fliebelNext month I'm going to live code a web app in 15 minutes. I'm thinking about a simple wiki with Ring, Moustache and Hiccup, or something like that. Any input?
05:10fliebelIt's for the Amsterdam Clojurians meetup, Uncle Bob is also going to present that month.
05:12TheBusbytsdh: Joy of Clojure?
05:14scottjfliebel: simple multiplayer version of http://strategerygame.com/ including cljs :)
05:14tsdhtsdh: Already looked there, but couldn't find it...
05:15TheBusbyPage 87
05:15tsdhTheBusby: Ah, found it.
05:15tsdh:-)
05:16tsdhI've only checked the Java.next chapter...
05:17bsteuberscottj: looks really nice - how much cljs does it involve?
05:17scottjfliebel: http://canvas.opalang.org/ would also be cool, especially if the audience could use functionality as you add it
05:17fliebelWhoa, write a game in 15 minutes?
05:17scottjfliebel: tic tac toe?
05:17TheBusbyfliebel: minesweeper?
05:18bsteuberoh I misunderstood it, nevermind :)
05:18Fossii dislike such talks for being "lazy", because you can't really show off the hard parts
05:18Fossii'd maybe concentrate on corners that aren't so easy to get right
05:19Fossior mistakes that are prone to happen if somebody would try without knowing the frameworks/domain much
05:21robermannfliebel: a music live coding? http://mad.emotionull.com/
05:22fliebelHm, fair point. What are hard parts in your opinion?
05:22Fossidon't know moustache or hiccup very well
05:22Fossiserving static resources with the right mime types and headers
05:22fliebelrobermann: We had Jeff Rose show off Overtone a while back.
05:22Fossigetting authorization to work
05:23Fossilittle things like that
05:23robermann(fliebel: ok )
05:23thorwilfliebel: not sure for a wiki, but for a blog, nested comments and role-depending variations in the views can make things complicated
05:23fliebelAuth might be nice.
05:23Fossihow to work in session data and keeping your site functional
05:23Fossihow to connect some backend
05:23Fossi(ie, get data first, then render)
05:23Fossiswitching renderers from html to json maybe
05:25clgvfliebel: +1 for authorization
05:25thorwilhandling cases where the same html fragments need to be generated server-side first, then on client-side for updates
05:28fliebelI think the game is nice, But not sure it fits in 15 minutes. Because things like Ruby on Rail can generate a lot of the CRUD for you. Doing non-standard stuff is more powerful I think.
05:32fliebelThanks for the input everyone :)
05:33Fossiwe've been hacking a meetup replacement in the clojure hamburg group for a while :)
05:33Fossiso we've had quite a few of those talks :)
06:19tsdhIf a java class has both a field foo as well as a method foo without args, what will (.foo obj) access? And how can I access the other?
06:20clgvtsdh: is that possible?
06:20tsdhclgv: Yes
06:21tsdhclgv: For java, it's easy to distinguish obj.foo from obj.foo().
06:22clgvtsdh: it calls the method in my example.
06:22opqdonuttsdh: that will call the method
06:22clgvtsdh: maybe you can use the more verbose java interop where it might be distinguished
06:23tsdhclgv: (. foo obj) has the same semantics, doesn't it?
06:24opqdonutyes
06:24clgvtsdh: well it cant access the property it seems ;
06:24tsdhclgv: If you already have an example, could you check if (set! (.foo obj) 42) works?
06:24opqdonutISTR that obj/foo works for the field, but is undocumented
06:25opqdonutno
06:26clgvtsdh: it pretends to do something by returning the number
06:26tsdhclgv: Thanks
06:26clgvbut I cant read the value back as it is now ;)
06:27clgvtsdh: yes it works
06:27tsdhGreat
06:28mcstarhi
06:28mcstarim in trouble with swank-clojure
06:28tsdhWell, the foo/foo() is a basically a non-issue. usually it's foo/getFoo()...
06:28mcstarwhat is the preffered way nowadays to get slime working with clojure?
06:29clgvmcstar: technomancys guide?
06:31mcstarlein plugin install swank-clojure 1.3.2
06:31mcstarthats what he says
06:31mcstarhowever it seems when i lein swank and then slime-connect that the swank clojure is from 20100404
06:31mcstaror some like that
06:32clgvdidnt he have a detailed guide up? I thought I remember him posting a link sometime...
06:32mcstarthe slime prompt accepts numbers, but not expressions like (+ 3 4)
06:32tsdhmcstar: I use only clojure-mode and did the lein plugin recipe. From inside emacs, I simply do M-x clojure-jack-in. Works fine...
06:32mcstarclgv: ive only found the github readme of his
06:32mcstartsdh: do you start lein before?
06:33mcstarsorry guys im new to java/maven/ant/leiningen
06:34joshnzmcstar: I went thru your pain a few weeks back. I added my notes on to the wiki: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
06:34mcstaraham, clojure-jack-in starts the swank itself
06:35mcstarthx
06:35tsdhmcstar: No
06:35tsdhmcstar: I just open some clojure file in a project that contains a project.clj.
06:36joshnzI particular, the bottom paragraph where I attempt to explain how the process works. Clojure-jack-in will actually grab the slime.el file from swank-clojure 1.3.2 so it's a recent, working version of slime, independent of any other slime version you may have installed. I think.... lol
06:36joshnzI do what tsdh does. Open a file within a lein project and run clojure-jack-in
06:37mcstari did just that
06:37mcstarthan jacked in
06:38mcstarthan swank started
06:38mcstarthan it notified me of the version mismatch
06:38joshnzmcstar: I should add, I'm running clojure-mode 1.10.0 and swank-clojure 1.3.2. If you have different versions thing might not work. You also need to ensure you don't have older versions of swank-clojure around as that can cause issues
06:38mcstarthan i can enter single expressions, but not anything other than a symbol
06:38tsdhI use clojure 1.3, clojure-mode 1.10.0 and lein-swank 1.4.0-SNAPSHOT.
06:39mcstaranyway, where does lein store its stuff?
06:39tsdhmcstar: Somewhere in ~/.lein/
06:39joshnz~/..lein
06:39clojurebotTitim gan éirí ort.
06:39joshnzthe swank files are in the plugins dir
06:40mcstarive got 1.3.2
06:40joshnzme too. I have no idea about clojure 1.3 with swank 1.4 snapshot sorry.
06:41tsdhmcstar: I think I had troubles once when in ~/.lein/self-installs/ there were multiple leiningen jars of different versions.
06:41mcstaremacs-clojure-mode-git 20110914-1
06:41mcstarleiningen-1.6.1.1-standalone.jar only
06:42joshnzmcstar: do you reference swank-clojure at all in the project.clj file? Do you have any swank jars anywhere within your project tree at all? You should remove all of these if you do, I don't believe they're needed and can cause issues
06:42tsdhAh, good point.
06:42scottjcemerick: what's the name of the "open source generalized Bayesian network modeling library" in your abstract?
06:42mcstar:dependencies [[org.clojure/clojure "1.2.1"]]
06:43cemerickscottj: I'm in the process of extracting it from a larger project :-)
06:44scottjcemerick: ok do you have an expected release timeframe?
06:44cemerickI'm hoping to get a first rev of it on github next month
06:46scottjcool I'm looking forward to it
07:01clgvBayesian networks seem pretty popular nowadays
07:11opqdonutirc networks on the other hand are declining in popularity
07:14clgvlol
07:25mcstarwhoa
07:25mcstarit seems to work
07:25mcstarwith the old swank though
07:25mcstari cleaned up my .emacs, and commented all the slime related things that i use with sbcl
07:26mcstarcommented out*
07:27mcstarbut i seem to lost my slime buffer?
07:29mcstarhm, maybe i just accidentaly closed it
07:30mcstarbefore i start hacking my way through clojure, i want to ask this
07:30mcstaris any of you familiar with AI Agent Systems?
07:31mcstardo you think that the clojure concurrenty agent model is a god candidate to implement such a system/model:
07:31mcstar?
07:31mcstar(pls get over my typos :))
07:34companion_cubeagents can be in separate processes
07:34companion_cube(or computers, for that matter)
07:35mcstar(i forgot to tell that i added 1.3.0-master-SNAPSHOT to the project dependencies)
07:36mcstarcompanion_cube: i dont care about that right now, it could be single-threaded (in the end it WILL be)
07:36companion_cubewait, you were talking about clojure's concurrency model
07:36companion_cubebut it's a general-purpose concurrency model anyway, so i guess the answer is "yes"
07:38mcstarcompanion_cube: i guess i was hoping for some comparison, idk,for example erlang has a similar actor-based message passing concurrency model, so an agent system could be implemented in it "naturally" too
07:39companion_cubemessage passing can be done with queues
07:39mcstarcompanion_cube: i guess, clojure doesnt NEED multiple threads to do its agent-thing, right? it can serialize it
07:39companion_cubeeven if the actor model probably fits more naturally to AI's agents
07:39companion_cubeoh, "agent" in clojure has a special meaning
07:40mcstarisnt it something that can initiate a transaction?
07:40companion_cubesee http://clojure.org/agents
07:41companion_cubeyou give actions to the agent and it applies them to its state, sequentially
07:41fliebelI thought Moustache was super easy and intuitive? It just sits there staring at me, pretending it doesn't know what I mean.
07:42manutterIt's thursday, moustache always takes extra breaks on thursday
07:42mcstarim halfway through rich hickey's presentation to the Western Mass or similar, thats how far my clojure understanding goes
07:43mcstarcompanion_cube: how do you pronounce rich?
07:43mcstarrik or rich?
07:43companion_cubeno idea
07:43mcstari guess the second one
07:43companion_cubei'm not an english native speaker
07:43fliebelmanutter: I have a helper that looks like this: [title] {:get title} requesting /foo gives me java.lang.String cannot be cast to clojure.lang.IFn.
07:44mcstarcompanion_cube: i didnt think so, i thought you were a nice cube with a heart on it
07:45mcstari was surprised you could write
07:45manutterfliebel: gist?
07:45companion_cubeyou're not supposed to read what i type 0:-)
07:45mcstarwhats the tendency? do people usually come from the lisp world to clojure or not?
07:46fliebelmanutter: That's all there is to it. If I make it a literal string, it works, so It's macro trickery.
07:46fliebelThe thing is, if I pass it a handler, I don't get to acces title at all.
07:48thorwilmcstar: seems to be a wild mix of prior experience often including java, common lisp. sometimes python, ruby.
07:50clgvmcstar: I cam from java, c#, c, c++, pascal/delphi ;)
07:50thorwilfliebel: without more context, that looks like a complete misunderstanding of how moustache works
07:50manutterfliebel: I'm not really a moustache user, but from looking at the docs, I'd expect your app to look more like (def my-app (app ["foo" title] {:get title} title))
07:51mcstari guess why im asking, is because i wasnt half as interested in clojure if it didnt have lisp fundamentals
07:51manutterno, I'm wrong
07:51mcstarwasnt->wouldnt be
07:52manutterfliebel: how about (app ["foo" title] {:get title})? That's still slightly different from what you posted, but if I'm reading the docs right it should work
07:52thorwilfliebel: how about [title] {:get (-> title constantly response)}?
07:52fliebelLet me see
07:53manutterno, I'm still wrong, I think. I'll just shut up and try drinking some coffee until I wake up.
07:54thorwilfliebel: that was implying [ring.util.response :only [response redirect]]
07:54fliebelthorwil: What is the constantly for?
07:55thorwilfliebel: makes it callable, as a fn is expected, as far as i understand it
07:56fliebelthorwil: That seemed to work... but it's silly. Oh, I think I know.
07:57manuttercgrand's example is (def my-app (app ["hi" name] (:get ["hello " name]}))
07:58manutterthat should imply that fliebel's original code ought to work
07:58manutterit's the same without the "hi", and with title instead of name
07:58fliebelmanutter: He's using s seq everywhere for some reason.
07:59manutterthe example before that is (def my-app (app ["hi"] {:get "hello world only for GET!"})), which seems to return only a string
07:59manutterMeh, I'm sticking with noir :)
08:01fliebel["foo" title] {:get [title]} breaks, ["foo" title] {:get ["" title]} works
08:02thorwilfliebel: i'm all ears if you figured out why/when the response and constantly is necessary / how to do away with it
08:03fliebelthorwil: I'm about to just switch to Noir or DIY. I'm just looking for a sweet router without magic.
08:03gtrak`mcstar, i think a bunch of people came from java
08:04thorwilfliebel: moustache is very small, not much room for magic. but the allowed variations can be confusing
08:04gtrak`mcstar, like me, I always wanted to learn a lisp... and concurrency, so clojure was a good next step
08:04thorwilfliebel: with noir, routing becomes a bit less explicit, even
08:05manutterfleibel: Ok, I studied the syntax diagram a bit more, I understand why {:get title} doesn't work
08:05fliebelmanutter: Yay! Whats it?
08:05manutterfliebel: after the {:get part, it's expecting a handler body, a method dispatch, a string, a symbol, or (some clojure code)
08:06manuttertitle by itself is a symbol, but there's a not that says, if it's a symbol, it must evaluate to a handler body
08:06manutterwhich it doesn't, because it's been mapped to just a param
08:07manutterif you say ["" title] then that invokes moustache's built-in handler that contatenates vectors as strings
08:07manuttereh, *but there's a NOTE that says...
08:08fliebelSo, what about ["foo" title] {:get (response title)}, That is some clojure code.
08:08fliebelJust gives 404! No error, same request as before.
08:09bhenryfliebel: what does response do?
08:09manutterdoes (response x) return a handler function, or just response data?
08:09manutterI'm guessing that it returns a map, not an actual handler
08:09fliebela response map, like {:status 200 :body "hwhatever"}
08:09manutterAh, forgot to mention, another note says (some clojure code) has to return a handler
08:10bhenryfliebel: have you looked at delegate?
08:10fliebelah, so its literal string or map, a handler or something that evaluates to a handler.
08:10manutterLooks that way to me
08:10fliebelbhenry: delegate?
08:11mcstargtrak`: lisp is quite a lot in itself, i would imagine clojure is not that easy without prior lisp experience, but sure its ok if you give it enough time, or you are very determined
08:12gtrak`I had a scheme class 8 years ago :-), too bad they dropped it for python
08:13mcstargtrak`: you know computers were getting faster, so they needed python to slow the execution, so that everyone can follow in the class :D
08:15gtrak`haha, I think GT just does whatever MIT wants to do, still annoyed about it. What's an intro to computing without SICP or HTDP?
08:16bhenryfliebel: ["clients" "edit" id] (delegate views/edit-client id)
08:16mcstari wouldnt know i dont have a CS background(but i watched quite a bit of sicp)
08:16bhenrygives id to the edit-client handler
08:16bhenryfliebel: you had said if you pass a handler you don't have access to the title anymore
08:17clgvmcstar: didnt have huge problem despite I didnt know any lisp before
08:18mcstargood, than i might stand a chance to understand clojure
08:18manutterHeh, I'm coming from PHP
08:18manutterThis is my first *successful* attempt at learning a LISP or LISP-like language
08:19mcstari dont understand youre use of a special variable in a lexical context
08:19mcstar:D
08:21gtrak`manutter, are you still a fan of php?
08:22manutterwas I ever?
08:22gtrak`haha, good answer
08:22manutterphp's ok, pays the bills and stuff
08:22manutterI'd love to port our app to clojure tho
08:47kzarIs using java.io.File the best way to list files? Also what's the base path assumed for relative paths? Is it the root of my project?
08:48bhenrykzar, i think it's where you launch from
08:50kzarOh, just managed to get it listing files and I think it's the root of the project - at least when I eval it interatively
08:55clgvkzar: with leiningen and lein repl it's where your project.clj is
08:55khaliGi'm looking for web hosting, is there any particular feature to keep an eye out for if I intend to run some sort of java/clojure webapps in future?
08:56clgvkhaliG: vserver?
08:57khaliGclgv, okay
08:57clgvor are there specialized tomcat hosting offers?
08:58khaliGclgv, i should say i'm completely new to all of this :P
08:59clgvyeah well, you'll need some "java server" like tomcat or jetty where your clojure app is hosted.
08:59khaliGclgv, noted
09:24ladichaI'm having trouble using a third party closure library in my cljs project. I jar'd up the lib and put it in $CLOJURESCRIPT_HOME/lib, but I still get a compile error: required namespace never provided
09:24ladichaany tips on where I'm going wrong?
09:26clgvladicha: checking if the namespace exists?
09:27tsdhIf I want to release a jar at clojars, is it mandatory to use a groupId of org.clojars.tsdh?
09:27joegallonope, pretty sure you can use whatever group id you want
09:28tsdhOk, then I guess de.uni_koblenz is more appropriate for *our*, not mine lib.
09:29ladichaclgv: the js files in the jar do provide the namespace
09:29tsdhAnd what's the difference between artifactId and name?
09:30clgvtsdh: you are claiming that group-id with it, so maybe you could add your department as well in case someone else in your uni might develop clojure as well in the future ;)
09:31ladichaI get this specifically: ERROR - required "scottlogic.chart.Chart" namespace never provided
09:31tsdhclgv: Ok.
09:31joegallofor that matter, you should probably put the current department head's name in there, too. in case a new one comes in later and the policy changes.
09:31ladichain my project I have a [scottlogic.chart.Chart :as SLChart]
09:31joegallocouldn't hurt to add the year, too.
09:32joegalloin stardate form.
09:32ladichain my namespace require
09:33ladichathe scottlogic/chart/chart.js file in the jar contains: goog.provide('scottlogic.chart.Chart');
09:34clgvjoegallo: lol then he could simply add his own name^^
09:35tsdhclgv: What do I specify for a non-released version? 5.0.0-SNAPSHOT?
09:35tsdhjoegallo: Ups, I've meant clgv. :-)
09:36ladichaclgv: are there any special directives I need to compile against a third-party lib? Am I putting the jar in the right place?
09:43clgvladicha: I don't know. I just did a smal example with it yet
09:50fliebelDoes Ring pass the query string as a plain string??
09:50lazybotfliebel: Definitely not.
09:50fliebelOh, okay lazybot.
09:51ladichaclgv: I just cloned the bitbucket, jar'd up the closure-charts/closure-charts/src/main/webapp/js/scottlogic directory as scottlogic
09:51ladichascottlogic.jar
09:52ladichaand put the jar in $CLOJURESCRIPT_HOME/lib
09:53bhenryfliebel: it puts the items in :params in the request map. {:params {"key" "val" "key2" "val2"}}
09:53bhenryactually, that's wrap-params middleware that does that.
09:53fliebelbhenry: AH, I just found a middleware that claims to do that, but it already does that by default?
09:53fliebelah
09:54bhenryfliebel: yeah sorry. i use that middle ware.
09:54fliebelok, I'll add it as well
09:55Fossifliebel: see, funky things like that ;)
09:56Fossimiddlewares are a good topic on it's own
09:56fliebelhmhm
09:57khaliGis there a particular license preferred by the community?
09:59clgvthe license clojure has itself?
10:00m0wfohttps://github.com/clojure/clojure/blob/master/epl-v10.html
10:01khaliGclgv, Eclipse one? i'm considering that one vs MIT
10:04fliebelHow do I destructure nested maps? Like... {:params {body "body"}}
10:05fliebelAH, the other way around of course...
10:05fliebelI always get map destructuring the wrong way around.
10:09clgvfliebel: how does the resulting destructuring look like for your example?
10:09fliebel{{body "body" rev "rev"} :params}
10:10raek{{:strs [body rev]} :params} works too
10:10bhenryraek: whoa. is :strs like using :keys?
10:11bhenrybut for string keys?
10:12raekexactly so.
10:12bhenryneato
10:12TimMcnice
10:12raekthere is syms too for symbol keys
10:12TimMcBut no nums, I hope.
10:13TimMc...considering how badly they behave as keys.
10:14TimMcHa! I'm an idiot, that wouldn't make sense anyway.
10:14raek:nums doesn't make much sense since there is no symbol "with the same name" as a number
10:14TimMc(let [1 2] ...)
10:31manutter,(let [+ -] (+ 2 2))
10:31clojurebot0
10:31manuttermuahaha
10:32companion_cube,(let [let +] (let 2 2))
10:32clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding>
10:32companion_cubeoops
10:32opqdonutlet is a built-in
10:33mcstar,(let [s] (dance))
10:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires an even number of forms in binding vector>
10:34llasramOh, geez. Just now realized that slime lets you drill down to the source of the actual error when you throw an exception during lazy list evaluation
10:52kzarI'm trying to use the noir.options module to check which mode the server's running in. Problem is when I use noir.options/get or noir.options/dev-mode? I always get "Var noir.options/*options* is unbound.". The server's running and I've required noir.options as options, not sure what else to try.
10:53bhenrykzar: i forgot how i got around that. let me check in a minute.
10:55manutterkzar: *options* is set by a wrap-options middleware, maybe you need to put that in?
10:56manutterhmm, looks like it's setting that by default tho
10:59manutterkzar: try (server/start 8080 {})
11:01kzarmanutter: That address was already in use so I did (noir.server/start 8081 {}), then (noir.options/dev-mode?) and got te same error
11:01duncanmhaha, "Haskell is lazier than Ruby, but Rubyists are lazier than Haskeller."
11:01manutterhrm
11:03manutterkzar: you got the "Server started on port [8081]" message?
11:04manuttermy next try would be (server/stop) (server/start 8081 {:mode :dev})
11:07bhenrykzar are you trying to evaluate (dev-mode?) in the repl?
11:07manutterah, good question
11:07manutterserver's going to be off running in a different thread with different bindings, yeah?
11:08bhenryyep
11:08kzarmanutter: I was trying to eval it interactively in the source file and I tried typing it at the repl
11:09manutteryeah, I think bhenry has hit it then, you're having thread problems
11:11manutterI believe I've worked around that sort of issue by (1) def an atom in the main thread (2) have the other thread push a debugging message into the atom and (3) deref the atom from the main thread.
11:11manutterclumsy but quick-n-dirty
11:13kzarHmm so I'm starting the server normally by doing (my-project-name/-main) and I need to access the options from repl + my other code.
11:13kzarWould that mean messing with server.clj or actually changing noir do you think?
11:15manutterMe being an irresponsible SOB I might try having my server-side code push the *options* var into some atom I def'ed from the REPL
11:15mdeboardyou son of a bitch
11:15mdeboardhow *dare* you
11:15manutterdunno if that would let you view/modify the *options* directly, but I'd try it
11:15manutter:)
11:15manutterYeah, I've picked up a lot of bad habits writing PHP
11:16mdeboard:O
11:17kzarIs noir quite new?
11:17sridI think, yes.
11:17manutteryeah, relatively
11:18sridwhat other web 'frameworks' are there?
11:18mdeboardCompojure
11:18mdeboardis one
11:18manutter<plug>http://www.clojure-toolbox.com/&lt;/plug&gt;
11:19mdeboarder
11:19mdeboardwow, django attack
11:19mdeboardhtml tag
11:24KirinDavemdeboard: Wanna change that to clojure at both? :)
11:24KirinDavemdeboard: Just start suggesting features that python is way to slow to provide. :D
11:25mdeboardKirinDave: We already have a few processes that could benefit from transitioning to a JVM FPL
11:26mdeboardmassive XML processing for example
11:26KirinDavemdeboard: I'm working at a giant monolithic merb shop.
11:26mdeboarddaily
11:26mdeboardmerb?
11:26mdeboardsomething-ruby?
11:26KirinDavemdeboard: All I had to do was show that ONE box running a jvm version of the software is the equivalent of THREE boxes running ruby versions of the process. :D
11:26KirinDaveYeah
11:26mdeboardwhat's the `me` part?
11:28mdeboardYeah I have entertained the thought of setting up a test bed to handle our XML processing with Clojure, esp. since I just took a huge employment offer with these guys. But I'm bogged down in some customer-facing feature implementations atm
11:28mdeboardfliebel: Yeah, agreed, was thinking the same
11:30mattmitchellIs it possible to inspect a namespace so I can see what vars/functions it contains?
11:30KirinDaveI kinda miss working in clojure.
11:30KirinDaveFor some reason scala is an easier sell to my shop. :(
11:30KirinDaveHaven't done much in clj recently.
11:32mdeboardKirinDave: "Scala has fewer parens"
11:32clojurebotthe scala compiler | is | <reply> see: http://harrah.github.com/browse/samples/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala.html#65760
11:32mdeboardalso Scala's older and certainly more widely used
11:32mdeboardprob why
11:33KirinDavemdeboard: Probably
11:33mdeboardya
11:33mdeboardI need to conspire more on getting clojure into play :P
11:33mdeboardyou're right on that
11:33KirinDavemdeboard: Although I do confess that my time with haskell has made me like static typing more. As I work with scala more I think I feel like I fight its type system way too much.
11:33KirinDaveMakes me pine for clojure.
11:34mdeboardhaskell hurt my brain, I gave up
11:34bhenrymattmitchell: ##(doc ns-publics)
11:34lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
11:34mdeboardthat was a while ago though, first FPL I'd ever touched
11:34mattmitchellbhenry: cool thank you
11:38gtrakKirinDave, you like static typing, but scala's is so bad that you prefer dynamic typing?
11:40kzarSo I'm still a bit bamboozled as to how I can look at the noir server's options. Been poking around noir's code but I don't even really understand the explanation to do with threads that you guys described to be honest
11:40kzarIt seems to me that there must be a reasnoble way to check the options, otherwise what's the point of setting them?
11:41KirinDavegtrak: Scala isn't bad. Scala's schizo three-way culture clash is bad.
11:41KirinDavegtrak: You have the scalaz guys, the typesafe/akka guys, and the java purists.
11:41KirinDaveYou literally cannot write code that 2/3 of the scala community will not roll their eyes at. It's a very demoralizing code culture.
11:45kzarAnd the "Var noir.options/*options* is unbound." message confuses me, I don't see the distinction between that error and an "Unable to resolve symbol" one
11:46clgvkzar: the var is defined but has no value
11:47bhenrykzar: https://github.com/ibdknox/noir/blob/master/src/noir/options.clj#L5
11:48kzarbhenry: aha, gotya
11:48kzar(declare frebob) fredbob -> "Var fredbob is unbound."
11:58manutterkzar: what options do you need to look at? The options are just whatever you pass as the 3rd arg to server/start (as I understand it), so you control what they are.
11:59manuttersorry, 2nd arg, not 3rd
11:59manutter(server/start <port> <map-of-options>)
12:13kzarmanutter: I need to see the mode variable so I know if it's production or not. I'm launching the app with foreman because I'm putting it up on heroku for now, not sure how it works
12:14kzarmanutter: oh could I def a ref at the top of the server.clj and then have the -main function update that to contain the options so I can check them later?
12:15manutterkzar: I'd def an atom (ref would be overkill) but yeah, I think that would work
12:15kzarmanutter: Gotya, OK I'll do it that way
12:15kzarBrill thanks, was stuck there
12:16manutter:)
12:47belunhi
12:47beluncould anyone help with this error
12:47belunuser=> (use 'midje.sweet)
12:47belunCompilerException java.lang.RuntimeException: Unable to resolve symbol: print-doc in this context, compiling:(clojure/contrib/ns_utils.clj:67)
12:47manutterbelun: missing use/require?
12:48belunthis is the actual settings
12:48belun(defproject play-with-midje "1.0"
12:48belun :description "Playground for messing around with Midje"
12:48belun :dependencies [[org.clojure/clojure "1.3.0-beta3"]
12:48belun [org.clojure/clojure-contrib "1.1.0"]]
12:48belun :dev-dependencies [[midje "1.3-alpha1"]
12:48belun [lein-midje "1.0.0"]])
12:48manutter,(doc print-doc)
12:48clojurebotexcusez-moi
12:48manuttereh
12:48belunwhat do you mean? like i dont have the jars u mean ?
12:48technomancybelun: get rid of that ancient contrib version
12:49manutterno, you might be missing a (:require [something :as something]) in your (ns) declaration
12:49technomancybelun: also: use gisthub.com next time
12:49belunwhat is latest contrib
12:49belunuse it for what u mean ?
12:49beluncontrib ?
12:50technomancyuse gist instead of pasting into the channel
12:51bhenryhow can i turn an epoch time to a date with minimal imports?
12:51bhenryerr scratch that. date to epoch
12:51technomancyclojurebot: where did contrib go is <reply>well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
12:51clojurebot'Sea, mhuise.
12:51technomancybelun: ^
12:52technomancybelun: depends on which specific parts you need
12:52belunlike i know...
12:52belunlet me just drop it :P
12:54naeuis there a way of determining whether a number is a long
12:55naeulong? doesn't seem to be available
12:55belunso i got same error without contrib
12:56belungit://gist.github.com/1219793.git
12:56belunmight it be the beta version of midje ?
12:56manutterbhenry: clj-time ? https://github.com/getwoven/clj-time
12:57belunum...maybe i need the utils part of contrib
12:57kjeldahl`Anybody have any recent example of using clojure.java.jdbc; let's start simple - getting a connection. The usual "(def db {.... params}) ... (with-connection db (create-table :somename))" does not seem to actually connect to the database. Anybody?
12:57kjeldahl`.. with postgresql I should add.
12:57technomancybelun: do you need clojure 1.3? if you drop back to clojure 1.2.1 you can add back in contrib version 1.2.0
12:57technomancythat's going to be the path of least resistance
12:57bhenrymanutter: thanks. turns out i'm just a dummy (.getTime date)
12:58belunthat path i like
12:59technomancybelun: but try to avoid adding any additional usages of contrib so that it will be easier to upgrade in the future.
13:00belunwohoo
13:01belunworked to run a midje fact
13:01belunluv u
13:01seancorfieldkjeldahl`: that should work fine - postgresql is one of the base test cases for that library
13:01seancorfielddo you get any exceptions?
13:02kjeldahl`seancorfield: I get "no current database connection" when doing it.
13:02kjeldahl`seancorfield: None that I can see, but I'm not "try"'ing either, if I have to do that...
13:04seancorfieldare you following a particular article / blog post?
13:04hiredmankjeldahl`: make sure you force your lazy-seq before leaving the scope of the connection
13:04kjeldahl`I've looked at several. They all simply use the hash/map and "with-connection"...
13:04kjeldahl`hireman: Ah, good idea.
13:04seancorfieldah, good point... that often gives a no connection exception!
13:05seancorfieldhaving said that, for create-table it should "just work"
13:08choffsteinHey all. Is there a way to initialize a vector to be a certain size filled with a given initial value?
13:09choffsteinFor example, I have a non-deterministic input that I bind to the variable n. I then need to create a vector of length n with all 1s.
13:10manutter,(repeat 3 1)
13:10clojurebot(1 1 1)
13:11choffsteinsweeeet. thanks
13:11seancorfieldkjeldahl`: any success?
13:28dnolenerg, anybody encounter the problem where cljcs/build doesn't pull in the goog deps into the out dir ?
13:28gtrak,(vec (repeat 3 1))
13:28clojurebot[1 1 1]
13:29gtrak,(vec ( take 3 (cycle 1)))
13:29clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
13:29gtrak,(vec ( take (cycle 1) 3))
13:29clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Number>
13:30manutter,(vec (take 3 (cycle constantly 1)))
13:30clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$cycle>
13:30manutter:P
13:30amalloyomg guys, ##(take 3 (cycle [1]))
13:30bhenry,(vec (take 3 (cycle [1])))
13:30lazybot⇒ (1 1 1)
13:30clojurebot[1 1 1]
13:30gtraklol, how many ways are there to eff that up?
13:30amalloyor ##(take 3 (repeat 1))
13:30manutter,(vec (take 3 (cycle (repeatedly 1))))
13:30lazybot⇒ (1 1 1)
13:30clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
13:30manutterhrug
13:31amalloymanutter: ##(vec (take 3 (repeatedly (constantly 1)))) is a bit silly but looks like what you meant
13:31lazybot⇒ [1 1 1]
13:31manutterdoh
13:31manutter,(vec (take 3 (cycle (constantly 1)))
13:31clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
13:31manutter,(vec (take 3 (cycle (constantly 1))))
13:31clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__3684>
13:31gtraklike monkeys banging on pots
13:32manutterhonestly, kids these days
13:43kjeldahl`Sorry, got pulled away. Yes, I now get an exception, which I think I can handle. Thank you for the pointers!
13:47zerokarmaleftnew to swank here; is there a better way to reload changes to a source file to a slime repl than 1) C-x C-s 2) C-c C-l 3) C-c C-z?
13:47amalloyzerokarmaleft: C-c C-k does (1+2)
13:49Vinzentzerokarmaleft, I have save-and-compile bound to C-s
13:50technomancyC-c C-l forces a reload of all deps; C-c C-k just does the current file
13:50amalloytechnomancy: no shit, really? i need to start using C-c C-l sometimes, then
13:50zerokarmaleftthat's good to know
13:50amalloythat suddenly explains weird behavior
13:51technomancyamalloy: C-c C-, also invokes the reload behaviour
13:54zerokarmaleftguess i should dive into elisp and make a command for what i want
13:55zerokarmaleftbasically save, don't prompt me, reload all deps, switch back to repl, gtfo my way i'm testing my small change
14:08choffsteinOptimization question for everyone: I have a huge bottle neck in parsing a couple thousand strings to date objects using a SimpleDateFormat. There is no reason that all the parsing can't be done in parallel, but I it would seem that SimpleDateFormat is not thread safe -- and creating a new object for each parse seems like an allocation nightmare. Any ideas?
14:09amalloysplit into chunks, create a parser for each chunk, and then pmap?
14:09choffsteinthat was my next thought
14:10hiredmandepending on the format you could just write your own parser
14:13choffsteinseems like overkill hiredman
14:14Chousuke(map send some-agents (make-enough-parser-functions) (partition data (/ data-size number-of-agents))) wonder if that would work :P
14:14Chousukewith a do-all of course
14:28khaliGchoffstein, would it help to use clj-time (jodatime)?
14:28sridi'm not *very* familiar with github contrib workflow, so here's a question: must each pull request happen on a separate branch? i sent one the 4clojure repo under 'playground' branch. now if I want to work on another bug/feature, I must create a new branch?
14:28choffsteinI don't know about clj-time. I'll check it out. Thanks for the suggestion.
14:29amalloysrid: no, but you should make sure your new commits are based on the upstream develop
14:30joegallosrid: yes, you really should
14:30sridamalloy: I noticed that when I make commits to the 'playground' branch, they automatically gets added to the pull request.
14:30joegallocorrect
14:30joegallopull requests are about branches, not commits
14:30sridthis is why I refrain from making irrelevant commits (addressing a different bug) to this branch
14:30khaliGchoffstein, its a nice library, i rely on it a lot. it wraps jodatime, which is a well designed java library that's written in a functional style (as well as these things can be)
14:30amalloyjoegallo: i see what you mean. his pull request has been merged already, so he could reuse the same branch if he wanted
14:30choffsteinlooks very clean.
14:30joegalloah, yes, true enough
14:31joegalloin that case, though, i would fetch the remote and base my work on the newly updated master
14:31amalloybut, srid, you should do something like $ git merge --ff-only dbyrne/4develop
14:31joegalloto have the remote merge commit and everything
14:31amalloyright
14:32amalloys/4//
14:49sridamalloy: i should do that on my 'develop' branch, and then merge that to 'playground' right?
14:49sridor directly do it on playground?
14:50amalloydoesn't matter, i think
14:50amalloyi think it's easier to understand if you keep your develop up to date with ours, but that's more of your problem than mine :P
14:51sridi guess, i'll just keep my 'develop' clean (and merge from upstream often) and always work on branches made from it.
14:52amalloythat's a common pattern
14:52iceyis there a version of contains? that tests for multiple keys?
14:53iceyor should i just wrap multiple contains? with an and?
14:53amalloy(fn [m ks] (every? #(contains? m) ks))
14:53amalloy(fn [m ks] (every? #(contains? m %) ks))
14:53sdboCan you define a default implementation of a protocol method, similar to a default implementation of a typeclass function in Haskell?
14:54amalloy(extend-protocol Foo Object (method [args] impl))
14:54iceyamalloy: thanks.. that was fast - does that question get asked a lot?
14:54amalloynot as far as i'm aware, Icey
14:55sdboamalloy: I tried that, but it's not working. It says there's no implementation. Let me make a simplest replication of the situation.
14:56iceyamalloy: it does exactly what i need, thanks again :)
15:01sdboThis is the situation that I'd like to use, but throws errors
15:01sdboamalloy: https://gist.github.com/1220157
15:01amalloyyou can't partially extend a protocol - all or nothing
15:02amalloyif you want to be able to plug in different impls for different functions within a protocol, you need different protocols instead
15:03amalloyie, Place implements AProtocol/say-hello by throwing an exception, rather than not implementing it at all
15:03ordnungswidrig…or when you implement only single function you can stick to multimethods
15:04sdboOkay, that's how I thought it might work. I'm just used to Haskell typeclasses. I suppose it can be implemented by using multimethods, but that would involve a lot more complexity than I need. Thanks!
15:06sdboActually, what would be the Clojure idiom for a situation like this:
15:06sdboI want to implement a protocol of probability distributions. The primary method is (prob [this obj])
15:07sdboKnowing only that, I can implement conditional distributions by constricting the object space and renormalizing.
15:07dnolenman being able to print DOM localStorage as a Clojure map is pretty awesome. having access to the reader so stored Clojure data types print properly even more awesome
15:08sdboBut if the distribution is implemented underneath as a particular functional form, it might be much faster to return the answer directly.
15:08sdboSo there is a way to implement conditional-prob knowing only that an object implements DistributionProtocol
15:08amalloysdbo: i'm solving the same problem (not for probability distributions, though) myself at the moment
15:09amalloyi'm writing protocols for "things i could do for you but maybe you can do faster" and extending those protocols to Object with default impls
15:09sdboWith type classes you can just define a default method (depending only on other protocol methods) which is overridden at extension time.
15:09amalloyit's more complicated than i'd like, but seems cleanest
15:09sdboAnd there's a minimal complete definition of a protocol
15:10sdboYeah— that's what I thought the solution might be, but it seems a little heavy-handed
15:10amalloyagreed. call me back if you find something better :P
15:11sdboProbably not without resorting to serious multimethod dispatching, haha
15:11sdbobut will do ;D
15:12dnolensdbo: you can add default implementations by extending your protocol to Object.
15:12amalloydnolen: right, but that extends the whole protocol. see his gist at https://gist.github.com/1220157
15:12sdbodnolen: see https://gist.github.com/1220157 for where that fails.
15:14sdboThe idea is that a protocol could have a "minimal complete definition" (or multiple ones) and that anything outside of that definition is optional and can have defaults defined only on that minimal complete set.
15:18sdboamalloy: so far the best thing I can think of is to create a defprotocol* and extend-protocol* which wrap the original macros, store default methods if they exist, and patches them in if they don't get defined. That doesn't seem so bad on the user end…
15:19amalloysdbo: don't forget to write deftype*, defrecord*, and reify* :P
15:19sdboYeah, exactly… which is why I'm not even going to consider doing that until I need this functionality in at least 3 different places
15:20sdboRight now it's just 2 ;P
15:21dnolensdbo: I see, yeah protocols just weren't intended for this, and I don't think they ever will be.
15:21dnolenconverting it multimethods is pretty simple tho, certainly not any more code.
15:24sdbodnolen: I just assumed protocols mapped nicely to typeclasses, but it's not quite 1-1. Multimethods would work, but to be a general solution I'd really want to write a whole macrology to restrict the generality. I really like the idea of protocols/typeclasses and don't want to abandon it to the full generality of multi methods.
15:24dnolensdbo: I'm not following, what generality of multimethod is problematic here?
15:29sdbodnolen: Full control over the dispatch means there's more ways to do it. I don't need full generality, so I hazard to invoke it. It's not something specific, really.
15:29dnolensdbo: just limit your dispatch to type, no one can change that later.
15:30dnolensdbo: https://gist.github.com/1220237
15:31sdbodnolen: I understand *how* to do it. I just don't think the complexity tradeoff is worth it yet.
15:31dnolensdbo: ok, I just don't see where the "complexity" is here.
15:32sdbodnolen: The gist is just a toy example, the real code is much different
15:32dnolenand by trying to make it work with protocols will just create complexity.
15:32dnolensince they don't map to the behavior you want
15:32sdbodnolen: that's exactly it. I'm not going to anymore.
15:33dnolengotcha
15:34sdbodnolen: I implemented this before in Haskell. Typeclasses are ubiquitous and so it's natural to think and communicate using them, and they're powerful enough to easily unify counted frequency distributions and parametric probability distributions.
15:34sdboBut outside of math, those are actually two very different objects. I'm happy enough just treating them differently
15:38robermannhi was trying the amazing debug stuff from the JoY book on emacs + swank
15:39robermannbut when I insert the (break) breakpoint call,
15:39robermannthe REPL swank does not eval the variables
15:40robermannwhen running the same code in a plain REPL (lein repl) it works
15:41robermannIs there something peculiar on emacs/swank/slime when parsing a sub-repl? (I'm referring to pag 309ss of JoY book)
15:49amalloysrid: out of curiosity, what's the next thing you're working on?
15:53cwbHow do I "re-export" vars imported into a namespace? That is, I want to put a/myvar into b so that I can then do b/myvar from c. I thought refer (use) would achieve this but no luck..
15:53hiredmandon't do that
15:53cwbAll right, what should I do instead?
15:54joegallodefalias or https://github.com/ztellman/potemkin
15:54joegallobut yeah, reconsider whether that's as great an idea as it appears at first
15:56joegalloi guess the argument would be that you should just define things where they are supposed to end up
15:56joegalloand that big namespaces aren't that bad
15:56joegalloor something along those lines
15:56naeuout of interest, is anyone aware of any macro changes between 1.2 and 1.3?
15:56hiredmancwb: write tiers namespace a provides functionality that b relies on, and namespace b provides functionality c relies on
15:59cwbjoegallo, hiredman: I'm defining a protocol and multimethods in b, extending them in d,e, etc. All of b,d,e, etc. are required by a, so that I can import a from c and ensure the multimethod has been loaded with all methods. Is there a neater way of doing that (keeping related logic in the same module).
15:59hiredmanif c requires b and a it should require both
16:00hiredman(ns a (:require b d e))
16:15sridclojure regex supports named groups? just wondering how to concisely get these matches into an array map.
16:15sridhttps://gist.github.com/1220343
16:22nickmbaileyany clojure contrib committers around
16:30cwbhiredman: The problem is that I'd like c to only know about a, not b,d,e.
16:43cemericknickmbailey: what's up?
16:45nickmbaileyso i created a couple jira tickets for the jmx contrib library in the main clojure-contrib jira project, seems like maybe each contrib project is getting its own jira project though?
16:45nickmbaileycemerick: ^
16:45nickmbaileyshould i ping someone for making a java.jmx jira project or something?
16:46cemericknickmbailey: Yes, send a mail to the clojure list (or the clojure-dev list if you can).
16:46nickmbaileyk, will do
16:46cemericknickmbailey: I'd just delete those tickets you added to the legacy clojure-contrib JIRA tho.
16:47cemerickI'd create the jmx project in JIRA for you, but I don't own it :-)
16:48nickmbaileywell if i get someone to create it i can just move the tickets which would be nicer than recreating them
16:48cemericktrue
16:49jliClojure doesn't use this for hotswapping code, does it? http://download.oracle.com/javase/1.4.2/docs/guide/jpda/enhancements.html
16:49cemerickno
16:50cemerickClojure just generates and loads bytecode corresponding to new implementing classes.
16:58amalloysrid: zipmap would be my choice, though you might also see if https://github.com/cgrand/regex/ has the features you want
16:58amalloy(from the wiki, it looks like it does)
17:01amalloynaeu: i don't think so
17:02naeuamalloy: it might not be macros per se, but with 1.3 one of my macros is doing bad things which it doesn't do with 1.2
17:02naeui'm finding it very hard to track down what's going wrong
17:02dnolennaeu: what error are you getting?
17:03naeusomething lame: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector
17:04naeuI'm not entirely sure how to reduce the problem to something communicable
17:04naeuit could very well just be me doing something abusively bad with macros which somehow managed to work with 1.2 but 1.3 is complaining about
17:04raekprobably a word too much or too less next to a parameter list
17:05raek,(let foo [x 1] x)
17:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding>
17:05naeuraek: how would you guess that?
17:05raek,(fn foo foo [x 1] x)
17:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol>
17:05TimMc,(let 'foo [x 1] x)
17:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding>
17:06TimMcnaeu: Is it occurring at macro expansion time or at call time?
17:06raeknaeu: well, I have seen such exceptions before from the compiler
17:06naeuTimMc: call time
17:06dnolennaeu: should be pretty easy to isolate then, you should have a precise line number.
17:07naeudnolen: how would I find that line number?
17:07dnolennaeu: the stacktrace.
17:08dnolennaeu: this sounds like a bug related to expanding to a fn, or protocol, deftype/record
17:08naeudnolen: I just see: 18: overtone.sc.cgen$eval10533.invoke(NO_SOURCE_FILE)
17:08dnolena symbol where there should be a vector
17:09naeudnolen: I wonder why 1.3 would pick it up and not 1.2
17:09dnolennaeu: hard to say. but I'm sure it will turn out to be something simple.
17:09naeudnolen: that's usually the case with these things ;-)
17:10naeudnolen: so how would you get the line number from the stacktrace
17:10naeuI'm getting that trace from an emacs buffer
17:10naeuwould I be better off generating it through some other way?
17:10dnolennaeu: you said the error is at call time
17:10amalloyeasiest way: gist the stacktrace and tell people you need help understanding it
17:10naeudnolen: yep, emacs throws that buffer at call time
17:11naeuhere's the stacktrace: https://gist.github.com/1220495
17:11naeu"people, I need help understanding it!" :-)
17:13dnolennaeu: if this at call time then what is the smallest form that causes the problem.
17:13dnolennaeu: what is the macroexpansion?
17:13naeudnolen: it's a bit of a beast, hold on...
17:13dnolennaeu: tho it's clear here its *not* a call time error, it's a compile time error
17:14naeudnolen: ok, but emacs throws that buffer up when I try and 'call' the fn
17:14naeuand not when I use the macro to generate the fn
17:19naeudnolen: I've updated the gist to include the macroexpansion (which I've simplified a little)
17:20amalloynaeu: 1.3 sees the exception sooner because it checks for primitive typehints on arglists, i suspect
17:20naeuamalloy: 1.2 never even complained...
17:21amalloyi'm just saying, i'm looking at the compiler, the line where the stacktrace tries to cast, and it's looking through the arglists to see if there's a primitive hint
17:22naeuamalloy: oh cool :-)
17:23naeumy java-fu is sadly weak - I really should start reading some one day
17:24naeuamalloy: how do you know where in the stacktrace to look?
17:24amalloywell, i just looked at the topmost line
17:24amalloysince that's the immediate cause
17:25naeuah, yes, makes sense
17:25hugodthat error normally comes from passing a symbol to something that is being destructured as a vector
17:25naeuI just tend to skip to the clojure bit - perhaps I should stop doing that
17:25amalloyhugod: then you usually get nth not supported
17:25dnolennaeu: your source looks strange are you def'ing inside a vector?
17:26amalloylooking at the stacktrace, it seems like the compiler is trying to parse something like (fn [foo] (bar ...)), and when it looks up the global variable bar it sees that its arglists are illegal in some way
17:26naeudnolen: I'm looking at exactly that right now trying to figure out why I'm def'ing inside a vec
17:31naeudnolen: it looks like I was tryign to create a list of defs to def, but never actually got round to unwrapping it
17:31naeuand yet it seemed to work with 1.2 like that
17:31dnolennaeu: so is it fixed now?
17:31naeunot yet
17:32naeugoing to stick it in a do and see what happens
17:37naeuhmm, there seems to be an issue with my use of `(with-meta c-name metadata)`
17:37naeuwhere c-name is a symbol and metadata is a map
17:37naeuI'm using that in a macro
17:38naeuand binding it to default-c-name in a let statement
17:38naeunext, I do the following: `(def ~default-c-name ~default-cgen)`
17:39naeu~default-c-name doesn't seem to resolve to a symbol
17:39clojurebota symbol is just a variable name
17:40amalloynaeu: link to where your with-meta is?
17:40naeuamalloy: you mean the source code?
17:40amalloyyeah
17:41naeuhttps://github.com/overtone/overtone/blob/master/src/overtone/sc/cgen.clj#L176
17:45amalloynaeu: sadly nothing stands out as crazy, as long as none of those cgens depend on each other
17:45amalloyi've had an issue before where a name's metadata gets eval'd more than i expected, but that doesn't seem to be your issue
17:46raekhrm, shouldn't there be a 'do' around all those defs?
17:46naeuwhen you say "cgens depend on each other" you mean the possibility that one def might invoke the other and visa versa?
17:46amalloyraek: well, he's putting them in a vector, which is silly but should work if they're not interdependent
17:46naeuraek: yup, there is now in my local source :-)
17:46raekto me it looks like the macro generates something like [(def ...) ((def ...) (def ...) (def ...))]
17:47amalloyraek: yeah, it does do that, which in fact is crazy :)
17:47naeuraek: yeah, it was, now it's (do (def..) (def …))
17:47raekthat looks better :)
17:48naeubut that doesn't fix the exception ;-)
17:48naeujust tidies things up
17:48raekwell, a def is an expression, so it's valid syntax :)
17:48amalloynaeu: btw, (list* `do def1 (for ...)) is the easiest way to get that, imo. i guess `(do ~def1 ~@(for...)) works too, but it seems more confusing
17:48raekand a def returns a var, which implemets IFn
17:50naeuamalloy: good tip
17:50naeuthanks
17:56ZolrathI'm having an issue with Noir/CongoMongo in that I have a page which fetches entries from the MongoDB but it caches the values the first run.
18:01ZolrathIn the defpage it calls a function that calls (fetch :jobs) and inserts html using the data but apparently that is not the right way to go about this.
18:01naeuamalloy: so it appears to be the with-meta lines which are blowing up
18:01sridis there a primitive to remove nil/false from a collection?
18:02amalloyfilter
18:02naeuamalloy: everything works now after I removed those specific lines
18:04srid(filter #(%) (map f records))
18:04naeusrid: (filter identity (map f records))
18:05srid that's same as using #(not (nil? %)) as pred, I hope
18:06amalloyno; it's the same as using #(not (boolean %))
18:07amalloyer...that's the opposite
18:07amalloymy point is just that it removes false as well as nil
18:07naeuamalloy: I think that's what srid wanted?
18:08amalloyyes, which is why i'm puzzled that he hopes it's the same as something that obviously isn't what he wanted
18:11sridchecking for nil alone is fine.
18:11sridcan `(println (filter ...))` ever raise NullPointerException?
18:12srid... after printing a single (
18:12sridyes, lazy seqs
18:13sridso the nullpointer must have happened inside the filter's pred, even though clojure traceback points to the println location.
18:14amalloyit doesn't even have to happen in the filter pred
18:15amalloy&(println (filter identity (map #(.size %) [nil nil])))
18:15lazybotjava.lang.NullPointerException
18:16sridthe culprint was zipmap ignoring the last key because re-matches did not include the last group (for one log record).
18:33sridI need the result of a cond test expr in the result expr; is there a primitive function for that? or do I have to reimplement cond?
18:34sridthe cond test expr in question doesn't always return true/false - they may return complex data structures too
18:34sridi want to bind the data structures for use in the result expr.
18:36nickmbaileyperhaps you just want a few if-lets rather than cond?
18:36nickmbaileyi don't think there is a cond-let
18:37llasramThere is in clojure.contrib.cond, but it looks... odd. I'm having difficulty parsing what it does, other than "not what I'd think"
18:40llasramOh, I see. Interesting. I think it might do what srid wants.
18:40llasramIt just seems a little weird because you specify a single binding form to use for all the text/expr pairs
18:41nickmbaileyyeah something like '(cond-let [x] false nil true x)'
18:42sridnickmbailey: if-let's are not exclusive, unless you nest them which is ugly.
18:42nickmbaileyyeah but cond-let seems to do exactly what you need
18:43sridseems so; (cond-let [x] (+ 2 3) (* x 2))
18:44sridthe first I read the cond-let doc in clojuredocs.com it was confusing, then later I understood.
18:45llasramI think the example needs a little love... At the very least, the formatting doesn't intuitively express the relationship between the forms
18:50srid`map` is annoying. i can't easily debug errors in its predicate, because clojure's traceback doesn't include line number information for the stack after the call to predicate.
18:50sridthat's because map returns lazyseq
18:51nickmbaileyyeah its not exactly clear in that example that '[5 2 3]' is the test
18:51llasramnickmbailey: updated -- hopefully better now :-)
18:51sridand primitives like `(count a-lazy-seq)` fail without telling which line the error occured
18:51llasramsrid: What dev env are you using?
18:51sridemacs - cake swank
18:51sridi type C-c C-k and then invoke my main function in REPL
18:51llasramsrid: Cool! I literally just today learned that you can drill down when you get lazy seq errors
18:52sridhow do you drill down?
18:52llasramHit 1 in the exception buffer
18:54llasramI was so excited when I found that out, because debugging lazy seqs had been a pain in my ass too
18:55llasramanyway, I'm off -- gl
19:21sridhit 1 and?
19:22sridexception buffer now shows "0 1" to qui slime or abort slime.
19:22amalloysrid: but now it has a new stacktrace
19:22sridah yes.
19:24amalloygfredericks: meh. it's just showing the next "Caused By" exception you'd see in a real stacktrace
19:24gfredericksoh okay
19:24gfredericksgood
19:24gfredericksthat'll make it easier for me to keep sitting in my corner over here telling myself that emacs isn't all that cool
19:30sridin the 'caused by' exception, I see nullpointerexception at -- (if-let [attr (typ record)]
19:30mdeboardcomputers are hard
19:30sridwhat could have happened? if it the source was in the 'typ' function, then i'm surprised that the 'caused by' exception didn't show it (the line no)
19:30mdeboardfor me*
19:34srid'typ' was null. (last entry of loop)
19:35amalloyif-let is a macro - you can lose line metadata information when macros enter the picture
20:49devnhm, is there a way to have a clojurescript node repl?
20:50devnas in: once I require [cljs.nodejs :as node], I get access to node/require, etc. in script/repljs
20:50devnmethinks I might need to start from script/repl instead
20:52sridamalloy: ok. still, pringin *which* variable was 'null' would have been more useful than a mere "nullpointerexception". then again, i don't know much of clojure/java internals to judge if that is doable.
20:52srid*printing
20:52amalloynot really, no
20:53sridno - to what?
21:00alandiperti think ataggart is around there, and i imagine he will be coming
21:03sridbest to go to vancouver clojure group (sept 20) and find out http://www.meetup.com/Vancouver-Clojure/
21:12hiredman,(/ 128 8)
21:12clojurebot16
21:13tomojI see that method annotations work with reify, but is there no way to give a class annotation?
21:20cemericktomoj: I don't believe so; there's no class/type name to hang metadata off of in that case.
21:24tomojshucks
21:24cemericka deftype will bring you home
21:24tomojgot that working, but what I want is anonymous
21:24tomojthough
21:25cemerickI wouldn't put money on that happening. :-)
21:25tomojI was going to replace them all with a single gen-class, can just replace them all with a single deftype
21:28redingersrid: Even better, go to the vancouver meet up and tell them all to attend the conj. :)
21:49TheBusbycan you have multiple namespaces in a single file and have them reference each other?
21:58alandipertTheBusby: yes, but in a file like (ns a) (ns b) stuff in ns a doesn't know about ns b
21:59TheBusbyalandipert: Would "ns b" be able to require/user from "ns a" ?
21:59alandipertTheBusby: yes
22:02TheBusbyalandipert: Hmm, trying a simple example I get "java.io.FileNotFoundException: Could not locate foo/a__init.class or foo/a.clj on classpath"
22:03alandipertTheBusby: how are you compiling?
22:03TheBusbyalandipert: via slime and the command line
22:04TheBusbyalandipert: Here is the sample code I was using to test, http://pastie.org/2540810
22:04alandipertoh, whoops - i was mistaken. 'require' needs a file
22:05TheBusbyer, and 'use' ?
22:05TheBusbyprobably the same, is there another way to access it though?
22:06alandipertTheBusby: http://pastie.org/2540826
22:07TheBusbyalandipert: doh, much thanks!
22:08alandipertnp, happy computing!
22:13bprUsing definterface, can you specify parameterized method parameters (ie. Map<String, String>)?
22:15bprfor example i'd like to do something like (definterface IAvailableResourcesCallback (onResources [^Map<String,String> m])) ; sorry for the horrid syntax...
22:17amalloybpr: no
22:17bpramalloy: that doesn't surpise. I had to ask though
22:27sridare their presentations/articles detailing why Heroku chose Clojure (over ruby/python) for implementing some of its components (eg: pulse)?
22:35devnsrid: http://www.theregister.co.uk/2011/07/11/heroku_does_clojure_and_beyond/
22:37devnsrid: Also, it looks like Mark McGranaghan is going to be giving a talk at Clojure/conj 2011 about Pulse: http://lanyrd.com/2011/clojure-conj/shhfd/
22:37devnsrid: (There's an abstract there that might give a bit more insight)
22:39sriddevn: mark's talk is how I came to know about pulse (in fact, i was just starting today at work to do some log analysis in clojure)
22:41sriddevn: but as for the theregister article, the rationale behind choosing clojure for pulse is just intuition (gut sense, hip, feels right)?
22:42sridhe says "Clojure is suited to building application components that must be eminently predictable" - i don't even know what that means. what is 'eminently predicable'?
22:44dhmsrid: i'd read it as another way of saying "functional"
22:45sridthat raises the question - how are clojure-based components 'eminently/more functional' than others (ruby/python).
22:45zippy314are folks talking about clojurescript on this channel or is there a better place?
22:45redingerzippy314: This is the ClojureScript channel, too.
22:46zippy314kewl. Just digging into now. Checking out the twitterbuzz example. Anybody know of any other good sample clojurescript/closure apps out there to learn from?
22:48amalloysrid: they don't mutate
22:48amalloyzippy314: pacman!
22:48amalloy$google github pacman clojure
22:48lazybot[Twitter / @btbytes/clojure] http://twitter.com/btbytes/clojure
22:48amalloy...
22:48sridheh
22:49amalloyhttp://mjg123.github.com/pacman/pacman.html
22:49sridzippy314: https://github.com/heroku/leech is written in clojurescript
23:02bpr``is there a way to declare abstract classes in clojure? I know it's *very* non-idiomatic, but I'm creating a Java-interop interface...
23:05brehautbpr``: that sounds like the realm of AOT compilation
23:07brehautbpr``: http://clojure.org/compilation
23:08brehautno idea if it actually supports defining abstract classes specifically
23:13bpr``this is my first major chunk of java-interop where I'm exposing clojure functionality to Java code. So I'm looking for all the advice I can get haha. This is especially true because I'm not really a Java dev. I come from the dynamic language world lol
23:13bpr``dynamic type*
23:13zippy314wow. That pacman link really fries safari!
23:21iceyi am writing a small noir example app for practice and i've got a couple of functions that don't feel idiomatic to me. anyone feel like taking a peek?
23:21iceyhttps://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/utils/utils.clj
23:22iceythe human-date function's let section looks gross to me
23:22iceythe -> didn't really help much
23:26brehauticey. where does 'markdown' come from? (in markdownify)
23:26iceybrehaut: markdownj
23:26brehautoh. im out of practise at reading that form of method call
23:27iceybrehaut: ah, is there a preferred method?
23:27iceyerr, form
23:27brehaut(.markdown mdp …)
23:27brehauti think
23:28brehauthttp://clojure.org/java_interop
23:28brehautyeah
23:29iceybrehaut: sweet, thanks. i'll give it a whirl
23:30alandipertthe naked dot form is handy in macros
23:32brehauticey: contains-all is kinda funny
23:32brehauticey: you only need it if your map might contain false or nil
23:40brehauticey: human-date is ok. the only actual gross part is that its not pure functional…
23:41iceybrehaut: i'm trying to recall the exact reason i went the contains-all route
23:42brehauticey: well the alternative is just to use every? with the map as the function. your function is fine if you think there is a chance that the value of one of the key is nil or false
23:43iceybrehaut: yeah, i'm using it on a page with 2 possible entry points and I may get different data between them
23:44iceybrehaut: i'm using it here https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/views/post.clj around like 86 -
23:44brehauticey: if you click the line numbers, gh updates the url
23:44iceyerr, line 86
23:45iceysweet, i never knew that
23:45iceythanks
23:47iceyi think every? will work here
23:49alandiperti'd probly do (clojure.set/subset? (set ks) m) there
23:49brehautalandipert: thats nice
23:50amalloythat's not going to work, is it? it will seq m, and look at the k/v pairs
23:50alandipertsets are degenerate maps
23:50amalloyyes
23:50brehauthuh. subset? just uses every under the hood anyway
23:51brehaut(in 1.2 anyway)
23:51amalloyi see. i guess it works if you pass the args in that order
23:51amalloyi think i was thinking of intersection or something
23:52alandipert(subset? ks m) also works, but for reasons unknown to me
23:52amalloyalandipert: the first arg just gets seq'd
23:53brehautalandipert: it doesnt treat keys as a set
23:53amalloysince you have to look at all of them anyway
23:53alandipertah, cool
23:55alandipertwell, i'm outs. looking forward to seeing peeps at strangeloop!
23:55iceyalandipert: thanks for the advice - i'm reading up on subset right now
23:56alandipertnp, happy clojuring