#clojure logs

2008-09-13

07:48meredyddWhoever maintains clojure.contrib.sql - I just put a patch on the list to make 'with-connection return its body value rather than nil.
07:49meredydd(and yes, I have the necessary contributor arrangement signed with rhickey)
08:29meredyddrhickey: Do you have my CA?
08:35rhickeymeredydd: only the photo, nothing in the mail
08:35meredyddOh, dear. I sent that quite some time ago.
08:36rhickeyI see your email was from July
08:37meredyddBlast. Looks like I'm going to have to send it again.
08:38meredyddAm I okay with the photographed document just for the present patch (if it's accepted)?
09:22markella_athenshallo, is this a scottish chat room?
09:22markella_athenshallo, is this a scottish chat room?
11:14StartsWithKhow to remove something from *ns* refere map? with ns-unmap?
11:14rhickey_StartsWithK: yes
11:15StartsWithKif i write my own with-refer macro, should i do something like (binding [*ns* *ns*] ..)
11:15StartsWithKand then manipulate refer of that local *ns* var?
11:16rhickey_namespaces are global
11:16StartsWithKthen maybe i woudn't need ns-unmap at all
11:16StartsWithKthanks
11:25StartsWithKok, just one more question. Is this safe? do other threads see new refers? should i maybe create new ns, copy all referes from current ns and add my own in it.
11:26rhickey_StartsWithK: I don't think this is a promising endeavor, as I said, namespaces are global
11:26gnuvinceAre there plans to add Clojure benchmarks to the Computer Language Shootout
11:26gnuvince?
11:27rhickey_gnuvince: I presume someone will at some point
12:30Chouserrhickey_: care to briefly describe the purpose of delayed class loading, or should we just wait until you're done?
12:43rhickey_Chouser: it was an experiment to improve startup time - compile but do not load fns until called. Uses a self-replacing thunk. I only got ~20% improvement, which is less than I hoped.
12:43rhickey_My thinking now is that AOT will trump that.
12:43Chouserhm! ok.
12:44Chousercompiling to Java source is the only AOT you're considering right now?
12:45rhickey_No, I'll look at both, but there are a lot of subtle tradeoffs. There seems to be some relcutance about AOT->Java, any reason?
12:46ChouserI'm not in the target market.
12:46rhickey_One nice thing about Clojure->Java is I can gen one Java file for one Clojure file, instead of 400 .class files. Of course, compiling the Java file will generate 400 classfiles...
12:47Chouserheh.
12:48ChouserI guess I assumed AOT->.class would be easier. I hadn't really considered AOT->.java before you brought it up.
12:48rhickey_There are some awkwardnesses to Java for some expressions (in bytecode I have goto), but my experience with HotSpot tells me it can probably make them go away in the end
12:49ChouserAs I said, I doubt I'll use any of the AOT stuff, but off the top of my head I can't think why AOT->.java is at all inferior.
12:50rhickey_Chouser: you might use AOT if you want to run on Android
12:51Chouserhm, sure. Does Android consume .class?
12:51rhickey_Chouser: yep
12:53rhickey_Chouser: but many things that consume .class trip over any bytecode sequences other than what javac would have generated.
14:10jgracinis there a variant of 'some' which returns the element that matched and not the value of predicate?
14:11jgracinand not -> instead
14:20achim_pjgracin: i've been looking for something like that recently, but found nothing. i ended up rewriting pred as #(if (pred %) %)
14:21jgracinachim_p: yeah, that's what I've been doing too.
14:23jgracinachim_p: I kinda remeber someone talking about that, but it might have been related to 'collect'.
14:27parth_mrhickey: (nth [1 2 3] -1 nil) throws "java.lang.ArrayIndexOutOfBoundsException: -1". Is this by design or is it a bug? (get ..) returns nil.
14:28arohnerhuh, the doc on get doesn't indicate that it also works on vectors
14:29parth_mOh. I missed that. I just saw coll and assumed that it worked.
14:30parth_mIs that a doc error or is it not supposed to work?
14:30arohnerI don't know
14:31achim_pvectors are maps with implicit keys in clojure, as i understand it ...
14:31parth_mActually (doc get) just talks about map but it seems to work like (nth coll idx nil) for vectors. I suppose thats by design.
14:31parth_mAh. .. that makes sense.
14:32achim_pmight be wrong though, i'm not sure :)
14:33arohnerI think clojure vectors have normal vector lookup characteristics, i.e. O(1) by index
14:33arohnerI think it's better to say that vectors are functions of their indices, similar to how maps are functions of their keys
14:37rhickey_parth_m: get and nth work differently by design, that's documented
14:39parth_mrhickey: Is "not-found" arg ignored in nth for -ve index?
14:40rhickey_parth_m: looks like it
14:41rhickey_negative indexes are not meaningful
14:44parth_mTrue. But "not-found" being ignored is somewhat confusing. The use case I have is I want to get some items from a vector (nth v (- len 1) nil) .. (nth v (- len 2) nil) ... and so on.
14:44parth_mThis works fine. However, when len is 0. (- len 1) give -1 and we get an exception.
14:45parth_mThe work around is quite simple ... but I was just thinking what might be intuitive behavior.
14:45parth_mI can fix it in my user code ... but do you think its a good idea to allow not-found for -ve args as well?
14:47parth_mThis would also be consistent with get, so nth+not-found = get for vecs
14:49rhickey_fixed nth with not-found arg - when negative index returns not-found - rev 1025
14:49parth_mVery cool :) Thanks.
16:26arohneris there a way to get the current function you're in?
16:27arohnerfunctionality similar to __FILE__, __LINE__, etc in C?
16:37rhickey_arohner: *file*
16:37arohnerbut no line or function?
16:40rhickey_no
17:35ChouserIn order to expand macros, I've got to resolve symbols at compile time, which means I have to honor (eval?) some expressions at compile time, like in-ns, refer, require, etc.
17:36ChouserOr am I thinking about this incorrectly?
17:38ChouserBut clearly some expressions I do not want to eval at compile time, since that means they would try to run in the JVM when they're written to execute in the browser.
18:15rhickey_Chouser: those expressions won't be in macro logic, only in expansions
18:28jouberthello
18:29joubertI have a question about Java class / Clojure bridging
18:30rhickey_ok
18:30joubertin an API I am using I have to pass a parameter that references a generic type
18:30joubertfor "normal" classes, referencing in Clojure is trivial
18:31jouberte.g. java.util.Date
18:31jouberthowever, I'm uncertain how to specify a generic
18:31rhickey_joubert: just leave off the generic bit
18:31rhickey_i.e. the type parameters
18:32rhickey_e.g. java.util.Collection
18:47Chouserrhickey_: You've explained it several times now, but I'm still not getting it. If I use Compiler/analyze on '(defn foo []), it needs to be able to find defn in the clojure namespace.
18:48Chouserif the user has their own macros, they'd define them in some other namespace, like 'my-ns
18:49ChouserSo if I have a file of clojurescript (.cljs?) it seems most natural to start if off with something like (ns my-js-ns (:use my-ns)), and then proceed to use macros from 'my-ns and 'clojure
18:51ChouserI can analyze that form and get the expansion, but if I just emit js and don't eval it, the following forms in the cljs file will fail to expand my-ns macros.
18:52Chouserfor now, I'm eval'ing just the (ns ...) form, but that doesn't feel right.
19:06joubertrich: perhaps I should be more specific
19:10joubertactually, let me experiment with a few approaches before I ask more questions
19:29rhickey_Chouser: you will have to load into Clojure any macros you'll use in emitting js
19:30rhickey_Since they are only used on the Clojure side, they'll likely be separate from the js code
19:32rhickey_there's no point in sending macro code over to the browser
19:34rhickey_I understand there is an extra level here - compilation deps vs runtime deps. The new Scheme modules distinguish code needed for syntax in some way IIRC. I don't know that we need anything as ornate
19:36rhickey_CL has eval-when
19:37rhickey_we could have a (use ... :when :compile ...)
19:37rhickey_or something