#clojure log - Mar 03 2010

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

0:00 brandonw: how can it use two different version of clojure at once?

0:00 swank-clojure itself doesn't specify a specific version of clojure as a dependency

0:00 unless it is somehow agnostic to which version you use...?

0:02 well, i will have to attack this tomorrow

0:02 i am up way too late (again) :)

0:02 clojure has the habit of making me do that... heh

3:21 vy: Isn't it possible to make "intern" guess the ns from the ns of the caller?

3:48 * zmila has no idea about intern ns

3:55 LauJensen: Morning guys

3:55 All set for Open Source Days this friday ? :)

4:00 esj: Morning folks

4:03 adityo: afternoon folks

4:04 zmila: beforenoon :)

4:05 lpetit: morning :)

4:11 spariev: morning )

4:42 ordnungswidrig: mornig

5:13 pjackson:

5:29 bsteuber: I wonder how github knows about the language of a project - counting known language names in the docs?

5:32 gregh: probably something simpler, like file extensions

5:32 bsteuber: sounds reasonable :) silly me

5:44 LauJensen: bsteuber: When you push into a project, your IP is logged - Github then scours through Google Groups, IRC logs, Fora etc trying to match your IP, once it finds your posts it does some textual analysis on the finds, trying to assert which language you have spoken the most about, in the days and hours leading up to your commit. Its quite simple really

5:45 esj: its only simple because the wrote it in clojure

5:46 otherwise, whew.... nightmare.

5:46 LauJensen: True .. oh yea, and then theres the whole file extension thing :)

5:47 eevar2___: afaik there's actually some parsing going on. or maybe that's ohloh

5:51 dsop: at least it doesnt detect javascript inside java as in gwt, soeople ary only stabbed once for using java and not twice for java and javascript :)

5:53 vy: I define the fooproj ns in fooproj.clj file. How can I make (ns fooproj ...) to load/require fooproj/util.clj, fooproj/main.clj also?

5:53 Chousuke: don't define single-segment namespaces

5:54 but (ns foo.bar (:use foo.bar.util ...))

5:54 vy: Chousuke: So what should I do instead of using single-segment namespaces?

5:55 Chousuke: use a multi-segment namespace :)

5:55 vy: I couldn't understand. Can you given an example please?

5:55 Chousuke: instead of (ns foo) use (ns foo.bar). It's that simple

5:55 single-segment namespaces end up in the default package which causes problems in some cases

5:56 vy: Chousuke: I'm already using something like that. tr.edu.bilkent.cs.vyazici. Are all those multi-segments enough? :D

5:56 Chousuke: ah, that will do :)

5:57 vy: I just want my tr/edu/bilkent/cs/vyazici.clj to load the files I specified under tr/edu/bilkent/cs/vyazici/ directory.

5:57 Chousuke: you can use :load in the ns form

5:58 the files should contain an appropriate (in-ns 'tr.edu.bilkent.cs.vyazici) call though. Just to make sure all the defs end up in the correct namespace

6:00 vy: Chousuke: That's already done. But this time I have to append a "vyazici/" prefix to every file I specify in the :use clause. How can I avoid that?

6:01 Chousuke: hm, what do you mean?

6:02 vy: Here is my ns clause in tr/edu/bilkent/cs/vyazici.clj file: (ns 'tr.edu.bilkent.cs.vyazici ... (:use "vyazici/util" "vyazici/graph" ...)) See those "vyazici/" prefixes?

6:03 Chousuke: shouldn't that be :load?

6:03 but, I don't think there's any way around it.

6:03 it's just a bit of extra typing

6:03 vy: Oops... Yup, I meant :load, not :use.

6:05 Chousuke: you could of course call load manually like (apply load (map #(str "vyazici/" %) '[util graph ...])))

6:05 but I don't think that's much better.

6:10 vy: Chousuke: I wish stu's ticket about ns macro would get approved.

6:12 Chousuke: It'll probably get reworked at some point.

6:36 bsteuber: laujensen: just read the github/google interpretation you gave an hour ago - yeah, that sounds very reasonable to me :)

6:53 zmila: is there an efficient way to map and return only not-null results? other then use mapcat and wrap result into list (mapcat (fn [item] (if (,,,) (list newitem) nil) coll)

6:55 esj: could try for with a :when clause ?

6:58 zmila: thx esj! it works :)

6:58 esj: np

7:12 Maddas: (filter identity ...) should work too

7:13 esj: even nicer !

7:14 Maddas: :)

7:14 AWizzArd: If you only want to remove nils from your coll (and keep 'false') then (remove nil? coll) is even better.

7:14 ,(filter identity [1 2 nil 3 4 false 5 true 6])

7:14 clojurebot: (1 2 3 4 5 true 6)

7:14 AWizzArd: ,(remove nil? [1 2 nil 3 4 false 5 true 6])

7:14 clojurebot: (1 2 3 4 false 5 true 6)

7:14 zmila: i want map and remove nils

7:15 Maddas: Oh, sorry, I misread that.

7:15 * Maddas shakes his fist at AWizzArd

7:15 AWizzArd: Then I suggest you to (remove nil? (map ...)). This documents your code best.

7:15 * Maddas agrees

7:16 zmila: (remove (map )) does two iteration over the coll, don't?

7:20 bsteuber: zmila: I don't think so - lazy sequences kick ass =)

7:23 zmila: bsteuber - yes, you're right! (remove nil? (map ,,,)) works even quicker than (for :when ) in my case

7:24 esj: so, while we're on this, I use a (for :while) to processing to stop when a nil is hit. Is there another way ?

7:25 an until ?

7:34 bsteuber: ,(doc take-while)

7:34 clojurebot: "([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."

7:36 bsteuber: (take-while (complement nil?) collection) seems a little verbose, though

7:38 esj: merci !

7:45 zmila: could smbd show example of using (when-let )?

7:47 esj: check out cgrand's kickass solution on this thread: http://groups.google.com/group/clojure/browse_thread/thread/49bd20eb4bcba20c/269d55e544d3a55a?lnk=gst&q=kata#269d55e544d3a55a

7:47 he uses a when-let

8:00 AWizzArd: esj: do you know about :when?

8:00 In a for.

8:01 esj: your asking question altered my state...

8:01 i guess I don't, what's the catch ?

8:02 AWizzArd: I just wanted to mention it. It can add a filtering effect to for.

8:02 esj: hmmm..... like my suggestion at 11:55 ?

8:06 AWizzArd: Ah, 12:55

8:07 esj: aaah, timezones

8:07 bsteuber: haha

9:20 powr-toc: What's the idiomatic way to evaluate a symbol?? Should I do (eval '+) or is there something more specific I can use?

9:22 lpetit: powr-toc: wanna give more context ?

9:23 chouser: you can get similar results in that particular case with (deref (resolve '+)), but yeah it'd be good to know what you're trying to do.

9:23 or perhaps why

9:24 powr-toc: lpetit: sure... I have a function, that currently takes a value as an argument... I want to modify it to take the symbol, so I can look up some metadata on it and then resolve the symbols value

9:24 I think derefing is what I'm wanting

9:25 rhickey: symbols don't have values

9:25 powr-toc: rhickey: yeah, I mean resolving the symbols var and derefing that :-)

9:25 chouser: resolve find the value of a Var named by the symbol. If you mean for the symbol to name a local, resolve won't work.

9:26 actually, resolve just finds the Var. deref gets its value.

9:26 powr-toc: chouser: yes, I think that's what I want to do

9:26 rhickey: powr-toc: but you could instead pass a var instead of a symbol

9:26 powr-toc: rhickey: good point!

9:26 rhickey: since the metadata you want is probably on the var anyway

9:27 powr-toc: rhickey: it is

9:28 rhickey: thanks for that :-)

9:29 praptak: Is there a cat that is more lazy than lazy-cat? Something that yields a lazy sequence that is a concatenation of a lazy sequence of sequences?

9:31 rhickey: praptak: (apply concat lazy-sequence-of-sequences)

9:31 praptak: Thanks!

9:31 AWizzArd: Experts of combinatorics, here is a nice riddle for you: For which FOO will we get (foo [[1] [2 3] [4] [5 6]]) ==> ([1 2 4 5] [1 2 4 6] [1 3 4 5] [1 3 4 6])?

9:32 foo must be a function. The FOR macro can do it:

9:32 ,(for [x1 [1], x2 [2 3], x3 [4], x4 [5 6]] [x1 x2 x3 x4])

9:32 clojurebot: ([1 2 4 5] [1 2 4 6] [1 3 4 5] [1 3 4 6])

9:33 AWizzArd: Foo should not be a function that constructs and evals a for loop :)

9:35 eliantor: ,(doc extends?)

9:35 clojurebot: Huh?

9:36 eliantor: ,(doc defprotocol)

9:36 clojurebot: Pardon?

9:36 lpetit: ,(source for)

9:37 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

9:37 lpetit: ~source for

9:38 eliantor_: I posted clojure group but my message doesn't seens to appear

9:39 chouser: AWizzArd: clojure.contrib.combinatorics/cartesian-product

9:39 eliantor_: oh well i reloaded the page once more and it's posted now

9:39 does clojurebot understands protocols and datatypes functions?

9:40 AWizzArd: chouser: 100 points

9:41 chouser: AWizzArd: cool! Can I redeem those points for plane tickets to Clojure conferences?

9:41 ,`defprotocol

9:41 clojurebot: sandbox/defprotocol

9:41 chouser: eliantor_: looks like it doesn't.

9:42 ,(clojure-version)

9:42 clojurebot: "1.1.0-master-SNAPSHOT"

9:42 eliantor_: oh thanks

9:42 chouser: huh. pre-1.1 even

9:42 eliantor_: i just downloaded the nightly build

9:43 and trying to use extends? extenders and satisfies, but they dont seem to work

9:43 they always return nil

9:44 AWizzArd: chouser: we can talk about this if you plan to visit Europe as a speaker on a Clojure Con :)

9:46 chouser: eliantor_: hm... I think you're running into a sort of impedence mismatch between protocols and deftype. If you use extend instead of deftype, I think you'll see what you're expecting.

9:46 (extend-class String P (foo [x] (str "This is a string: " x))

9:46 (extends? P String) ;=> true

9:47 dunno if the behavior of (satisfies? P T) is going to change or not

9:48 oh

9:48 (satisfies? P (T)) ;=> true

9:49 eliantor_: 'satisfies?' wants an instance of the the object to check against a protocol.

9:49 eliantor_: it's the only one i didn't tried

9:50 i don't remember exactly the docs but i think they are not clear on this

9:56 S11001001: clojure 1.1: (defn- helper [] ...) (defmacro the-thing [] `(helper)), then, in another module, (module/the-thing) => "IllegalStateException: var: #'module/helper is not public". Any way around this other than publishing helper?

9:57 chouser: `(#'helper) might do it

10:03 S11001001: thanks, unfortunately, nth not supported on this type: Symbol

10:03 oh, I was macroexpanding the wrong thing, it worked. Thanks again chouser

10:04 chouser: np

10:12 eliantor_: if i define a protocol (defprotocol P (foo [x] )) (type P) i get clojure.lang.PersistentArrayMap, so protocols don't have a type of themselves

10:13 what if i want to know something like (protocol? P) ?

10:15 chouser: a protocol is currently just a map. You really have an object that at runtime might be a protocol or might be something else?

10:16 eliantor_: no, i was just trying to understand :)

10:16 chouser: you can look at a protocol and glean useful info from it. You tried just P at the repl?

10:16 eliantor_: yes

10:16 it gives me a map

10:17 chouser: right.

10:17 eliantor_: i'm not on my machine so i'cant try it again

10:17 chouser: the one you've defined by whatever combinations of defprotocol and extend you've invoked

10:18 rhickey_: protocols are currently opaque other than what is provided by the api, everything else representation-wise could change

10:19 chouser: heh, perhaps "should be treated as" rather than "are"? Because the thing is a map the nicely prints all kinds of stuff about itself.

10:43 zmila: am I missing: what multi-line comments in clojure? besides (quote ...)

10:44 lpetit: rhickey_: hello. did you work on this issue that was talked about in the ml ? http://groups.google.com/group/clojure/browse_thread/thread/a8b4a1a00fe8d0f2/9f0ba0234487b00b?lnk=gst&q=engelberg#9f0ba0234487b00b

10:44 a_strange_guy: zmila: #_

10:44 rhickey_: lpetit: yes, I have some ideas involving macros in deftype/reify

10:45 a_strange_guy: ,(+ 1 2 #_(ignored until) 3)

10:45 clojurebot: 6

10:45 lpetit: rhickey_: cool. was just a checkpoint, thanks :)=

10:45 :)

10:45 rhickey_: hopefully I'll get to that within the next week or so

10:46 I'm definitely not satisfied with how it is now

10:48 zmila: a_strange_guy, thanks, but #_ requires that the next form be valid clojure syntax? what if i want paste some unstructered text and hide it from reader?

10:49 chouser: zmila: there's no true multi-line comment in clojure. Just put ; at the front of each line for text that's can't be read by the reader

10:49 zmila: many editors provide a convenient way to do this

10:49 stuartsierra: Or write #_ "comments in a string"

10:50 chouser: which is ok until you want quotes in you comment. :-/

10:50 zmila: chouser, yes. but eclipse plugin still not :)

10:51 a_strange_guy: i actually noticed that almost anything is valid for the reader

10:52 just use #_ and parens-matching

10:54 lpetit: chouser: what is "a convenient way" ? if hitting Enter and quitting a comment line, automatically add a ; at the right indentation level in the newline ?

10:58 chouser: lpetit: I use vim. with just a few keystrokes I can add ; to the front of a block of text, with a few less I can tell it I'm going enter a bunch of text for which I'd like it to insert ; at the front of each line.

10:58 lpetit: ah, ok, this one. I thought "while typing"

10:59 chouser: the second part is interesting. I'm not sure there's an equivalent in eclipse

10:59 chouser: how do you "end" the sequence ?

10:59 chouser: lpetit: I'm not quite sure what you're asking. If I'm on a line that starts with a ; and in insert mode press <enter>, the next line gets a ; automatically

11:00 if I don't want that ; there, I just backspace over it and go back to writing code

11:01 lpetit: chouser: ok

11:29 Licenser: is there something good for a REST web framework in clojure?

11:29 chouser: for the server side I like ring

11:30 Licenser: hmm ring, the doesn't ring a bell - I'll ask Mr. G. oogle

11:32 chouser: http://github.com/mmcgrana/ring

11:34 Licenser: ah found it :) thanks chouser

11:50 danlei: chouser: btw, I think you were right yesterday, "let block" is actually used. (but the hyperspec example you posted was something different)

11:51 chouser: I don't think I posted a hyperspec link. Perhaps Chousuke did.

11:51 danlei: ah, ok

11:53 chouser: ,(case Integer/MAX_VALUE Integer/MAX_VALUE :good)

11:53 clojurebot: java.lang.Exception: Unable to resolve symbol: case in this context

11:54 chouser: oh. anyway, apparently static final fields don't work as case test-constants

12:04 brandonw: hmm perfect timing

12:05 technomancy: i had some questions on how swank-clojure works

12:05 is swank-clojure agnostic of the clojure version you specify as a dep in your project?

12:05 technomancy: brandonw: it should be

12:06 brandonw: how do you manage that?

12:06 technomancy: brandonw: it doesn't use any 1.1+ features and doesn't have AOT'd classes

12:06 so it's compatible across versions even up to a year old

12:06 brandonw: ah, that is what i was thinking

12:07 i finally got around to finishing a lein-nailgun plugin that mimics your lein-swank plugin, but for vimclojure

12:08 but it has some dependency issues on specific clojure versions. i'll have to check out the vimclojure source to see how hard it would be to take out any 1.1+ stuff and see if there are any AOT'd classes

12:09 technomancy: AOT is the biggest problem. supporting 1.0 is not as big of a deal.

12:11 brandonw: yeah, looking through the clojure source of vimclojure real quick i don't see anything 1.1+

12:11 do you not have any deps on contrib at all either?

12:14 technomancy: I think they are optional.

12:15 brandonw: yeah, especially for something like supporting quick pprint usage, i would think

12:17 S11001001: technomancy: I was reading jar.clj, and was wondering why you defined a method on copy-to-jar for nil instead of saying (write-jar project jar-file (remove nil? filespecs)).

12:19 technomancy: S11001001: that does sound strange. I don't remember why it's done that way.

12:19 patches welcome. =)

12:20 brandonw: technomancy: when you say that you don't use AOT, is that because it hasn't always existed in clojure (pre-1.0)? or is it because there have been changes in how AOT works since 1.0?

12:23 chouser: case doesn't macro-expand its test-cases does it?

12:24 oh it can't because parens means "or"

12:46 technomancy: brandonw: using AOT locks you to a specific version of clojure. libraries AOT'd with 1.1 will not work with other versions.

12:48 brandonw: okay

12:48 i looked a little into the vimclojure group and meikel has made changes in the current dev version that tries to reduce dependency on a specific clojure version

12:48 so it is in the pipeline :)

13:03 hiredman: clojurebot: ping?

13:03 clojurebot: PONG!

13:06 gregh: ,'PONG!

13:06 clojurebot: PONG!

13:10 esj: sssh cb, people are trying to work here.

14:00 Licenser: Hy I've a project which I'd love to release, so I am not sure about which license to choose I thought about what I want but I really have a problem to decide which license is best fitting for me. Main problem might be that I have a very hard time to read the juristic english and understand it. What I want is: 1) The code shall stay open source. 2) Everyone can modify & use etc the code 3) It may be used commercially (as long as code stays OS)

14:00 when it is used the user should note it somewhere (as in acknowledge the work done) 5) I don't want to hold any warrenty.

14:04 stuartsierra: Licenser: GPL will do that.

14:04 hiredman: :(

14:04 only if you are willing to go to court over it

14:04 gregh: well that depends on what exactly you mean by (3)

14:04 Licenser: stuartsierra: commercial use? I don't like the GPL

14:05 chouser: but you can't mix GPL code with clojure code.

14:05 Licenser: that validates 2) :P

14:06 chouser: Licenser: I think for a clojure project, you should go with EPL unless you can point out some way in which it is deficient.

14:06 and from my rather weak understanding of the EPL and your requirements, it'll do.

14:07 Licenser: chouser: my problem is I read the EPL but didn't understood a work

14:07 *word

14:07 chouser: yeah. :-/

14:07 bilts: what's the issue with mixing GPL code and Clojure code?

14:07 programble: Licenser: what do you license? :P

14:07 Licenser: programble: A) a engine for game combat B) a JS framwork to visualize the fights

14:08 A) is written in clojure

14:08 programble: Licenser: cool

14:08 Licenser: I know it's not really a topic for the channel but people here are more helpfull then in most other channels :P

14:08 programble: lol yeah

14:08 most people in freenode help channels are assholes

14:09 very rude and tell you you are stupid type

14:09 chouser: GPL only may be mixed with something that amounts to GPL, and EPL is not exactly that. So GPL effectively excludes EPL, and Clojure is EPL.

14:09 Licenser: I am the stupid type!

14:09 programble: lol

14:09 technomancy: chouser: depends on your definition of derived of course.

14:09 programble: but people in here will liekly not tell you that

14:10 Licenser: I don't think that counts, I can compile GPL code with VisualStudio

14:10 programble: license your code under teh WTFPL

14:11 hiredman: Licenser: but vs is not under a viral license

14:11 Licenser: What I don't want: Someone use my code without telling anyone and claiming my work. Someone using my code and making it better without recontributing to the world. I won't mind someone using it in a game for example.

14:11 is clojure?

14:11 hiredman: no

14:11 Licenser: see :P

14:11 fanatico: a recent writeup on what "derivative" means: http://perpetualbeta.com/release/2009/11/why-the-gpl-does-not-apply-to-premium-wordpress-themes/

14:12 "The Galoob court rejected Nintendo’s argument. In order to be considered a derivative work, the alleged derivative must “physically incorporate a portion of a copyrighted work… [or] supplant demand for a component of that work.”"

14:12 stuartsierra: Licenser: Enforcement of GPL/EPL tyep licenses is very weak; you're better off just asking nicely.

14:12 Apage43: quickly learning not to just toss parenthesis all willy-nilly in when code doesn't compile due to a mismatch.. it makes it compile but severely changes the behavior.

14:12 fanatico: I don't think using clojure in a gpl'd project fits that definition.

14:12 programble: is the WTFPL GPL compatible?

14:13 S11001001: yes

14:14 Licenser: I know stuartsierra but what I certenly done't want is that I violate my own license in the future

14:14 programble: WTFPL is good for small things that don't matter much, i go with GPL otherwise

14:14 Licenser: I don't like the GPL :(

14:14 Chousuke: I think the MIT licence is better than the WTFPL

14:14 Licenser: I agree less aggressive

14:15 programble: ...

14:15 wut

14:15 how is anything less aggressive than WTFPL

14:15 Chousuke: And it incorporates a warranty disclaimer, and more legally sound language :)

14:15 programble: lol

14:15 Licenser: So generally there is no good license to use?

14:16 chouser: Again, for maximum Clojure compatibility, I'd recommend going with EPL unless you know it doesn't fit somehow.

14:16 stuartsierra: Licenser: You can't violate your own license. You created it, you own the copyright, you can do whatever you want.

14:16 Chousuke: wouldn't EPL work for you?

14:16 * programble doesn't care about the license he uses cuz hes never made anything worth creating deriative works or stealing

14:16 Licenser: Chousuke: I am not sure what the EPL exaclty does :P

14:16 technomancy: http://en.wikipedia.org/wiki/Eclipse_Public_License

14:17 Chousuke: it's kinda like the GPL, but doesn't propagate itself to works linked against EPL code

14:18 programble: GPL is kinda annoying that way

14:18 Chousuke: ie. someone who modifies *your* code has to distribute their changes, but any code they develop and distribute alongside an unchanged binary of your code, can be licenced in whatever fashion they like.

14:18 Licenser: So if someone wants to use my code and make money with it, it's fine. But would they be allowed to do so 'secretly'?

14:18 Chousuke: that is EPL?

14:18 Chousuke: I'm not sure if the EPL requires attribution.

14:19 I'm not a lawyer, so don't count on me for legal advice, but that's my impression :)

14:19 danlarkin: use use 3-clause BSD :)

14:19 s/use/just/

14:19 SynrG: is it necessary to make code compatible with the license of the interpreter that runs it?

14:19 programble: just use public domain :P

14:19 Chousuke: the public domain is problematic :P

14:20 SynrG: for most of my projects i favour GPL. i wouldn't deliberately choose a license that's not compatible

14:20 danlarkin: programble: it's questionable whether it's possible to put something in public domain in the US :)

14:20 programble: well why not?

14:20 public domain makes it so no one has to worry about it

14:20 chouser: SynrG: probably not. But Clojure is not an interpreter -- clojure programs must be "linked" (by the JVM) to clojure.jar. I believe this violates vanilla GPL

14:20 programble: no legal anything

14:21 Chousuke: it's still a legal thing

14:21 loosely, it means the absence of copyright holders

14:21 programble: a legal thing with nothing really about it

14:21 Chousuke: in some countries, you can't place things in the public domain.

14:21 danlei: how about putting clojure in ones own jar? is that already a modification?

14:21 Chousuke: you simply can't give away your rights.

14:21 danlei: probably not.

14:21 danlei: ok

14:21 SynrG: chouser: so i would need to GPL with a linkage exception

14:22 chouser: SynrG: that might do it, yes.

14:22 Chousuke: danlei: and still, it would only require you to distribute the clojure sources :)

14:22 programble: Chousuke: what about things like the song "Happy Birthday"

14:22 danlei: Chousuke: I see, thank you!

14:22 programble: that are in public domain because the copyright holders are unkown

14:22 danlarkin: programble: ha! funny you use that as an example

14:22 SynrG: chouser: still just learning. i think i'd want to have a talk with debian-legal first, as most of my code is targetted specifically at debian

14:22 Chousuke: programble: things end up in the public domain. the question is whether you can intentionally *place* things there

14:22 danlarkin: happy birthday is _not_ in the public domain

14:23 Licenser: I'll try to find some explenation of the EPL

14:23 SynrG: they are bound to have some particular views on it

14:23 Chousuke: programble: in the US that's probably possible, but elsewhere it might not be.

14:23 fanatico: programble: Time Warner owns "Happy Birthday".

14:23 chouser: http://www.snopes.com/music/songs/birthday.asp

14:23 fanatico: seriously.

14:23 http://en.wikipedia.org/wiki/Happy_Birthday_to_You#Copyright_status

14:24 programble: damn

14:24 w/e

14:24 you know what i mean

14:24 very old songs and things

14:25 old stuff

14:25 so wait

14:25 ...

14:25 is it legal to sing happy birthday?

14:25 fanatico: did you pay your public performance royalties?

14:26 programble: >_> no

14:26 although

14:26 i wouldnt call it public

14:26 so... i think im fine

14:27 fanatico: Any reason deftype doesn't support vararg-style constructors?

14:28 programble: to annoy you

14:29 chouser: fanatico: if your deftype mentions IPersistentMap, you can assoc onto instances after creation.

14:29 (deftype Foo [a b] clojure.lang.IPersistentMap) (assoc (Foo 1 2) :x 3 :y 4) ;=> #:Foo{:a 1, :b 2, :y 4, :x 3}

14:30 Licenser: hmm after reding some FAQ about the EPL Ikind of like it

14:31 programble: Ikind? is that an interface?

14:33 technomancy: my biggest complaint with the EPL is the word "Eclipse"

14:33 programble: lol

14:33 chouser: (extend-class Licenser Ikind (like [x] true))

14:33 Licenser: ^^

14:36 hmm do I have to put a header in the code for EPL?

14:38 technomancy: I certainly hope not.

14:38 Licenser: okay fine fine :)

14:39 dakrone: is the EPL compatible with the LGPL?

14:39 technomancy: I think that's just something that people do because they're used to working in Java where you already have a bunch of boilerplate anyway. =)

14:39 Licenser: ^^

14:40 programble: shouldnt you at least have a one liner'

14:40 ; License under the EPL

14:40 Chousuke: or ; see LICENCE file for details

14:40 technomancy: programble: that goes in the readme

14:40 or license

14:40 doesn't have to be spewed across every single file.

14:40 programble: if the files get separated?

14:41 Chousuke: I think a simple licence header should be in every file

14:41 makes things easier in case someone inspects just one of the file

14:41 s

14:41 technomancy: programble: then they're still under the same copyright as before; nothing changed

14:42 programble: ^ like Chousuke said

14:42 Chousuke: technomancy: yes, but it's an issue for people who need to know what the licence is :)

14:42 technomancy: Chousuke: hopefully they can tell from the ns clause what project the file is a part of and do the legwork to track it down.

14:42 they're the ones wanting to use the code; they can do a little more work to figure it out. =)

14:42 Chousuke: Yes. unless the project was relicenced in the meantime.

14:43 or a number of other funky things happened

14:43 A header doesn't take much space, and makes things simpler, so I would include one in any case, just to be safe.

14:43 programble: funky thigns

14:45 technomancy: btw: someone with commit rights to contrib should remove this file: http://github.com/richhickey/clojure-contrib/blob/master/CPL.TXT

14:48 rads: how do I sort a query with congomongo? use the java api?

14:48 chouser: technomancy: done, thanks.

14:48 tomoj: rads: I think there is no other way yet

14:48 I was going to write a patch for that but haven't had time yet

14:52 rads: how do you even sort with the java api? can't seem to find it

14:53 oh, it's part of DBCurosr

14:53 DBCursor*

15:08 reburg: hey, i'm having a problem where JSwat doesn't show line numbers in clj files, and i'm unable to set breakpoints. google dug up a few other people with a similar problem, but i couldn't find any solution.

15:08 hiredman: reburg: how are you loading the clojure code?

15:10 reburg: i'm connecting to a remote (actually local) running java process, manually setting the sourcepath.

15:11 hiredman: reburg: did you see http://groups.google.com/group/clojure/msg/267cc5cc6cef6403

15:13 reburg: hiredman: i should try it in a less cockamamie setup... the thing i'm debugging is a java embedded in another application, and i've hacked clojure to use a funny classloader

15:14 Drakeson: is (fn [x] (when (pred x) x)) defined somewhere?

15:15 actually, I meant (fn [pred x] (when (pred x) x))

15:16 tomoj: how about (if x x y)

15:17 Drakeson: tomoj: that is "or"

15:17 tomoj: oh, (or x y)

15:17 yep :)

15:17 thanks

15:17 kotarak: tomoj: beware if nil and false are valid values

15:17 tomoj: thanks, they aren't

15:18 hiredman: Drakeson: when-let?

15:18 bleh actually it's and

15:18 (and (pred x) x)

15:19 Drakeson: ,(defn assure [pref x] (when (pred x) x))

15:19 clojurebot: DENIED

15:19 hiredman: ,(and (even? 2) 2)

15:19 clojurebot: 2

15:19 hiredman: ,(and (even? 1) 2)

15:19 clojurebot: false

15:19 Drakeson: hiredman: the whole point is to have just one "x"

15:20 hiredman: *shrug*

15:20 Drakeson: (defn assure [pref x] (when (pred x) x)) (assure not-empty? (some computation))

15:22 or maybe even better, (assure coll? not-empty? nice? high-quality? (some calculation))

15:31 fliebel: I don't want to start a language war, but I'd like to hear some opinions about other lisps, I never did any lisp before clojure, are they very different?

15:32 danlei: they all share sexps

15:33 (but some have surface syntax, like dylan)

15:33 hiredman: fliebel: http://clojure.org/rationale there is a section on lisp

15:38 fliebel: thanks

15:40 I'm looking for a Clojure internship in The Netherlands, but I only found one for Common Lisp.

15:47 Drakeson: wasn't there a variation of -> that stops when any intermediate result is nil?

15:47 tomoj: -?>

15:47 in contrib

15:47 (I think)

15:47 ordnungswidrig: tomoj: yes.

15:48 tomoj: clojure.contrib.core/-?>

15:50 Drakeson: thanks :)

15:52 reburg: hiredman: ok, i've now tried it in a vanilla kind of setup. i still get no line numbers in jswat's source window, and can't set any breakpoints

15:52 hiredman: :(

15:53 vanilla as in you followed th instructions in that post?

15:55 reburg: hiredman: yeah. i made a simple namespace "cycljng.hello" with one method, started a clojure instance with the debug-related stuff on the command line and clojure.jar and the directory w/ the cycljng directory in the classpath, did (load "cycljng/hello"), then attached jswat

15:56 hiredman: reburg: yeah, no

15:57 reburg: hiredman: "yeah, no" meaning i did it wrong?

15:58 hiredman: reburg: I think you'll need to aot compile your code

15:58 reburg: ok, well i actually did that first

15:58 dnolen: how can one download jars directly from clojars?

15:59 reburg: dnolen: clojars.org/repo

15:59 hiredman: but it didn't seem to work. since the link you pointed to said to load the file at the repl, i did that

15:59 hiredman: hmmm

15:59 ok, sorry, I dunno then

16:00 reburg: hiredman: thanks anyhow. i'm gonna maybe try a 3.x version of jswat

16:01 although the jswat page complains that there's some bug w/ jdk6u11+ and older versions...

16:04 initial success! jswat 3.16 shows the line numbers! now i try breakpoints.

16:06 aaaand it works. apparently the moral is that updating your software is bad.

16:26 cljneo: hi, how can I add a specific directory to the classpath before launching slime/swank to start a repl

16:33 mabes: For logging in a compojure app what is the popular method? Use org.mortbay.log.Log or clojure.contrib.logging? Totally new to both so I don't know what the potential tradeoffs would be...

16:33 or maybe c.c.logging can be used with org.mortbay.log.Log?

16:35 arohner: cljneo: are you using lein?

16:35 cljneo: or starting manually?

16:35 cljneo: yes but I don't need to create a project. I just want to launch a repl to experiment with a library

16:37 arohner: I see some functions in swank but I don't know how to use them. Like swank-clojure-classpath

16:37 arohner: cljneo: the easiest way is probably to just make a simple project.clj

16:38 and dump your library .jar in lib/

16:38 Chousuke: I think you can just do (add-to-list 'swank-clojure-classpath "somepath")

16:38 then start swank

16:38 arohner: if you're already using lein

16:38 if you're using lein

16:38 cljneo: let me try that

16:38 reburg: cljneo: if you're using slime, making a lein project file and then running lein swank is probably just as simple as configuring swank

16:43 cljneo: I tried Chousuke's form but got (void-variable swank-clojure-classpath)

16:49 Chousuke: hmm

16:49 you need to have swank required, of course.

16:49 let me check my config :P

16:50 yeah, at least I didn't get the variable name wrong :)

16:52 Though it might be that the variable won't exist even after clojure-swank is loaded. I guess you'll have to do (setq swank-clojure-classpath (list "paths")) or something then :/

16:52 cljneo: I'll try that

16:52 Chousuke: make sure you include the clojure jar in the paths :)

16:55 cljneo: even if swank is loaded, the classpath does not change. Doesn't the jvm support dynamically adding to the classpath?

16:58 Licenser: there shall be releases!

17:01 technomancy: cljneo: it does not.

17:01 brandonw: cljneo: http://github.com/technomancy/swank-clojure look under Usage after step 4.

17:03 cljneo: I see. I searched and found it cannot be done (changing classpath) except with a hack

17:04 like the one here http://www.velocityreviews.com/forums/t148021-dynamically-change-the-classpath.html

17:30 nathanmarz: technomancy: leiningen q for you

17:57 technomancy: nathanmarz: oh?

18:00 nathanmarz: so my app is dependent on hadoop, but i can't include hadoop as a dependency using the normal mechanisms

18:00 for two reasons: one, i'm using uberjar to distribute my jobs and can't include hadoop in there

18:00 second, i need to set some configs in hadoop to get my local setup working correctly

18:01 i ended up hacking leiningen so that project.clj could include something like ":external-libraries [(System/getenv "HADOOP_HOME")]"

18:01 what are your thoughts on that / should i be doing this a different way?

18:02 tomoj: it seems 'lein test' has a 0 exit code when the tests fail

18:04 technomancy: tomoj: yes, it's impossible (afaict) to return an exit code from the subclassloader in which the tests run.

18:05 nathanmarz: maybe put hadoop configs in resources/?

18:05 tomoj: technomancy: that sucks

18:05 guess I should grep it?

18:06 technomancy: tomoj: there might be a way to do it with some more digging into the ant API, but I couldn't find a way when I looked.

18:06 nathanmarz: oh, I see what you mean. yeah, I remember hadoop configuration being pretty disastrous.

18:07 nathanmarz: yea, i don't want to distribute the configs i have locally - that's just for testing stuff locally

18:13 tomoj: "! lein test | grep -q FAIL" seems to work

18:30 jcromartie: It seems to me that Clojure would be a great place to build a rules engine.

18:49 dcnstrct: hi. Question: when you compile a clojure program down to .class files.. the bytecode that is produced... is it relatively trivial to decompile these .class files and reverse engineer them just like normal java bytecode ? or is the code significantly obfuscated ?

18:50 a_strange_guy: dcnstrct: pretty impossible to do so

18:50 arohner: dcnstrct: it's not intentionally obfuscated

18:50 how readable it is depends on how good at assembly you are :-)

18:51 dcnstrct: so would you say it's at least as obfuscated as jruby bytecode ?

18:51 programble: why does it matter?

18:52 arohner: if you're curious about how readable it is, just go look at one

18:52 dcnstrct: well I'm thinking of building consumer application that I will have to ship to customers and I would rather keep the program from being cracked for a while if I can

18:52 good idea arohner

18:53 arohner: basically every DRM system ever created has been cracked. It's just a question of motivation

18:54 dcnstrct: yes :) I know DRM never even worked in theory much less in practice.

18:54 a_strange_guy: dcnstrct: if they are motivated, they could start a repl inside your program and poke around

18:56 dcnstrct: I just wanted to make sure clojure byecode didn't decompile into prestinly readible java class files. These crackers are not goin to go through the trouble to learn clojure. Besides poking around in my program from a repl would not be much of a problem that would not help them defeat the licensing system.

18:58 a_strange_guy: the classfiles rarely decompile into legal java

18:58 arohner: I have a deftype that implements IPersistentMap. I want to print its contents in an exception message, but I the string 'foo__3857@df0f7c2" appears

18:59 rather than the output that (pr foo) would generate

18:59 a_strange_guy: arohner: don't use toString

19:00 ,(print-string (map str '(1 2 3 4 5)))

19:00 clojurebot: java.lang.Exception: Unable to resolve symbol: print-string in this context

19:02 a_strange_guy: ,(pr-str (map str '(1 2 3 4 5)))

19:02 clojurebot: "(\"1\" \"2\" \"3\" \"4\" \"5\")"

19:02 arohner: a_strange_guy: thanks

19:02 a_strange_guy: ,(str (map str '(1 2 3 4 5)))

19:02 clojurebot: "clojure.lang.LazySeq@47ed8d2"

19:05 {newbie}: ,(doseq (str (map str '(1 2 3 4 5))))

19:05 clojurebot: java.lang.IllegalArgumentException: doseq requires a vector for its binding

19:06 {newbie}: ,(doall (str (map str '(1 2 3 4 5))))

19:06 clojurebot: "clojure.lang.LazySeq@47ed8d2"

19:07 a_strange_guy: {newbie}: i was just demonstrating the difference between print and .toString

19:08 {newbie}: a_strange_guy: and I was trying to do a retarded thing

19:08 a_strange_guy: ;)

19:08 lazy strings

19:09 {newbie}: yeah

19:09 I didin't look at the "s

19:09 around lazyseq

19:18 slyphon: how do you "append" an element to the end of a vector?

19:18 assoc?

19:18 technomancy: conj'll do it

19:18 slyphon: oh, duh duh duh

19:18 of course

19:19 awesome

19:22 hrm

19:22 there's no built-in way to uniq a (non-infinite) sequence?

19:23 technomancy: slyphon: you can convert it into a set.

19:23 ,(set [2 2 2 34 4 5])

19:23 clojurebot: #{2 34 4 5}

19:23 slyphon: yeah, and lose ordering...

19:23 technomancy: true

19:24 slyphon: oh, sorted-set

19:24 no

19:24 hrm

19:24 i guess i can just do includes? before adding the item

19:37 heh, from the Dept. of Helpful Documentation:

19:37 array-map: Constructs an array-map.

19:37 thanks!

19:51 hiredman: ,(doc split-with)

19:51 clojurebot: "([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"

19:52 hiredman: ^- implementation in docstring

19:52 ,(doc distinct)

19:52 clojurebot: "([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"

19:56 slyphon: oh, that'll do it

19:58 hiredman: ~def distinct

20:01 programble: how can i tell if a value is in a list?

20:01 ,(some? \a "aeiou")

20:01 clojurebot: java.lang.Exception: Unable to resolve symbol: some? in this context

20:01 programble: er

20:01 ,(some \a "aeiou")

20:01 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn

20:02 programble: agh im so n00b

20:02 lol

20:02 ,(some #(= % \a) "aeiou")

20:02 clojurebot: true

20:02 programble: that works, but is there an easier/shorter way?

20:05 a_strange_guy: ,(some #{\a} "aeiou")

20:05 clojurebot: \a

20:07 programble: excuse my n00bness...

20:08 some takes a predicate or a set?

20:09 arohner: programble: sets, and maps, can operate as functions

20:09 ({:a 1 :b 2} :b)

20:09 returns 2

20:09 ,({:a 1, :b 2} :b)

20:09 clojurebot: 2

20:09 arohner: ,({:a 1, :b 2} :bogus)

20:09 clojurebot: nil

20:10 programble: oh yeah

20:10 cool

20:10 rhickey_: ,(some {:a 1, :b 2} [:z :b])

20:10 clojurebot: 2

20:10 programble: i basically wanted it to check if something was a vowel

20:12 rhickey_: (def vowel? #{\a \e \i \o \u})

20:14 programble: oh that would work too

20:19 hiredman: around?

20:21 hiredman: programble: yes

20:21 S11001001: programble: there are different vowels for different languages, you may want to check a unicode database instead ;)

20:22 programble: S11001001: i think aeiou will do fine for my purposes

20:22 hiredman: i am supposed to ask you how to make a /secure/ clojure eval bot

20:23 S11001001: programble: hmm, you wouldn't happen to be writing a servlet with compojure, programble, would you?

20:23 programble: S11001001: im writing a simple piglatin translator :P

20:23 hiredman: clojurebot: sandbox

20:23 clojurebot: sandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html

20:24 programble: thanks

20:24 hiredman: the sandboxing will stop IO, that kind of stuff

20:24 S11001001: then you might want to count w as a vowel

20:24 programble: hm...

20:24 hiredman: but you can still do stuff like putting the bot into an infinite loop

20:24 programble: water -> aterway

20:24 works fine

20:24 S11001001: aterway -> ater

20:25 since ater -> aterway

20:25 programble: um...

20:25 no

20:25 hiredman: different dialects of p. latin

20:25 S11001001: madness!

20:27 programble: im going with the food -> oodfay so water -> aterway

20:27 S11001001: apple -> ...

20:29 programble: apple

20:29 thats why i check for vowels

20:29 (some #{(first s)} "aeiou")

20:29 s

20:37 technomancy: so clojure.test has extensible assertion reporting, right?

20:37 (is (= [...])) has special equality checking that (is bool) doesn't

20:37 I wonder if it could be extended to be smarter about checking equality of maps

20:37 so it would only show the keys/values that were different

20:45 S11001001: technomancy: I'm doing that with clojure.test

20:45 technomancy: S11001001: you're extending it to support that?

20:46 S11001001: technomancy: not exactly, but the semantics are similar: (defmethod assert-expr 'has-assocs? [msg [_ map assocs]] `(report ...))

20:46 technomancy: interesting

20:46 that's already supported?

20:46 S11001001: the generated expr should evaluate to return {:type ... :message ... :expected ...}; the exact format of these can be seen in the other examples in test.clj

20:46 as of 1.1

20:47 technomancy: cool

20:48 I guess since those methods aren't first-class they don't have high visibility

20:49 S11001001: that's not present in my checkout of 1.2

20:50 S11001001: technomancy: it's there in b497cbb

20:52 technomancy: S11001001: is this in a brach or something?

20:52 no mention of it in http://github.com/richhickey/clojure/commits/master/src/clj/clojure/test.clj

20:55 S11001001: technomancy: it's the head of master in richhickey's clojure

20:56 technomancy: oh, are you looking for 'has-assocs?

20:57 sorry, I meant to say that is how *I* extended `is' in a module for better reporting.

20:59 technomancy: S11001001: gotcha. any plans to submit it upstream?

21:01 S11001001: I'll ask Jeff Straszheim, a contributor I work with, if he thinks it would be generally useful

21:01 it actually tests that arg0 has a superset of arg1's assocs, so is not quite what you're looking for :/

21:01 technomancy: actually that would work here

21:01 but a more general diffing solution would be nice too

21:07 S11001001: technomancy|away: http://paste.lisp.org/display/95904

21:22 Raynes: Are there any instructions anywhere for running your own clojurebot?

21:26 hiredman: it takes a wily cunning and nerves of steel

21:27 programble: in other words, you designed it in a way that does not facilitate running it on any other machine except the one you are running it on

21:31 hiredman: uh, well, I wouldn't say it was designed that way

21:31 I just don't run any other instances so that is not an itch I've scratched

21:31 programble: but it wasn't designed with anyone in mind except for yourself

21:32 Raynes: If anyone replied to me /after/ I asked that question, I didn't get said reply.

21:32 programble: not a good way to design software

21:32 Raynes: <hiredman> it takes a wily cunning and nerves of steel

21:32 rogramble> in other words, you designed it in a way that does not facilitate running it on any other machine except the one you are running it on

21:33 Raynes: Aye.

21:33 I'd just rather not have to write my own. ;)

21:41 programble: hiredman: is it possible?

21:42 jcromartie: probablyCorey: you're doing Clojure now too?

21:42 a man of good tastes

21:43 hiredman: programble: yes

21:43 you just need to rip stuff out until it works, I guess

21:44 programble: oh nice

21:44 Raynes: It appears there needs to be a clojurebot.properties file.

21:44 Where should that be, and what exactly should go in it?

21:52 hiredman: Raynes: on the classpath somewhere

21:53 to say it needs it is kind of uh, well I use it to store passwords that I don't want to git commit, but it is very possible, and I did for a long time, to run the bot without it

21:54 it's only used from hiredman.clojurebot

21:55 Raynes: hiredman: Yeah, I removed all that stuff. I have it working, though it did give me an error.

21:56 Whatever it was, it doesn't appear to have broken the bot.

21:56 hiredman: feel free to share errors

21:57 Raynes: http://gist.github.com/321353 I'm surprised it works at all. I removed all the stuff that didn't /look/ important. :)

21:57 hiredman: at some point I'd like a proper -main and being able to run it from a jar with a config file

21:58 Raynes: That would be cool.

21:59 hiredman: ah

21:59 that is the max people thing

22:00 Raynes: What is this factoid server stuff?

22:01 hiredman: it's an http/json interface for querying the factoid database

22:02 Raynes: What do I need to remove to keep it from spamming github commits on startup? :o

22:02 hiredman: the github entry in the :require in hiredman.clojurebot should do it

22:03 and it should only spam the first time or so

22:03 Raynes: Oh.

22:03 hiredman: the plugins are loaded there

22:03 * programble python eval bot so much easier

22:04 Raynes: This is easier than it looked, assuming I don't break it.

22:04 hiredman: or you can remove the (hiredman.clojurebot.github/start-github-watch mybot "#clojure")

22:05 Raynes: More than I've already broke it, that is. :>

22:24 ,(def x 2)

22:24 clojurebot: DENIED

22:31 slyphon: uh, how do you compile a clojure file w/o running the repl?

22:32 oh

22:32 google knows everything

22:32 hiredman: I usually use -e "(compile 'foo.bar)"

22:33 slyphon: what does that full cmdline look like?

22:33 clj -e "(compile 'foo.bar)"?

22:33 hiredman: java clojure.main -e …

22:33 slyphon: ah, k

23:50 the "implicit 'this' arg" for a gen-class method means that i can "just use it" without having to do (defn -meth [this] ...) ?

Logging service provided by n01se.net