#clojure logs

2010-03-03

00:00brandonwhow can it use two different version of clojure at once?
00:00brandonwswank-clojure itself doesn't specify a specific version of clojure as a dependency
00:00brandonwunless it is somehow agnostic to which version you use...?
00:02brandonwwell, i will have to attack this tomorrow
00:02brandonwi am up way too late (again) :)
00:02brandonwclojure has the habit of making me do that... heh
03:21vyIsn't it possible to make "intern" guess the ns from the ns of the caller?
03:55LauJensenMorning guys
03:55LauJensenAll set for Open Source Days this friday ? :)
04:00esjMorning folks
04:03adityoafternoon folks
04:04zmilabeforenoon :)
04:05lpetitmorning :)
04:11sparievmorning )
04:42ordnungswidrigmornig
05:13pjackson
05:29bsteuberI wonder how github knows about the language of a project - counting known language names in the docs?
05:32greghprobably something simpler, like file extensions
05:32bsteubersounds reasonable :) silly me
05:44LauJensenbsteuber: 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
05:45esjits only simple because the wrote it in clojure
05:46esjotherwise, whew.... nightmare.
05:46LauJensenTrue .. oh yea, and then theres the whole file extension thing :)
05:47eevar2___afaik there's actually some parsing going on. or maybe that's ohloh
05:51dsopat 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 :)
05:53vyI define the fooproj ns in fooproj.clj file. How can I make (ns fooproj ...) to load/require fooproj/util.clj, fooproj/main.clj also?
05:53Chousukedon't define single-segment namespaces
05:54Chousukebut (ns foo.bar (:use foo.bar.util ...))
05:54vyChousuke: So what should I do instead of using single-segment namespaces?
05:55Chousukeuse a multi-segment namespace :)
05:55vyI couldn't understand. Can you given an example please?
05:55Chousukeinstead of (ns foo) use (ns foo.bar). It's that simple
05:55Chousukesingle-segment namespaces end up in the default package which causes problems in some cases
05:56vyChousuke: I'm already using something like that. tr.edu.bilkent.cs.vyazici. Are all those multi-segments enough? :D
05:56Chousukeah, that will do :)
05:57vyI just want my tr/edu/bilkent/cs/vyazici.clj to load the files I specified under tr/edu/bilkent/cs/vyazici/ directory.
05:57Chousukeyou can use :load in the ns form
05:58Chousukethe 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
06:00vyChousuke: 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?
06:01Chousukehm, what do you mean?
06:02vyHere 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?
06:03Chousukeshouldn't that be :load?
06:03Chousukebut, I don't think there's any way around it.
06:03Chousukeit's just a bit of extra typing
06:03vyOops... Yup, I meant :load, not :use.
06:05Chousukeyou could of course call load manually like (apply load (map #(str "vyazici/" %) '[util graph ...])))
06:05Chousukebut I don't think that's much better.
06:10vyChousuke: I wish stu's ticket about ns macro would get approved.
06:12ChousukeIt'll probably get reworked at some point.
06:36bsteuberlaujensen: just read the github/google interpretation you gave an hour ago - yeah, that sounds very reasonable to me :)
06:53zmilais 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)
06:55esjcould try for with a :when clause ?
06:58zmilathx esj! it works :)
06:58esjnp
07:12Maddas(filter identity ...) should work too
07:13esjeven nicer !
07:14Maddas:)
07:14AWizzArdIf you only want to remove nils from your coll (and keep 'false') then (remove nil? coll) is even better.
07:14AWizzArd,(filter identity [1 2 nil 3 4 false 5 true 6])
07:14clojurebot(1 2 3 4 5 true 6)
07:14AWizzArd,(remove nil? [1 2 nil 3 4 false 5 true 6])
07:14clojurebot(1 2 3 4 false 5 true 6)
07:14zmilai want map and remove nils
07:15MaddasOh, sorry, I misread that.
07:15AWizzArdThen I suggest you to (remove nil? (map ...)). This documents your code best.
07:16zmila(remove (map )) does two iteration over the coll, don't?
07:20bsteuberzmila: I don't think so - lazy sequences kick ass =)
07:23zmilabsteuber - yes, you're right! (remove nil? (map ,,,)) works even quicker than (for :when ) in my case
07:24esjso, while we're on this, I use a (for :while) to processing to stop when a nil is hit. Is there another way ?
07:25esjan until ?
07:34bsteuber,(doc take-while)
07:34clojurebot"([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
07:36bsteuber(take-while (complement nil?) collection) seems a little verbose, though
07:38esjmerci !
07:45zmilacould smbd show example of using (when-let )?
07:47esjcheck out cgrand's kickass solution on this thread: http://groups.google.com/group/clojure/browse_thread/thread/49bd20eb4bcba20c/269d55e544d3a55a?lnk=gst&q=kata#269d55e544d3a55a
07:47esjhe uses a when-let
08:00AWizzArdesj: do you know about :when?
08:00AWizzArdIn a for.
08:01esjyour asking question altered my state...
08:01esji guess I don't, what's the catch ?
08:02AWizzArdI just wanted to mention it. It can add a filtering effect to for.
08:02esjhmmm..... like my suggestion at 11:55 ?
08:06AWizzArdAh, 12:55
08:07esjaaah, timezones
08:07bsteuberhaha
09:20powr-tocWhat's the idiomatic way to evaluate a symbol?? Should I do (eval '+) or is there something more specific I can use?
09:22lpetitpowr-toc: wanna give more context ?
09:23chouseryou 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.
09:23chouseror perhaps why
09:24powr-toclpetit: 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
09:24powr-tocI think derefing is what I'm wanting
09:25rhickeysymbols don't have values
09:25powr-tocrhickey: yeah, I mean resolving the symbols var and derefing that :-)
09:25chouserresolve find the value of a Var named by the symbol. If you mean for the symbol to name a local, resolve won't work.
09:26chouseractually, resolve just finds the Var. deref gets its value.
09:26powr-tocchouser: yes, I think that's what I want to do
09:26rhickeypowr-toc: but you could instead pass a var instead of a symbol
09:26powr-tocrhickey: good point!
09:26rhickeysince the metadata you want is probably on the var anyway
09:27powr-tocrhickey: it is
09:28powr-tocrhickey: thanks for that :-)
09:29praptakIs 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?
09:31rhickeypraptak: (apply concat lazy-sequence-of-sequences)
09:31praptakThanks!
09:31AWizzArdExperts 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])?
09:32AWizzArdfoo must be a function. The FOR macro can do it:
09:32AWizzArd,(for [x1 [1], x2 [2 3], x3 [4], x4 [5 6]] [x1 x2 x3 x4])
09:32clojurebot([1 2 4 5] [1 2 4 6] [1 3 4 5] [1 3 4 6])
09:33AWizzArdFoo should not be a function that constructs and evals a for loop :)
09:35eliantor,(doc extends?)
09:35clojurebotHuh?
09:36eliantor,(doc defprotocol)
09:36clojurebotPardon?
09:36lpetit,(source for)
09:37clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
09:37lpetit~source for
09:38eliantor_I posted clojure group but my message doesn't seens to appear
09:39chouserAWizzArd: clojure.contrib.combinatorics/cartesian-product
09:39eliantor_oh well i reloaded the page once more and it's posted now
09:39eliantor_does clojurebot understands protocols and datatypes functions?
09:40AWizzArdchouser: 100 points
09:41chouserAWizzArd: cool! Can I redeem those points for plane tickets to Clojure conferences?
09:41chouser,`defprotocol
09:41clojurebotsandbox/defprotocol
09:41chousereliantor_: looks like it doesn't.
09:42chouser,(clojure-version)
09:42clojurebot"1.1.0-master-SNAPSHOT"
09:42eliantor_oh thanks
09:42chouserhuh. pre-1.1 even
09:42eliantor_i just downloaded the nightly build
09:43eliantor_and trying to use extends? extenders and satisfies, but they dont seem to work
09:43eliantor_they always return nil
09:44AWizzArdchouser: we can talk about this if you plan to visit Europe as a speaker on a Clojure Con :)
09:46chousereliantor_: 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.
09:46chouser(extend-class String P (foo [x] (str "This is a string: " x))
09:46chouser(extends? P String) ;=> true
09:47chouserdunno if the behavior of (satisfies? P T) is going to change or not
09:48chouseroh
09:48chouser(satisfies? P (T)) ;=> true
09:49chousereliantor_: 'satisfies?' wants an instance of the the object to check against a protocol.
09:49eliantor_it's the only one i didn't tried
09:50eliantor_i don't remember exactly the docs but i think they are not clear on this
09:56S11001001clojure 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?
09:57chouser`(#'helper) might do it
10:03S11001001thanks, unfortunately, nth not supported on this type: Symbol
10:03S11001001oh, I was macroexpanding the wrong thing, it worked. Thanks again chouser
10:04chousernp
10:12eliantor_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:13eliantor_what if i want to know something like (protocol? P) ?
10:15chousera protocol is currently just a map. You really have an object that at runtime might be a protocol or might be something else?
10:16eliantor_no, i was just trying to understand :)
10:16chouseryou can look at a protocol and glean useful info from it. You tried just P at the repl?
10:16eliantor_yes
10:16eliantor_it gives me a map
10:17chouserright.
10:17eliantor_i'm not on my machine so i'cant try it again
10:17chouserthe one you've defined by whatever combinations of defprotocol and extend you've invoked
10:18rhickey_protocols are currently opaque other than what is provided by the api, everything else representation-wise could change
10:19chouserheh, perhaps "should be treated as" rather than "are"? Because the thing is a map the nicely prints all kinds of stuff about itself.
10:43zmilaam I missing: what multi-line comments in clojure? besides (quote ...)
10:44lpetitrhickey_: 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:44a_strange_guyzmila: #_
10:44rhickey_lpetit: yes, I have some ideas involving macros in deftype/reify
10:45a_strange_guy,(+ 1 2 #_(ignored until) 3)
10:45clojurebot6
10:45lpetitrhickey_: cool. was just a checkpoint, thanks :)=
10:45lpetit:)
10:45rhickey_hopefully I'll get to that within the next week or so
10:46rhickey_I'm definitely not satisfied with how it is now
10:48zmilaa_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:49chouserzmila: 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:49chouserzmila: many editors provide a convenient way to do this
10:49stuartsierraOr write #_ "comments in a string"
10:50chouserwhich is ok until you want quotes in you comment. :-/
10:50zmilachouser, yes. but eclipse plugin still not :)
10:51a_strange_guyi actually noticed that almost anything is valid for the reader
10:52a_strange_guyjust use #_ and parens-matching
10:54lpetitchouser: 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:58chouserlpetit: 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:58lpetitah, ok, this one. I thought "while typing"
10:59lpetitchouser: the second part is interesting. I'm not sure there's an equivalent in eclipse
10:59lpetitchouser: how do you "end" the sequence ?
10:59chouserlpetit: 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:00chouserif I don't want that ; there, I just backspace over it and go back to writing code
11:01lpetitchouser: ok
11:29Licenseris there something good for a REST web framework in clojure?
11:29chouserfor the server side I like ring
11:30Licenserhmm ring, the doesn't ring a bell - I'll ask Mr. G. oogle
11:32chouserhttp://github.com/mmcgrana/ring
11:34Licenserah found it :) thanks chouser
11:50danlei chouser: btw, I think you were right yesterday, "let block" is actually used. (but the hyperspec example you posted was something different)
11:51chouserI don't think I posted a hyperspec link. Perhaps Chousuke did.
11:51danleiah, ok
11:53chouser,(case Integer/MAX_VALUE Integer/MAX_VALUE :good)
11:53clojurebotjava.lang.Exception: Unable to resolve symbol: case in this context
11:54chouseroh. anyway, apparently static final fields don't work as case test-constants
12:04brandonwhmm perfect timing
12:05brandonwtechnomancy: i had some questions on how swank-clojure works
12:05brandonwis swank-clojure agnostic of the clojure version you specify as a dep in your project?
12:05technomancybrandonw: it should be
12:06brandonwhow do you manage that?
12:06technomancybrandonw: it doesn't use any 1.1+ features and doesn't have AOT'd classes
12:06technomancyso it's compatible across versions even up to a year old
12:06brandonwah, that is what i was thinking
12:07brandonwi finally got around to finishing a lein-nailgun plugin that mimics your lein-swank plugin, but for vimclojure
12:08brandonwbut 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:09technomancyAOT is the biggest problem. supporting 1.0 is not as big of a deal.
12:11brandonwyeah, looking through the clojure source of vimclojure real quick i don't see anything 1.1+
12:11brandonwdo you not have any deps on contrib at all either?
12:14technomancyI think they are optional.
12:15brandonwyeah, especially for something like supporting quick pprint usage, i would think
12:17S11001001technomancy: 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:19technomancyS11001001: that does sound strange. I don't remember why it's done that way.
12:19technomancypatches welcome. =)
12:20brandonwtechnomancy: 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:23chousercase doesn't macro-expand its test-cases does it?
12:24chouseroh it can't because parens means "or"
12:46technomancybrandonw: using AOT locks you to a specific version of clojure. libraries AOT'd with 1.1 will not work with other versions.
12:48brandonwokay
12:48brandonwi 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:48brandonwso it is in the pipeline :)
13:03hiredmanclojurebot: ping?
13:03clojurebotPONG!
13:06gregh,'PONG!
13:06clojurebotPONG!
13:10esjsssh cb, people are trying to work here.
14:00LicenserHy 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:00Licenserwhen 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:04stuartsierraLicenser: GPL will do that.
14:04hiredman:(
14:04hiredmanonly if you are willing to go to court over it
14:04greghwell that depends on what exactly you mean by (3)
14:04Licenserstuartsierra: commercial use? I don't like the GPL
14:05chouserbut you can't mix GPL code with clojure code.
14:05Licenserthat validates 2) :P
14:06chouserLicenser: I think for a clojure project, you should go with EPL unless you can point out some way in which it is deficient.
14:06chouserand from my rather weak understanding of the EPL and your requirements, it'll do.
14:07Licenserchouser: my problem is I read the EPL but didn't understood a work
14:07Licenser*word
14:07chouseryeah. :-/
14:07biltswhat's the issue with mixing GPL code and Clojure code?
14:07programbleLicenser: what do you license? :P
14:07Licenserprogramble: A) a engine for game combat B) a JS framwork to visualize the fights
14:08LicenserA) is written in clojure
14:08programbleLicenser: cool
14:08LicenserI know it's not really a topic for the channel but people here are more helpfull then in most other channels :P
14:08programblelol yeah
14:08programblemost people in freenode help channels are assholes
14:09programblevery rude and tell you you are stupid type
14:09chouserGPL 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:09LicenserI am the stupid type!
14:09programblelol
14:09technomancychouser: depends on your definition of derived of course.
14:09programblebut people in here will liekly not tell you that
14:10LicenserI don't think that counts, I can compile GPL code with VisualStudio
14:10programblelicense your code under teh WTFPL
14:11hiredmanLicenser: but vs is not under a viral license
14:11LicenserWhat 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:11Licenseris clojure?
14:11hiredmanno
14:11Licensersee :P
14:11fanaticoa recent writeup on what "derivative" means: http://perpetualbeta.com/release/2009/11/why-the-gpl-does-not-apply-to-premium-wordpress-themes/
14:12fanatico"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:12stuartsierraLicenser: Enforcement of GPL/EPL tyep licenses is very weak; you're better off just asking nicely.
14:12Apage43quickly 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:12fanaticoI don't think using clojure in a gpl'd project fits that definition.
14:12programbleis the WTFPL GPL compatible?
14:13S11001001yes
14:14LicenserI know stuartsierra but what I certenly done't want is that I violate my own license in the future
14:14programbleWTFPL is good for small things that don't matter much, i go with GPL otherwise
14:14LicenserI don't like the GPL :(
14:14ChousukeI think the MIT licence is better than the WTFPL
14:14LicenserI agree less aggressive
14:15programble...
14:15programblewut
14:15programblehow is anything less aggressive than WTFPL
14:15ChousukeAnd it incorporates a warranty disclaimer, and more legally sound language :)
14:15programblelol
14:15LicenserSo generally there is no good license to use?
14:16chouserAgain, for maximum Clojure compatibility, I'd recommend going with EPL unless you know it doesn't fit somehow.
14:16stuartsierraLicenser: You can't violate your own license. You created it, you own the copyright, you can do whatever you want.
14:16Chousukewouldn't EPL work for you?
14:16LicenserChousuke: I am not sure what the EPL exaclty does :P
14:16technomancyhttp://en.wikipedia.org/wiki/Eclipse_Public_License
14:17Chousukeit's kinda like the GPL, but doesn't propagate itself to works linked against EPL code
14:18programbleGPL is kinda annoying that way
14:18Chousukeie. 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:18LicenserSo 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:18LicenserChousuke: that is EPL?
14:18ChousukeI'm not sure if the EPL requires attribution.
14:19ChousukeI'm not a lawyer, so don't count on me for legal advice, but that's my impression :)
14:19danlarkinuse use 3-clause BSD :)
14:19danlarkins/use/just/
14:19SynrGis it necessary to make code compatible with the license of the interpreter that runs it?
14:19programblejust use public domain :P
14:19Chousukethe public domain is problematic :P
14:20SynrGfor most of my projects i favour GPL. i wouldn't deliberately choose a license that's not compatible
14:20danlarkinprogramble: it's questionable whether it's possible to put something in public domain in the US :)
14:20programblewell why not?
14:20programblepublic domain makes it so no one has to worry about it
14:20chouserSynrG: 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:20programbleno legal anything
14:21Chousukeit's still a legal thing
14:21Chousukeloosely, it means the absence of copyright holders
14:21programblea legal thing with nothing really about it
14:21Chousukein some countries, you can't place things in the public domain.
14:21danleihow about putting clojure in ones own jar? is that already a modification?
14:21Chousukeyou simply can't give away your rights.
14:21Chousukedanlei: probably not.
14:21danleiok
14:21SynrGchouser: so i would need to GPL with a linkage exception
14:22chouserSynrG: that might do it, yes.
14:22Chousukedanlei: and still, it would only require you to distribute the clojure sources :)
14:22programbleChousuke: what about things like the song "Happy Birthday"
14:22danleiChousuke: I see, thank you!
14:22programblethat are in public domain because the copyright holders are unkown
14:22danlarkinprogramble: ha! funny you use that as an example
14:22SynrGchouser: 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:22Chousukeprogramble: things end up in the public domain. the question is whether you can intentionally *place* things there
14:22danlarkinhappy birthday is _not_ in the public domain
14:23LicenserI'll try to find some explenation of the EPL
14:23SynrGthey are bound to have some particular views on it
14:23Chousukeprogramble: in the US that's probably possible, but elsewhere it might not be.
14:23fanaticoprogramble: Time Warner owns "Happy Birthday".
14:23chouserhttp://www.snopes.com/music/songs/birthday.asp
14:23fanaticoseriously.
14:23fanaticohttp://en.wikipedia.org/wiki/Happy_Birthday_to_You#Copyright_status
14:24programbledamn
14:24programblew/e
14:24programbleyou know what i mean
14:24programblevery old songs and things
14:25programbleold stuff
14:25programbleso wait
14:25programble...
14:25programbleis it legal to sing happy birthday?
14:25fanaticodid you pay your public performance royalties?
14:26programble>_> no
14:26programblealthough
14:26programblei wouldnt call it public
14:26programbleso... i think im fine
14:27fanaticoAny reason deftype doesn't support vararg-style constructors?
14:28programbleto annoy you
14:29chouserfanatico: if your deftype mentions IPersistentMap, you can assoc onto instances after creation.
14:29chouser(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:30Licenserhmm after reding some FAQ about the EPL Ikind of like it
14:31programbleIkind? is that an interface?
14:33technomancymy biggest complaint with the EPL is the word "Eclipse"
14:33programblelol
14:33chouser(extend-class Licenser Ikind (like [x] true))
14:33Licenser^^
14:36Licenserhmm do I have to put a header in the code for EPL?
14:38technomancyI certainly hope not.
14:38Licenserokay fine fine :)
14:39dakroneis the EPL compatible with the LGPL?
14:39technomancyI 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:39Licenser^^
14:40programbleshouldnt you at least have a one liner'
14:40programble; License under the EPL
14:40Chousukeor ; see LICENCE file for details
14:40technomancyprogramble: that goes in the readme
14:40technomancyor license
14:40technomancydoesn't have to be spewed across every single file.
14:40programbleif the files get separated?
14:41ChousukeI think a simple licence header should be in every file
14:41Chousukemakes things easier in case someone inspects just one of the file
14:41Chousukes
14:41technomancyprogramble: then they're still under the same copyright as before; nothing changed
14:42programble^ like Chousuke said
14:42Chousuketechnomancy: yes, but it's an issue for people who need to know what the licence is :)
14:42technomancyChousuke: 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:42technomancythey're the ones wanting to use the code; they can do a little more work to figure it out. =)
14:42ChousukeYes. unless the project was relicenced in the meantime.
14:43Chousukeor a number of other funky things happened
14:43ChousukeA header doesn't take much space, and makes things simpler, so I would include one in any case, just to be safe.
14:43programblefunky thigns
14:45technomancybtw: someone with commit rights to contrib should remove this file: http://github.com/richhickey/clojure-contrib/blob/master/CPL.TXT
14:48radshow do I sort a query with congomongo? use the java api?
14:48chousertechnomancy: done, thanks.
14:48tomojrads: I think there is no other way yet
14:48tomojI was going to write a patch for that but haven't had time yet
14:52radshow do you even sort with the java api? can't seem to find it
14:53radsoh, it's part of DBCurosr
14:53radsDBCursor*
15:08reburghey, 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:08hiredmanreburg: how are you loading the clojure code?
15:10reburgi'm connecting to a remote (actually local) running java process, manually setting the sourcepath.
15:11hiredmanreburg: did you see http://groups.google.com/group/clojure/msg/267cc5cc6cef6403
15:13reburghiredman: 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:14Drakesonis (fn [x] (when (pred x) x)) defined somewhere?
15:15Drakesonactually, I meant (fn [pred x] (when (pred x) x))
15:16tomojhow about (if x x y)
15:17Drakesontomoj: that is "or"
15:17tomojoh, (or x y)
15:17tomojyep :)
15:17tomojthanks
15:17kotaraktomoj: beware if nil and false are valid values
15:17tomojthanks, they aren't
15:18hiredmanDrakeson: when-let?
15:18hiredmanbleh actually it's and
15:18hiredman(and (pred x) x)
15:19Drakeson,(defn assure [pref x] (when (pred x) x))
15:19clojurebotDENIED
15:19hiredman,(and (even? 2) 2)
15:19clojurebot2
15:19hiredman,(and (even? 1) 2)
15:19clojurebotfalse
15:19Drakesonhiredman: the whole point is to have just one "x"
15:20hiredman*shrug*
15:20Drakeson(defn assure [pref x] (when (pred x) x)) (assure not-empty? (some computation))
15:22Drakesonor maybe even better, (assure coll? not-empty? nice? high-quality? (some calculation))
15:31fliebelI 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:32danleithey all share sexps
15:33danlei(but some have surface syntax, like dylan)
15:33hiredmanfliebel: http://clojure.org/rationale there is a section on lisp
15:38fliebelthanks
15:40fliebelI'm looking for a Clojure internship in The Netherlands, but I only found one for Common Lisp.
15:47Drakesonwasn't there a variation of -> that stops when any intermediate result is nil?
15:47tomoj-?>
15:47tomojin contrib
15:47tomoj(I think)
15:47ordnungswidrigtomoj: yes.
15:48tomojclojure.contrib.core/-?>
15:50Drakesonthanks :)
15:52reburghiredman: 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:52hiredman:(
15:53hiredmanvanilla as in you followed th instructions in that post?
15:55reburghiredman: 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:56hiredmanreburg: yeah, no
15:57reburghiredman: "yeah, no" meaning i did it wrong?
15:58hiredmanreburg: I think you'll need to aot compile your code
15:58reburgok, well i actually did that first
15:58dnolenhow can one download jars directly from clojars?
15:59reburgdnolen: clojars.org/repo
15:59reburghiredman: 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:59hiredmanhmmm
15:59hiredmanok, sorry, I dunno then
16:00reburghiredman: thanks anyhow. i'm gonna maybe try a 3.x version of jswat
16:01reburgalthough the jswat page complains that there's some bug w/ jdk6u11+ and older versions...
16:04reburginitial success! jswat 3.16 shows the line numbers! now i try breakpoints.
16:06reburgaaaand it works. apparently the moral is that updating your software is bad.
16:26cljneohi, how can I add a specific directory to the classpath before launching slime/swank to start a repl
16:33mabesFor 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:33mabesor maybe c.c.logging can be used with org.mortbay.log.Log?
16:35arohnercljneo: are you using lein?
16:35arohnercljneo: or starting manually?
16:35cljneoyes but I don't need to create a project. I just want to launch a repl to experiment with a library
16:37cljneoarohner: I see some functions in swank but I don't know how to use them. Like swank-clojure-classpath
16:37arohnercljneo: the easiest way is probably to just make a simple project.clj
16:38arohnerand dump your library .jar in lib/
16:38ChousukeI think you can just do (add-to-list 'swank-clojure-classpath "somepath")
16:38Chousukethen start swank
16:38arohnerif you're already using lein
16:38arohnerif you're using lein
16:38cljneolet me try that
16:38reburgcljneo: if you're using slime, making a lein project file and then running lein swank is probably just as simple as configuring swank
16:43cljneoI tried Chousuke's form but got (void-variable swank-clojure-classpath)
16:49Chousukehmm
16:49Chousukeyou need to have swank required, of course.
16:49Chousukelet me check my config :P
16:50Chousukeyeah, at least I didn't get the variable name wrong :)
16:52ChousukeThough 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:52cljneoI'll try that
16:52Chousukemake sure you include the clojure jar in the paths :)
16:55cljneoeven if swank is loaded, the classpath does not change. Doesn't the jvm support dynamically adding to the classpath?
16:58Licenserthere shall be releases!
17:01technomancycljneo: it does not.
17:01brandonwcljneo: http://github.com/technomancy/swank-clojure look under Usage after step 4.
17:03cljneoI see. I searched and found it cannot be done (changing classpath) except with a hack
17:04cljneolike the one here http://www.velocityreviews.com/forums/t148021-dynamically-change-the-classpath.html
17:30nathanmarztechnomancy: leiningen q for you
17:57technomancynathanmarz: oh?
18:00nathanmarzso my app is dependent on hadoop, but i can't include hadoop as a dependency using the normal mechanisms
18:00nathanmarzfor two reasons: one, i'm using uberjar to distribute my jobs and can't include hadoop in there
18:00nathanmarzsecond, i need to set some configs in hadoop to get my local setup working correctly
18:01nathanmarzi ended up hacking leiningen so that project.clj could include something like ":external-libraries [(System/getenv "HADOOP_HOME")]"
18:01nathanmarzwhat are your thoughts on that / should i be doing this a different way?
18:02tomojit seems 'lein test' has a 0 exit code when the tests fail
18:04technomancytomoj: yes, it's impossible (afaict) to return an exit code from the subclassloader in which the tests run.
18:05technomancynathanmarz: maybe put hadoop configs in resources/?
18:05tomojtechnomancy: that sucks
18:05tomojguess I should grep it?
18:06technomancytomoj: 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:06technomancynathanmarz: oh, I see what you mean. yeah, I remember hadoop configuration being pretty disastrous.
18:07nathanmarzyea, i don't want to distribute the configs i have locally - that's just for testing stuff locally
18:13tomoj"! lein test | grep -q FAIL" seems to work
18:30jcromartieIt seems to me that Clojure would be a great place to build a rules engine.
18:49dcnstrcthi. 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:50a_strange_guydcnstrct: pretty impossible to do so
18:50arohnerdcnstrct: it's not intentionally obfuscated
18:50arohnerhow readable it is depends on how good at assembly you are :-)
18:51dcnstrctso would you say it's at least as obfuscated as jruby bytecode ?
18:51programblewhy does it matter?
18:52arohnerif you're curious about how readable it is, just go look at one
18:52dcnstrctwell 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:52dcnstrctgood idea arohner
18:53arohnerbasically every DRM system ever created has been cracked. It's just a question of motivation
18:54dcnstrctyes :) I know DRM never even worked in theory much less in practice.
18:54a_strange_guydcnstrct: if they are motivated, they could start a repl inside your program and poke around
18:56dcnstrctI 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:58a_strange_guythe classfiles rarely decompile into legal java
18:58arohnerI 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:59arohnerrather than the output that (pr foo) would generate
18:59a_strange_guyarohner: don't use toString
19:00a_strange_guy,(print-string (map str '(1 2 3 4 5)))
19:00clojurebotjava.lang.Exception: Unable to resolve symbol: print-string in this context
19:02a_strange_guy,(pr-str (map str '(1 2 3 4 5)))
19:02clojurebot"(\"1\" \"2\" \"3\" \"4\" \"5\")"
19:02arohnera_strange_guy: thanks
19:02a_strange_guy,(str (map str '(1 2 3 4 5)))
19:02clojurebot"clojure.lang.LazySeq@47ed8d2"
19:05{newbie},(doseq (str (map str '(1 2 3 4 5))))
19:05clojurebotjava.lang.IllegalArgumentException: doseq requires a vector for its binding
19:06{newbie},(doall (str (map str '(1 2 3 4 5))))
19:06clojurebot"clojure.lang.LazySeq@47ed8d2"
19:07a_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:08a_strange_guy;)
19:08a_strange_guylazy strings
19:09{newbie}yeah
19:09{newbie}I didin't look at the "s
19:09{newbie}around lazyseq
19:18slyphonhow do you "append" an element to the end of a vector?
19:18slyphonassoc?
19:18technomancyconj'll do it
19:18slyphonoh, duh duh duh
19:18slyphonof course
19:19slyphonawesome
19:22slyphonhrm
19:22slyphonthere's no built-in way to uniq a (non-infinite) sequence?
19:23technomancyslyphon: you can convert it into a set.
19:23technomancy,(set [2 2 2 34 4 5])
19:23clojurebot#{2 34 4 5}
19:23slyphonyeah, and lose ordering...
19:23technomancytrue
19:24slyphonoh, sorted-set
19:24slyphonno
19:24slyphonhrm
19:24slyphoni guess i can just do includes? before adding the item
19:37slyphonheh, from the Dept. of Helpful Documentation:
19:37slyphonarray-map: Constructs an array-map.
19:37slyphonthanks!
19:51hiredman,(doc split-with)
19:51clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
19:52hiredman^- implementation in docstring
19:52hiredman,(doc distinct)
19:52clojurebot"([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"
19:56slyphonoh, that'll do it
19:58hiredman~def distinct
20:01programblehow can i tell if a value is in a list?
20:01programble,(some? \a "aeiou")
20:01clojurebotjava.lang.Exception: Unable to resolve symbol: some? in this context
20:01programbleer
20:01programble,(some \a "aeiou")
20:01clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn
20:02programbleagh im so n00b
20:02programblelol
20:02programble,(some #(= % \a) "aeiou")
20:02clojurebottrue
20:02programblethat works, but is there an easier/shorter way?
20:05a_strange_guy,(some #{\a} "aeiou")
20:05clojurebot\a
20:07programbleexcuse my n00bness...
20:08programblesome takes a predicate or a set?
20:09arohnerprogramble: sets, and maps, can operate as functions
20:09arohner({:a 1 :b 2} :b)
20:09arohnerreturns 2
20:09arohner,({:a 1, :b 2} :b)
20:09clojurebot2
20:09arohner,({:a 1, :b 2} :bogus)
20:09clojurebotnil
20:10programbleoh yeah
20:10programblecool
20:10rhickey_,(some {:a 1, :b 2} [:z :b])
20:10clojurebot2
20:10programblei basically wanted it to check if something was a vowel
20:12rhickey_(def vowel? #{\a \e \i \o \u})
20:14programbleoh that would work too
20:19programblehiredman: around?
20:21hiredmanprogramble: yes
20:21S11001001programble: there are different vowels for different languages, you may want to check a unicode database instead ;)
20:22programbleS11001001: i think aeiou will do fine for my purposes
20:22programblehiredman: i am supposed to ask you how to make a /secure/ clojure eval bot
20:23S11001001programble: hmm, you wouldn't happen to be writing a servlet with compojure, programble, would you?
20:23programbleS11001001: im writing a simple piglatin translator :P
20:23hiredmanclojurebot: sandbox
20:23clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
20:24programblethanks
20:24hiredmanthe sandboxing will stop IO, that kind of stuff
20:24S11001001then you might want to count w as a vowel
20:24programblehm...
20:24hiredmanbut you can still do stuff like putting the bot into an infinite loop
20:24programblewater -> aterway
20:24programbleworks fine
20:24S11001001aterway -> ater
20:25S11001001since ater -> aterway
20:25programbleum...
20:25programbleno
20:25hiredmandifferent dialects of p. latin
20:25S11001001madness!
20:27programbleim going with the food -> oodfay so water -> aterway
20:27S11001001apple -> ...
20:29programbleapple
20:29programblethats why i check for vowels
20:29programble(some #{(first s)} "aeiou")
20:29programbles
20:37technomancyso clojure.test has extensible assertion reporting, right?
20:37technomancy(is (= [...])) has special equality checking that (is bool) doesn't
20:37technomancyI wonder if it could be extended to be smarter about checking equality of maps
20:37technomancyso it would only show the keys/values that were different
20:45S11001001technomancy: I'm doing that with clojure.test
20:45technomancyS11001001: you're extending it to support that?
20:46S11001001technomancy: not exactly, but the semantics are similar: (defmethod assert-expr 'has-assocs? [msg [_ map assocs]] `(report ...))
20:46technomancyinteresting
20:46technomancythat's already supported?
20:46S11001001the 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:46S11001001as of 1.1
20:47technomancycool
20:48technomancyI guess since those methods aren't first-class they don't have high visibility
20:49technomancyS11001001: that's not present in my checkout of 1.2
20:50S11001001technomancy: it's there in b497cbb
20:52technomancyS11001001: is this in a brach or something?
20:52technomancyno mention of it in http://github.com/richhickey/clojure/commits/master/src/clj/clojure/test.clj
20:55S11001001technomancy: it's the head of master in richhickey's clojure
20:56S11001001technomancy: oh, are you looking for 'has-assocs?
20:57S11001001sorry, I meant to say that is how *I* extended `is' in a module for better reporting.
20:59technomancyS11001001: gotcha. any plans to submit it upstream?
21:01S11001001I'll ask Jeff Straszheim, a contributor I work with, if he thinks it would be generally useful
21:01S11001001it actually tests that arg0 has a superset of arg1's assocs, so is not quite what you're looking for :/
21:01technomancyactually that would work here
21:01technomancybut a more general diffing solution would be nice too
21:07S11001001technomancy|away: http://paste.lisp.org/display/95904
21:22RaynesAre there any instructions anywhere for running your own clojurebot?
21:26hiredmanit takes a wily cunning and nerves of steel
21:27programblein 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:31hiredmanuh, well, I wouldn't say it was designed that way
21:31hiredmanI just don't run any other instances so that is not an itch I've scratched
21:31programblebut it wasn't designed with anyone in mind except for yourself
21:32RaynesIf anyone replied to me /after/ I asked that question, I didn't get said reply.
21:32programblenot a good way to design software
21:32programbleRaynes: <hiredman> it takes a wily cunning and nerves of steel
21:32programblerogramble> 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:33RaynesAye.
21:33RaynesI'd just rather not have to write my own. ;)
21:41programblehiredman: is it possible?
21:42jcromartieprobablyCorey: you're doing Clojure now too?
21:42jcromartiea man of good tastes
21:43hiredmanprogramble: yes
21:43hiredmanyou just need to rip stuff out until it works, I guess
21:44programbleoh nice
21:44RaynesIt appears there needs to be a clojurebot.properties file.
21:44RaynesWhere should that be, and what exactly should go in it?
21:52hiredmanRaynes: on the classpath somewhere
21:53hiredmanto 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:54hiredmanit's only used from hiredman.clojurebot
21:55Rayneshiredman: Yeah, I removed all that stuff. I have it working, though it did give me an error.
21:56RaynesWhatever it was, it doesn't appear to have broken the bot.
21:56hiredmanfeel free to share errors
21:57Rayneshttp://gist.github.com/321353 I'm surprised it works at all. I removed all the stuff that didn't /look/ important. :)
21:57hiredmanat some point I'd like a proper -main and being able to run it from a jar with a config file
21:58RaynesThat would be cool.
21:59hiredmanah
21:59hiredmanthat is the max people thing
22:00RaynesWhat is this factoid server stuff?
22:01hiredmanit's an http/json interface for querying the factoid database
22:02RaynesWhat do I need to remove to keep it from spamming github commits on startup? :o
22:02hiredmanthe github entry in the :require in hiredman.clojurebot should do it
22:03hiredmanand it should only spam the first time or so
22:03RaynesOh.
22:03hiredmanthe plugins are loaded there
22:04RaynesThis is easier than it looked, assuming I don't break it.
22:04hiredmanor you can remove the (hiredman.clojurebot.github/start-github-watch mybot "#clojure")
22:05RaynesMore than I've already broke it, that is. :>
22:24Raynes,(def x 2)
22:24clojurebotDENIED
22:31slyphonuh, how do you compile a clojure file w/o running the repl?
22:32slyphonoh
22:32slyphongoogle knows everything
22:32hiredmanI usually use -e "(compile 'foo.bar)"
22:33slyphonwhat does that full cmdline look like?
22:33slyphonclj -e "(compile 'foo.bar)"?
22:33hiredmanjava clojure.main -e …
22:33slyphonah, k
23:50slyphonthe "implicit 'this' arg" for a gen-class method means that i can "just use it" without having to do (defn -meth [this] ...) ?