#clojure logs

2011-11-05

00:01leo2007something weird happened. after quitting swank-closure, port 4005 is still occupied and preventing swank-clojure from listening on that port again.
00:01leo2007ideas?
00:01ibdknoxamalloy: can anything execute as a result of doing read-string?
00:02scottjleo2007: how did you start swank and how did you quit it?
00:02leo2007scottj: I run the swank-clojure script and C-c to quit it
00:02scottjswank-clojure script?
00:03leo2007scottj: http://paste.pound-python.org/show/14726
00:03alandipertibdknox, binding *read-eval* to false turns off EvalReader if that answers your question
00:03scottjleo2007: windows?
00:03leo2007scottj: osx
00:04scottjleo2007: why not lein swank?
00:04ibdknoxalandipert: basically I want a safe way to read a datastructure
00:04leo2007scottj: probably because I did swank-clojure first.
00:04alandipertibdknox, ok yeah, do *read-eval* false
00:04ibdknoxalandipert: awesome, thanks
00:04leo2007anyway, how to find out what's listening on port 4005 and kill it.
00:05amalloy&(inc #=(inc 1))
00:05lazybotjava.lang.IllegalStateException: clojure.lang.LispReader$ReaderException: EvalReader not allowed when *read-eval* is false.
00:05scottjleo2007: ps look for java with classpath including swank and kill it
00:05amalloyleo2007: lsof
00:06tensorpuddingawesome, grabbing clojure-contrib fails
00:06leo2007amalloy: I don't know how to use lsof
00:07leo2007lsof -l
00:07leo2007?
00:07scottjtensorpudding: using clojure 1.3? clojure-contrib is split up
00:07tensorpuddingi'm using 1.2
00:07tensorpuddingi think
00:07tensorpudding1.2.1
00:07amalloylsof -i:4005
00:08leo2007that returns nil
00:08tensorpuddinganyway
00:08leo2007but I can ping localhost:4005
00:08tensorpuddingit's a bunch of errors with Maven or something
00:09tensorpuddingdoes clojure-contrib 1.2.1 not exist?
00:09tensorpuddingis it a wrong version?
00:09amalloyleo2007: you can...ping it? what does that even mean? i'm sure there's no pingserver listening on port 4005
00:10mdeboardibdknox: I'm reading the models module of your blog project, but I'm not really following on the general idea of a model in Noir. I'm used to -- for better or worse -- a model being a representation of a db table. But the models.clj code looks more like a controller (well, a view in MTV world)
00:10amalloy(and i *think* pings are at the IP level, not the TCP/UDP level, so they don't even have a port at all)
00:10goodieboyhow can I get the k var to execute here? (let [k '(prn "hello")] `~k)
00:10leo2007amalloy: http://paste.pound-python.org/show/14728
00:11amalloygoodieboy: odds are good that's not what you want to do
00:11ibdknoxmdeboard: I don't really tell you how to do any of that, because it's really up to you how you want to organize that studd
00:11mdeboardOk thanks stud
00:11ibdknoxmdeboard: the way I tend to organize things is in the more traditional MVC sense
00:11mdeboardGuess I have some learning to do then.
00:11ibdknoxmdeboard: where the view calls the model directly
00:12amalloyleo2007: bet you a dollar that $ ping localhost:12345 works too? it's probably either ignoring the part after the : or doing something unrelated with it
00:12amalloybut ping only operates at a host level. there's no way you can ping a specific port
00:12mdeboardibdknox: I don't have any experience with MVC, so this is all new territory for me
00:12leo2007amalloy: you owe me a dollar.
00:13leo2007amalloy: http://paste.pound-python.org/show/14729
00:13tensorpuddingwhere can i see what versions of clojure-contrib are available?
00:13tensorpuddingwhere doe lein dep get its jars from?
00:14mdeboardtensorpudding: clojars & maven
00:14amalloyhuh. that's pretty damn weird. you can have a dollar at the conj. but what OS and/or some crazy version of ping?
00:14tensorpuddingis clojure-contrib at clojars or maven
00:14tensorpuddingi can't find it at clojars
00:14mdeboardtensorpudding: clojure-contrib doesn't exist anymore
00:14tensorpuddingokay
00:14mdeboardtensorpudding: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
00:15tensorpuddingwhich versions does this apply to
00:15tensorpuddingi'm using 1.2.1
00:15leo2007amalloy: I am on osx 10.6.8.
00:16amalloyANYway a quick google search reveals that ping is not related to ports at all. so while i can't explain your actual behavior, i really wouldn't worry about the possibilitythat you have a server listening on 4005: if lsof can't find it, then it ain't there, no matter what weird shit ping is doing
00:17tensorpuddinggod, this tutorial is a dud
00:17tensorpuddingit seems to be referencing plenty of things that don't exist
00:17jlidoes | mean something special in clojure? I was hoping to use it as the name of thrush
00:18amalloyjli: no, but i think it also isn't guaranteed to be a valid symbol character in the future
00:19tensorpuddingtrying to require my namespace gives me an error on line 1
00:19tensorpudding"Parameter declaration set should be a vector"
00:19leo2007amalloy: but the point is that swank cannot start on port 4005 any more.
00:19tensorpuddingdid ns get changed somehow
00:20amalloy&(fn x (set) (inc set))
00:20lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
00:20amalloyhm. is it only defn that does that?
00:20tensorpuddingthe boilerplate generated by lein doesn't even work
00:21leo2007I have "user=> Connection opened on null port 4005." printed on the terminal.
00:21jliamalloy: hum, thanks
00:22amalloyleo2007: i dunno, man
00:22jlileo2007: does "netstat -anp | grep 4005" say something about TIME_WAIT?
00:23leo2007somehow, ping localhost:4005 is resolved to the ip address 202.106.195.30
00:23leo2007If I pass 192.168.0.101 to slime, it can connect.
00:25leo2007jli: it says "tcp4 0 0 192.168.0.101.4005 192.168.0.101.55761 TIME_WAIT"
00:25leo2007-p is not supported by netstat on osx
00:26leo2007so that is the result of netstat -an | grep 4005
00:26jliyeah, that's fine
00:26leo2007what is fine?
00:26jlinetstat -an. -p just prints the program name.
00:27leo2007jli: now netstat -an|grep 4005 prints nothing
00:27jliso roughly, swank-clojure didn't close the port cleanly before going away, so the OS left it hanging around. it'll become available in a little while.
00:27jlileo2007: okay, so swank should be able to start as normal again
00:27amalloyleo2007: it sounds like you have slime and swank working just fine but your system thinks localhost:4005 is the IP address of some computer in russia?
00:28leo2007amalloy: looks like so
00:28goodieboyaye, why doesn't this print? https://gist.github.com/1341105
00:30leo2007jli: not really, localhost:4005 is resolved to an strange address
00:31jliwhat?
00:31clojurebotwhat is cells
00:32jlileo2007: swank-clojure should be able to start normally again.
00:32scottjgoodieboy: I think you want (~@s#) or better ~s#
00:33scottjgoodieboy: what you have no the let has a body of prn and "test", the last of which gets returned
00:33amalloyscottj: not really good enough
00:33leo2007jli: you are right. I can start swank-clojure except now localhost + 4005 points to somewhere else.
00:33amalloyyou need the let to be outside of the syntax-quote
00:33amalloy(defmacro run [f] (next f)) ;; this is really it
00:35amalloyor if you want to be really verbose about it, (defmacro run [f] (let [s (rest f)] s))
00:36goodieboyscottj amalloy: thanks! I don't understand, but at least I know what I'm trying to do is possible :)
00:37amalloygoodieboy: ask yourself: do you want to return code that calls next on the form, or do you want to call next on the form and return that as code?
00:37amalloythe latter: you don't want asdf to ever appear in code that clojure tries to run
00:38goodieboyyeah i see
00:38goodieboymakes sense
00:38toxmeisterhello dears! would anyone have some ideas how to overcome this little show-stopper? http://stackoverflow.com/questions/8018207/clojure-classpath-issue-within-an-eclipse-plugin
00:40mdeboardtoxmeister: Would it be way too snarky to say "use emacs or vim"?
00:41brehautmdeboard: yes
00:41mdeboardOk, I won't then
00:44goodieboyso i'm trying to create a "dsl" using mostly keywords/vectors. Something like this [:or {:name "test"} {:name "this"}] would get transformed into "name:(test OR this)" -- is it possible to do this without eval?
00:45brehautgoodieboy: yes of course
00:45toxmeistermdeboard: not too much, no :) - am sure it's just a silly config issue, since obviously other people (incl. laurent) have managed building this stuff. really do need RCP on this project…
00:45mdeboardgoodieboy: Are you building a Solr interface?
00:46goodieboymdeboard: well, just experimenting yes
00:46jlileo2007: man, why is your computer resolving localhost:4005 into an IP? do you have something weird in your /etc/hosts?
00:46brehautgoodieboy: i cant imagine how even using eval would help
00:46mdeboardgoodieboy: Nice, nice.
00:47leo2007jli: I have never touched that file. The whole thing is http://paste.pound-python.org/show/14730
00:47goodieboybrehaut: well, i've been using clojure.walk to transform the input vector/keywords into function calls/lists, then calling eval
00:48amalloybrehaut: well if i implemented my code as (constantly (quote (quote "name:(test OR this)"))) an eval would be a big help
00:48goodieboyit works, but something tells me this is not "normal" clojure
00:48brehautamalloy: lol :P
00:49amalloygoodieboy: agreed, it's nuts
00:49alandipertsweet that it's possible, though :-)
00:50mdeboardgoodieboy: You might actually take a cue from Hiccup here. `[:name [:or '("value1" "value2")]]` or something
00:50mdeboardgoodieboy: I've been doing a lot of work with Solr the past 6 weeks or so, so this caught my eye
00:52leo2007why doesn't this (#(%1 %2) Math/sin 3e2) work?
00:52jlileo2007: oh, maybe you're using some cruddy DNS server that "resolves" non-hostnames to some wacky thing
00:52goodieboymdeboard: nice, solr is great
00:52alandipertgoodieboy, have you seen http://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure?
00:52amalloyleo2007: Math/sin isn't a function
00:52goodieboyalandipert: yeah, maybe time to re-read :)
00:52amalloyit's a method
00:53jlileo2007: what's your /etc/resolv.conf ?
00:53leo2007jli: nameserver 192.168.0.1
00:54jlileo2007: are you in China?
00:54leo2007jli: yes
00:54alandipertgoodieboy, beginning of clojurescript compiler also good. multimethods are where the money is
00:54goodieboyalandipert: oh you mean the source for clojurescript?
00:55alandipertgoodieboy, yes - https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj in particular
00:56leo2007jli: China's internet is pretty shitty.
00:56jlileo2007: heh, yeah. so yeah, your DNS server is resolving "localhost:4005" to the IP of some silly portal thing
00:57goodieboyalandipert: awesome thanks. i'll have a look
00:57jliif you go to the IP in a web browser, you'll see
00:57alandipertgoodieboy, np. it's dense reading but the overall layout is what you may consider emulating
00:57jli(that's my best guess, at least)
00:58leo2007jli: but it worked before I ran into this problem.
00:58alandipertand omg, the conj is next week
00:58leo2007amalloy: how to replace Math/sin so that the example works?
01:00amalloyhttp://stackoverflow.com/questions/5726334/passing-functions-as-arguments-in-clojure/5726449#5726449
01:01jlileo2007: what?
01:01jliwhat worked? what problem?
01:02leo2007jli: a silly example (#(%1 %2) Math/sin 3e2)
01:03jlihuh? I'm.. talking about DNS
01:04mdeboardamalloy: Do you know of/follow any particular style conventions in your code? e.g. line length, white space, order of imports, etc.
01:04mdeboarder, order of requires, etc.
01:04leo2007amalloy: thanks
01:05amalloymdeboard: well, the lisp/scheme indentation rules. i mostly keep lines under 80 chars, but the office guideline is 100
01:05brehautmdeboard: related: http://mumble.net/~campbell/scheme/style.txt
01:06amalloypersonally i like to line up clauses in ns forms, but not elsewhere; i know people who prefer to line up let-bindings but not ns forms. i think i'm in the minority and most people don't line up anything
01:06scottjI thought stu created a clojure style guidelines
01:06mdeboardbrehaut: perfect, thank you.
01:07brehautmdeboard: not perfect ;) its a scheme reference
01:07mdeboardbrehaut: Perfect in its fit to what I was looking for
01:08brehautmdeboard: re:imports, more important than order is that you should prefer refer to use, and should never use bare use in your NS (ie, use :only)
01:08mdeboardI see
01:09scottjhttp://dev.clojure.org/display/design/Library+Coding+Standards but doesn't mention whitespace
01:10amalloybrehaut: prefer refer to use? that doesn't make sense. i could see preferring require to use, though i don't really agree
01:12brehautamalloy: man what am i saying. require
01:12brehautdefinitely require not refer
01:13brehautamalloy: it might be my python background that makes me prefer require
01:13scottjbrehaut: en/don't en/you en/get en/tired en/of en/prefixing en/your en/functions?
01:13brehautscottj: no
01:14scottjand you have to remember whether that function is in page-helpers or form-helpers or core
01:14brehauti dont use hiccup, so no, i dont have to ;)
01:14amalloyscottj: i was going to complain about that link to library coding style, but it's much more helpful than i remember it being
01:15mdeboardbrehaut: Eh, I only keep a `module.method(args)` convention in modules with a lot of imports. Otherwise, unnecessary, imo, since you can `import foo as f` or what not.But that's python talk and neither here nor there
01:18brehautmdeboard: you can require clojure modules as shorter names as needed to. i dont understand your point
01:18mdeboardbrehaut: Didn't have one :)
01:20scottjadvantages of require as: 1) you don't have to list all the functions in :only 2) immediately visible where function comes from 3) can have multiple functions with same name
01:31jliusually I just suck it up and list things in :only
01:31jlifuture you will thank you
01:47amalloyscottj: fwiw (2) is rarely an issue for me
01:48amalloyand you can solve (3) with a :refer/:rename, but i agree usually :require/:as is better
01:55robeari have a clojurescript question. anyone online that can help?
01:55ibdknox~anyone
01:55clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
01:59robeari am new to clojure script and wondering what the best practices are when dealing with closure structures. specifically, if i do something like (gdom/getElementsByTagNameAndClass "div") the result is an [object NodeList]. Should I iterate through the list and put it into a clojure data structure or pass it back and deal with it as a closure data structure? what is the best way to iterate through the NodeList with clojurescript? Thanks
02:00ibdknoxrobear: I transform them into a collection
02:00ibdknoxrobear: btw, you might want to check out pinot http://github.com/ibdknox/pinot
02:01ShinkaHas anyone here used Clojure for computational biology on some cloud service ? I'm curious about the performance you could achieve.
02:05robearibdknox: thanks. i see what you did with nodelist->col in dom.cljs. thanks a lot!
02:11mdeboardibdknox: Does (defpartial) support a docstring
02:12ibdknoxmdeboard: unfortunately no, though that's likely something I should fix
02:12mdeboardibdknox: k
02:14ibdknoxmdeboard: though to be fair, your partials really shouldn't do anything complicated, so doc strings are mostly unnecessary.
02:15mdeboardibdknox: Well, it's mostly as a reminder to myself :P
02:15ibdknoxyeah, I buy that
02:16ibdknoxunfortunately dealing with args like that is really annoying lol
02:19leo2007why doesn't this work (-> 3.0 #(Math/sin %) #(Math/cos %)) ?
02:23brehaut,(macroexpand '(-> 3.0 #(Math/sin %) #(Math/cos %)))
02:23clojurebot(fn* (clojure.core/-> 3.0 (fn* [p1__27#] (Math/sin p1__27#))) [p1__28#] (Math/cos p1__28#))
02:23ibdknox,(-> 3.0 Math/sin Math/cos)
02:23clojurebot0.9900590857598653
02:26ambrosebs,(macroexpand '(-> 3.0 Math/sin Math/cos))
02:26clojurebot(. Math cos (clojure.core/-> 3.0 Math/sin))
02:27leo2007I still don't where the problem is.
02:28ambrosebslooks like rest of the -> is being put as the first argument as fn*
02:28ambrosebswhich should be an argument list
02:28ambrosebsvector
02:38mdeboardibdknox: Is this gross/stupid? http://p.mattdeboard.net/gross_or_not.html
02:40mdeboardoverly complex, etc.
02:41brehautmdeboard: multimethods, just saying
02:42mdeboardbrehaut: Yeah I started down that path but realized it's a simple enough case that cond suffices without losing extensibility
02:43mdeboardBTW if anyone's--
02:43brehautmdeboard: well your cond is already quite repeatitive. you could replace it with (apply str (interpost "/" [({:CSS css-path :JS js-path} (:Type fmap)) (:Filename fmap))]))
02:44mdeboardWhat the hell? technomancy wrote scpaste?
02:44brehautalso, campitals in keywords is surprising
02:44brehautmdeboard: technomancy wrote _everything_
02:44brehauts/campitals/capitals/
02:44mdeboardbrehaut: I was following the example here http://clojure.org/runtime_polymorphism
02:44brehautmdeboard: huh
02:45brehauti guess its using it to indicate 'typeness'
02:45brehautbut :Type and :Filename is still weird i think
02:46mdeboardYeah.
02:46mdeboardSorry I'm still kind of shocked technomancy wrote scpaste.
02:46mdeboardsingularity chat
02:47brehautseriously, everything
02:49llasramHe start a project named "everything," just to make that literally true
02:49llasramshould, even
03:02mdeboardOh yeah? Well... https://github.com/technomancy/scpaste/pull/1/files
03:04mdeboard02:40 <brehaut> mdeboard: well your cond is already quite repeatitive. you could replace it with (apply str (interpost "/" [({:CSS css-path :JS js-path} (:Type fmap)) (:Filename fmap))]))
03:04mdeboardThat strays into "unreadable" territory for me, as a newb. Decreased maintainability etc., etc., etc.
03:05mdeboardJust for me, I mean. I'll optimize that later.
03:07amalloyibdknox: allowing docstrings is a pain, you're saying?
03:08ibdknoxparsing optional args not at the end is, yeah
03:08amalloyclojure.contrib.def/name-with-attributes handled that reasonably well, though i don't think it's been ported to 1.3 formally
03:09amalloythough, as with anything i like, i copied it into useful
03:09ibdknox:)
03:09mdeboardgod I haven't stayed up hacking like this for months
03:09mdeboardtight
03:10amalloyeg, (name-with-attributes foo "test" stuff more-stuff) returns [(with-meta foo {:doc "test"}), [stuff more-stuff]]
03:11ibdknoxamalloy: cool, I'll take a look at that
03:11ibdknoxI definitely feel like there's some relatively general solution to the problem
03:12mdeboardbrehaut: Fine you win, your way is better :)
03:12amalloyibdknox: aha. it made it into tools.macro
03:12ibdknoxoo
03:12amalloywhich useful already depends on, so i can just drop the copied impl
03:12ibdknox:)
03:12mdeboardOvO
03:19amalloyibdknox: well! thanks for prodding me into looking at that again
03:19ibdknoxamalloy: haha thanks for the solution :)
03:20mdeboardDamn, most productive/fun Friday hackathon I've had in like... 3 months probably.
03:20ibdknoxmdeboard: cool
03:20ibdknoxwho isn't really?
03:20mdeboardClueless fanboy
03:20mdeboardas all fanboys are
03:20ibdknoxaside from amalloy, who I now have to be nice to since he found name-with-attributes for me
03:21mdeboardnothing worse than "Django is so amazing" fanboys who won't shut up
03:21amalloyindeed, i am inexplicably recalcitrant
03:22mdeboardstultifyingly, stupefyingly recidivist
03:22ibdknoxamalloy: one day though, you'll wake up and all your sites will be noir :p
03:22amalloyi don't think it's actually *criminal* to not use noir
03:22mdeboardamalloy: lol
03:23mdeboardamalloy: 4clojure is written on top of Compojure? I can't remember and too tired/lazy to look
03:23amalloythough presumably there is some legislation on it, being held up by a filibuster at this very moment
03:23amalloymdeboard: compojure and hiccup, yeah
03:23amalloyand ring, of course
03:23mdeboardOf course
03:23ibdknoxlol
03:23ibdknoxtranslates http into maps
03:23ibdknoxis the short version
03:43callenmdeboard: HTTP middleware.
03:43callenmdeboard: what ibdknox said.
03:44callenmdeboard: the idea being that if you want to spin your own webframework, reusing Ring prevents you from instrumenting the raw HTTP interface yourself. Cf: rack, wsgi, etc.
03:46mdeboardAhh
03:46ibdknoxour good friend brehaut has the best overall description of the space, though Noir wasn't on his radar then: http://brehaut.net/blog/2011/ring_introduction
03:47callenmdeboard: in general, it's best to avoid being one of those cockbites that has to have his own implementation of everything.
03:47mdeboardcallen: Hahaha, If I ever find myself implementing an HTTP API I'll stab myself.
03:48ibdknoxyeah, it's not really fun
03:49mdeboardIt's just one of those things that sets off my spidey sense, the "You are doing this way, way wrong" feeling.
03:53mdeboardwhat a retarded thing to say, bed time.
03:56callenthat's the most self-aware thing I've ever seen said on IRC
03:56callenwish more people were like that.
03:57brehautibdknox: luckily noir has solid docs
04:18leo2007#'swank.commands.basic/print-doc* seems to have code to handle special forms but I could never get the doc from within slime by `C-d C-d d'
04:30fliebelgood morning :) Do we have any new reader macros today?
04:33leo2007why isn't http://clojuredocs.org/ mentioned in the title any more?
04:33fliebelamalloy: are you still awake? How fast is the randnth?
04:34ibdknoxfliebel: that would depend entirely on the structure
04:34ibdknoxon a vector? basically as fast as generating a random int
04:34amalloyfliebel: tbh i'm not sure. a mini-benchmark showed it was about 4 times as fast as my previous impl, but then re-running your performance graphs it seemed to be slower than any of the others
04:34amalloyibdknox: picking up an old conversation
04:35ibdknoxamalloy: ah, not rand-nth then
04:35fliebelah, no
04:36fliebelamalloy: So is there a fork of my gist that includes this? Because now I need to beat you of course.
04:36amalloyfliebel: i don't think i actually pushed it back to github
04:37amalloybut you can take my gist and add it to yours
04:37fliebelamalloy: I did a really nice one with Forth :) wasn't lazy though :(
04:39fliebelI can'y find my own gist
04:39fliebelah https://gist.github.com/805747
04:49leo2007is clojure in action published
04:54leo2007'joy of clojure' is sold 43 USD here in China.
04:55leo2007a discounted price.
06:02floatbothhi
06:05floatbothhow do I check how much args a fn takes? (:arglists (meta this-fn)) works only w/ vars in 1.2.x. try/catch isn't fast, right?
06:13mrh0057I don't know of a built in function to do that except for java reflection api
06:14mrh0057floatboth: http://download.oracle.com/javase/tutorial/reflect/
06:44anttihI'm trying to set up a clojurescript repl with the browser eval env but I can't get it working when connecting from a webpage hosted on localhost (Noir app). The examples work when serving from a static local html page.
06:44anttihwhat am I missing?
06:45anttihwhat happens is that the repl just hangs there
07:25asmalaI'm having some trouble with "lein jack-in" (and, by extension, M-x clojure-jack-in in Emacs)
07:26asmalaIf I run "lein jack-in" in a nested directory (say src/music) inside my lein project, I get "Couldn't find project.clj […]"
07:27asmalaI found some relevant tips in the #clojure archives, but it seems like everything *should* be set up correctly (fresh emacs install, no other lein plugins, new lein project)
07:29asmalaIs it possible to call jack-in from a directory other than the project root?
07:48asmala"lein swank" + "M-x slime-connect" seems to work fine but I couldn't get "M-x clojure-jack-in" working outside a lein project root ("Couldn't find project.clj […]"
11:03edwA Compojure Q: Is there a way to get the method when using the ANY routes macro?
11:13tensorpuddingprinting in clojure thoroughly and completely confuses me
11:14tensorpuddingthere's a ton of different functions but i don't think any do what i want
11:15edwYeah, there are a few seemingly arbitrarily named functions to memorize.
11:15edwWhat do you want to do?
11:15tensorpuddingi want something which works like sprintf
11:15raekthat would be format
11:15edwSee FORMAT.
11:15raek,(format "%x" 255)
11:15clojurebot"ff"
11:16edwMore like asprintf...
11:17tensorpudding,(let [name "Clojure"] (format "Hello, %s" name))
11:17clojurebot"Hello, Clojure"
11:17tensorpuddingbut it doesn't seem to do what i want
11:17edwWhat do you want it to do?
11:18tensorpuddingnevermind, it works
11:18tensorpuddingi had a typo
11:18tensorpuddingis there a way to read function docstrings in the repl
11:18edw(use 'clojure.repl) (doc format)
11:19edwNo need for the USE if you're using <1.3
11:19raek(in clojure < 1.3 'doc' is in clojure.core)
11:19tensorpuddingwhat is use?
11:19skelternet'(doc doc)
11:19tensorpuddingis that like require
11:19edwYes, but it imports the symbols into the current environment.
11:20tensorpuddingor wait, does it import....ah
11:20tensorpuddingi prefer explicit namespacing usually
11:20edwIMPORT is different.
11:21tensorpuddinghow do i read docs on java functions
11:21gfredericksI don't think that's possible at runtime...
11:21edwThe javadoc?
11:21tensorpuddingwhat's javadoc?
11:22gfredericksa standard method for generating HTML documentation from java source code. What java functions are you interested in?
11:22tensorpuddingjust the ones referenced in clojure docs
11:22gfredericksif they're from standard java libraries, you can google their names and find them
11:23gfredericks$google java 6 inputstream
11:23lazybot[InputStream (Java Platform SE 6)] http://download.oracle.com/javase/6/docs/api/java/io/InputStream.html
11:23gfredericksmost public java libraries post their javadocs on the web, and are easy to find with google
11:23edwYou should use a search engine (Google.com is a search engine) and type something like "java.io.File".
11:36ambrosebsdoes anyone think it's a good idea to dedicate a yearlong CS honours project to a Clojure-in-Clojure compiler?
11:36ambrosebsI'm not aware of an effort currently for this type of thing
11:38ejacksonambrosebs: how much of clojurescript would be useful for that ?
11:38ambrosebsI'm not sure
11:39ambrosebsmy very rough understanding is that it's not completely CinC because it uses Clojure
11:39ambrosebsbut, please correct me if I'm wrong
11:40ambrosebsI'd imagine it's a starting point
11:43ejacksonI have no idea, but I got the impression it was a stab at working on the ideas
11:46ejacksoni think it would a really exciting exercise
11:48ambrosebsyes, there seems to be many factors to account for
11:59gfredericksambrosebs: would you try to design it from the ground up, or just go through the java classes translating functionality into deftypes and such?
12:03ambrosebsgfredericks: well it wouldn't be a 1-1 translation, there are suggested improvements for a CINC compiler on a confluence page
12:03ambrosebsbut really, I haven't looked at the compiler much, this is something i'd spend a while thinking about before jumping in
12:04gfredericksif I had an honors project to do, I would definitely enjoy such a thing.
12:05ambrosebsyes, it sounds like a bunch of fun
12:06ambrosebsanother possibility is working on an a la carte type system for clojure
12:07gfredericksthat sounds more research oriented
12:07gfrederickswhich I mean neutrally
12:07ambrosebs:)
12:08ejacksonhahaha
12:16srid,(Integer/toString 37 37) ;; radix cannot be greater than 36?!
12:16clojurebot"37"
12:17gfrederickssrid: from javadoc: "If the radix is smaller than Character.MIN_RADIX or larger than Character.MAX_RADIX, then the radix 10 is used instead."
12:18gfredericks,Character/MAX_RADIX
12:18clojurebot36
12:24TimMcew
12:24TimMcSilent fail fail.
12:28TimMc,(Integer/toString 37 -1)
12:28clojurebot"37"
12:39TimMcI'm surprised it doesn't throw a checked exception. :-P
12:44gfredericksyeah that's what I'd expect from java
12:44gfredericksif it were a clojure function what would you expect it to do?
13:05tensorpuddinghow do you define a main entry point for a clojure app?
13:05tensorpuddingdo you use clojure.main/main
13:08carktensorpudding: depends if you're AOT compiling or not
13:08tensorpuddingi'm producing a jar
13:09carkdo you want to have an "executable" jar ?
13:09carkor can you take care of that from the command line ?
13:09tensorpuddingi want an executable jar
13:10carkthen you need to make a gen-class namespace
13:10raekyou specify the main namespace in your project.clj: :main foo.bar
13:10raekthen add a (:gen-class) in the ns form of that namespace
13:11raekand then add a function called "-main" in the same namespace
13:11carksomething like this : https://gist.github.com/1341778
13:12TimMcgfredericks: nil
13:12tensorpuddinghow do i use lein to generate a .jar that i can use?
13:13TimMctensorpudding: lein jar
13:13raeklein uberjar
13:13TimMcor uberjar, really
13:16tensorpuddingdoes java have to give these horribly obtuse error messages every time
13:16TimMca-yup
13:17TimMcThat's Java. And Clojure is worse about it (but getting better.)
13:18tsallyis there any way to have a jar only clojar ?
13:18TimMctsally: "only clojar" <-- could not parse
13:18tsallyTimMc: I want to upload a library to clojars, but with the jar only
13:19tensorpuddingclojure would be more fun to use if the java part were less obvious
13:20tsallyI think clj-time does this where they upload joda here: http://clojars.org/joda-time
13:20tsallysimilarly, I'm wrapping a java library and want to follow the same style
13:21TimMctsally: I don't understand -- clojars takes jars, that's what it does.
13:23tsallyoh I see, so I can just a minimal pom.xml file
13:23TimMcraek: Is it possible to create an executable JAR without AOT of the bulk of one's code? I understand *something* needs to be precompiled for the jar to work... but maybe it could just be a bootstrapper.
13:24TimMctsally: Yeah, it doesn't take much. Just mimic what leiningen produces, I guess.
13:24TimMc(I see what you were aksing now.)
13:24tsallyTimMc: hehe sorry, I wasn't so clear
13:25tsallythanks for the help
13:28tsallyTimMc: for future reference, clojars wiki actually has exactly what I was wondering about https://github.com/ato/clojars-web/wiki/POM
14:20TimMcAll tests passed!
14:20TimMcTime to write more tests...
14:29dbushenkohi all!
14:29dbushenkowhere is the forme clojure.contrib.repl-utils?
14:29dbushenkoI really miss the function "show"...
14:33cemerickdbushenko: I never used show, but I think the clojure.reflect namespace provides a superset of it (pretty-printing the results may be up to you right now)
14:33dbushenkowow! thanks!
14:38dbushenkocemerick, I've just looket through clojure.reflect... could you advise me how I can see the methods of a java object?
14:46cemerick,(->> (reflect "") :members (filter :return-type) (map :name))
14:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: reflect in this context, compiling:(NO_SOURCE_PATH:0)>
14:47cemerick,(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))
14:47clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.reflect>
14:47cemerick(require 'clojure.reflect)
14:47cemerick,(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))
14:47clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.reflect>
14:47cemerick&(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))
14:47lazybotjava.lang.ClassNotFoundException: clojure.reflect
14:47cemerick&(require 'clojure.reflect)
14:47lazybot⇒ nil
14:47cemerick&(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))
14:47lazybot⇒ (valueOf regionMatches valueOf indexOf getBytes toUpperCase lastIndexOf contentEquals endsWith indexOf startsWith valueOf split valueOf indexOf valueOf replace replace toLowerCase getChars codePointBefore indexOf offsetByCodePoints contains hashCode compareTo toLow... https://gist.github.com/1341867
14:48cemerickdbushenko: ^^
14:48dbushenkothanks!!
14:48cemerickclojurebot ignores require now?
14:48cemerickdbushenko: there's also &(map #(.getName %) (.getMethods (class "")))
14:49llasramcemerick: I think you left off the initial ','?
14:49cemerickhosty, I guess
14:49cemerickllasram: so I did!
14:49cemerick,(require 'clojure.reflect)
14:49clojurebotnil
14:49llasramrequire all the namespaces!
14:50dbushenkocemerick, have tried that. This is just great!!
14:51cemerickdbushenko: read the docs now. You're on your own from here on out. ;-)
14:51dbushenko:-)
14:57tensorpuddingis there a recommended templating library in clojure?
15:02chewbrancatensorpudding: my personal preferences are https://github.com/weavejester/hiccup and https://github.com/cgrand/enlive
15:03tensorpuddingehh
15:03chewbrancatensorpudding: ?
15:03tensorpuddingi don't want to use clojure to write html
15:03chewbrancaahh
15:03chewbrancawell enlive is very interesting
15:03TimMctensorpudding: You don't exactly write it.
15:04chewbrancayou use clojure to select dom elements of existing html and use clojure to update them with the relevant data
15:04RaynesHiccup is closer to writing it -- enlive is more templateish.
15:04chewbrancabut I imagine there is also a mustache port in clojure
15:04ibdknoxthere is
15:04ibdknoxclostache or stencil
15:04ibdknoxwe use stencil
15:04ibdknoxit's worked nicely
15:04tensorpuddingenlive seems complicated
15:04TimMc"clostache" ugh
15:04ibdknoxit is, unfortunately
15:04ibdknoxTimMc: I know
15:05Raynesibdknox: We use clostache in spawn.
15:05chewbrancaenlive is definitely different, I think that's where a lot of the complications come from
15:05ibdknoxTimMc: one of the reasons I use stencil was because of that name ;)
15:05ibdknoxRaynes: yeah, I know, they're basically equivalent
15:05chewbrancadifferent goals though, if you're working with html and need to continue to work with only html then it can be very useful
15:05ibdknoxthere's also string template
15:06tensorpuddingi've not used mustache before but it seems close to expectations
15:06ibdknoxwhich is basically like the templating you get in other web stacks
15:06chewbrancamustache is alright, I typically don't use it aside from very basic things
15:07chewbrancamy issue with mustache is that its too basic, I like to have more tools available inside my templates than what mustache provides
15:08chewbrancaI mean, I know that's the point of mustache, I'm just not a fan
15:09ibdknoxwith lambdas you can basically do anything?
15:09ibdknoxthe cool thing is mixing lambdas with hiccup :D
15:11chewbrancalambdas work _ok_, they give you the absolute minimum required to be able to create html functions
15:12chewbrancathat doesn't mean they're fun to use for larger codebases
15:13chewbrancabecause when you start wanting to reuse these lambdas, they become more like functions, and you build up a helper system, in which case, why didn't you just use something with more functionality than only lambdas in the first place?
15:13ibdknoxthat argument doesn't really make sense to me
15:14ibdknoxwhat system is more powerful than being able to execute any arbitrary function?
15:14chewbrancayeah yeah its turing complete
15:14ibdknoxin any case though, I've never had any issues, but templating is always a very contentious subject :)
15:14ibdknoxI've used them all
15:14ibdknoxI like the concept of enlive, but I have an issue with its implementation
15:14chewbrancamy point is that you end up building a helper system because mustache maps your lambdas directly with your data
15:15chewbrancaso you end up reinventing the wheel
15:18bartjI have just downloaded cascalog
15:18bartjand after I do a "lein compile"
15:18bartjI do not know where the ".class" files are
15:19bartjie. they are not present in the classes folder
15:19ibdknoxthat .classes for what?
15:19bartjso when I am trying to get started with running the "playground"
15:19bartjie: (use 'cascalog.playground) (bootstrap)
15:20bartjI get the error: java.io.FileNotFoundException: Could not locate cascalog/playground__init.class or cascalog/playground.clj on classpath: (NO_SOURCE_FILE:0)
15:21bartjibdknox, to run cascalog
15:22ibdknoxwhen you say you downloaded cascalog, what do you mean?
15:22ibdknoxyou added it to your project.clj and ran lein deps?
15:23bartjno
15:23ibdknoxah
15:23ibdknoxthat's how you should do it
15:23bartjdownloaded a .zip from https://github.com/nathanmarz/cascalog
15:23ibdknoxok
15:23tensorpuddingthere's like a half dozen different jars for this package on clojars
15:24tensorpuddinghow the heck do i decide which to use
15:24TimMcno kidding
15:24bartjand then ran lein deps && lein compile && lein repl
15:24ibdknoxopen your project.clj and add [cascalog "1.8.3"]
15:24ibdknoxto your dependencies
15:24raekbartj: that would be how you did it before Leiningen came about
15:24ibdknoxthen run lein deps, lein repl
15:24raek(download zip and compile, that is)
15:24tensorpuddingi don't know what its qualified namespace is
15:24bartjoh
15:25tensorpuddingthat's why i was looking on clojars
15:25tensorpuddingi chose the one that ended up being just the name of the package
15:25bartjbut looking at the "Getting Started" section on https://github.com/nathanmarz/cascalog
15:25raektensorpudding: the namespace and maven group + artifact ID do not always match exactly
15:25bartjthe idea seems to be just to download the .zip file and follow the instructions there
15:25raektensorpudding: which library are you looking for?
15:25tensorpuddingenlive
15:27bartjraek, correct me if I am mistaken, but my project here *is* cascalog
15:27raekI personally find the clojars search function not so useful. I usually look up the group and artifact id in the project.clj on the project's github page
15:27raekand then look here: http://clojars.org/repo/
15:27raekfor the latest stable version
15:27tensorpudding(this is too complicated)
15:27bartjso, adding that to the dependencies doesn't make sense to me
15:27ibdknoxbartj: your project *uses* cascalog
15:28ibdknoxbartj: it's not cascalog itself
15:28bartjibdknox, hmm
15:28tensorpuddingwhat is the group and artifact i
15:28tensorpuddingd
15:28raekbartj: the most common way to play with a library is to create a project that has it as a dependency. running lein repl in the cascalog folder should work too, though
15:28Raynestensorpudding: The part before the / is the group id, the part after is the artifact id.
15:29tensorpuddingoh
15:29RaynesSo foo.bar/baz = group id foo.bar and artifact id baz.
15:29raekso, in this file https://github.com/cgrand/enlive/blob/master/project.clj
15:29tensorpuddingit just says enlive
15:29tensorpuddingso both of them are enlive?
15:29raekit just says "enlive". that means that both the group ID and the artifact ID is enlive
15:29tensorpuddingokay
15:29raek(this is probably documented in the lein tutorial somewhere)
15:29tensorpuddingso how do i deal with its other namespaces?
15:30raekso I would look here: http://clojars.org/repo/enlive/enlive/
15:30raekand decide to go with [enlive "1.0.0"]
15:30Raynesraek: http://clojars.org/enlive worksa
15:30Raynesworks*
15:30tensorpuddingi found it on clojars and put that in and got the deps
15:30raekok
15:30tensorpuddingbut now i need to figure out how to :use its namespaces
15:31raekthat should (ideally) be documented in the docs for the project
15:31tensorpuddingthe docs don't tell you that
15:31tensorpuddingdo i use it literally as it appears in the source?
15:31raekhttps://github.com/cgrand/enlive/wiki
15:31raekhere it says (:use net.cgrand.enlive-html)
15:32tensorpuddingtake that as yes
15:32TimMctensorpudding: Ideally, a projectwill tell you on its GitHub (or whatever) page 1) the group & artifact IDs, 2) the core namespaces to require.
15:32TimMcSome fail at that.
15:32cemerickibdknox: for the record, I think korma's color scheme is tops :-D
15:32raeka lot of projects fail to do convey 2)
15:32ibdknoxcemerick: best thing ever :D
15:32bartjibdknox, ok, I just add cascalog to the dependencies
15:32ibdknoxspeaking of..
15:33ibdknoxI'm thinking about a breaking change for Korma that I'd like some feedback on, if you're interested go to #korma for a minute
15:33cemerickibdknox: are the headlines just an image you produce using a tablet and a brush or something?
15:33bartjbut when I run a (bootstrap), I get the error: "java.lang.Exception: Unable to resolve symbol: flatten in this context (vars.clj:72)
15:33bartj"
15:33bartjmaybe the latest version is not stable enough ?
15:33bartjor maybe 1.8.2 is not stable enough
15:44ibdknoxcemerick: it's actually a font called "From where you are"
15:46cemerick~google "From where you are"
15:46clojurebotFirst, out of 524000 results is:
15:46clojurebotLifehouse - From Where You Are - YouTube
15:46clojurebothttp://www.youtube.com/watch?v=LBh7Muv0yac
15:46cemerickoh well :-)
15:46ibdknoxhaha\
15:46ibdknoxcemerick: http://www.dafont.com/from-where-you-are.font
15:46ibdknoxfont selection takes forever
15:46cemerickibdknox: yeah, got it
15:46cemerickNice pointer.
15:46cemerickThe diacriticals are cute. :-)
16:41bartjtrying out the examples in cascalog
16:41bartjI get this for any query: cascading.flow.FlowException: unhandled exception (NO_SOURCE_FILE:0)
16:42goodieboyanyone know of a library for striping tags from html?
16:43goodieboyhmm https://gist.github.com/393194
16:47bartjgoodieboy, is Perl ok ?
16:48bartjgoodieboy, http://stackoverflow.com/questions/832620/stripping-html-tags-in-java
16:50goodieboybartj: thanks, checking out that java question
16:51Raynestechnomancy: Ping
16:56technomancyRaynes: pong
16:56Raynestechnomancy: lein search "g:clj-github" <-- isn't it strange that the hyphen screws this up?
16:57RaynesI can search for stuff like g:clojail and get proper answers, but anything with a hyphen causes lucene to say wut.
16:57RaynesJust curious if you have any idea why.
16:57technomancyI think it needs a different query parser
16:58technomancyprobably just a matter of digging through the nexus indexer to see what they use
16:59technomancy"g:github AND g:clj" doesn't work probably because it's getting tokenized as a single term at indexing-time
17:00Raynesg:clj-github* works… for some reason.
17:00RaynesLucene is dark, dark magic.
17:01technomancyhm, probably forces their equivalent of a full table scan
19:16goodieboyanyone familiar with noir/compojure? Wondering if it can support faking the delete/put request methods by using a _method request param?
19:17ibdknoxgoodieboy: yes you can
19:18goodieboynice, are there docs on how to do this? Is it pretty straight forward?
19:18ibdknoxgoodieboy: https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L13
19:18ibdknoxbasically as long as you submit _method with your http request
19:18ibdknoxit will happen magically
19:19goodieboyibdknox: very nice, thanks!
19:23goodieboyibdknox: do you know if this works for noir as well? (defpage [:delete "/blah"] ... ?
19:24ibdknoxgoodieboy: yup
19:25goodieboyawesome
19:45tensorpuddingwhy did the latest clojure put things in weird places
19:45tensorpuddingsomeone remind me where doc is again
19:45ibdknoxhow do you start your repl?
19:45tensorpuddingnevermind, now i remember
19:45ibdknox(use' clojure.repl)
19:45ibdknoxer
19:45ibdknox(use 'clojure.repl)
20:07tensorpuddingthe dev cycle with clojure feels really slow
20:08scottjhow so?
20:08tensorpuddingwell
20:08tensorpuddingi write something which i don't know if it works
20:08tensorpuddingi do 'lein run'
20:08tensorpuddingit takes 20 seconds to build
20:08tensorpuddingthen spits out around 100 lines of inscrutable exception backtrace
20:09tensorpuddingi scroll my terminal to find the line i care about, fix the error, repeat
20:09scottjwhy not use a repl?
20:09tensorpuddingi'd need to restart the repl every time i changed my program
20:10tensorpuddingin any case, if the program is invalid the repl isn't going to work is it?
20:10scottjMost people develop clojure code by writing their code in a file and then sending expressions and definitions to the repl with a keystroke
20:12tensorpuddingwell
20:12tensorpuddingi'm writing a "webapp"
20:12tensorpuddingit's using compojure, ring and enlive
20:12tensorpuddingwhat part do i send to the repl
20:13amalloyall the parts :P
20:13scottjtensorpudding: emacs?
20:13tensorpuddingyes
20:14scottjtensorpudding: most people use C-c C-k to send the entire file
20:14tensorpuddingi just did
20:14tensorpuddingso what now?
20:15tensorpuddingit compiled i guess
20:15scottjanything that's not running that you want running should be send in similar way
20:15tensorpuddingi'm running my -main in the repl and it's not doing anything
20:15scottjsay you have start-server.clj you should send that
20:15tensorpuddingoh wait, it worked
20:16tensorpuddingit's just not sending output on the repl saying jetty was started
20:16tensorpuddingalso totally failed at finding my css
20:16tensorpuddingright, i commented out that line
20:17tensorpuddingokay
20:17tensorpuddingi killed it, tried to start it again but the old -main is still running
20:17tensorpuddingdo i have to restart slime
20:18scottjidk, normally you start the server once per dev session
20:18amalloytensorpudding: i usually (def j (start-jetty ...)), and then i can (.stop j)
20:22tensorpuddingrunning that, the repl doesn't return
20:23scottj(future (start-jetty...))
20:27tensorpuddinghow do i do aliased requires on the repl?
20:28chouser(require '[foo.bar :as b])
20:29amalloyscottj, tensorpudding: jetty takes a :join false option
20:29amalloyrunning it in a future won't work because you won't have a result object to .stop
20:30scottj:Join?
20:30scottj:join?
20:30amalloyah
20:33tensorpuddingi don't suppose someone familiar with compojure can explain compojure.route/resources
20:44scottjbtw another option if you're struggling to get your environment setup correctly is to use noir, have it create a project for you, and then run it in restart on save mode and it will give you fast nice exceptions.
21:10stevelewhello
21:11stevelewI have a supernoob question if there's not a discussion going on already.
21:12stevelewI'm trying to wrap my mind around thinking functionally
21:13cemerickstevelew: you should always ask, even if there's chaff flying :-)
21:13stevelewSo I'm reading about datatypes and protocols here: http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/
21:13stevelewwhich is quite good, but it looks an awful lot like OOP to me, with my noob mind
21:13stevelewtypes, with functions attached to the type
21:14stevelewso I'm missing something conceptually, I think.
21:15stevelewpartly, I think it's the fact that there's immutable state
21:15stevelewso any function call using a record would just return a new instance of the record
21:16cemerickFirst, OO generally implies stateful, mutable objects.
21:16stevelewright
21:16cemerickSecond, protocols allow you to define implementations for types you don't control.
21:16stevelewok
21:17stevelewmaybe that's it, the stateless part
21:17stevelewi'm so used to mutating state on an object via a method
21:17cemerickPeople usually get more excited about the second bit. :-)
21:17stevelewyeah I just watched stuart halloway's vimeo on protocols
21:17stevelewvery cool.
21:18stevelewi'm partly just trying to figure out how I'd implement records with a Customer, an Order, and a Product sort of idea
21:18cemerickThe implementations are also dynamic (i.e. you can change them at the REPL for all of your instances, assuming you're using extend et al. instead of in-line impls).
21:18stevelewso my mind is on records
21:19amalloystevelew: if you have an OO mindset you tend to jump to records for modeling your data even though they're not necessary
21:19cemerick(defrecord Customer [fname lname address customer-number])?
21:19amalloyclojure encourages the use of plain old hashmaps, and functions that operate on those maps
21:19cemerick(inc amalloy) ; though I'd say s/encourages/allows, but sure. :-)
21:19lazybot⇒ 1
21:20amalloylazybot: eh? when did your karma get reset?
21:20cemerickhappens every could of days, I think.
21:20Raynesamalloy: Well, it's kind of completely broken anyways.
21:20Raynes$karma amalloy
21:20lazybotamalloy has karma 0.
21:20stevelewi'm okay with using hashmaps. i love hashmaps
21:21Raynesamalloy: Feel free to commit something every once in a while. ;)
21:21cemerick(defn karma [handle] (if (= handle "amalloy") 0 (get-karma handle)))
21:22stevelewI'd seen a few things by Alex Miller blogging about how he's used records at his workplace
21:23amalloyman, i've looked into the karma plugin a number of times. can't repro the problem
21:24amalloystevelew: i've heard records described as an "advanced feature". not a bad way to think of them
21:24stevelewpart of it is thinking about how I'd introduce Clojure at my workplace. I'm not sure my coworkers would prefer to throw away all types and go with hashmaps.
21:24amalloyand of course advanced features are more fun to blog about...
21:39tensorpuddingcan you destructively change a map?
21:40cemerickdestructively?
21:40tensorpuddingsorry
21:40tensorpuddingi mean
21:40tensorpuddingi kinda want to have a global mutable map
21:41tensorpuddingand a function which changes its value
21:41tensorpuddingit's a temporary key-value store for my app
21:41cemericksounds like an atom with a map inside
21:41stevelewlike a cache?
21:42tensorpuddingi guess like a cache
21:57gfrederickscemerick: if you s/encourages/allows, then you're not really saying anything anymore ;-)
21:57gfredericksor at least nothing beyond "clojure has hashmaps"
21:57cemerickgfredericks: then my work here is done :-P
21:57cemerickwell, "you should use hash maps for modeling" vs. "you can use hash maps for modeling" is different
21:58cemerickjust a matter of emphasis
21:58gfredericksyou can use hash maps for modeling in java as well though
21:58cemerickech, not pleasantly nor idiomatically
21:58cemerickrecords have a variety of creature comforts, and provide a superset of hash maps in the process
21:59alexbaranoskyseems like hasmaps are where you usually start, and start using Records once you decide you need something they offer over and above simple hashmaps
21:59stevelewi like comfy
21:59gfredericksSo I guess by "allow" we mean "doesn't inhibit"
21:59cemericke.g. (defrecord Thing []) is better than a regular hash map at least insofar as you can wire it up to protocols
22:00cemerickalexbaranosky: yeah, that's the right path in practice
22:00gfrederickscemerick: sorry, I pay too much attention to words most of the time :)
22:01cemerickThough once you've gone down both roads far enough, you are better able to predict which entities should be records from the start.
22:01alexbaranoskyexperience is helpful that way
22:01alexbaranosky:)
22:01cemerickgfredericks: Likewise. Usually to the detriment of my readers and bystanders, though!
22:02gfredericksonce you (defrecord Thing []), before you know it you'll be (deftype ThingFactoryBean [])
22:03cemerickbeans and factory objects need not apply :-P
22:05zakwilsonhttps://github.com/zakwilson/imgcompare <-- I wrote some bad Clojure code that does a surprisingly good job identifying duplicate images given its lack of sophistication.
22:06cemerickooh, dangerous territory :-D
22:07stevelewFactoryBridgeAdapter
22:08cemerickzakwilson: do you have your test data online anywhere?
22:12tensorpuddingwhere is defproject defined?
22:12tensorpuddingwhy does it suddenly not work
22:13tensorpuddingit's like this thing is trying to come with inventive new ways of not working
22:13tensorpuddingclojure has been a really bad dev experience so far
22:14gfredericksdefproject is part of leiningen. I've never had to look for the definition, if there is such a thing. What did you change when it stopped working?
22:14alexbaranoskyyou having trouble with your project file?
22:16alexbaranoskyput your project.clj in a gist, and I'll look at it if you want
22:16zakwilsoncemerick: nope. I just played with a few random images on my hard drive and give it to somebody who had some more substantial test data from a paper he wrote.
22:16tensorpuddingit was saying that defproject was unknown
22:16tensorpuddingwhen i tried compiling my core.clj in emacs
22:17cemerickzakwilson: Which paper?
22:17cemericks/out/out to
22:18zakwilsoncemerick: no idea. All I know is it had to do with image similarity and search.
22:19tensorpuddingand it still can't find this function in a namespace that is mentioned in the api docs for this one package
22:19tensorpuddingi made sure i had the same release as the source
22:19tensorpuddingthe package loads fine
22:19tensorpuddingi can find other functions in the package, just not this one
22:21stevelewdefproject is part of leiningen, you probably won't find it in core.clj
22:23alexbaranoskyyou *definitely* won't find it in core.clj
22:24stevelewwhat file is trying to use defproject, tensor?
22:25alexbaranoskyI'm setting up Emacs on Ubuntu, using Emacs starter kit version 2
22:25alexbaranoskyhttp://technomancy.us/153
22:25alexbaranoskyI was under the impression that package.el came with Emacs now based on Phil's blog)
22:26alexbaranoskybut when I eval-buffer (require 'package) it says it can't load file: package
22:26alexbaranoskywhat am I missing?
22:27stevelewemacs 24 or 23?
22:28alexbaranoskylet me check
22:28stevelewpackage.el has been integrated into Emacs 24. If you use Emacs 23, please use this version instead.
22:28tensorpuddingcan the api docs for a package lie?
22:28stevelewhttp://technomancy.us/133
22:29alexbaranoskyyep, 23
22:29alexbaranoskyso I should get 24 explicitly I guess
22:29tensorpuddingi have ring 1.0.0-rc1 and i can tell for sure that ring.util.response/redirect-after-post doesn't exist
22:29tensorpuddingbut the docs mention it, the github source has it
22:30tensorpuddingmaybe it's so new that the version on clojars doesn't have it, even though it's the same version tag?
22:31alexbaranoskytensor: that's a possibility
22:31stevelewi don't know about ring, but sometimes api docs on a website are a little ahead or behind of an an rc1.
22:32tensorpuddingwait, dang
22:32tensorpuddingit's hard to tell
22:32stevelewis the github source the rc1 version or the trunk/in-development version?
22:32tensorpuddingthe commit in clojars is only two weeks old
22:33tensorpuddingthe trunk/in-development version has 1.0.0-RC1
22:33stevelewwas it added after rc1?
22:33tensorpuddingbut this thing is not in 0.3.6
22:33tensorpuddingi guess it must've been added within the last two weeks
22:33stevelew:(
22:33tensorpuddingeven though the version wasn't incremented
22:33alexbaranoskyeasy to find out
22:33tensorpuddingwell friggin fine
22:33tensorpuddingi'll just send a 302 instead of 303
22:34stevelewheh
22:34stevelewyou show 'em.
22:34alexbaranoskyclone the repo, and checkout a version from 2.5 weeks ago and see if the functions in there
22:35tensorpuddingthe 1.0.0-beta2 release is older than the one on clojars, but has the feature
22:36stevelewweird
22:36alexbaranoskysounds like you're in some sort of twighlight zone
22:36tensorpuddingthe commit that marks the change to RC1 has the change, i think
22:36tensorpuddingyes, it does
22:37stevelewis it just mislabeled on clojars?
22:37tensorpuddingmaybe
22:38tensorpuddingokay, now i find i am not deref-ing my atom correctly
22:38tensorpuddinghow do you use deref on an atom?
22:38alexbaranoskyany of you going to be at the Conj? I just got a wave of excitement :)
22:38alexbaranosky@ will do it
22:38stevelew@atom
22:38alexbaranosky@atom
22:39tensorpuddingoh
22:39tensorpuddingoh!
22:39tensorpudding...
22:39tensorpuddingi thought it meant literally @atom
22:39tensorpuddingnot @<atom name>
22:39alexbaranosky(deref atom) ;; also, right?
22:41stevelewhttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/deref
22:41stevelewlooks like it, alex.
22:41alexbaranoskyI think @ is the reader macro that expands out into `deref`
22:45brehaut,(read-string "@foo")
22:46clojurebot(clojure.core/deref foo)
22:50alexbaranoskyHow many people are going to be at the Conj in total? I wasn't there last year... wonder how big it will be
22:51tensorpuddingugh, this is too confusing
22:51tolstoyWhen you have a lazy-sequence, and then do a (doseq [name sequence] …) Does sequence get fully realized before the body is executed?
22:52tensorpuddinghow are you supposed to know what confusingly documented clojure code does without reading the source?
22:52stevelewexperiment?
22:52tensorpuddingnot cut out for untyped languages, i'm lost
22:52alexbaranoskyyou'll get used to it
22:53tensorpuddingit just seems like more work for little gain
22:53alexbaranoskyI know dorun will go through all of a sequence
22:53stevelewi've done tcl and python before trying clojure so it's not as foreign to me, tensor. it's a big change.
22:54tensorpuddingi've used python a good bit
22:54tensorpuddingit was less weird because it supported more introspection
22:55tensorpuddingpythons also a lot simpler
22:55alexbaranoskyI'm looking at the source for doseq right now
22:55alexbaranoskyits a bigggg macro
22:55stevelewif i didn't understand something in python, I'd try the REPL
22:55alexbaranoskyso give me a minute :)
22:55stevelewi used dir a ton when I was learning python
22:56tolstoyalexbaranosky: I guess I could set up a test, but it's breaks my flow. I was hoping it was common knowledge. ;)
22:56tensorpuddingi don't understand this function any better on the repl
22:56alexbaranoskyI don't think Python is simpler, but I guess I'm biased
22:56tensorpuddingbecause it returns some object of some kind which i don't know what it does
22:56stevelewyou may have to look at the source and break it down, then, tensor. :(
22:57amalloytolstoy: i don't think your question is clear
22:57tensorpuddingthe source is hard to read
22:57amalloyif you mean: is every element realized before the body is executed for any of them? then no
22:57cemericktensorpudding: FWIW, clojure provides just as much (if not more) introspection: it's just that Clojure functions aren't tied up into the values.
22:57tensorpuddingi can't figure out what it does because it filters through a complicated macro and i haven't gotten macros down
22:57tolstoyamalloy: Yes, that's was my question. Thanks!
22:58tensorpuddingi wanted to get by without having to touch macros for a while
22:58tolstoyamalloy: Ultimately, I'm trying to figure out if Mongo is really slow (as I'm using it) or if I'm just screwing up clojure a bit.
22:59alexbaranoskyyou can force the sequence to evaluate using dorun I think
22:59technomancytensorpudding: do you know about the slime inspector?
23:00tensorpuddingno
23:00technomancyC-c S-i will let you inspect any object
23:00technomancyincluding hyperlinks on the method names to see what classes they return
23:00tensorpuddingin what
23:00tensorpuddingin slime?
23:00alexbaranoskytolstoy: scratch that, I meant doall
23:00tensorpuddingit's not bound here
23:01technomancyright, you have to be using slime
23:01tensorpuddingi am
23:01tensorpuddingi see slime-inspect
23:01tensorpuddingbound to C-c I
23:02technomancysure, same thing
23:02technomancyshift+i is I
23:02tensorpuddingand what do i use this on
23:03tensorpuddingit doesn't work on macros
23:03technomancyany value you want to introspect
23:04technomancyif you want to see what code a macro generates you can use macroexpand
23:04technomancyC-c RET
23:04tensorpuddingokay, i did it on the result that confused me
23:04tensorpuddingthe output is...something
23:05alexbaranoskyanyone know how to run a .in file?
23:05tensorpuddingit doesn't provide me anything useful
23:05alexbaranoskylooks like I need to run configure.in to configure my Emacs download
23:05tensorpuddingyou need to run autoconf
23:06alexbaranoskythanks
23:06tensorpuddingactually, emacs?
23:06tensorpuddingyou run autogen.sh
23:06tensorpuddingwhich does autoconf plus other things
23:07technomancycemerick: http://www.cul.de/images/autotoolscg.jpg
23:07amalloytechnomancy: wow slime inspector is awesome
23:09amalloytechnomancy: how do i go "back" after drilling down into some field or method?
23:10amalloyah, found the slime-inspector keymap. apparently it's L
23:10technomancyamalloy: not sure you can. seems like an odd omission
23:12tensorpuddingdang
23:13tensorpuddingdo i have to jack in with swank every time i change deps
23:13amalloytensorpudding: the jvm doesn't like adding dependencies at runtime, so mostly you can't do it (but ask cemerick about pomegranate)
23:14tensorpuddingi want to know how to override the way compojure handles http responses
23:14tensorpuddingso that i can send a 302 for redirect
23:15amalloytensorpudding: why would you override anything? just return {:status 302 :headers {"Location" foo}}, right?
23:15tensorpuddingwell
23:15tensorpuddingthe way that defroutes works, i don't know how to do that
23:16amalloyjust return that map instead of a string or html thing
23:16tensorpuddingthe examples, they all use macros which takes a route
23:16tensorpuddingthat's what i'm doing
23:16tensorpuddingi had absolutely no idea if it was the right thing to do
23:16amalloyit's really that simple
23:17tensorpuddingthe docs muddied the matter, and the source was unfollowable
23:17tensorpuddingand in any event, it doesn't actually work
23:17tensorpuddingmy redirect didn't happen
23:17amalloy~bug report
23:17clojurebotA bug report has three parts: What you did; what you expected to happen; what happened instead. If any of those three are missing, it is awfully hard to help you.
23:18tensorpuddingwell, from the point of view of the browser, it just loaded forever
23:20amalloymy objection is that i haven't heard what you actually did. i suggested you do X, which works, but you say it didn't work. so without seeing your code i can't know how what you actually did differs from X
23:22ADWongHi guys, I'm playing around with clojure and I'm a little stuck trying to get specific values from a data structure I have. Could someone guide me as to how I would pull the value 5 from the following structure: [{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]? Thanks!
23:22tensorpuddingmaybe my html form is doing the wrong thing
23:22tensorpuddingbut if it were sending a POST with the wrong information why is it taking forever
23:22tensorpuddingmaybe it's timing out trying to deref the atom? i don't know why it'd do that
23:23tolstoyADWong: Something like (:val (nth thing 1))?
23:23tolstoyOr (:val (second thing))?
23:24amalloy&(get-in [{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}] [1 :val])
23:24lazybotjava.lang.RuntimeException: Unable to resolve symbol: dog in this context
23:24amalloy&(get-in '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}] [1 :val])
23:24lazybot⇒ 5
23:24tolstoyOh, yeah, that *-in stuff is really nice.
23:25ADWongOh sorry. I guess I wasn't specific enough. Let's just say i had a requirement that the :attrs needs to be b and I want the corresponding :val.
23:26amalloy&(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (keep (comp #{'b} :attrs) data))))
23:26lazybot⇒ nil
23:26stevelewyou're using ring, tensor?
23:26tensorpuddingcompojure and ring
23:26amalloy&(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (first (keep (comp #{'b} :attrs) data)))))
23:26lazybot⇒ nil
23:26amalloydangit
23:26stevelewyeah that makes no sense for it to hang like that
23:26stevelewbut i know very little about compojure & ring
23:27tensorpuddingi have no idea what it's hanging on
23:27amalloy&(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (first (filter (comp #{'b} :attrs) data))))
23:27lazybot⇒ 5
23:27stevelewin python I'd start adding prints in the django source
23:28amalloyADWong: ^
23:29ADWongWow. I need to play with slime for a bit to see how that actually works. Thanks!
23:29tensorpuddingi had a lot less trouble getting django to do what i wanted, last time i tried it
23:29tensorpuddingbut django is pretty heavy
23:31stevelewyeah it only happened once. i don't remember what it was
23:31stevelewit ended up being my fault, I'm sure.
23:33amalloyhah, that's how you can tell a real developer. "tool X didn't work, and i forget why, but it was definitely my fault"
23:34stevelewi remember in college, my prof said, "no matter what you think, the C++ compiler is not broken"
23:34stevelewno one even asked it, it was just a warning ahead of time to everyone in class
23:34amalloywell. it performs according to its specs. but the spec is pretty broken
23:35stevelewyeah, he was just trying to let us know that our code was going to be buggier than the compiler.
23:35amalloyindeed
23:35tensorpuddingoh, good
23:36tensorpuddingi found the issue
23:36stevelewnow i'm curious, tensor
23:36tensorpuddingturns out that keyword doesn't work on ints?
23:36tensorpuddingexcept the atom either isn't getting updated or my retrieval functions aren't working
23:37tensorpuddingwell, it can't be the latter since it works fine for the initial values
23:37tensorpuddingoh
23:37tensorpuddingit's probably that my POST request doesn't have the right names
23:37tensorpuddingor something
23:37stevelewthe keys?
23:37stevelewin the POST?
23:38tensorpuddingyes
23:38stevelewi've done that before
23:38amalloytbh i was a bit shocked when i found out that ##(keyword 4) doesn't work
23:38lazybot⇒ nil
23:38tensorpudding(POST "/new" [title body] (handler title body))
23:39stevelewone time the key was expecting "physican" instead of physician
23:39stevelewtook me forever to find that out
23:39tensorpuddingi had assumed that it binds title and body to the values of the keys of the same name in the http request
23:39stevelewwth is a pysican
23:40amalloystevelew: i like how you made it even worse by spelling it three different ways in your story
23:41stevelewlol
23:41stevelewphysican
23:41stevelewi stared at it, even. and decided it was right.
23:41stevelewbefore i pressed enter.
23:41tolstoyDid you s/physician/doc/ after a while?
23:41stevelewlol
23:41tensorpuddinghow can i make my browser send a post request
23:41stevelewjquery?
23:42stevelewthat would make sense, tolstoy
23:42tensorpuddingi don't mean programmatically
23:42tensorpuddingi want to test my webapp
23:42stevelewcreate a test form?
23:42tensorpuddingi have a form
23:42tensorpuddingi can't figure out if it's working
23:42tolstoyI worked on something a long time ago and use "proctologist" instead of "proctorship" because "proctorship" is such an awkward word to say.
23:43cemerickBut "proctologist" isn't?
23:43tolstoySome sort of medical records things. "How many proctologists does Dr Smith have?"
23:44tensorpudding<form method="post" id="form" action=""><input type="text" name="title"/><input type="text" name="body"/><input type="submit" value="Post"/></form>
23:44tensorpuddingthat's what i wrote
23:44stevelewyou need something in the action i suppose
23:44tensorpuddingwhat would go there?
23:45tensorpuddingi assumed the submit handled it
23:45tensorpuddingthe html docs suggested such a thing
23:45stevelewdoes compojure or ring have something to register which urls work?
23:45stevelewoh hmmm
23:46amalloyi'm with cemerick here. in what domain is proctologist a viable substitute for proctorship?
23:46tensorpuddingit's running my handler
23:46tensorpuddingit's just got the keys as empty
23:46tensorpuddingfor some reason
23:47tensorpuddingi can only guess the keys are misnamed
23:47tolstoyamalloy: Absolutely none. I think that's why the medical-record ladies were highly amused.
23:47stevelewheh
23:47stevelewso you have title, body..
23:47tolstoyamalloy: I though they were two versions of the same word.
23:47stevelewwhich in theory would correspond to a map with :title and :body keys
23:48stevelewin the handler
23:48tolstoySome people say orien-TAY-ted, and others say ori-EN-ted. All around really stupid of me. ;)
23:49amalloytensorpudding: do you have a middleware like wrap-params installed? i don't htink ring does that, and there are compojure starting points that don't include that
23:50tensorpuddingno?
23:50tensorpuddingcompojure didn't mention it
23:51ibdknoxwhat's the issue?
23:51stevelewCompojure provides a “params” hash-map that has the parameters of the servlet, which we will pass to a “login” controller
23:51tensorpuddingmy html form sends a post request, which my app handles
23:52tensorpuddingit seems to handle fine except the keys that i passed to the handler are empty
23:52steveleware you getting a params map, tensor?
23:52amalloyibdknox: bug: accidentally used compojure instead of noir
23:52tensorpuddinga what?
23:52ibdknoxamalloy: sounds like it.
23:52stevelewa variable named "params"
23:52stevelewcoming into the handler
23:52tensorpuddingno
23:53tensorpuddingwhy is there so many libraries for clojure that all do similar things
23:53stevelewthis guy has a form example
23:53stevelewhttp://justin.harmonize.fm/index.php/tag/compojure/
23:53tensorpuddingso that i can always choose the one that people hate
23:53stevelewwith a login handler
23:53ibdknoxtensorpudding: no one hates compojure
23:53amalloytensorpudding: compojure is great though
23:53tensorpuddingit's not a session
23:53stevelew"You have chosen ... unwisely"
23:53amalloyit's just ibdknox wrote noir
23:53amalloyand you sound like the sort of guy who would prefer noir
23:53ibdknoxwhich is actually built on top of compojure :)
23:54stevelewwhat does your handler function take as paramters?
23:54tensorpuddingi assume that since those posts are from 2009 they have no relevancy to today
23:54tensorpuddingsince everything else i read from that time period recently was totally, completely wrong
23:54stevelewhmm sorry. didn't see the 2009.
23:54tensorpuddingyikes
23:54tensorpuddingnoir built on compojure built on ring
23:54tensorpuddingthat's not enough layers
23:54stevelewblue pill
23:54ibdknoxhaha
23:55ibdknoxtensorpudding: those are very small libraries
23:55tensorpuddingnot small enough for me to understand them
23:55ibdknoxtensorpudding: the point of them was actually that they *could* be built on top of
23:55ibdknoxtensorpudding: well, those are fairly low level
23:55ibdknoxtensorpudding: and not as well documented as they could be
23:55tensorpuddingi just don't see why what i'm doing has an issue
23:55ibdknoxtensorpudding: so let me help then. Can you put a gist up of your code?
23:56tensorpuddingseveral files at the moment
23:56tensorpuddingi'm not sure it's not the fault of my templates either
23:56tensorpuddingwell, the post page isn't templated
23:56ibdknoxall I need to see is your defroutes and your handler function
23:59ibdknoxlol
23:59ibdknoxtexnomancy?