#clojure log - Jan 02 2011

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

0:49 auser: is there a way, with leningen to specify a dependency that is on github and not in clojars?

0:51 anyone?

0:51 clojurebot: Please do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.

0:52 qbg: I'm not sure you can add github as a Maven repo

0:52 auser: okay... well. I'm trying to use leningen to specify a dependency that is on github and not in clojars, how would I go about doing that?

0:52 hm I see

0:52 qbg: You could build the project yourself and do lein install

0:52 for a local install

0:53 (or so I hear)

0:54 Or you could put the project on Clojars under your own group

0:55 auser: hm... need to investigate

0:55 qbg: Just pushed my first project to Clojars a few minutes ago; its really easy

0:55 auser: oh yeah?

0:57 qbg: You could also send a message to the owner of the repo on github and tell them to put it on Clojars themselves

1:00 auser: that was easy

1:46 dakrone: auser: since you are using leiningen, you can use checkout dependencies to do what you'd like as well

1:47 auser: I can?

1:48 dakrone: yea, check the "I want to hack two projects in parallel, but it's annoying to switch between them." question on the FAQ, it describes how to use what you'd like

1:48 auser: sweet

1:48 dakrone: you basically create a checkouts directory and symlink projects into it

1:49 auser: hm, which FAQ?

1:50 oh wait

1:50 there it is

2:48 amalloy: bendlas: ##(some :x (transient {:x 1}))

2:48 sexpbot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.PersistentArrayMap$TransientArrayMap

2:48 amalloy: oh. or i guess just ##(:x (transient {:x 1})) :P

2:48 sexpbot: ⟹ 1

3:26 auser: so... I'm trying to grok how this works: https://github.com/texodus/saturnine/blob/master/src/saturnine/handler.clj#L137-181

3:38 amalloy: auser: what part? it looks like it's turning the methods you supply into a map, and then iterating through all the handler types, splicing in either your version or the default

3:39 rather, it splices in your versions, and then all the defaults that aren't covered by your version

3:43 auser: ah i see... hm. I guess i need to research defmacro more

3:45 I see

3:46 thanks amalloy

3:47 amalloy: what is the difference between that and say something with a defprotocol

3:47 if you don't mind

3:49 would it be that that allows you to not implement all the methods?

3:49 thx

5:06 fliebel: What can I do about this? java.lang.ClassCastException: some.reify cannot be cast to clojure.lang.Named

5:10 Nothing, thank you.

8:19 Licenser: cookies

8:54 fliebel: Does the author of Lamina, Aleph, Gloss, and a few more brilliant libs come in here?

9:05 schizoschaf: hi all. i'm very new to clojure.

9:05 I try to return a java object from a clojure function. I get a ClassCastException: cannot be cast to clojure.lang.IFn

9:07 raek: it looks like you are trying to call the return value as a funcion

9:08 (also, all clojure values are java objects too)

9:08 &(StringBuilder. "abc")

9:08 sexpbot: ⟹ #<StringBuilder abc>

9:08 raek: &((StringBuilder. "abc"))

9:08 sexpbot: java.lang.ClassCastException: java.lang.StringBuilder cannot be cast to clojure.lang.IFn

9:19 schizoschaf: thank you raek. you were right

9:22 i have this:

9:22 (if(instance? JpegImageMetadata metadata )(.getExif metadata) metadata )

9:23 the instance? gives true. the result of (.getExif metadata) should be returned, but gives the classcastexception

10:18 _na_ka_na_: hellos, how can I await an agent to finish its work completely sent from many different threads (assuming I'm sure no more sends will be done)

10:23 I can do: assuming all prior sends have been done, I can do (send agt identity) & then (await agt)

10:24 one more question: do we _need_ to capture the return value of send ?

10:30 ,(let [a (agent [])] @(future (send a conj 10)) (send a conj 20) (await a) @a)

10:30 clojurebot: [10 20]

10:30 _na_ka_na_: Is the above code guaranteed to always produce [10 20] ?

11:47 kumarshantanu: hi, is it possible to access "this" or "super" inside a proxy?

12:39 chouser: kumarshantanu: yes, this is called just this

12:41 kumarshantanu: chouser: yes, thanks...noticed here too -- http://clojure.org/java_interop (under proxy)

12:54 amalloy: _na_ka_na_: yes, that is guaranteed

13:03 _na_ka_na_: amalloy, thx so I can assume that send queues the function in the agent queue and then only returns

13:03 amalloy: _na_ka_na_: yes, send will not return until the agent has queued up your action

13:28 raek: does anyone know how to assert that a certain exception is thrown in lazytest?

13:36 qbg: deftype is easy to parse using my syntax-rules library (https://github.com/qbg/syntax-rules/wiki/Parsing-deftype, http://clojars.org/org.clojars.qbg/syntax-rules)

13:39 AWizzArd: Any ideas about which Keyword fits the following purpose well? I implemented a macro that helps to set up UIs with swing. It adds ui components to a specific container. But some components I don't want to add but just create, for example FileChoosers, or tables (it is instead added to a ScrollPane which then gets added to the container, but not the table itself). What is good? :dont-add :noadd :dontadd something else?

13:40 :create-only

13:40 :create-but-do-not-add ;)

13:40 qbg: :create

13:40 LauJensen: :create

13:41 AWizzArd: [username-label (JLabel. "Username:")]

13:41 [open (JFileChooser.) :dont-add]

13:42 [color (JColorChooser.) :create]

13:45 So, :create looks better?

13:45 I am just not sure if it puts enough emphasis on the widget not being added to its container.

13:46 amalloy: AWizzArd: :detached maybe?

13:46 AWizzArd: also interesting

13:46 qbg: [:create color (JColorChooser.)]

13:46 ?

13:48 AWizzArd: for conformity the name of the object and its creation form come first, and then all key/value args and all binary args.

13:49 Thanks for the inputs, I appreciate it.

13:51 LauJensen: AWizzArd: :invisible?

13:52 AWizzArd: Also an option, yes, good idea.

13:52 LauJensen: btw - Im still open for bright ideas for names for my CMS system :)

13:52 AWizzArd: Is it a Clojure cms?

13:53 LauJensen: yea

13:53 AWizzArd: Lau-Compose

13:53 LauJensen: hehe

13:53 CMSjure :(

13:53 qbg: Terrible name

13:53 AWizzArd: You could think about putting your name in.

13:53 amalloy: LauJensen, AWizzArd: i don't like :invisible

13:53 it suggests to me that it will be added, with (.setVisible false)

13:54 qbg: LauJensen: What is special about this CMS again?

13:54 AWizzArd: Contentjure Manajing Sysjam

13:54 LauJensen: HAHA

13:54 AWizzArd: amalloy: I think it will be between :detach and :dont-add

13:54 But it is good to have many ideas during a brain storming.

13:55 LauJensen: qbg: oh its a very special system. You get a simple webinterface, where you upload templates and add pages. A template is simply an html files, which somewhere has a <div class="content">. In the page editor you write markdown and with every keystroke a live preview of the final site is generated. Once everything looks fine, hit generate and you got a nice, easily maintained static site

13:55 AWizzArd: LauJensen: your name sounds catchy, so it could be a cool component of a name for a piece of software.

13:55 LauJensen: AWizzArd: I think I'd have to grow my ego a little first :(

13:55 AWizzArd: *g*

13:56 qbg: (swap! LauJensen update-in [:ego] inc)

13:56 enough?

13:56 LauJensen: No - I was thinking of something like "Typo4" or "Drupaljure"

13:58 qbg: I'd probably name it something terrible like Grinddown

13:59 LauJensen: Grind sounds a little negative to me

14:01 qbg: Mark 'n Bake

14:01 LauJensen: hehe, clever

14:01 bendlas: Hai

14:03 LauJensen: bendlas: My hat is off to you for that pull request from last night, big thanks for your good work!

14:03 bendlas: Glad to help :)

14:06 Got those projected group-by fields sorted out yet?

14:07 LauJensen: Just about to dig into it

14:07 I think I'll just revert my last commit and start over. I've thought of a much more elegant way to handle it

14:08 Then a little website work in my shiny new unnamed CMS and we're 1.0

14:10 krumholt: hello. can someone explain to me why (def c 'x) (let [x 1] (eval c)) will give an exception: Unable to resolve symbol x

14:10 qbg: Hmm... Interactive MarkDown Baker = IMDB; why does this keep happening?

14:11 krumholt: eval doesn't have access to the lexical environment

14:12 krumholt: qbg, which environment will eval use?

14:12 qbg: toplevel

14:14 dynamic bindings work with eval though

14:14 There are some eval-in-env macros out there too

14:14 krumholt: qbg, ok thanks

14:14 qbg: It should be noted that eval is usually the wrong thing to do

14:15 bendlas: LauJensen, nice. I'm off for the drive to Vienna now. Gonna ping when I'm home.

14:15 LauJensen: Have a good one :)

14:17 krumholt: qbg, what else should i use?

14:21 amalloy: krumholt: it depends on what you're trying to do from a larger perspective

14:22 krumholt: amalloy, i calculate a function at runtime and then i have an expression like (+ x 15 (* x x)) and eval it with a certain value for x

14:24 amalloy: krumholt: if you can't avoid constructing the function at runtime (say the user gives it to you), you might try (eval `(let [~'x ~the-x-value] ~user-function))

14:24 but if possible you should try to construct the function at compile time, with a macro or some higher-order function

14:25 krumholt: amalloy, its not possible at compile time

14:27 amalloy, i'll try that thanks

14:31 anars: evening

14:33 I don't like the feeling of having nested let forms, so I was wondering whether or not it's frowned upon to actually have them

14:35 instead, is there anything "wrong" with having a let form with bindings dependant on other bindings in the same form? e.g., [url (....) contents (client/get url)]

14:37 amalloy: anars: your sample is perfectly fine and idiomatic

14:37 nested let forms are sometimes needed, and i don't see why they're ugly, but i can't think of any time you'd have them *directly* nested

14:39 eg, (let [foo bar] (when (something foo) (let [baz (inc foo)] (do-something-with baz)))) you can't easily condense, but you shouldn't need (let [a b] (let [c b]))

14:42 anars: amalloy, that's exactly what I needed to know. thank you.

14:46 chett: Quick question

14:46 say I have (defstruct foo :bar)

14:47 (def x (struct foo "bar"))

14:48 and (defn test [fb] (println (:foo fb)))

14:49 why do i get an error with (tets x)

14:49 *(test x)

14:49 anars: because the key is called :bar

14:49 not :foo

14:50 chouser: what error? you should get only nil

14:52 chett: Thanks

14:52 just a typo

14:54 chouser: btw, there's really no reason to use defstruct anymore with Clojure 1.2 or later

14:54 defrecord generally works better

14:55 chett: ^thanks. Working through examples in Halloway book.

15:13 ddudey: If I have a local .jnilib file can I specify it in project.clj?

15:13 Thx :)

16:39 hippiehunter: does anyone have any good resources to help me understand how order of macro expansion affects other expansions?

16:40 amalloy: hippiehunter: what do you mean, other expansions?

16:43 hippiehunter: im not sure, but im having a mental block in understanding macros, order of operations seems like a good place to get clarity

16:46 amalloy: hippiehunter: well, outside-in. the outer-most macro receives its body as a list; it manipulates that

16:47 that macro will return a new list, which is treated as code; if there are more macros in there, then they'll be expanded when they're gotten to

16:49 hippiehunter: does the hygienic'ness mean I dont have to worry about anything other than outside-in?

16:49 amalloy: eg, (macroexpand '(m1 (m2))) will return '(something-using (m2)); if you macroexpand that again, then m2 will be expanded

16:50 raek: hippiehunter: "hygenic" is most often refering to the absence of symbol capture

16:50 amalloy: hippiehunter: more or less. if you nest macros, or want to get around hygiene, you'll have to do some thinking/fiddling with ~', '~, ~foo#, ~'foo# and the like

16:50 raek: i.e. no shadowing 'let's

16:51 hippiehunter: what does "shadowing lets" mean?

16:51 anars: hippiehunter: if you have a global symbol, and you rebind it using let, then that new binding will shadow the global.

16:52 hippiehunter: how does that apply to macro's?

16:52 raek: the macro can inject a let form

16:53 * raek tries to come up with a simple example

16:53 anars: on a side note, check this out, hippiehunter: http://java.ociweb.com/mark/clojure/article.html

16:54 amalloy: hippiehunter: i've never had a case where i care about order of macro expansion

16:54 the one that gets me is the order in which ~ applies when constructing a nested macro

16:54 hippiehunter: I suppose i may just be injecting assumed complexity

16:55 amalloy: hippiehunter: try writing some simple macros, like the ubiquitous (square x)

16:55 raek: (defmacro m [exp] `(let [x 1] ~exp)) ; not allowed in clojure

16:56 amalloy: and you'll see that macros are "automatically" composable without having to worry about ordering: (square (square 2)) will return 16 just like you expect

16:56 raek: this macro does nothing, except when the expression you pass in contains an x

16:56 in that case, the macro will break that code

16:57 macros are just functions (well, almost)

16:58 they get some unevaluated code, which they can do whatever they want with

16:58 and return some new piece of code

16:59 then the compiler continues as if that code instead

17:00 anars: good example with the shadowing let, raek

17:00 do you understand why shadowing lets in macros can break your code, hippiehunter?

17:00 shadowing bindings in general.

17:04 raek: I think "symbol capture" is a more common term, btw

17:05 amalloy: right, because shadowing bindings is more general

17:06 raek: more common than "shadowing let", sorry

17:06 amalloy: ah

17:06 raek: for this particular thing

17:06 hippiehunter: anars: I think so, but what does the safety cost? or more specifically why is it allowed in other lisps?

17:07 raek: clojure macros resolve all symbols

17:07 so conj becomes clojure.core/conj

17:07 Raynes: raek: Don't you mean syntax quote?

17:08 raek: Raynes: yes. good catch

17:08 Raynes: raek: I was just writing about that in the macro chapter of my book. :p

17:08 raek: and 'let' does not allow one to let a qualified symbol

17:09 so you use auto-gensymed symbols in that case to get a unique collision-free name

17:10 amalloy: hippiehunter: CL and clojure allow the same set of things to happen in macros; clojure mostly chooses a safer default

17:11 anars: hippiehunter: it's perfectly legal to do, and it will compile just fine. but if you rebind a symbol unintentionally inside a macro, and another function uses the original symbol value, then you're out of luck.

17:11 that is if you're using the binding function to rebind, which causes the symbol to be rebound through the entire call stack

17:11 ,doc binding

17:11 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/doc

17:12 amalloy: &(doc binding)

17:12 sexpbot: ⟹ "Macro ([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made i... http://gist.github.com/762871

17:12 anars: there you have it ;)

17:13 hippiehunter: so bindings is like a single value let that is specifically for shadowing other names?

17:14 or is it multi value

17:14 nvm, i see now

17:15 amalloy: &(map macroexpand [`(let [x 10] x) `(let [x# 10] x#) `(let [~'x 10] ~'x)])

17:15 sexpbot: ⟹ ((let* [clojure.core/x 10] clojure.core/x) (let* [x__8744__auto__ 10] x__8744__auto__) (let* [x 10] x))

17:15 raek: 'binding' temporarily gives a var a new value in the current thread. it only works on vars and not on function parameters and locals introduced by let

17:16 jkn2: can someone explain why using (doall) changes the behavior in this case? http://pastebin.com/yvfQrjaD

17:17 amalloy: jkn2: the first version returns a lazy-seq that points to *q*, and is forced after leaving the binding scope, when the repl decides to print it for you

17:18 jkn2: ahh... i keep forgetting htat. the binding scope has already been exited

17:18 thx amalloy

17:21 amalloy: jkn2: you can do it while maintaining laziness: (let [q *q*] (map ...))

17:46 is there a clojure library around for building some kind of table? i'm working on generalizing --help output from command-line scripts and the text manipulation is a pain

17:50 i just found clojure.pprint/print-table, which i can use in a pinch, but it doesn't do word-wrap or any other kind of handling for strings with newlines in them

17:56 BobFunk_: anyone here with clojure/appengine experience?

17:57 amalloy: clojurebot: anyone?

17:57 clojurebot: Please do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.

17:57 BobFunk_: playing around with appengine-magic and have a little app running that works when I run it from the repl, but am getting a strange internal server error when trying to run in with the dev_appserver.sh

17:58 amalloy: BobFunk_: appengine seems to be a hot topic in here recently. no experience myself, but someone will be by eventually, i expect

17:59 BobFunk_: am just starting to play around with clojure - suspect my main problem is inexperience with how to debug something like this

17:59 seems to be related to https://github.com/alienscience/form-dot-clj

17:59 the error I get is java.lang.IllegalArgumentException: No matching ctor found for class form_dot_clj.server_side$maxlength$fn__712

18:00 in a huge stacktrace

18:01 amalloy: BobFunk_: sounds a little like a version mismatch, maybe. are you using the same versions of your libraries locally and on ae?

18:02 BobFunk_: I haven't actually gotten as far as trying to run it on ae - it's just running the ae servlet locally that breaks

18:02 raek: (those problems only arise if you use ahead-of-time compilation)

18:03 BobFunk_: raek: pretty sure its related to AOT compilation

18:03 since that's what I'm testing - need to run a lein appengine-prepare task that aot compiles the servlet so it can be pushed to app engine

18:04 and it's when testing the result that I run into the illegal argument exception

18:04 raek: then you're probably using a lib that is AOT compiled for another clojure version

18:05 dthurn: Question:

18:05 BobFunk_: hmm, could that happen if the project.clj specifies one clojure version and I have lein installed with another clojure version?

18:05 dthurn: I see a "thrown?" form referenced here: http://richhickey.github.com/clojure/clojure.test-api.html

18:05 But it's not in the source or accessible to me

18:05 What's going on?

18:06 raek: no, lein uses its own clojure instance

18:06 dthurn: the 'is' macro interprets it

18:06 and translates it into something else

18:07 (also, the current version of the docs is on http://clojure.github.com/...)

18:07 dthurn: ahhh... magical.

18:08 BobFunk_: so what could make me end up with a version mismatch?

18:08 raek: one of the libs you are using

18:09 BobFunk_: and how would I aproach figuring out which lib has this problem?

18:09 raek: BobFunk_: you could also try to remove all files in classes/

18:11 BobFunk_: which clojure version do you have in your project.clj?

18:11 BobFunk_: 1.2.0

18:11 raek: what libs are you using?

18:12 BobFunk_: my /classes dir is empty - removed everything there, and running the lein appengine-prepare task doesn't seem to generate new classes there

18:12 https://gist.github.com/762922

18:12 ^^^ my project.clj

18:15 raek: hrm, the form-dot-clj jar file contains only source files and no binaries...

18:17 same thing for appengine-magic

18:17 you could try removing everything in lib/ and do a lein deps again

18:17 BobFunk_: hehe - was just doing that! :)

18:18 hmm - no luck - removed lib - reran lein deps and lein appegine-prepare, but same error when starting the server

18:20 I think this started breaking when I had to rename the app to get the appengine script to be able to upload it to the right place - and my first guess was that I hda some aot compiled classes with the wrong namespace lying around - but after clearing lib/ and classes/ I don't know where any old bytecode could be lying around

18:21 raek: do you get this problem locally?

18:21 mreynolds: *Newb question* Is the Clojure-way of listing files simply to use File.listFiles ?

18:21 BobFunk_: yeah - both locally and after uploading to appengine

18:22 amalloy: mreynolds: i think so

18:22 ossareh: :refer-clojure is the shiznitz

18:23 raek: mreynolds: yes. files-seq and the stuff in clojure.java.io might be useful too, but they are only convenience functions for the java stuff

18:23 mreynolds: raek: Yeah, I'm looking at file-seq, but haven't gotten too much further (trying to learn how to use doc from the repl), thanks amalloy

18:27 raek: BobFunk_: I'm afraid I'm out of advice. this might be something specific to how appengine-magic does it magic.

18:32 BobFunk_: hmm, got it to work by simply commenting out the form validations - must be a problem specific to the forms-dot-clj library

18:32 raek: very strange

18:33 amalloy: BobFunk_: it is version 0.0.3 - use with caution :P

18:33 BobFunk_: hehe

18:33 mreynolds: Can someone shoot me a valid use of the doc function from the REPL (so I can verify my install isn't screwed up)?

18:34 raek: ,(doc conj)

18:34 amalloy: ,(doc first)

18:34 clojurebot: "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."

18:34 "([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."

18:34 raek: ,(doc clojure.set/union)

18:34 clojurebot: "([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets"

18:34 amalloy: clojurebot: no fair, raek gets higher priority?

18:34 clojurebot: Titim gan éirí ort.

18:35 raek: note that the namespace containing the var has to be loaded before calling doc

18:38 mreynolds: thanks, that seems to work

18:38 Doh, forgot () around the syntax, heh

18:39 amalloy: mreynolds: when i don't know what to write, i start with (. it's usually right

18:43 hippiehunter: Im getting java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol can anyone tell me why? http://pastebin.com/ZmrqHdL5

18:44 raek: hippiehunter: remove the "defn"

18:44 amalloy: hippiehunter: deftype shouldn't have defns inside it

18:44 hippiehunter: just saw that

18:44 thanks

18:45 are there any plans for noob friendly error messages?

18:46 are does that meta'ness preclude it

18:46 or*

18:46 amalloy: hippiehunter: try "human friendly" :P

18:46 npoektop: hi! i want to do smth like (let [field ...] (set! (. obj field) value)). But . doesnt let me do this.

18:47 amalloy: hippiehunter: my understanding from reading the dev mailing list is that there are plans in motion but they're early stages still

18:48 npoektop: right, . needs to know the field name at compile time

18:50 npoektop: if you want to hack it, the following might work: (clojure.lang.Reflector/setInstanceField obj "length")

18:52 npoektop: amalloy: thanks. i'll try that

19:10 kanak: Hi, where do I find out about the major things being worked on for clojure 1.3? (Major things == not bugfixes)

19:13 a_strange_guy: kanak: there is a changelog for alpha 4

19:13 http://groups.google.com/group/clojure/browse_thread/thread/59a22dcbc6be628f

19:14 amalloy: do we have a string padding function somewhere? i can write it myself but it's kinda ugly; i want to pad a string with spaces

19:14 Raynes: amalloy: Can't format do that?

19:15 kanak: a_strange_guy: thank you. is pods scheduled for 1.3?

19:16 a_strange_guy: they still arent in the alphas, so 1.3 will be pod-free

19:16 amalloy: Raynes: yeah, i guess it can, thanks

19:17 a_strange_guy: $(+ 1 2)

19:18 Raynes: &(+ 1 2)

19:18 sexpbot: ⟹ 3

19:18 kanak: does anyone know the status of "Joy of Clojure"? Manning site claims that all chapters are Available but that the book is still in "MEAP". What exactly does this mean? is the book in final form?

19:18 a_strange_guy: ,(format (str "%1$#" 20 \s) "padded")

19:18 clojurebot: " padded"

19:19 a_strange_guy: format strings are as readable as perl...

19:19 amalloy: a_strange_guy: and worse than C's format strings, even :P

19:19 Raynes: kanak: The book is complete. I'm not sure why it isn't out yet.

19:20 amalloy: kanak: it's going through publishing, i think. supposed to be arriving in hard copy this month or next, i forget

19:20 kanak: Raynes: complete as in only printing is left?

19:21 Raynes: I believe so.

19:21 hippiehunter: any idea why this makes a null pointer exception? (defrecord contact-feed [^{Key () :tag List} entry])

19:22 kanak: Raynes: thanks. i guess i should get the ebook then. I was waiting until it was in a finished state.

19:22 a_strange_guy: hippiehunter: do you want to use annotations?

19:23 hippiehunter: yes

19:23 kanak: how does Joy compare to "Clojure in Action" in terms of depth?

19:23 a_strange_guy: e.g. is Key a annotation?

19:23 oh

19:23 hippiehunter: im trying to type a field as java.util.List with @Key

19:23 yeah

19:29 BobFunk_: still trying to figure out why form-dot-clj library is causing problem with app engine

19:29 looking into the error No matching ctor found for class form_dot_clj.server_side$check_integer$fn__721

19:30 when I unzip the jar that lein appengine-prepare made I see the form_dot_clj dir with the server_side$check_integer$fn__721.class

19:31 hippiehunter: are you passing the right number of arguments?

19:31 BobFunk_: anybody know what can cause the "No matching ctor" error?

19:31 amalloy: hippiehunter: he's not calling that constructor directly, of course

19:32 BobFunk_: nopes - using a "def-field" macro from the library that ends up using the function

19:33 a_strange_guy: hippiehunter: try (defrecord contact-feed [^{Key [] :tag List} entry])

19:33 hippiehunter: that got it

19:33 why though?

19:33 amalloy: BobFunk_: that class represents a clojure function, specifically a closure; somehow or other it's trying to close over a number of bindings that is different from the number it expected

19:34 a_strange_guy: the syntax for annotation parameters is [arg arg arg] and not (arg arg arg)

19:34 amalloy: eg, (let [x 1] (fn foo [] x)) turns into a class "foo" with a one-arg constructor expecting to be passed the value of x

19:35 (let [x 1] (fn bar [] 10)) is a class "bar" with a no-arg constructor

19:35 somehow the compiler, or an AOTed something or other, is passing the wrong number of locals to a closure

19:36 BobFunk_: if nothing is AOTed, that simply shouldn't happen; so i'm going to guess that something is AOTed and we just can't find it

19:36 hippiehunter: a_strange_guy: why do i see {} https://gist.github.com/377213

19:36 BobFunk_: really don't get why though

19:38 a_strange_guy: hippiehunter: dunno, ive nerver used parametrized annotations

19:38 amalloy: do (format) and String/format really not include a variable-width specifier like C's %*?

19:38 a_strange_guy: BobFunk_: do you get the "No matching ctor" as a naked error, or wrapped in ExceptionInInitializerException?

19:41 BobFunk_: in the ExceptionInInitializerException

19:41 a_strange_guy: &(eval '(+ 1 2))

19:41 sexpbot: java.lang.SecurityException: You tripped the alarm! eval is bad!

19:42 a_strange_guy: this means that somewhere a macro embeds a function in a form

19:43 (defmacro embed [obj] obj)

19:43 BobFunk_: here's basically all the bits of code involved + the stacktrace: https://gist.github.com/762922#comments

19:43 and yeah, there's a macro - def-field

19:44 that looks up a validation function generator for :integer

19:46 amalloy: ah

19:47 it's trying to (def foo some-function), but it can't embed the function in code

19:47 because it can't be serialized to a string once it's been compiled

19:48 BobFunk_: hmm, so it's a problem with macros and AOT compilation?

19:48 clojurebot: not a problem, the average bid for it on getacoder is $821.00

19:49 a_strange_guy: &(binding [*print-dup* true] (let [local 5] (print (fn a-closure [] local))))

19:49 sexpbot: ⟹ #=(sandbox6382$eval8764$a_closure__8765. )nil

19:49 a_strange_guy: no its a problem with the writer of form-dot-clj xD

19:49 BobFunk_: hehe

19:49 amalloy: BobFunk_: yeah. form.clj isn't right if it's trying to do that

19:50 BobFunk_: hmm, ok - guess I should be looking for another form validation library then

19:50 a_strange_guy: well its presently a limitation of the way print-dup works right now

19:51 i did once extend the print-dup multimethod to serialize closures properly

19:52 https://gist.github.com/313601

19:55 amalloy: a_strange_guy: that's cute

19:55 only works in a single instance of the jvm though, i imagine

19:56 a_strange_guy: yeah, no way to access the bytecode of a class on the JVM

19:58 amalloy: a_strange_guy: someone actually did that; it was on the mailing list a few months ago

19:58 a_strange_guy: really? without instrumentation?

19:58 amalloy: trying to write some kind of persistent-ref that acts like an STM construct and also passed through to a database; it took a while but i think he got closures

20:00 a_strange_guy: ah, found it

20:01 amalloy: http://groups.google.com/group/clojure/browse_thread/thread/dd0f77c885bcfb4e/dd89d34843bfc3a8?lnk=gst&q=dref#dd89d34843bfc3a8 looks like the thread

20:05 a_strange_guy: hm, maybe it never got finished. it looks like closures are on the todo list; did you find any evidence that it was done?

20:18 BobFunk_: anyone got a good tip on whats best to use for forms/validations ?

20:19 ossareh: does anyone know what the default behaviour of trying to save a fraction to a table (jdbc) is going to be - i.e. is it cast to a float?

20:21 BobFunk_: I went through this recently - tried most of the libs out there and ended up rolling my own. Sandbar is very good - forms-dot-clj felt a bit too immature.

20:21 Sandbar didn't fit for me since it required that you knew, up front, what your forms would be - which I don't. I have the format of a form, but no idea about the actual details until later on.

20:21 i.e. at form submission time.

20:22 amalloy: ossareh: jdbc makes you do .setInt, .setFloat, etc, so there's no default i know of; whatever method you call, it will do that

20:22 ossareh: amalloy: ah, I'd not seen that last time I went through this - I was just passing it the vectors or maps or whatever clojure.contrib.sql expects - it has been a while.

20:22 BobFunk_: gonna give Sandbar a try then, since the forms I have right now should be simple enough

20:23 at least gonna have a look at the source

20:23 ossareh: BobFunk_: good luck, feel free to holler at me if you want to ask any questions.

20:25 currentB: sort of on the subject: what's everyone using for html templating these days?

20:25 ossareh: currentB: without question; hiccup.

20:26 I actually converted html5boilerplate to hiccup

20:26 tis a pretty sweet foundation to begin from

20:26 BobFunk_: nice - did you put it on github?

20:27 ossareh: not yet - I was hoping to build out this project first to ensure it works as I think it should. Also I'm unclear on how best to enforce filesystem dependencies

20:27 currentB: my one issue with hiccup is that it doesn't really work if you're outsourcing the design work

20:28 ossareh: currentB: are you getting HTML back from the outsourcer?

20:28 currentB: ideally :)

20:28 ossareh: currentB: if it is xml it shouldn't be too hard to read the doc and output hiccup vectors

20:29 which is actually on the slate for me since I don't want to convert html5boilerplate to vectors by hand each time they update

20:30 currentB: yeah i did that for the last web thing I did with clojure

20:31 just didn't feel particularly scalable

20:34 ossareh: what issues did you find with it as a process?

20:40 BobFunk_: would appreciate any comments you have: https://gist.github.com/763017

20:47 hippiehunter: is there something im doing wrong? Whenever I make a change to a protocol I have to do lein clean or I get error messages like java.lang.IllegalArgumentException: Can't define method not in interfaces: load_unavailability

20:48 BobFunk_: ossareh: nice! will play around with it :)

20:52 amalloy: hippiehunter: i think defprotocol has defonce semantics; restarting the repl is probably necessary, but lein clean shouldn't be unless you AOT something

20:55 hippiehunter: Im only AOT'ing my app-servlet

20:55 by something do you mean anything?

20:56 amalloy: hippiehunter: i don't know enough to be that specific :P

22:23 duck1123: is there a good place to go to see the docs for clojure and contrib for 1.3? Everything is all 1.2

22:24 or am I best just building my own docs

22:25 I wish there was a document that just gave the lookups "if you were using <this>, use <this> now"

22:34 hippiehunter: why does this line result in dat containing more elements then just token and secret

22:34 (let [{:keys [token secret] :as dat} (social/load-from-key social-key)]

22:34 have I missed a caveat or am i mistyping something?

22:34 it seems to contain the entire map, rather than just the keys ive asked for

22:44 amalloy: hippiehunter: you've missed the point of destructuring

22:44 dat will be the whole map because you asked for it with :as; you'll also have locals named 'token and 'secret, representing those values from the map

22:45 &(let [{:keys [a] :as m} {:b 2 :a 1}] [a m])

22:45 sexpbot: ⟹ [1 {:b 2, :a 1}]

22:46 amalloy: if you want to get back a map that only has some subset of the original keys, you want ##(select-keys {:b 2 :a 1} [:a])

22:46 sexpbot: ⟹ {:a 1}

22:48 amalloy: hippiehunter: that help?

22:48 hippiehunter: yeah

22:49 im a little confused as to the purpose of :as though

22:49 amalloy: it's for when you want to pull out some keys, but also keep the whole map around

22:49 hippiehunter: ok, thanks

22:49 amalloy: eg, you need to pass it through to some lower layer, but also want to peek at the :foo key on the way

22:53 hippiehunter: any idea why i can get select-keys from the auto completion in the search bar of clojuredocs.org but if I type it all the way out, it finds 0 search results? It seems to happen to anything i type with a '-'

23:11 amalloy: hippiehunter: good question. i imagine - is being interpreted as a search metacharacter of some kind, like "select, NOT keys"

23:12 hippiehunter: I just took a look on github but ruby is not really my thing

23:29 joshua__: Anyone ever heard of a tagsoup to markdown converter?

23:36 amalloy: joshua__: what would that mean? tagsoup is a program for pretending malformed xml is well-formed; markdown is a format for writing text

23:41 joshua__: ahhh.. well enlive says it uses tagsoup to get its html so..

23:41 I meant is there a way to convert an html resource grabbed by enlive into markdown.

23:41 I guess I was confused.

23:44 amalloy: joshua__: i doubt it. html is much more complete and complicated than markdown; you can convert up to html, but not down to markdown

23:44 joshua__: amalloy: really I just want to convert a subset of html.

23:45 amalloy, and that subset actually fits within the markdown subset

23:45 amalloy: joshua__: you probably have to do it yourself, then. or since you have well-formed xml (courtesy of tagsoup) you might be able to persuade an xslt to do it for you

23:55 joshua__: amalloy, I found a java stackoverflow thread asking how to do this and they pointed to an xlst stylesheet that does it so I'm going the XLST route. I had never heard of it before today.

23:56 * amalloy has battle scars from an xslt endeavor

Logging service provided by n01se.net