#clojure log - Nov 05 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:01 leo2007: something weird happened. after quitting swank-closure, port 4005 is still occupied and preventing swank-clojure from listening on that port again.

0:01 ideas?

0:01 ibdknox: amalloy: can anything execute as a result of doing read-string?

0:02 scottj: leo2007: how did you start swank and how did you quit it?

0:02 leo2007: scottj: I run the swank-clojure script and C-c to quit it

0:02 scottj: swank-clojure script?

0:03 leo2007: scottj: http://paste.pound-python.org/show/14726

0:03 alandipert: ibdknox, binding *read-eval* to false turns off EvalReader if that answers your question

0:03 scottj: leo2007: windows?

0:03 leo2007: scottj: osx

0:04 scottj: leo2007: why not lein swank?

0:04 ibdknox: alandipert: basically I want a safe way to read a datastructure

0:04 leo2007: scottj: probably because I did swank-clojure first.

0:04 alandipert: ibdknox, ok yeah, do *read-eval* false

0:04 ibdknox: alandipert: awesome, thanks

0:04 leo2007: anyway, how to find out what's listening on port 4005 and kill it.

0:05 amalloy: &(inc #=(inc 1))

0:05 lazybot: java.lang.IllegalStateException: clojure.lang.LispReader$ReaderException: EvalReader not allowed when *read-eval* is false.

0:05 scottj: leo2007: ps look for java with classpath including swank and kill it

0:05 amalloy: leo2007: lsof

0:06 tensorpudding: awesome, grabbing clojure-contrib fails

0:06 leo2007: amalloy: I don't know how to use lsof

0:07 lsof -l

0:07 ?

0:07 scottj: tensorpudding: using clojure 1.3? clojure-contrib is split up

0:07 tensorpudding: i'm using 1.2

0:07 i think

0:07 1.2.1

0:07 amalloy: lsof -i:4005

0:08 leo2007: that returns nil

0:08 tensorpudding: anyway

0:08 leo2007: but I can ping localhost:4005

0:08 tensorpudding: it's a bunch of errors with Maven or something

0:09 does clojure-contrib 1.2.1 not exist?

0:09 is it a wrong version?

0:09 amalloy: leo2007: you can...ping it? what does that even mean? i'm sure there's no pingserver listening on port 4005

0:10 mdeboard: ibdknox: 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)

0:10 amalloy: (and i *think* pings are at the IP level, not the TCP/UDP level, so they don't even have a port at all)

0:10 goodieboy: how can I get the k var to execute here? (let [k '(prn "hello")] `~k)

0:10 leo2007: amalloy: http://paste.pound-python.org/show/14728

0:11 amalloy: goodieboy: odds are good that's not what you want to do

0:11 ibdknox: mdeboard: 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

0:11 mdeboard: Ok thanks stud

0:11 ibdknox: mdeboard: the way I tend to organize things is in the more traditional MVC sense

0:11 mdeboard: Guess I have some learning to do then.

0:11 ibdknox: mdeboard: where the view calls the model directly

0:12 amalloy: leo2007: 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

0:12 but ping only operates at a host level. there's no way you can ping a specific port

0:12 mdeboard: ibdknox: I don't have any experience with MVC, so this is all new territory for me

0:12 leo2007: amalloy: you owe me a dollar.

0:13 amalloy: http://paste.pound-python.org/show/14729

0:13 tensorpudding: where can i see what versions of clojure-contrib are available?

0:13 where doe lein dep get its jars from?

0:14 mdeboard: tensorpudding: clojars & maven

0:14 amalloy: huh. that's pretty damn weird. you can have a dollar at the conj. but what OS and/or some crazy version of ping?

0:14 tensorpudding: is clojure-contrib at clojars or maven

0:14 i can't find it at clojars

0:14 mdeboard: tensorpudding: clojure-contrib doesn't exist anymore

0:14 tensorpudding: okay

0:14 mdeboard: tensorpudding: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

0:15 tensorpudding: which versions does this apply to

0:15 i'm using 1.2.1

0:15 leo2007: amalloy: I am on osx 10.6.8.

0:16 amalloy: ANYway 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

0:17 tensorpudding: god, this tutorial is a dud

0:17 it seems to be referencing plenty of things that don't exist

0:17 jli: does | mean something special in clojure? I was hoping to use it as the name of thrush

0:18 amalloy: jli: no, but i think it also isn't guaranteed to be a valid symbol character in the future

0:19 tensorpudding: trying to require my namespace gives me an error on line 1

0:19 "Parameter declaration set should be a vector"

0:19 leo2007: amalloy: but the point is that swank cannot start on port 4005 any more.

0:19 tensorpudding: did ns get changed somehow

0:20 amalloy: &(fn x (set) (inc set))

0:20 lazybot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

0:20 amalloy: hm. is it only defn that does that?

0:20 tensorpudding: the boilerplate generated by lein doesn't even work

0:21 leo2007: I have "user=> Connection opened on null port 4005." printed on the terminal.

0:21 jli: amalloy: hum, thanks

0:22 amalloy: leo2007: i dunno, man

0:22 jli: leo2007: does "netstat -anp | grep 4005" say something about TIME_WAIT?

0:23 leo2007: somehow, ping localhost:4005 is resolved to the ip address 202.106.195.30

0:23 If I pass 192.168.0.101 to slime, it can connect.

0:25 jli: it says "tcp4 0 0 192.168.0.101.4005 192.168.0.101.55761 TIME_WAIT"

0:25 -p is not supported by netstat on osx

0:26 so that is the result of netstat -an | grep 4005

0:26 jli: yeah, that's fine

0:26 leo2007: what is fine?

0:26 jli: netstat -an. -p just prints the program name.

0:27 leo2007: jli: now netstat -an|grep 4005 prints nothing

0:27 jli: so 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.

0:27 leo2007: okay, so swank should be able to start as normal again

0:27 amalloy: leo2007: 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?

0:28 leo2007: amalloy: looks like so

0:28 goodieboy: aye, why doesn't this print? https://gist.github.com/1341105

0:30 leo2007: jli: not really, localhost:4005 is resolved to an strange address

0:31 jli: what?

0:31 clojurebot: what is cells

0:32 jli: leo2007: swank-clojure should be able to start normally again.

0:32 scottj: goodieboy: I think you want (~@s#) or better ~s#

0:33 goodieboy: what you have no the let has a body of prn and "test", the last of which gets returned

0:33 amalloy: scottj: not really good enough

0:33 leo2007: jli: you are right. I can start swank-clojure except now localhost + 4005 points to somewhere else.

0:33 amalloy: you need the let to be outside of the syntax-quote

0:33 (defmacro run [f] (next f)) ;; this is really it

0:35 or if you want to be really verbose about it, (defmacro run [f] (let [s (rest f)] s))

0:36 goodieboy: scottj amalloy: thanks! I don't understand, but at least I know what I'm trying to do is possible :)

0:37 amalloy: goodieboy: 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?

0:37 the latter: you don't want asdf to ever appear in code that clojure tries to run

0:38 goodieboy: yeah i see

0:38 makes sense

0:38 toxmeister: hello 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

0:40 mdeboard: toxmeister: Would it be way too snarky to say "use emacs or vim"?

0:41 brehaut: mdeboard: yes

0:41 mdeboard: Ok, I won't then

0:44 goodieboy: so 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?

0:45 brehaut: goodieboy: yes of course

0:45 toxmeister: mdeboard: 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…

0:45 mdeboard: goodieboy: Are you building a Solr interface?

0:46 goodieboy: mdeboard: well, just experimenting yes

0:46 jli: leo2007: man, why is your computer resolving localhost:4005 into an IP? do you have something weird in your /etc/hosts?

0:46 brehaut: goodieboy: i cant imagine how even using eval would help

0:46 mdeboard: goodieboy: Nice, nice.

0:47 leo2007: jli: I have never touched that file. The whole thing is http://paste.pound-python.org/show/14730

0:47 goodieboy: brehaut: well, i've been using clojure.walk to transform the input vector/keywords into function calls/lists, then calling eval

0:48 amalloy: brehaut: well if i implemented my code as (constantly (quote (quote "name:(test OR this)"))) an eval would be a big help

0:48 goodieboy: it works, but something tells me this is not "normal" clojure

0:48 brehaut: amalloy: lol :P

0:49 amalloy: goodieboy: agreed, it's nuts

0:49 alandipert: sweet that it's possible, though :-)

0:50 mdeboard: goodieboy: You might actually take a cue from Hiccup here. `[:name [:or '("value1" "value2")]]` or something

0:50 goodieboy: I've been doing a lot of work with Solr the past 6 weeks or so, so this caught my eye

0:52 leo2007: why doesn't this (#(%1 %2) Math/sin 3e2) work?

0:52 jli: leo2007: oh, maybe you're using some cruddy DNS server that "resolves" non-hostnames to some wacky thing

0:52 goodieboy: mdeboard: nice, solr is great

0:52 alandipert: goodieboy, have you seen http://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure?

0:52 amalloy: leo2007: Math/sin isn't a function

0:52 goodieboy: alandipert: yeah, maybe time to re-read :)

0:52 amalloy: it's a method

0:53 jli: leo2007: what's your /etc/resolv.conf ?

0:53 leo2007: jli: nameserver 192.168.0.1

0:54 jli: leo2007: are you in China?

0:54 leo2007: jli: yes

0:54 alandipert: goodieboy, beginning of clojurescript compiler also good. multimethods are where the money is

0:54 goodieboy: alandipert: oh you mean the source for clojurescript?

0:55 alandipert: goodieboy, yes - https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj in particular

0:56 leo2007: jli: China's internet is pretty shitty.

0:56 jli: leo2007: heh, yeah. so yeah, your DNS server is resolving "localhost:4005" to the IP of some silly portal thing

0:57 goodieboy: alandipert: awesome thanks. i'll have a look

0:57 jli: if you go to the IP in a web browser, you'll see

0:57 alandipert: goodieboy, np. it's dense reading but the overall layout is what you may consider emulating

0:57 jli: (that's my best guess, at least)

0:58 leo2007: jli: but it worked before I ran into this problem.

0:58 alandipert: and omg, the conj is next week

0:58 leo2007: amalloy: how to replace Math/sin so that the example works?

1:00 amalloy: http://stackoverflow.com/questions/5726334/passing-functions-as-arguments-in-clojure/5726449#5726449

1:01 jli: leo2007: what?

1:01 what worked? what problem?

1:02 leo2007: jli: a silly example (#(%1 %2) Math/sin 3e2)

1:03 jli: huh? I'm.. talking about DNS

1:04 mdeboard: amalloy: Do you know of/follow any particular style conventions in your code? e.g. line length, white space, order of imports, etc.

1:04 er, order of requires, etc.

1:04 leo2007: amalloy: thanks

1:05 amalloy: mdeboard: well, the lisp/scheme indentation rules. i mostly keep lines under 80 chars, but the office guideline is 100

1:05 brehaut: mdeboard: related: http://mumble.net/~campbell/scheme/style.txt

1:06 amalloy: personally 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

1:06 scottj: I thought stu created a clojure style guidelines

1:06 mdeboard: brehaut: perfect, thank you.

1:07 brehaut: mdeboard: not perfect ;) its a scheme reference

1:07 mdeboard: brehaut: Perfect in its fit to what I was looking for

1:08 brehaut: mdeboard: 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)

1:08 mdeboard: I see

1:09 scottj: http://dev.clojure.org/display/design/Library+Coding+Standards but doesn't mention whitespace

1:10 amalloy: brehaut: prefer refer to use? that doesn't make sense. i could see preferring require to use, though i don't really agree

1:12 brehaut: amalloy: man what am i saying. require

1:12 definitely require not refer

1:13 amalloy: it might be my python background that makes me prefer require

1:13 scottj: brehaut: en/don't en/you en/get en/tired en/of en/prefixing en/your en/functions?

1:13 brehaut: scottj: no

1:14 scottj: and you have to remember whether that function is in page-helpers or form-helpers or core

1:14 brehaut: i dont use hiccup, so no, i dont have to ;)

1:14 amalloy: scottj: i was going to complain about that link to library coding style, but it's much more helpful than i remember it being

1:15 mdeboard: brehaut: 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

1:18 brehaut: mdeboard: you can require clojure modules as shorter names as needed to. i dont understand your point

1:18 mdeboard: brehaut: Didn't have one :)

1:20 scottj: advantages 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

1:31 jli: usually I just suck it up and list things in :only

1:31 future you will thank you

1:47 amalloy: scottj: fwiw (2) is rarely an issue for me

1:48 and you can solve (3) with a :refer/:rename, but i agree usually :require/:as is better

1:55 robear: i have a clojurescript question. anyone online that can help?

1:55 ibdknox: ~anyone

1:55 clojurebot: Just 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 ..."

1:59 robear: i 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

2:00 ibdknox: robear: I transform them into a collection

2:00 robear: btw, you might want to check out pinot http://github.com/ibdknox/pinot

2:01 Shinka: Has anyone here used Clojure for computational biology on some cloud service ? I'm curious about the performance you could achieve.

2:05 robear: ibdknox: thanks. i see what you did with nodelist->col in dom.cljs. thanks a lot!

2:11 mdeboard: ibdknox: Does (defpartial) support a docstring

2:12 ibdknox: mdeboard: unfortunately no, though that's likely something I should fix

2:12 mdeboard: ibdknox: k

2:14 ibdknox: mdeboard: though to be fair, your partials really shouldn't do anything complicated, so doc strings are mostly unnecessary.

2:15 mdeboard: ibdknox: Well, it's mostly as a reminder to myself :P

2:15 ibdknox: yeah, I buy that

2:16 unfortunately dealing with args like that is really annoying lol

2:19 leo2007: why doesn't this work (-> 3.0 #(Math/sin %) #(Math/cos %)) ?

2:23 brehaut: ,(macroexpand '(-> 3.0 #(Math/sin %) #(Math/cos %)))

2:23 clojurebot: (fn* (clojure.core/-> 3.0 (fn* [p1__27#] (Math/sin p1__27#))) [p1__28#] (Math/cos p1__28#))

2:23 ibdknox: ,(-> 3.0 Math/sin Math/cos)

2:23 clojurebot: 0.9900590857598653

2:26 ambrosebs: ,(macroexpand '(-> 3.0 Math/sin Math/cos))

2:26 clojurebot: (. Math cos (clojure.core/-> 3.0 Math/sin))

2:27 leo2007: I still don't where the problem is.

2:28 ambrosebs: looks like rest of the -> is being put as the first argument as fn*

2:28 which should be an argument list

2:28 vector

2:38 mdeboard: ibdknox: Is this gross/stupid? http://p.mattdeboard.net/gross_or_not.html

2:40 overly complex, etc.

2:41 brehaut: mdeboard: multimethods, just saying

2:42 mdeboard: brehaut: Yeah I started down that path but realized it's a simple enough case that cond suffices without losing extensibility

2:43 BTW if anyone's--

2:43 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))]))

2:44 mdeboard: What the hell? technomancy wrote scpaste?

2:44 brehaut: also, campitals in keywords is surprising

2:44 mdeboard: technomancy wrote _everything_

2:44 s/campitals/capitals/

2:44 mdeboard: brehaut: I was following the example here http://clojure.org/runtime_polymorphism

2:44 brehaut: mdeboard: huh

2:45 i guess its using it to indicate 'typeness'

2:45 but :Type and :Filename is still weird i think

2:46 mdeboard: Yeah.

2:46 Sorry I'm still kind of shocked technomancy wrote scpaste.

2:46 singularity chat

2:47 brehaut: seriously, everything

2:49 llasram: He start a project named "everything," just to make that literally true

2:49 should, even

3:02 mdeboard: Oh yeah? Well... https://github.com/technomancy/scpaste/pull/1/files

3:04 02: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))]))

3:04 That strays into "unreadable" territory for me, as a newb. Decreased maintainability etc., etc., etc.

3:05 Just for me, I mean. I'll optimize that later.

3:07 amalloy: ibdknox: allowing docstrings is a pain, you're saying?

3:08 ibdknox: parsing optional args not at the end is, yeah

3:08 amalloy: clojure.contrib.def/name-with-attributes handled that reasonably well, though i don't think it's been ported to 1.3 formally

3:09 though, as with anything i like, i copied it into useful

3:09 ibdknox: :)

3:09 mdeboard: god I haven't stayed up hacking like this for months

3:09 tight

3:10 amalloy: eg, (name-with-attributes foo "test" stuff more-stuff) returns [(with-meta foo {:doc "test"}), [stuff more-stuff]]

3:11 ibdknox: amalloy: cool, I'll take a look at that

3:11 I definitely feel like there's some relatively general solution to the problem

3:12 mdeboard: brehaut: Fine you win, your way is better :)

3:12 amalloy: ibdknox: aha. it made it into tools.macro

3:12 ibdknox: oo

3:12 amalloy: which useful already depends on, so i can just drop the copied impl

3:12 ibdknox: :)

3:12 mdeboard: OvO

3:19 amalloy: ibdknox: well! thanks for prodding me into looking at that again

3:19 ibdknox: amalloy: haha thanks for the solution :)

3:20 mdeboard: Damn, most productive/fun Friday hackathon I've had in like... 3 months probably.

3:20 ibdknox: mdeboard: cool

3:20 * mdeboard is a total Noir fanboy now.

3:20 ibdknox: who isn't really?

3:20 mdeboard: Clueless fanboy

3:20 as all fanboys are

3:20 ibdknox: aside from amalloy, who I now have to be nice to since he found name-with-attributes for me

3:21 mdeboard: nothing worse than "Django is so amazing" fanboys who won't shut up

3:21 amalloy: indeed, i am inexplicably recalcitrant

3:22 mdeboard: stultifyingly, stupefyingly recidivist

3:22 ibdknox: amalloy: one day though, you'll wake up and all your sites will be noir :p

3:22 amalloy: i don't think it's actually *criminal* to not use noir

3:22 mdeboard: amalloy: lol

3:23 amalloy: 4clojure is written on top of Compojure? I can't remember and too tired/lazy to look

3:23 amalloy: though presumably there is some legislation on it, being held up by a filibuster at this very moment

3:23 mdeboard: compojure and hiccup, yeah

3:23 and ring, of course

3:23 mdeboard: Of course

3:23 * mdeboard doesn't know what Ring does, exactly.

3:23 ibdknox: lol

3:23 translates http into maps

3:23 is the short version

3:43 callen: mdeboard: HTTP middleware.

3:43 mdeboard: what ibdknox said.

3:44 mdeboard: 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.

3:46 mdeboard: Ahh

3:46 ibdknox: our 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

3:47 callen: mdeboard: in general, it's best to avoid being one of those cockbites that has to have his own implementation of everything.

3:47 mdeboard: callen: Hahaha, If I ever find myself implementing an HTTP API I'll stab myself.

3:48 ibdknox: yeah, it's not really fun

3:49 mdeboard: It's just one of those things that sets off my spidey sense, the "You are doing this way, way wrong" feeling.

3:53 what a retarded thing to say, bed time.

3:56 callen: that's the most self-aware thing I've ever seen said on IRC

3:56 wish more people were like that.

3:57 brehaut: ibdknox: luckily noir has solid docs

4:18 leo2007: #'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'

4:30 fliebel: good morning :) Do we have any new reader macros today?

4:33 leo2007: why isn't http://clojuredocs.org/ mentioned in the title any more?

4:33 fliebel: amalloy: are you still awake? How fast is the randnth?

4:34 ibdknox: fliebel: that would depend entirely on the structure

4:34 on a vector? basically as fast as generating a random int

4:34 amalloy: fliebel: 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

4:34 ibdknox: picking up an old conversation

4:35 ibdknox: amalloy: ah, not rand-nth then

4:35 fliebel: ah, no

4:35 * ibdknox goes back to his corner :p

4:36 fliebel: amalloy: So is there a fork of my gist that includes this? Because now I need to beat you of course.

4:36 amalloy: fliebel: i don't think i actually pushed it back to github

4:37 but you can take my gist and add it to yours

4:37 fliebel: amalloy: I did a really nice one with Forth :) wasn't lazy though :(

4:39 I can'y find my own gist

4:39 ah https://gist.github.com/805747

4:49 leo2007: is clojure in action published

4:54 'joy of clojure' is sold 43 USD here in China.

4:55 a discounted price.

6:02 floatboth: hi

6:05 how 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?

6:13 mrh0057: I don't know of a built in function to do that except for java reflection api

6:14 floatboth: http://download.oracle.com/javase/tutorial/reflect/

6:44 anttih: I'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.

6:44 what am I missing?

6:45 what happens is that the repl just hangs there

7:25 asmala: I'm having some trouble with "lein jack-in" (and, by extension, M-x clojure-jack-in in Emacs)

7:26 If I run "lein jack-in" in a nested directory (say src/music) inside my lein project, I get "Couldn't find project.clj […]"

7:27 I 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)

7:29 Is it possible to call jack-in from a directory other than the project root?

7:48 "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:03 edw: A Compojure Q: Is there a way to get the method when using the ANY routes macro?

11:13 tensorpudding: printing in clojure thoroughly and completely confuses me

11:14 there's a ton of different functions but i don't think any do what i want

11:15 edw: Yeah, there are a few seemingly arbitrarily named functions to memorize.

11:15 What do you want to do?

11:15 tensorpudding: i want something which works like sprintf

11:15 raek: that would be format

11:15 edw: See FORMAT.

11:15 raek: ,(format "%x" 255)

11:15 clojurebot: "ff"

11:16 edw: More like asprintf...

11:17 tensorpudding: ,(let [name "Clojure"] (format "Hello, %s" name))

11:17 clojurebot: "Hello, Clojure"

11:17 tensorpudding: but it doesn't seem to do what i want

11:17 edw: What do you want it to do?

11:18 tensorpudding: nevermind, it works

11:18 i had a typo

11:18 is there a way to read function docstrings in the repl

11:18 edw: (use 'clojure.repl) (doc format)

11:19 No need for the USE if you're using <1.3

11:19 raek: (in clojure < 1.3 'doc' is in clojure.core)

11:19 tensorpudding: what is use?

11:19 skelternet: '(doc doc)

11:19 tensorpudding: is that like require

11:19 edw: Yes, but it imports the symbols into the current environment.

11:20 tensorpudding: or wait, does it import....ah

11:20 i prefer explicit namespacing usually

11:20 edw: IMPORT is different.

11:21 tensorpudding: how do i read docs on java functions

11:21 gfredericks: I don't think that's possible at runtime...

11:21 edw: The javadoc?

11:21 tensorpudding: what's javadoc?

11:22 gfredericks: a standard method for generating HTML documentation from java source code. What java functions are you interested in?

11:22 tensorpudding: just the ones referenced in clojure docs

11:22 gfredericks: if they're from standard java libraries, you can google their names and find them

11:23 $google java 6 inputstream

11:23 lazybot: [InputStream (Java Platform SE 6)] http://download.oracle.com/javase/6/docs/api/java/io/InputStream.html

11:23 gfredericks: most public java libraries post their javadocs on the web, and are easy to find with google

11:23 edw: You should use a search engine (Google.com is a search engine) and type something like "java.io.File".

11:36 ambrosebs: does anyone think it's a good idea to dedicate a yearlong CS honours project to a Clojure-in-Clojure compiler?

11:36 I'm not aware of an effort currently for this type of thing

11:38 ejackson: ambrosebs: how much of clojurescript would be useful for that ?

11:38 ambrosebs: I'm not sure

11:39 my very rough understanding is that it's not completely CinC because it uses Clojure

11:39 but, please correct me if I'm wrong

11:40 I'd imagine it's a starting point

11:43 ejackson: I have no idea, but I got the impression it was a stab at working on the ideas

11:46 i think it would a really exciting exercise

11:48 ambrosebs: yes, there seems to be many factors to account for

11:59 gfredericks: ambrosebs: would you try to design it from the ground up, or just go through the java classes translating functionality into deftypes and such?

12:03 ambrosebs: gfredericks: well it wouldn't be a 1-1 translation, there are suggested improvements for a CINC compiler on a confluence page

12:03 but really, I haven't looked at the compiler much, this is something i'd spend a while thinking about before jumping in

12:04 gfredericks: if I had an honors project to do, I would definitely enjoy such a thing.

12:05 ambrosebs: yes, it sounds like a bunch of fun

12:06 another possibility is working on an a la carte type system for clojure

12:07 gfredericks: that sounds more research oriented

12:07 which I mean neutrally

12:07 ambrosebs: :)

12:08 ejackson: hahaha

12:16 srid: ,(Integer/toString 37 37) ;; radix cannot be greater than 36?!

12:16 clojurebot: "37"

12:17 gfredericks: srid: 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:18 ,Character/MAX_RADIX

12:18 clojurebot: 36

12:24 TimMc: ew

12:24 Silent fail fail.

12:28 ,(Integer/toString 37 -1)

12:28 clojurebot: "37"

12:39 TimMc: I'm surprised it doesn't throw a checked exception. :-P

12:44 gfredericks: yeah that's what I'd expect from java

12:44 if it were a clojure function what would you expect it to do?

13:05 tensorpudding: how do you define a main entry point for a clojure app?

13:05 do you use clojure.main/main

13:08 cark: tensorpudding: depends if you're AOT compiling or not

13:08 tensorpudding: i'm producing a jar

13:09 cark: do you want to have an "executable" jar ?

13:09 or can you take care of that from the command line ?

13:09 tensorpudding: i want an executable jar

13:10 cark: then you need to make a gen-class namespace

13:10 raek: you specify the main namespace in your project.clj: :main foo.bar

13:10 then add a (:gen-class) in the ns form of that namespace

13:11 and then add a function called "-main" in the same namespace

13:11 cark: something like this : https://gist.github.com/1341778

13:12 TimMc: gfredericks: nil

13:12 tensorpudding: how do i use lein to generate a .jar that i can use?

13:13 TimMc: tensorpudding: lein jar

13:13 raek: lein uberjar

13:13 TimMc: or uberjar, really

13:16 tensorpudding: does java have to give these horribly obtuse error messages every time

13:16 TimMc: a-yup

13:17 That's Java. And Clojure is worse about it (but getting better.)

13:18 tsally: is there any way to have a jar only clojar ?

13:18 TimMc: tsally: "only clojar" <-- could not parse

13:18 tsally: TimMc: I want to upload a library to clojars, but with the jar only

13:19 tensorpudding: clojure would be more fun to use if the java part were less obvious

13:20 tsally: I think clj-time does this where they upload joda here: http://clojars.org/joda-time

13:20 similarly, I'm wrapping a java library and want to follow the same style

13:21 TimMc: tsally: I don't understand -- clojars takes jars, that's what it does.

13:23 tsally: oh I see, so I can just a minimal pom.xml file

13:23 TimMc: raek: 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:24 tsally: Yeah, it doesn't take much. Just mimic what leiningen produces, I guess.

13:24 (I see what you were aksing now.)

13:24 tsally: TimMc: hehe sorry, I wasn't so clear

13:25 thanks for the help

13:28 TimMc: for future reference, clojars wiki actually has exactly what I was wondering about https://github.com/ato/clojars-web/wiki/POM

14:20 TimMc: All tests passed!

14:20 Time to write more tests...

14:29 dbushenko: hi all!

14:29 where is the forme clojure.contrib.repl-utils?

14:29 I really miss the function "show"...

14:33 cemerick: dbushenko: 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:33 dbushenko: wow! thanks!

14:38 cemerick, I've just looket through clojure.reflect... could you advise me how I can see the methods of a java object?

14:46 cemerick: ,(->> (reflect "") :members (filter :return-type) (map :name))

14:46 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: reflect in this context, compiling:(NO_SOURCE_PATH:0)>

14:47 cemerick: ,(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))

14:47 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.reflect>

14:47 cemerick: (require 'clojure.reflect)

14:47 ,(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))

14:47 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.reflect>

14:47 cemerick: &(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))

14:47 lazybot: java.lang.ClassNotFoundException: clojure.reflect

14:47 cemerick: &(require 'clojure.reflect)

14:47 lazybot: ⇒ nil

14:47 cemerick: &(->> (clojure.reflect/reflect "") :members (filter :return-type) (map :name))

14:47 lazybot: ⇒ (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:48 cemerick: dbushenko: ^^

14:48 dbushenko: thanks!!

14:48 cemerick: clojurebot ignores require now?

14:48 dbushenko: there's also &(map #(.getName %) (.getMethods (class "")))

14:49 llasram: cemerick: I think you left off the initial ','?

14:49 cemerick: hosty, I guess

14:49 llasram: so I did!

14:49 ,(require 'clojure.reflect)

14:49 clojurebot: nil

14:49 llasram: require all the namespaces!

14:50 dbushenko: cemerick, have tried that. This is just great!!

14:51 cemerick: dbushenko: read the docs now. You're on your own from here on out. ;-)

14:51 dbushenko: :-)

14:57 tensorpudding: is there a recommended templating library in clojure?

15:02 chewbranca: tensorpudding: my personal preferences are https://github.com/weavejester/hiccup and https://github.com/cgrand/enlive

15:03 tensorpudding: ehh

15:03 chewbranca: tensorpudding: ?

15:03 tensorpudding: i don't want to use clojure to write html

15:03 chewbranca: ahh

15:03 well enlive is very interesting

15:03 TimMc: tensorpudding: You don't exactly write it.

15:04 chewbranca: you use clojure to select dom elements of existing html and use clojure to update them with the relevant data

15:04 Raynes: Hiccup is closer to writing it -- enlive is more templateish.

15:04 chewbranca: but I imagine there is also a mustache port in clojure

15:04 ibdknox: there is

15:04 clostache or stencil

15:04 we use stencil

15:04 it's worked nicely

15:04 tensorpudding: enlive seems complicated

15:04 TimMc: "clostache" ugh

15:04 ibdknox: it is, unfortunately

15:04 TimMc: I know

15:05 Raynes: ibdknox: We use clostache in spawn.

15:05 chewbranca: enlive is definitely different, I think that's where a lot of the complications come from

15:05 ibdknox: TimMc: one of the reasons I use stencil was because of that name ;)

15:05 Raynes: yeah, I know, they're basically equivalent

15:05 chewbranca: different goals though, if you're working with html and need to continue to work with only html then it can be very useful

15:05 ibdknox: there's also string template

15:06 tensorpudding: i've not used mustache before but it seems close to expectations

15:06 ibdknox: which is basically like the templating you get in other web stacks

15:06 chewbranca: mustache is alright, I typically don't use it aside from very basic things

15:07 my issue with mustache is that its too basic, I like to have more tools available inside my templates than what mustache provides

15:08 I mean, I know that's the point of mustache, I'm just not a fan

15:09 ibdknox: with lambdas you can basically do anything?

15:09 the cool thing is mixing lambdas with hiccup :D

15:11 chewbranca: lambdas work _ok_, they give you the absolute minimum required to be able to create html functions

15:12 that doesn't mean they're fun to use for larger codebases

15:13 because 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:13 ibdknox: that argument doesn't really make sense to me

15:14 what system is more powerful than being able to execute any arbitrary function?

15:14 chewbranca: yeah yeah its turing complete

15:14 ibdknox: in any case though, I've never had any issues, but templating is always a very contentious subject :)

15:14 I've used them all

15:14 I like the concept of enlive, but I have an issue with its implementation

15:14 chewbranca: my point is that you end up building a helper system because mustache maps your lambdas directly with your data

15:15 so you end up reinventing the wheel

15:18 bartj: I have just downloaded cascalog

15:18 and after I do a "lein compile"

15:18 I do not know where the ".class" files are

15:19 ie. they are not present in the classes folder

15:19 ibdknox: that .classes for what?

15:19 bartj: so when I am trying to get started with running the "playground"

15:19 ie: (use 'cascalog.playground) (bootstrap)

15:20 I get the error: java.io.FileNotFoundException: Could not locate cascalog/playground__init.class or cascalog/playground.clj on classpath: (NO_SOURCE_FILE:0)

15:21 ibdknox, to run cascalog

15:22 ibdknox: when you say you downloaded cascalog, what do you mean?

15:22 you added it to your project.clj and ran lein deps?

15:23 bartj: no

15:23 ibdknox: ah

15:23 that's how you should do it

15:23 bartj: downloaded a .zip from https://github.com/nathanmarz/cascalog

15:23 ibdknox: ok

15:23 tensorpudding: there's like a half dozen different jars for this package on clojars

15:24 how the heck do i decide which to use

15:24 TimMc: no kidding

15:24 bartj: and then ran lein deps && lein compile && lein repl

15:24 ibdknox: open your project.clj and add [cascalog "1.8.3"]

15:24 to your dependencies

15:24 raek: bartj: that would be how you did it before Leiningen came about

15:24 ibdknox: then run lein deps, lein repl

15:24 raek: (download zip and compile, that is)

15:24 tensorpudding: i don't know what its qualified namespace is

15:24 bartj: oh

15:25 tensorpudding: that's why i was looking on clojars

15:25 i chose the one that ended up being just the name of the package

15:25 bartj: but looking at the "Getting Started" section on https://github.com/nathanmarz/cascalog

15:25 raek: tensorpudding: the namespace and maven group + artifact ID do not always match exactly

15:25 bartj: the idea seems to be just to download the .zip file and follow the instructions there

15:25 raek: tensorpudding: which library are you looking for?

15:25 tensorpudding: enlive

15:27 bartj: raek, correct me if I am mistaken, but my project here *is* cascalog

15:27 raek: I 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:27 and then look here: http://clojars.org/repo/

15:27 for the latest stable version

15:27 tensorpudding: (this is too complicated)

15:27 bartj: so, adding that to the dependencies doesn't make sense to me

15:27 ibdknox: bartj: your project *uses* cascalog

15:28 bartj: it's not cascalog itself

15:28 bartj: ibdknox, hmm

15:28 tensorpudding: what is the group and artifact i

15:28 d

15:28 raek: bartj: 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:28 Raynes: tensorpudding: The part before the / is the group id, the part after is the artifact id.

15:29 tensorpudding: oh

15:29 Raynes: So foo.bar/baz = group id foo.bar and artifact id baz.

15:29 raek: so, in this file https://github.com/cgrand/enlive/blob/master/project.clj

15:29 tensorpudding: it just says enlive

15:29 so both of them are enlive?

15:29 raek: it just says "enlive". that means that both the group ID and the artifact ID is enlive

15:29 tensorpudding: okay

15:29 raek: (this is probably documented in the lein tutorial somewhere)

15:29 tensorpudding: so how do i deal with its other namespaces?

15:30 raek: so I would look here: http://clojars.org/repo/enlive/enlive/

15:30 and decide to go with [enlive "1.0.0"]

15:30 Raynes: raek: http://clojars.org/enlive worksa

15:30 works*

15:30 tensorpudding: i found it on clojars and put that in and got the deps

15:30 raek: ok

15:30 tensorpudding: but now i need to figure out how to :use its namespaces

15:31 raek: that should (ideally) be documented in the docs for the project

15:31 tensorpudding: the docs don't tell you that

15:31 do i use it literally as it appears in the source?

15:31 raek: https://github.com/cgrand/enlive/wiki

15:31 here it says (:use net.cgrand.enlive-html)

15:32 tensorpudding: take that as yes

15:32 TimMc: tensorpudding: Ideally, a projectwill tell you on its GitHub (or whatever) page 1) the group & artifact IDs, 2) the core namespaces to require.

15:32 Some fail at that.

15:32 cemerick: ibdknox: for the record, I think korma's color scheme is tops :-D

15:32 raek: a lot of projects fail to do convey 2)

15:32 ibdknox: cemerick: best thing ever :D

15:32 bartj: ibdknox, ok, I just add cascalog to the dependencies

15:32 ibdknox: speaking of..

15:33 I'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:33 cemerick: ibdknox: are the headlines just an image you produce using a tablet and a brush or something?

15:33 bartj: but when I run a (bootstrap), I get the error: "java.lang.Exception: Unable to resolve symbol: flatten in this context (vars.clj:72)

15:33 "

15:33 maybe the latest version is not stable enough ?

15:33 or maybe 1.8.2 is not stable enough

15:44 ibdknox: cemerick: it's actually a font called "From where you are"

15:46 cemerick: ~google "From where you are"

15:46 clojurebot: First, out of 524000 results is:

15:46 Lifehouse - From Where You Are - YouTube

15:46 http://www.youtube.com/watch?v=LBh7Muv0yac

15:46 cemerick: oh well :-)

15:46 ibdknox: haha\

15:46 cemerick: http://www.dafont.com/from-where-you-are.font

15:46 font selection takes forever

15:46 cemerick: ibdknox: yeah, got it

15:46 Nice pointer.

15:46 The diacriticals are cute. :-)

16:41 bartj: trying out the examples in cascalog

16:41 I get this for any query: cascading.flow.FlowException: unhandled exception (NO_SOURCE_FILE:0)

16:42 goodieboy: anyone know of a library for striping tags from html?

16:43 hmm https://gist.github.com/393194

16:47 bartj: goodieboy, is Perl ok ?

16:48 goodieboy, http://stackoverflow.com/questions/832620/stripping-html-tags-in-java

16:50 goodieboy: bartj: thanks, checking out that java question

16:51 Raynes: technomancy: Ping

16:56 technomancy: Raynes: pong

16:56 Raynes: technomancy: lein search "g:clj-github" <-- isn't it strange that the hyphen screws this up?

16:57 I can search for stuff like g:clojail and get proper answers, but anything with a hyphen causes lucene to say wut.

16:57 Just curious if you have any idea why.

16:57 technomancy: I think it needs a different query parser

16:58 probably just a matter of digging through the nexus indexer to see what they use

16:59 "g:github AND g:clj" doesn't work probably because it's getting tokenized as a single term at indexing-time

17:00 Raynes: g:clj-github* works… for some reason.

17:00 Lucene is dark, dark magic.

17:01 technomancy: hm, probably forces their equivalent of a full table scan

19:16 goodieboy: anyone familiar with noir/compojure? Wondering if it can support faking the delete/put request methods by using a _method request param?

19:17 ibdknox: goodieboy: yes you can

19:18 goodieboy: nice, are there docs on how to do this? Is it pretty straight forward?

19:18 ibdknox: goodieboy: https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L13

19:18 basically as long as you submit _method with your http request

19:18 it will happen magically

19:19 goodieboy: ibdknox: very nice, thanks!

19:23 ibdknox: do you know if this works for noir as well? (defpage [:delete "/blah"] ... ?

19:24 ibdknox: goodieboy: yup

19:25 goodieboy: awesome

19:45 tensorpudding: why did the latest clojure put things in weird places

19:45 someone remind me where doc is again

19:45 ibdknox: how do you start your repl?

19:45 tensorpudding: nevermind, now i remember

19:45 ibdknox: (use' clojure.repl)

19:45 er

19:45 (use 'clojure.repl)

20:07 tensorpudding: the dev cycle with clojure feels really slow

20:08 scottj: how so?

20:08 tensorpudding: well

20:08 i write something which i don't know if it works

20:08 i do 'lein run'

20:08 it takes 20 seconds to build

20:08 then spits out around 100 lines of inscrutable exception backtrace

20:09 i scroll my terminal to find the line i care about, fix the error, repeat

20:09 scottj: why not use a repl?

20:09 tensorpudding: i'd need to restart the repl every time i changed my program

20:10 in any case, if the program is invalid the repl isn't going to work is it?

20:10 scottj: Most people develop clojure code by writing their code in a file and then sending expressions and definitions to the repl with a keystroke

20:12 tensorpudding: well

20:12 i'm writing a "webapp"

20:12 it's using compojure, ring and enlive

20:12 what part do i send to the repl

20:13 amalloy: all the parts :P

20:13 scottj: tensorpudding: emacs?

20:13 tensorpudding: yes

20:14 scottj: tensorpudding: most people use C-c C-k to send the entire file

20:14 tensorpudding: i just did

20:14 so what now?

20:15 it compiled i guess

20:15 scottj: anything that's not running that you want running should be send in similar way

20:15 tensorpudding: i'm running my -main in the repl and it's not doing anything

20:15 scottj: say you have start-server.clj you should send that

20:15 tensorpudding: oh wait, it worked

20:16 it's just not sending output on the repl saying jetty was started

20:16 also totally failed at finding my css

20:16 right, i commented out that line

20:17 okay

20:17 i killed it, tried to start it again but the old -main is still running

20:17 do i have to restart slime

20:18 scottj: idk, normally you start the server once per dev session

20:18 amalloy: tensorpudding: i usually (def j (start-jetty ...)), and then i can (.stop j)

20:22 tensorpudding: running that, the repl doesn't return

20:23 scottj: (future (start-jetty...))

20:27 tensorpudding: how do i do aliased requires on the repl?

20:28 chouser: (require '[foo.bar :as b])

20:29 amalloy: scottj, tensorpudding: jetty takes a :join false option

20:29 running it in a future won't work because you won't have a result object to .stop

20:30 scottj: :Join?

20:30 :join?

20:30 amalloy: ah

20:33 tensorpudding: i don't suppose someone familiar with compojure can explain compojure.route/resources

20:44 scottj: btw 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:10 stevelew: hello

21:11 I have a supernoob question if there's not a discussion going on already.

21:12 I'm trying to wrap my mind around thinking functionally

21:13 cemerick: stevelew: you should always ask, even if there's chaff flying :-)

21:13 stevelew: So I'm reading about datatypes and protocols here: http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/

21:13 which is quite good, but it looks an awful lot like OOP to me, with my noob mind

21:13 types, with functions attached to the type

21:14 so I'm missing something conceptually, I think.

21:15 partly, I think it's the fact that there's immutable state

21:15 so any function call using a record would just return a new instance of the record

21:16 cemerick: First, OO generally implies stateful, mutable objects.

21:16 stevelew: right

21:16 cemerick: Second, protocols allow you to define implementations for types you don't control.

21:16 stevelew: ok

21:17 maybe that's it, the stateless part

21:17 i'm so used to mutating state on an object via a method

21:17 cemerick: People usually get more excited about the second bit. :-)

21:17 stevelew: yeah I just watched stuart halloway's vimeo on protocols

21:17 very cool.

21:18 i'm partly just trying to figure out how I'd implement records with a Customer, an Order, and a Product sort of idea

21:18 cemerick: The 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:18 stevelew: so my mind is on records

21:19 amalloy: stevelew: if you have an OO mindset you tend to jump to records for modeling your data even though they're not necessary

21:19 cemerick: (defrecord Customer [fname lname address customer-number])?

21:19 amalloy: clojure encourages the use of plain old hashmaps, and functions that operate on those maps

21:19 cemerick: (inc amalloy) ; though I'd say s/encourages/allows, but sure. :-)

21:19 lazybot: ⇒ 1

21:20 amalloy: lazybot: eh? when did your karma get reset?

21:20 cemerick: happens every could of days, I think.

21:20 Raynes: amalloy: Well, it's kind of completely broken anyways.

21:20 $karma amalloy

21:20 lazybot: amalloy has karma 0.

21:20 stevelew: i'm okay with using hashmaps. i love hashmaps

21:21 Raynes: amalloy: Feel free to commit something every once in a while. ;)

21:21 cemerick: (defn karma [handle] (if (= handle "amalloy") 0 (get-karma handle)))

21:22 stevelew: I'd seen a few things by Alex Miller blogging about how he's used records at his workplace

21:23 amalloy: man, i've looked into the karma plugin a number of times. can't repro the problem

21:24 stevelew: i've heard records described as an "advanced feature". not a bad way to think of them

21:24 stevelew: part 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:24 amalloy: and of course advanced features are more fun to blog about...

21:39 tensorpudding: can you destructively change a map?

21:40 cemerick: destructively?

21:40 tensorpudding: sorry

21:40 i mean

21:40 i kinda want to have a global mutable map

21:41 and a function which changes its value

21:41 it's a temporary key-value store for my app

21:41 cemerick: sounds like an atom with a map inside

21:41 stevelew: like a cache?

21:42 tensorpudding: i guess like a cache

21:57 gfredericks: cemerick: if you s/encourages/allows, then you're not really saying anything anymore ;-)

21:57 or at least nothing beyond "clojure has hashmaps"

21:57 cemerick: gfredericks: then my work here is done :-P

21:57 well, "you should use hash maps for modeling" vs. "you can use hash maps for modeling" is different

21:58 just a matter of emphasis

21:58 gfredericks: you can use hash maps for modeling in java as well though

21:58 cemerick: ech, not pleasantly nor idiomatically

21:58 records have a variety of creature comforts, and provide a superset of hash maps in the process

21:59 alexbaranosky: seems 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:59 stevelew: i like comfy

21:59 gfredericks: So I guess by "allow" we mean "doesn't inhibit"

21:59 cemerick: e.g. (defrecord Thing []) is better than a regular hash map at least insofar as you can wire it up to protocols

22:00 alexbaranosky: yeah, that's the right path in practice

22:00 gfredericks: cemerick: sorry, I pay too much attention to words most of the time :)

22:01 cemerick: Though once you've gone down both roads far enough, you are better able to predict which entities should be records from the start.

22:01 alexbaranosky: experience is helpful that way

22:01 :)

22:01 cemerick: gfredericks: Likewise. Usually to the detriment of my readers and bystanders, though!

22:02 gfredericks: once you (defrecord Thing []), before you know it you'll be (deftype ThingFactoryBean [])

22:03 * gfredericks kids

22:03 cemerick: beans and factory objects need not apply :-P

22:05 zakwilson: https://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:06 cemerick: ooh, dangerous territory :-D

22:07 stevelew: FactoryBridgeAdapter

22:08 cemerick: zakwilson: do you have your test data online anywhere?

22:12 tensorpudding: where is defproject defined?

22:12 why does it suddenly not work

22:13 it's like this thing is trying to come with inventive new ways of not working

22:13 clojure has been a really bad dev experience so far

22:14 gfredericks: defproject 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:14 alexbaranosky: you having trouble with your project file?

22:16 put your project.clj in a gist, and I'll look at it if you want

22:16 zakwilson: cemerick: 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:16 tensorpudding: it was saying that defproject was unknown

22:16 when i tried compiling my core.clj in emacs

22:17 cemerick: zakwilson: Which paper?

22:17 * cemerick still shells out imagemagick for image comparisons o.0

22:17 cemerick: s/out/out to

22:18 zakwilson: cemerick: no idea. All I know is it had to do with image similarity and search.

22:19 tensorpudding: and it still can't find this function in a namespace that is mentioned in the api docs for this one package

22:19 i made sure i had the same release as the source

22:19 the package loads fine

22:19 i can find other functions in the package, just not this one

22:21 stevelew: defproject is part of leiningen, you probably won't find it in core.clj

22:23 alexbaranosky: you *definitely* won't find it in core.clj

22:24 stevelew: what file is trying to use defproject, tensor?

22:25 alexbaranosky: I'm setting up Emacs on Ubuntu, using Emacs starter kit version 2

22:25 http://technomancy.us/153

22:25 I was under the impression that package.el came with Emacs now based on Phil's blog)

22:26 but when I eval-buffer (require 'package) it says it can't load file: package

22:26 what am I missing?

22:27 stevelew: emacs 24 or 23?

22:28 alexbaranosky: let me check

22:28 stevelew: package.el has been integrated into Emacs 24. If you use Emacs 23, please use this version instead.

22:28 tensorpudding: can the api docs for a package lie?

22:28 stevelew: http://technomancy.us/133

22:29 alexbaranosky: yep, 23

22:29 so I should get 24 explicitly I guess

22:29 tensorpudding: i have ring 1.0.0-rc1 and i can tell for sure that ring.util.response/redirect-after-post doesn't exist

22:29 but the docs mention it, the github source has it

22:30 maybe it's so new that the version on clojars doesn't have it, even though it's the same version tag?

22:31 alexbaranosky: tensor: that's a possibility

22:31 stevelew: i don't know about ring, but sometimes api docs on a website are a little ahead or behind of an an rc1.

22:32 tensorpudding: wait, dang

22:32 it's hard to tell

22:32 stevelew: is the github source the rc1 version or the trunk/in-development version?

22:32 tensorpudding: the commit in clojars is only two weeks old

22:33 the trunk/in-development version has 1.0.0-RC1

22:33 stevelew: was it added after rc1?

22:33 tensorpudding: but this thing is not in 0.3.6

22:33 i guess it must've been added within the last two weeks

22:33 stevelew: :(

22:33 tensorpudding: even though the version wasn't incremented

22:33 alexbaranosky: easy to find out

22:33 tensorpudding: well friggin fine

22:33 i'll just send a 302 instead of 303

22:34 stevelew: heh

22:34 you show 'em.

22:34 alexbaranosky: clone the repo, and checkout a version from 2.5 weeks ago and see if the functions in there

22:35 tensorpudding: the 1.0.0-beta2 release is older than the one on clojars, but has the feature

22:36 stevelew: weird

22:36 alexbaranosky: sounds like you're in some sort of twighlight zone

22:36 tensorpudding: the commit that marks the change to RC1 has the change, i think

22:36 yes, it does

22:37 stevelew: is it just mislabeled on clojars?

22:37 tensorpudding: maybe

22:38 okay, now i find i am not deref-ing my atom correctly

22:38 how do you use deref on an atom?

22:38 alexbaranosky: any of you going to be at the Conj? I just got a wave of excitement :)

22:38 @ will do it

22:38 stevelew: @atom

22:38 alexbaranosky: @atom

22:39 tensorpudding: oh

22:39 oh!

22:39 ...

22:39 i thought it meant literally @atom

22:39 not @<atom name>

22:39 alexbaranosky: (deref atom) ;; also, right?

22:41 stevelew: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/deref

22:41 looks like it, alex.

22:41 alexbaranosky: I think @ is the reader macro that expands out into `deref`

22:45 brehaut: ,(read-string "@foo")

22:46 clojurebot: (clojure.core/deref foo)

22:50 alexbaranosky: How many people are going to be at the Conj in total? I wasn't there last year... wonder how big it will be

22:51 tensorpudding: ugh, this is too confusing

22:51 tolstoy: When you have a lazy-sequence, and then do a (doseq [name sequence] …) Does sequence get fully realized before the body is executed?

22:52 tensorpudding: how are you supposed to know what confusingly documented clojure code does without reading the source?

22:52 stevelew: experiment?

22:52 tensorpudding: not cut out for untyped languages, i'm lost

22:52 alexbaranosky: you'll get used to it

22:53 tensorpudding: it just seems like more work for little gain

22:53 alexbaranosky: I know dorun will go through all of a sequence

22:53 stevelew: i've done tcl and python before trying clojure so it's not as foreign to me, tensor. it's a big change.

22:54 tensorpudding: i've used python a good bit

22:54 it was less weird because it supported more introspection

22:55 pythons also a lot simpler

22:55 alexbaranosky: I'm looking at the source for doseq right now

22:55 its a bigggg macro

22:55 stevelew: if i didn't understand something in python, I'd try the REPL

22:55 alexbaranosky: so give me a minute :)

22:55 stevelew: i used dir a ton when I was learning python

22:56 tolstoy: alexbaranosky: I guess I could set up a test, but it's breaks my flow. I was hoping it was common knowledge. ;)

22:56 tensorpudding: i don't understand this function any better on the repl

22:56 alexbaranosky: I don't think Python is simpler, but I guess I'm biased

22:56 tensorpudding: because it returns some object of some kind which i don't know what it does

22:56 stevelew: you may have to look at the source and break it down, then, tensor. :(

22:57 amalloy: tolstoy: i don't think your question is clear

22:57 tensorpudding: the source is hard to read

22:57 amalloy: if you mean: is every element realized before the body is executed for any of them? then no

22:57 cemerick: tensorpudding: FWIW, clojure provides just as much (if not more) introspection: it's just that Clojure functions aren't tied up into the values.

22:57 tensorpudding: i can't figure out what it does because it filters through a complicated macro and i haven't gotten macros down

22:57 tolstoy: amalloy: Yes, that's was my question. Thanks!

22:58 tensorpudding: i wanted to get by without having to touch macros for a while

22:58 tolstoy: amalloy: 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:59 alexbaranosky: you can force the sequence to evaluate using dorun I think

22:59 technomancy: tensorpudding: do you know about the slime inspector?

23:00 tensorpudding: no

23:00 technomancy: C-c S-i will let you inspect any object

23:00 including hyperlinks on the method names to see what classes they return

23:00 tensorpudding: in what

23:00 in slime?

23:00 alexbaranosky: tolstoy: scratch that, I meant doall

23:00 tensorpudding: it's not bound here

23:01 technomancy: right, you have to be using slime

23:01 tensorpudding: i am

23:01 i see slime-inspect

23:01 bound to C-c I

23:02 technomancy: sure, same thing

23:02 shift+i is I

23:02 tensorpudding: and what do i use this on

23:03 it doesn't work on macros

23:03 technomancy: any value you want to introspect

23:04 if you want to see what code a macro generates you can use macroexpand

23:04 C-c RET

23:04 tensorpudding: okay, i did it on the result that confused me

23:04 the output is...something

23:05 alexbaranosky: anyone know how to run a .in file?

23:05 tensorpudding: it doesn't provide me anything useful

23:05 alexbaranosky: looks like I need to run configure.in to configure my Emacs download

23:05 tensorpudding: you need to run autoconf

23:06 alexbaranosky: thanks

23:06 tensorpudding: actually, emacs?

23:06 you run autogen.sh

23:06 * cemerick does a double-take @ "configure my Emacs download"

23:06 tensorpudding: which does autoconf plus other things

23:07 technomancy: cemerick: http://www.cul.de/images/autotoolscg.jpg

23:07 amalloy: technomancy: wow slime inspector is awesome

23:09 technomancy: how do i go "back" after drilling down into some field or method?

23:10 ah, found the slime-inspector keymap. apparently it's L

23:10 technomancy: amalloy: not sure you can. seems like an odd omission

23:12 tensorpudding: dang

23:13 do i have to jack in with swank every time i change deps

23:13 amalloy: tensorpudding: the jvm doesn't like adding dependencies at runtime, so mostly you can't do it (but ask cemerick about pomegranate)

23:14 tensorpudding: i want to know how to override the way compojure handles http responses

23:14 so that i can send a 302 for redirect

23:15 amalloy: tensorpudding: why would you override anything? just return {:status 302 :headers {"Location" foo}}, right?

23:15 tensorpudding: well

23:15 the way that defroutes works, i don't know how to do that

23:16 amalloy: just return that map instead of a string or html thing

23:16 tensorpudding: the examples, they all use macros which takes a route

23:16 that's what i'm doing

23:16 i had absolutely no idea if it was the right thing to do

23:16 amalloy: it's really that simple

23:17 tensorpudding: the docs muddied the matter, and the source was unfollowable

23:17 and in any event, it doesn't actually work

23:17 my redirect didn't happen

23:17 amalloy: ~bug report

23:17 clojurebot: A 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:18 tensorpudding: well, from the point of view of the browser, it just loaded forever

23:20 amalloy: my 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:22 ADWong: Hi 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:22 tensorpudding: maybe my html form is doing the wrong thing

23:22 but if it were sending a POST with the wrong information why is it taking forever

23:22 maybe it's timing out trying to deref the atom? i don't know why it'd do that

23:23 tolstoy: ADWong: Something like (:val (nth thing 1))?

23:23 Or (:val (second thing))?

23:24 amalloy: &(get-in [{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}] [1 :val])

23:24 lazybot: java.lang.RuntimeException: Unable to resolve symbol: dog in this context

23:24 amalloy: &(get-in '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}] [1 :val])

23:24 lazybot: ⇒ 5

23:24 tolstoy: Oh, yeah, that *-in stuff is really nice.

23:25 ADWong: Oh 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:26 amalloy: &(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (keep (comp #{'b} :attrs) data))))

23:26 lazybot: ⇒ nil

23:26 stevelew: you're using ring, tensor?

23:26 tensorpudding: compojure and ring

23:26 amalloy: &(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (first (keep (comp #{'b} :attrs) data)))))

23:26 lazybot: ⇒ nil

23:26 amalloy: dangit

23:26 stevelew: yeah that makes no sense for it to hang like that

23:26 but i know very little about compojure & ring

23:27 tensorpudding: i have no idea what it's hanging on

23:27 amalloy: &(let [data '[{:type dog :attrs a :val 3} {:type dog :attrs b :val 5}]] (:val (first (filter (comp #{'b} :attrs) data))))

23:27 lazybot: ⇒ 5

23:27 stevelew: in python I'd start adding prints in the django source

23:28 amalloy: ADWong: ^

23:29 ADWong: Wow. I need to play with slime for a bit to see how that actually works. Thanks!

23:29 tensorpudding: i had a lot less trouble getting django to do what i wanted, last time i tried it

23:29 but django is pretty heavy

23:31 stevelew: yeah it only happened once. i don't remember what it was

23:31 it ended up being my fault, I'm sure.

23:33 amalloy: hah, 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:34 stevelew: i remember in college, my prof said, "no matter what you think, the C++ compiler is not broken"

23:34 no one even asked it, it was just a warning ahead of time to everyone in class

23:34 amalloy: well. it performs according to its specs. but the spec is pretty broken

23:35 stevelew: yeah, he was just trying to let us know that our code was going to be buggier than the compiler.

23:35 amalloy: indeed

23:35 tensorpudding: oh, good

23:36 i found the issue

23:36 stevelew: now i'm curious, tensor

23:36 tensorpudding: turns out that keyword doesn't work on ints?

23:36 except the atom either isn't getting updated or my retrieval functions aren't working

23:37 well, it can't be the latter since it works fine for the initial values

23:37 oh

23:37 it's probably that my POST request doesn't have the right names

23:37 or something

23:37 stevelew: the keys?

23:37 in the POST?

23:38 tensorpudding: yes

23:38 stevelew: i've done that before

23:38 amalloy: tbh i was a bit shocked when i found out that ##(keyword 4) doesn't work

23:38 lazybot: ⇒ nil

23:38 tensorpudding: (POST "/new" [title body] (handler title body))

23:39 stevelew: one time the key was expecting "physican" instead of physician

23:39 took me forever to find that out

23:39 tensorpudding: i had assumed that it binds title and body to the values of the keys of the same name in the http request

23:39 stevelew: wth is a pysican

23:40 amalloy: stevelew: i like how you made it even worse by spelling it three different ways in your story

23:41 stevelew: lol

23:41 physican

23:41 i stared at it, even. and decided it was right.

23:41 before i pressed enter.

23:41 tolstoy: Did you s/physician/doc/ after a while?

23:41 stevelew: lol

23:41 tensorpudding: how can i make my browser send a post request

23:41 stevelew: jquery?

23:42 that would make sense, tolstoy

23:42 tensorpudding: i don't mean programmatically

23:42 i want to test my webapp

23:42 stevelew: create a test form?

23:42 tensorpudding: i have a form

23:42 i can't figure out if it's working

23:42 tolstoy: I worked on something a long time ago and use "proctologist" instead of "proctorship" because "proctorship" is such an awkward word to say.

23:43 cemerick: But "proctologist" isn't?

23:43 tolstoy: Some sort of medical records things. "How many proctologists does Dr Smith have?"

23:44 tensorpudding: <form method="post" id="form" action=""><input type="text" name="title"/><input type="text" name="body"/><input type="submit" value="Post"/></form>

23:44 that's what i wrote

23:44 stevelew: you need something in the action i suppose

23:44 tensorpudding: what would go there?

23:45 i assumed the submit handled it

23:45 the html docs suggested such a thing

23:45 stevelew: does compojure or ring have something to register which urls work?

23:45 oh hmmm

23:46 amalloy: i'm with cemerick here. in what domain is proctologist a viable substitute for proctorship?

23:46 tensorpudding: it's running my handler

23:46 it's just got the keys as empty

23:46 for some reason

23:47 i can only guess the keys are misnamed

23:47 tolstoy: amalloy: Absolutely none. I think that's why the medical-record ladies were highly amused.

23:47 stevelew: heh

23:47 so you have title, body..

23:47 tolstoy: amalloy: I though they were two versions of the same word.

23:47 stevelew: which in theory would correspond to a map with :title and :body keys

23:48 in the handler

23:48 tolstoy: Some people say orien-TAY-ted, and others say ori-EN-ted. All around really stupid of me. ;)

23:49 amalloy: tensorpudding: 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:50 tensorpudding: no?

23:50 compojure didn't mention it

23:51 ibdknox: what's the issue?

23:51 stevelew: Compojure provides a “params” hash-map that has the parameters of the servlet, which we will pass to a “login” controller

23:51 tensorpudding: my html form sends a post request, which my app handles

23:52 it seems to handle fine except the keys that i passed to the handler are empty

23:52 stevelew: are you getting a params map, tensor?

23:52 amalloy: ibdknox: bug: accidentally used compojure instead of noir

23:52 tensorpudding: a what?

23:52 ibdknox: amalloy: sounds like it.

23:52 stevelew: a variable named "params"

23:52 coming into the handler

23:52 tensorpudding: no

23:53 why is there so many libraries for clojure that all do similar things

23:53 stevelew: this guy has a form example

23:53 http://justin.harmonize.fm/index.php/tag/compojure/

23:53 tensorpudding: so that i can always choose the one that people hate

23:53 stevelew: with a login handler

23:53 ibdknox: tensorpudding: no one hates compojure

23:53 amalloy: tensorpudding: compojure is great though

23:53 tensorpudding: it's not a session

23:53 stevelew: "You have chosen ... unwisely"

23:53 amalloy: it's just ibdknox wrote noir

23:53 and you sound like the sort of guy who would prefer noir

23:53 ibdknox: which is actually built on top of compojure :)

23:54 stevelew: what does your handler function take as paramters?

23:54 tensorpudding: i assume that since those posts are from 2009 they have no relevancy to today

23:54 since everything else i read from that time period recently was totally, completely wrong

23:54 stevelew: hmm sorry. didn't see the 2009.

23:54 tensorpudding: yikes

23:54 noir built on compojure built on ring

23:54 that's not enough layers

23:54 stevelew: blue pill

23:54 ibdknox: haha

23:55 tensorpudding: those are very small libraries

23:55 tensorpudding: not small enough for me to understand them

23:55 ibdknox: tensorpudding: the point of them was actually that they *could* be built on top of

23:55 tensorpudding: well, those are fairly low level

23:55 tensorpudding: and not as well documented as they could be

23:55 tensorpudding: i just don't see why what i'm doing has an issue

23:55 ibdknox: tensorpudding: so let me help then. Can you put a gist up of your code?

23:56 tensorpudding: several files at the moment

23:56 i'm not sure it's not the fault of my templates either

23:56 well, the post page isn't templated

23:56 ibdknox: all I need to see is your defroutes and your handler function

23:59 lol

23:59 texnomancy?

Logging service provided by n01se.net