#clojure log - Feb 06 2011

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

0:00 sritchie: would you all consider this the best way to extract a 4 digit year from a filename?

0:00 ,(first (re-find #"(\d{4})" "precl_mon_v1.0.lnx.2000.gri0.5m.gz"))

0:00 clojurebot: "2000"

0:36 redline6561: Hi there. I'm a CL guy so sorry if this is a dumb question. Is there something I can use *from* the SLIME REPL to download and load libraries (ala quicklisp)?

0:36 I know about leiningen but heard it might not support this use case...

2:31 * ekoontz setting up ring

2:37 ekoontz: anyone know how to set up ring?

2:37 https://github.com/mmcgrana/ring

2:38 http://pastebin.com/EjzHHHQ4

2:43 ohh i have to run "lein deps"

2:44 nice, "Hello World from Ring" works :)

2:46 ztellman: hiredman: can you explain your earlier "that looks familiar" comment?

2:46 if there are any other similar libraries/bits of code around, I'd like to see them

3:06 * ekoontz setting up compojure

3:33 LauJensen: ekoontz: make sure you check out Moustache as well

3:34 ekoontz: hey LauJensen

3:34 LauJensen: Yo yo :)

3:34 ekoontz: that's a markup language right?

3:35 oh ok : https://github.com/cgrand/moustache

3:38 stuck in dependency hell : https://gist.github.com/813227

3:40 how do people set their classpaths while using clojure..maybe dumb question..?

3:40 brehaut: ekoontz: with lein or cake doing dependancy management

3:41 ekoontz: i created a ~/bin/clj which is a shell script: https://gist.github.com/813230

3:42 but i shouldn't have to keep adding .jars to my CLASSPATH right?

3:43 brehaut: ekoontz: github.com/technomancy/leiningen/ or https://github.com/ninjudd/cake

3:43 ekoontz: brehaut: cool

3:43 but i have leiningen installed

3:43 i can do lein deps

3:43 brehaut: you specify your dependancies for a project, and they manage downloading them and other dependancies, and then generate your classpath for you as needed

3:44 ekoontz: that's in project.clj right?

3:44 brehaut: yes

3:44 ekoontz: ok but suppose i want to start clj interactively

3:45 brehaut: if you want just a random repl, cake might provide one? otherwise i use cljr which is built on lein, and allows you to install packages

3:45 lein repl

3:45 ekoontz: ok yeah ..repl

3:45 let me try that..thanks :)

3:45 brehaut: its all in the tutorial for lein

3:45 ekoontz: so what is cake about..is that a competitor to lein?

3:45 brehaut: sort of ?

3:45 for basic usage they are equivalent

3:46 but they diverge on issues of plugins and expert features

3:46 ekoontz: which do you prefer

3:46 brehaut: im not a tool using monkey, i get by with the most basic of lein features

3:47 ekoontz: ok

3:47 so basically use "lein repl" yeah?

3:47 brehaut: yeah

3:48 you can also get lein to generate a packaged jar file which contains all your dependancies with uberjar which can make deployment super easy

3:49 ekoontz: hm ok, thanks, will keep that in mind..

3:51 brehaut: sorry, what am i doing wrong here ? https://gist.github.com/813236

3:51 brehaut: you dont use ns forms in a repl

3:51 replace that with

3:52 (use 'compojure.core ring.adapter.jetty) (require '[compojure.routes :as routes])

3:53 ekoontz: brehaut: https://gist.github.com/813238

3:54 brehaut: you have compojure in your dependancies in project.clj and run lein deps?

3:54 and the ring jetty adapter?

3:55 ekoontz: i have the default project.clj in compojure

3:55 brehaut: i dont use compojure sorry, so i dont know what that looks like

3:55 ekoontz: ok

3:56 brehaut: sorry its late here. i have to head to bed

3:56 ekoontz: thanks dude :)

3:56 i'll figure it out eventually

4:08 fliebel: morning

4:37 Dranik: hi all!

4:37 is there a way not to specify the exact versions of libs in leiningen project.clj?

4:38 e.g. I want just the latest libs regardless of their exact version

4:43 fliebel: Dranik: Some offer -SNAPSHOT versions

4:43 Dranik: fliebel, so the answer is "no" ?

4:43 fliebel: Other than that, it is considered bad practice, because it can break your code later.

4:44 I think it is.

4:44 Dranik: fliebel, so how should I learn the exact number of the latest version?

4:45 fliebel: Dranik: For Clojure code, byt looking at the version in project.clj or by looking at the Clojars page.

4:45 For Java code… Good luck!

4:46 Dranik: fliebel, thanks!

4:50 ekoontz: newb clojure q: how do i load a .clj file into the repl?

4:50 e.g. https://github.com/scottjad/slice/blob/master/src/slice/example.clj

4:50 fliebel: (use 'slice.example)

4:50 Dranik: also you may (load-file "my.clj")

4:51 ekoontz: fleibel: thanks, that works :)

4:52 Dranik: cool that works too

5:01 Dranik: I've loaded the namespace using the "use" command, then changed something. How to reload the namespace?

5:12 fliebel: Could anyone have a look with me at this function? http://pastebin.com/NcuciA3z It's the newer version of https://github.com/pepijndevos/ArmageDOM/blob/master/src/armagedom/dom.clj but it does not work yet. It gives a java.lang.ClassCastException

5:14 The new part is the reduce statement ate line 12

5:16 OKay, I know what's wrong, but I dont know how to fix it.

5:32 The problem is that I can't return 2 functions to trampoline.

5:39 Oh, whatever, what is the deepest XML file you've ever seen?

5:57 simonfxr: how can i get the class instance of a certain type? (java syntax: java.lang.Integer.class)

6:03 gko: (class ...)

6:06 simonfxr: thx

6:34 raek: ,java.lang.Integer

6:34 clojurebot: java.lang.Integer

6:34 raek: ,(class java.lang.Integer)

6:34 clojurebot: java.lang.Class

6:34 raek: ,(class 1)

6:34 clojurebot: java.lang.Integer

6:34 raek: simonfxr: ^

7:33 shortlord: can I get

7:33 sry

7:34 can I get a value of a ref that I've just changed in a transaction in the same transaction by dereferencing it?

7:43 dunk: I'm a bit lost on how to get a clojure install with slime. Is there a tutorial somewhere? What's the most up-to-date method?

7:43 clojurebot: clojureql is http://github.com/LauJensen/clojureql

8:54 rrc7cz: if you have (ns x (:use y)), then a (gen-class) with a method impl (defn -myEval [this sexpr] (eval (read-string sexpr))), why do calls to (.eval (MyClass.) "some symbol in ns y") throw Unable to resolve symbol? Other methods in the gen-class refer to symbols in y and it's fine. I'm guessing the compiler converts all symbols to fully ns qualified?

8:58 thinking about it more, I assume the (:use) in the ns is just for the compiler to resolve everything correctly, but then the class runs in its own ns w/out anything refered except core. I could probably put a (use) call in the myEval impl

9:17 jaskirat: hey guys, does anyone here use erc?

9:27 rrc7cz: jaskirat: I'm on it now

11:07 odyssomay: can I terminate a reduce call if some condition is met?

11:08 opqdonut: no, not really

11:08 you'll need to implement a custom breakable-reduce

11:09 odyssomay: ok

11:36 Is there a "drop-first" function?

11:38 jkrueger: pdyssomay: you mean rest ?

11:38 odyssomay: ...

11:39 yes

11:39 :)

11:43 Is it possible to reload already loaded files?

11:46 jkrueger: odyssomay: yes. you can also add a hint to the namespace that results in each depending namespace being reloaded as well

11:46 which is good for unit tests. for example

11:49 specifically you can add a :reload or :reload-all keyword to each require form

11:50 odyssomay: jkrueger: thank you

12:43 ldh: after I (use 'some.namespace) from the REPL, then modify the underlying source file, is there a way to reload the new version?

12:47 shortlord: is there an easy way to convert a normal java.util.Map directly into a clojure map?

12:49 zonpantli: ldh: (use :reload-all 'some.namespace)

12:49 ldh: zonpantli: ah, thanks

13:10 odyssomay: Is there a function similar to "take-while" which instead of sending each element to the specified function, sends the elements so far?

13:11 Ex: ("take-while" (fn [x] (not (= (count x) 3))) '(3 6 1 7)) => (3 6 1)

13:11 or maybe (3 6)

13:14 pdk: anyone in here familiar with counterclockwise

13:14 giving me a null pointer in eclipse whenever i open a file

13:15 more specifically file -> open file... on any .clj file = null pointer

13:24 rindolf: Hi all. Would it be acceptable if I start a philosophical discussion/QA-session about the philosophy of Clojure?

13:25 odyssomay: rindolf: sounds good to me

13:25 rindolf: odyssomay: OK.

13:25 pdk: we're used to em

13:27 rindolf: First of all an introduction, I am http://www.shlomifish.org/ (Shlomi Fish) and I mostly write Perl 5, shell and C daily (while knowing many other languages to some extent), and I've been waiting for a modern, usable, Lisp dialect for quite a while now.

13:28 I've had some hopes for Paul Graham's Arc, but eventually started my own effort (no code - only planning) called Park, which eventually became Spark, which kinda suffered from the second system effect.

13:28 Then Arc came out, and it was disappointing. While being kinda brief, it lacked many advanced features.

13:28 So I've heard of clojure.

13:29 Now I'm not sure if clojure has all the CSy features that I came to expect and like, but at least it's there and ready and has become somewhat popular and "hip".

13:30 OK, first question - does the core Clojure language aims for Minimalism (e.g: a la Scheme), or does it prefer to have some dark corners so programmers can express themselves and so it will be usable?

13:31 pdk: it seems to me it doesn't have anything quite as hackish as common lisp loop

13:31 odyssomay: pdk: for?

13:32 pdk: though it does have some extra junk intended for java interop that probably isn't as clean as the core language

13:32 rindolf: I think iterate is a little nicer than loop in CL.

13:32 pdk: nah cl's loop macro is different from for

13:32 rindolf: It's a third party extension.

13:32 pdk: cl's loop slices dices and purees while being a hulking mess from a purity standpoint

13:32 Raynes: Clojure, first and foremost, tries to be a practical language. It's only as minimal as practicality allows for.

13:33 pdk: sometimes the java brain damage shows through when you write code for java interop

13:33 odyssomay: pdk: yes, but I don't quite like the style of for anyway, it reminds me much of loop

13:33 pdk: coercing primitives and type hints especially

13:34 limitations of clojure's host platform also explain why loop/recur and explicit tco exist

13:35 rindolf: Raynes: OK, that sounds reasonable.

13:40 odyssomay: How come for example using "reverse" on a string, doesn't result in a string?

13:41 a_robbins: Hey guys, I'm working through the clojure koans and I am having trouble figuring out some behavior. Apparently (list first-name last-name) is different from '(first-name last-name). Is there a reader macro for making lists? If I just do (first-name last-name), it will try to execute first-name as a function.

13:42 rindolf: Now regarding APIs, I realise that you can use all the Java APIs in clojure, which is a good thing. Languages without APIs are in my opinion not very attractive.

13:43 odyssomay: a_robbins: http://www.lisperati.com/clojure-spels/casting.html

13:44 a_robbins: http://www.lisperati.com/clojure-spels/casting.html (if you didn't catch it)

13:45 rindolf: Of course, from my experience it's hard to install many third-party APIs for Java (a la Perl's CPAN) with maven being the beast that it is.

13:45 a_robbins: odyssomay: thanks, I read through that

13:45 odyssomay: I'll read through that*

13:45 ekoontz: rindolf: project.clj looks pretty nice

13:45 rindolf: ekoontz: what is it?

13:46 ekoontz: installs dependencies

13:46 a la maven

13:46 rindolf: ekoontz: ah.

13:46 ekoontz: can they be Java ones too? Or only clojure ones?

13:46 ekoontz: yep, java too :)

13:46 odyssomay: Aren't they java only?

13:46 ztellman: rindolf: anything with a Maven repository

13:46 rindolf: ztellman: hmmm.... :-S

13:46 ztellman: clojars provides a maven repository for clojure projects

13:47 trivial to set up

13:47 ekoontz: then do lein deps

13:47 ztellman: and most established java projects have their own

13:47 anthony__: If I have "key1:value1;key2:value2;key3:value3" and want to convert it to {key1 value1 key2 value2 key3 value3}, what functions should I start looking at?

13:47 rindolf: Can it easily interface with RPM/Deb-dpkg/etc.?

13:48 ekoontz: i don't know about that; i use it on mac os x for now

13:48 ztellman: anthony__: split on ";", then (apply hash-map ...) on the resulting sequence

13:48 sorry, split on ":"

13:48 anthony__: ztellman: Thanks. hash-map was my missing function. :D

13:56 rindolf: What did I also want to ask?

13:56 Let me see.

13:59 http://www.perl.com/pub/2007/12/06/soto-11.html - if you didn't read that, you should. How does clojure feel about being a language for writing quick (and sometimes dirty) code? And for "catering to mere mortals"?

14:05 ztellman: rindolf: I don't think anyone's fundamentally opposed to quick and dirty code, but the general message from on high is that Clojure should be a powerful tool for knowledgable users

14:05 rindolf: ztellman: well, I don't see these as necessarily contradictory.

14:06 ztellman: no, but there's a fundamental lower bar in terms of knowledge to use Clojure effectively

14:06 a novice can't easily use Clojure in a "quick and dirty" way

14:07 rindolf: ztellman: I mean, it's hard to write quick-and-dirty stuff in C and in Java, etc. but in Perl/Python/PHP/Ruby/etc. you can also write complex stuff , but also quick-and-dirty-stuff.

14:07 ztellman: hmm, maybe I'm just conflating the quick and dirty and "mere mortals" comments

14:07 rindolf: ztellman: would you accept a ClojureScript extension?

14:08 ztellman: rindolf: what would that be, exactly?

14:08 rindolf: ztellman: also see http://perl.plover.com/yak/12views/samples/notes.html#sl-39

14:09 ztellman: brb

14:09 rindolf: ztellman: see ya.

14:15 ztellman: rindolf: maybe this just speaks to my particular biases, but I don't think designing a language around one-liners is a particularly great idea

14:15 or rather, I don't think a language needs to be able to do both one-liners and large-scale programs

14:16 there are plenty of good scripting tools out there, why would Clojure try to displace them?

14:16 rindolf: ztellman: well, I don't think we should make sure a language is usable only for one liners.

14:16 and some of my perl -e programs are longer than 80 chars.

14:16 ztellman: well, if people use clojure on the command line, they will eventually use it for more serious stuff.

14:17 ztellman: some of them at least.

14:17 ztellman: rindolf: sure, that's one way to build a community

14:17 it worked very well for perl

14:17 but it's not the only way

14:17 obviously the one-liner/big program distinction is a spectrum, not a dichtomy

14:18 rindolf: Right.

14:18 Anyway, maybe I should try creating something like ClojureScript.

14:18 ztellman: I'd be interested to see that

14:18 rindolf: Yes.

14:19 One of the problems I found with Scheme and to a lesser extent CL was that they tended to be very verbose/wordy by default.

14:19 Long identifiers, etc.

14:19 You could avoid it eventually by writing many abstractions, but that's hardly a solution.

14:19 odyssomay: rindolf: that's a good thing

14:19 ztellman: again, i think it's just what you're optimizing for

14:20 rindolf: Paul Graham talked about it.

14:20 odyssomay: you mean verbosity?

14:20 odyssomay: rindolf: yes

14:20 rindolf: odyssomay: why?

14:20 ztellman: Paul Graham said that concision = expressiveness, which I'm wholly unconvinced of

14:20 rindolf: ztellman: http://www.paulgraham.com/power.html

14:20 odyssomay: rindolf: because when it's verbose, I can understand my programs

14:20 rindolf: Hmm... there's such a word as concision.

14:21 odyssomay: well, if it's too verbose, you'll have a problem following it.

14:21 ztellman: ha, yeah, I didn't just make it up

14:21 odyssomay: rindolf: which is?

14:21 ztellman: unnecessary verbosity = lack of expressiveness, sure

14:21 but that doesn't necessarily imply the converse

14:21 rindolf: odyssomay: I'm not a fan of using obscure identifiers, but I still think that conciseness is important.

14:22 odyssomay: I mean, of course I can see the problem of verbosity (ztellman got it), but for me verbosity always comes out on top

14:23 ztellman: I think the key is that if some boilerplate is getting in the way of you understanding your own code, you can abstract it away

14:24 rindolf: Yes, I think that preferably the language or the API-collection (CPAN/etc.) that you're using should make you avoid this boilerplate by default.

14:25 ztellman: rindolf: is that a language design issue, or a social convention issue?

14:26 rindolf: ztellman: well, if anyone has their own favourite and incompatible abstractions, then it creates fragmentation.

14:26 ztellman: rindolf: definitely true

14:26 but one of the things that I think Clojure got very right was choosing what the language forces people to standardize on

14:27 mutability is the big one

14:27 because two libraries that deal with that differently would basically be incompatible

14:28 not baking everything into the language will cause some growing pains due to people inventing their own conventions

14:28 but I think the idea is that the community will adopt conventions over time, as various approaches are proved out

14:29 rindolf: ztellman: yes, if people share their abstractions and APIs online as FOSS, then eventually standards emerge.

14:30 ztellman: rindolf: which seems to be happening at a pretty good clip

14:30 so I'm not personally very concerned by the fragmentation issue

14:33 a_robbins: I use django, a python web framework, and they are having a very similar ongoing discussion about what to bring into the contrib package, and what to leave out in the community. It seems like the basic dilemma is you can either 1) bless something and make it contrib, slowing down development on that problem since it is harder to modify than someone's personal project or 2)let everyone make their own solutions out in the community, whi

14:33 ch fragments and makes it hard for newer users to know what the available packages are.

15:02 rindolf: Hi all.

15:03 LauJensen: rindolf: yo yo

15:03 rindolf: LauJensen: I went to take a bath.

15:04 LauJensen: rindolf: thanks for sharing

15:04 rindolf: I see ztellman , and a_robbins have gone.

15:04 LauJensen: sorry. :-(.

15:04 LauJensen: ?

15:04 rindolf: LauJensen: regarding the "thanks for sharing."

15:04 LauJensen: It was said with a smile

15:04 rindolf: LauJensen: ah, OK.

15:05 LauJensen: :)

15:05 rindolf: Well, maybe I'll try working on a ClojureScript something.

15:05 Clojure has something like eval "string" right?

15:05 Or only eval (SEXPR)?

15:05 LauJensen: &(read-string "(+ 2 2)")

15:05 sexpbot: ⟹ (+ 2 2)

15:06 LauJensen: &(-> "(+ 2 2)" read-string eval)

15:06 sexpbot: java.lang.SecurityException: You tripped the alarm! eval is bad!

15:06 rindolf: Wow.

15:06 This -> looks cool.

15:06 I had a similar idea.

15:06 For Park->Spark I mean.

15:15 kumarshantanu: has anybody tried using fn names with dash/underscore in protocols and then using them in Java? does it work?

15:17 Raynes: kumarshantanu: Don't hold me to it, but I seem to remember Clojure converting the names to something Javable under the hood.

15:41 kumarshantanu: Raynes: that possibly means i need to know converted names pattern if i want to use them in Java

16:07 Raynes: defn: Ping

16:09 LauJensen: kumarshantanu: - becomes _, IIRC

16:23 phenom_: hey guys, im having some trouble understanding the male/female example from Programming Clojure ... why does the sequence not cause a SOE but the direct call does ?

16:27 rindolf: phenom_: can you give a URL?

16:27 phenom_: is Programming Clojure available online?

16:27 phenom_: rindolf: no it's not ... ill do a pastie

16:28 rindolf: phenom_: thanks.

16:28 phenom_: I'm not a clojure expert, though, but it's standard procedure.

16:28 kumarshantanu: LauJensen: i tested and found both dash and underscore work in Clojure..that leads me to suspect they have separate encoding pattern (certainly for the dash, because it)

16:28 ..it's not valid in Java..

16:30 rindolf: Well, maybe Java symbols accept arbitrary strings internally.

16:30 With some special API calls, not using code directly.

16:31 phenom_: rindolf: http://pastie.org/1535093

16:32 joshua__: $findfn {:test "123"} "123"

16:32 sexpbot: []

16:32 rindolf: phenom_: what is SOE?

16:32 phenom_: stackoverflowexception

16:33 joshua__: &(key {:test "123"})

16:33 sexpbot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry

16:33 joshua__: Is that what is suppose to happen?

16:33 &(doc key)

16:33 sexpbot: ⟹ "([e]); Returns the key of the map entry."

16:34 joshua__: &(key (first {:test "123"}))

16:34 sexpbot: ⟹ :test

16:35 joshua__: Ah, so the ArrapMap has map entries. I think I get it now.

16:36 $findfn (first {:test "123"}) "123"

16:36 sexpbot: [clojure.core/val clojure.core/second clojure.core/last clojure.core/peek clojure.core/fnext clojure.core/rand-nth]

16:36 joshua__: &(doc val)

16:36 sexpbot: ⟹ "([e]); Returns the value in the map entry."

16:37 joshua__: Yeay, found the function I was looking for.

17:09 __name__: hello

17:09 brehaut: morning __name__

17:10 rindolf: Hi __name__

17:10 __name__: how is it ensure that a transaction completes at some time?

17:10 *ensured

17:10 i mean, what if there's two concurrent threads that keep spawing transactions and one always wins?

17:11 brehaut: __name__: complicated heuristics ;)

17:11 __name__: sounds fun :)

17:11 companion_cube: it's STM magic :)

17:11 brehaut: __name__: http://java.ociweb.com/mark/stm/article.html

17:12 its probably a bit out of date now, but it'll give you more info than you want :P

17:13 __name__: brehaut: thank you

17:18 working on a laptop without having a proper table sucks

17:18 :(

17:32 riddochc: A random idea to plant in someone's head: because of homoiconicity, one could make a clojure project to ease migrating a clojure project from clojure 1.2 to 1.3.

17:33 It'd be a practical application of code-walking, anyway.

18:16 brehaut: is there a short hand for (let [r (exp...)] (when (seq r) (something r))) ?

18:18 riddochc: brehaut: Look for when-let?

18:19 brehaut: riddochc: an empty seq is truthy

18:20 riddochc: If that's the case, (when (seq r) ... ) might not be what you want?

18:21 brehaut: r is the result of a complex expression

18:21 when doesnt bind

18:21 hence i have a let wrapping a when with a seq test

18:22 riddochc: Hmm. http://clojuredocs.org/clojure_core/clojure.core/when-let

18:22 brehaut: i guess i can just move the expression round

18:23 riddochc: I suppose you could *make* a shorthand... (defn blah [exp something] (let [r (exp...)] (when (seq r) (something r))))

18:24 brehaut: meh it'll do

18:24 cheers

18:24 riddochc: I'm really not the best one to be giving advice on this, really. I'm sure someone else knows.

18:25 brehaut: no worries. i rejiggered thing saround so that when-let is a bit cleaner.

19:22 cheezey: so im trying to use lein with a library that uses jni. how would i do this =>

19:25 ssideris: cheezey: there is a native-deps parameter to lein

19:25 it goes in project.clj

19:26 for example:

19:26 :native-dependencies [[penumbra/lwjgl "2.4.2"]]

19:26 cheezey: oh

19:27 is there a place that lists all the options? i guess i suck at searching

19:27 ssideris: lein's default repo is clojars

19:27 http://clojars.org/

19:28 (there is a browse link in there)

19:41 cheezey: ssideris: thnx

19:41 joshua__: $findfn "longstringwhichcontaintsanother" "contains" true

19:41 sexpbot: [clojure.core/not= clojure.core/distinct?]

19:42 joshua__: <joshua__> $findfn "contains" "longstringwhichcontaintsanother" true

19:42 $findfn "contains" "longstringwhichcontaintsanother" true

19:42 sexpbot: [clojure.core/not= clojure.core/distinct?]

19:43 joshua__: $findfn "contains" "longstringwhichcontainsanother" true

19:43 sexpbot: [clojure.core/not= clojure.core/distinct? clojure.contrib.string/substring?]

19:44 joshua__: Love that function sooo much.

20:02 TimMc: whoa

20:02 $findfn 2 2 4

20:02 sexpbot: [clojure.core/unchecked-multiply clojure.core/+ clojure.core/* clojure.core/unchecked-add]

20:02 TimMc: That's superb.

20:03 But what about exponentiation?

20:04 Chousuke: I don't think there's any exponentiation function in core or contrib

20:16 joshua__: It only searches a few libraries for the sake of speed.

20:17 I don't think that math libraries that might have exponentiation are among the ones it searches.

20:18 $(src find-fn)

20:18 &(src find-fn)

20:18 sexpbot: java.lang.Exception: Unable to resolve symbol: src in this context

20:23 joshua__: If you want to check out the function it is at: https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/clojure.clj towards the bottom of the page

20:29 Where can I grab an sha-256 function for clojure?

20:30 Nevermind, think I found what I was looking for.

20:31 RazWelles: Anyone have examples of loading .net assemblies in clojureclr?

20:37 TimMc: joshua__: Where?

20:37 * KirinDave sighs.

20:37 KirinDave: Why do I try to explain coding concepts on HackerNews? :(

20:37 It always goes wrong.

20:37 joshua__: https://github.com/tebeka/clj-digest/blob/master/README.rst

20:38 How so KirinDave?

20:38 KirinDave: http://news.ycombinator.com/item?id=2185810 (and down)

20:38 Jerk makes statements about actor model

20:38 Some of which are not even wrong

20:38 (as in they're so bizarre to be nonsense)

20:42 RazWelles: is there any example code for clojureclr anywhere?

20:44 joshua__: Honestly, I don't understand what you two are talking about well enough to agree or disagree, but more people to be supporting your statements than his. Maybe that Proverb about correcting fools leading to trouble applies?

20:44 Obviously I'm going to need to add a project that will force me to learn concurrency to my to-do list. ;/

20:47 KirinDave: joshua__: He's just very full of passion for such an uninformed dude.

20:48 TimMc: Wait a tick... what's the difference between let and let*?

20:49 This is isn't like Scheme...

20:49 Chousuke: let is a porcelain macro, let* is the actual "plumbing" :P

20:50 let basically adds destructuring on top of let*, there's no difference otherwise.

20:50 TimMc: Ah! So that's why there's no destructuring in let*... I should be using let anyway.

20:50 Fascinating.

20:50 Chousuke: yeah

20:50 there's also fn* which is similar.

20:51 you'll see them in macroexpansions, but nowhere else really.

20:52 TimMc: Well, you'll see them in newbie code too. :-P

20:52 (let* at least)

20:53 Chousuke: I wonder. Why would they use let*? /

20:53 it's not documented anywhere

20:53 you can get by without knowing it even exists

20:53 hiredman: let* in cl is like clojure's let

20:54 TimMc: Chousuke: In R5RS Scheme, let does not evaluate each init-expr in the scope of the preceding bindings.

20:54 let* is the form to use for that.

20:55 I had no reason to expect any difference. :-)

21:01 Chousuke: Also, if they hadn't read http://clojure.org/lisps closely, like me. >_<

21:06 RazWelles: how do I access a method when it's like.. indrect by 2? aka object.object2.method()

21:06 (let [temp_instance object] (.object2.method args1 args2))?

21:07 brehaut: ,(doc ..)

21:07 clojurebot: "([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on t...

21:07 RazWelles: ty

21:11 brehaut: RazWelles: if it might return nil, you may find -?>> in clojure.contrib.core useful too;

21:11 -?>> is like -?>> but it will short circuit to nil if any of the intervening forms returns nil

21:11 RazWelles: ahh ok, ty :)

21:12 brehaut: s/ -\?>>/->>/

21:12 sexpbot: <brehaut> -?>> is like->> but it will short circuit to nil if any of the intervening forms returns nil

21:22 Chousuke: I think you mean ->

21:23 brehaut: i dont

21:24 Chousuke: hmm, I'm not sure how ->> is any better than ->

21:24 at least for method calls.

21:24 brehaut: in this case it doesnt matter

21:24 i meant -?> rather than -?>> i think

21:25 Chousuke: anyway, using -> with .foo symbols is IMO somewhat nicer than .., but use whichever you want.

21:25 brehaut: Chousuke: the advantage of .. is that it is explicity java object interop

21:26 Chousuke: well so are .foo symbols :)

21:26 it's more typing, but I prefer having the . for any java methods.

21:26 brehaut: fair enough

21:26 gfrlog: what are people using for sinatra-style http servers in clojure these days?

21:28 brehaut: gfrlog: what is 'sinatra-style' ?

21:28 gfrlog: welp

21:29 fairly minimal. if it parses the path and the query string and the post params and such that'd be nice

21:29 but don't need too much else I don't think

21:29 brehaut: then then answer is whatever server you like, and ring as the base layer

21:30 add compojure or moustache for route dispatch

21:30 most people stick with jetty for the server, but its basically one line in the whole thing

21:30 weavejester: Ring handles query and post params, so any Ring-based framework would do

21:32 brehaut: gfrlog: that approach is the default in clojure

21:33 gfrlog: yes but which library?

21:33 brehaut: gfrlog: it depends on taste. ring to start.

21:33 gfrlog: okay

21:33 I will look at that, thanks

21:33 brehaut: i have a preference for moustache for routing, and i suspect weavejester prefers compojure

21:34 weavejester: Haha - yes, you'd be correct ;)

21:34 brehaut: :)

21:34 gfrlog: and these are all mutually exclusive?

21:34 weavejester: I've actually been working on an example Compojure project: https://github.com/weavejester/compojure-example

21:34 gfrlog: no sane reason to combine them?

21:34 weavejester: Not really

21:34 brehaut: not really mutally exclusive

21:34 they both generate ring handlers

21:34 weavejester: Compojure and Moustache handle routing. So, I mean, you could use them both

21:34 brehaut: but you probably wouldnt choose to use both as they cover 90% the same ground

21:34 weavejester: But they do the same thing, more or less

21:35 brehaut: my gut feeling is that if you are coming from ruby/rails, compojure's routing may feel more familiar

21:35 weavejester: Really? I'd have though Moustache was more like Rails, in that it has a static routing system.

21:35 gfrlog: I've actually done a lot with 2-year-old compojure

21:35 weavejester: Compojure is I guess more like Sinatra

21:36 brehaut: hah ok :)

21:36 gfrlog: but I gathered it changed a lot more recently

21:36 weavejester: gfrlog: which version?

21:36 brehaut: im from django land, so i dont really know rails other than what i looked at about 3 or 4 years ago

21:36 gfrlog: weavejester: was there a major change a year or two ago?

21:36 I don't have the source code on hand

21:37 brehaut: gfrlog: basicly ring came into existance and compojure no longer duplicates that affort

21:37 weavejester: The major change was probably the move to Ring.

21:37 gfrlog: okay

21:37 brehaut: weavejester: and seperation of hiccup into its own thing?

21:37 gfrlog: certainly some version prior to that

21:37 weavejester: Yeah.

21:37 gfrlog: hiccup was still part of it too

21:37 weavejester: I started off building Compojure as a monolithic framework

21:37 Then Ring came along

21:38 so I factored out all of Compojure's parameter, cookie, session etc. stuff to Ring

21:38 Anything that wasn't framework-specific.

21:38 the html generating I stuffed into ring

21:38 Er, hiccup

21:38 So all that's left is about 200 lines of routing code.

21:38 gfrlog: my coworker and I were actually just commisioned to rewrite the whole thing in rails

21:39 since I didn't write the original app, I consider it legacy clojure code

21:39 weavejester: Haha - to be honest, Rails is pretty nice, and more mature. I use it in my day job.

21:39 I think Ring, Compojure, etc. have greater potential than Rails

21:40 The design is better, I think.

21:40 brehaut: weavejester: seconded

21:40 weavejester: But Rails has so much stuff for it

21:40 brehaut: and thats rails etc ;) django is my day job

21:40 weavejester: Django has a lot of stuff too

21:40 brehaut: and i feel the same way about it

21:40 weavejester: they're far more mature, so if I wanted to get a web app out fast, I'd probably use Rails

21:40 for now

21:41 But when I'm programming for fun

21:41 Clojure is better than Ruby :)

21:41 brehaut: the new clojureql is also a very replacement for an ORM too :)

21:41 weavejester: Yeah. Clojure web development libraries are coming along very quickly!

21:42 brehaut: yup! its exciting

21:42 gfrlog: I think I agree with just about everything that has been said

21:42 weavejester: I use Sinatra a lot at work for APIs and stuff, and I think Compojure has already overtaken it.

21:42 brehaut: im hoping to get a v1.1 of my xml-rpc library out along with a pingback implementation at 1.0 in the next month

21:42 weavejester: IMHO of course ;)

21:43 brehaut: heh

21:43 gfrlog: compojure was named after a more superior cultural icon

21:43 weavejester: Which cultural icon was that?

21:44 gfrlog: I hadn't planned on taking the joke this far

21:45 weavejester: haha - ok

21:45 gfrlog: my apologies.

21:46 weavejester: np

21:47 arbscht: weavejester: hi! btw, there is a #compojure channel too :) sometimes people ask questions there

21:47 brehaut: for the curious: i wrote a few words about getting started with fnparse http://brehaut.net/blog/2011/fnparse_introduction

21:48 weavejester: I really should keep on IRC

21:49 Thus far I've tended to just use Google groups

21:50 gfrlog: so if I want to programmatically start/stop a ring server

21:51 then I should ask here if anybody knows how to do that

21:51 does anybody know how to do that?

21:52 I'd like to be able to start one in a separate thread and then stop it later

21:55 I assume the second part is the trick one

21:56 tricky*

21:56 brehaut: gfrlog: i think there might be an example snippet on the ring github somewhere?

21:56 i just kill my whole jvm ;)

21:57 weavejester: There is lein-ring

21:57 Which can start a ring server from the console

21:57 gfrlog: yeah, that's how I would normally do it. I'd like to run this from within a test though.

21:57 weavejester: lein ring server

21:57 Ah, I see

21:57 gfrlog: I'm testing an HTTP client

21:57 weavejester: There's a test in the Ring repo that does that

21:58 gfrlog: I'll take a look, thanks

21:58 weavejester: https://github.com/mmcgrana/ring/blob/master/ring-jetty-adapter/test/ring/adapter/jetty_test.clj

21:59 But you can also test Ring just by sending request maps directly to the handler

21:59 gfrlog: I think {:join? false} is the key there?

22:00 weavejester: Yeah, that causes it to run in a background thread

22:00 Or rahter, not to block

22:00 gfrlog: weavejester: I'm not trying to test ring, I'm trying to test my client. I'm using ring to mock a rails project

22:00 weavejester: ah, I see

22:00 gfrlog: whereas in the rails project I use functional tests to mock the clojure client

22:03 * riddochc reads brehaut's intro to fnparse.

22:04 brehaut: riddochc: excellent :) if you spot any errors or weirdness, flick me a message

22:04 riddochc: I've had some problems getting fnparse to work under clojure more recent than 1.2, because of some errors in its dependencies in c-contrib. I posted about it on the list a few weeks ago, didn't get a reply.

22:06 brehaut: i figured it might be the case so i specifically mentioned clj 1.2 and fnparse 2.2.7

22:06 riddochc: I was going to try to use it to parse the git-fast-import format, as part of a project to convert between a mediawiki export dump and a file-based git repository of wiki pages.

22:06 I'm not sure whether I'll actually be continuing that project, though.

22:08 But it looks like the coffee shop is closing momentarily, so I should be going. I'll let you know how it reads, brehaut, once I finish reading it later.

22:08 brehaut: cheers

22:21 joshua__: $findfn {:test "123"} :test {}

22:21 sexpbot: [clojure.core/dissoc]

22:26 gfrlog: $findfn partial (partial partial)

22:26 sexpbot: java.security.PrivilegedActionException: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial (NO_SOURCE_FILE:0)

22:41 ttmrichter: OK, I'm seeing some oddity in the 1.2 REPL. Could anybody explain to me what's happening here?

22:41 user=> (def six `六)

22:41 #'user/six

22:41 user=> six

22:41 user/m

22:42 brehaut: ttmrichter: seems to be working sensible for me (other than an encoding problem)

22:42 user=> six

22:42 \?

22:43 ttmrichter: You think displaying "m" instead of 六 is sensible?

22:43 brehaut: i dont get m, i get \?

22:44 bdesham: I'm looking for a function to merge maps together, but which will merge arbitrarily deeply

22:44 for example, (merge-deeply {:a {:b 1}} {:a {:c 5}}) should give {:a {:b 1, :c 5}}

22:44 brehaut: user=> (int six)

22:44 20845

22:44 bdesham: does such a thing exist in core or clojure-contrib?

22:44 hiredman: ttmrichter: you are using jline?

22:44 ttmrichter: hiredman: Yes.

22:44 hiredman: jline doesn't do utf-8 properly

22:44 ttmrichter: brehaut: (int six)

22:44 java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Character (NO_SOURCE_FILE:0)

22:45 hiredman: Ah. Is there an alternative I could use?

22:45 brehaut: ttmrichter: see hiredman's comment

22:45 hiredman: rlwrap

22:46 ttmrichter: Is there a quick pointer to using rlwrap for clojure's REPL somewhere?

22:47 hiredman: rlwrap java …

22:48 ekoontz: is there a function to return the hash-map minus a given element?

22:48 return a hash map i mean

22:49 bdesham: dissoc?

22:49 (dissoc {:a 4, :b 5} :a) -> {:b 5}

22:49 ekoontz: cool, thanks bdesham, that works :)

22:51 bdesham: :-)

22:53 ekoontz: i tried google but no luck

22:53 actually i see it now: http://faustus.webatu.com/clj-quick-ref.html#map

23:00 bdesham: to answer my own question... it looks like (deep-merge-with (fn [_ b] b) map1 map2) will do what I wanted

23:01 ttmrichter: hiredman, brehaut: Thanks for the help.

23:06 sritchie_: hey all - is there a good idiomatic way to check if an item exists in a collection? something like:

23:06 ,((fn [x y coll] (some #(= [x y] %) coll)) 4 5 [[4 3][4 3]])

23:06 clojurebot: nil

23:06 sritchie_: ,((fn [x y coll] (some #(= [x y] %) coll)) 4 5 [[4 5][4 3]])

23:06 clojurebot: true

23:06 brehaut: the idiom depends on the collection

23:07 sritchie_: brehaut: I'm using the for macro to generate all combinations of these tiles: http://modis-land.gsfc.nasa.gov/MODLAND_grid.htm

23:07 brehaut: but I need to ignore the tiles that don't touch the globe at all

23:07 anthony__: What's the most elegant way to see if a string contains a substring out of a set of strings? ie "Does string a contain string b, c, or d?" It seems like I can maybe use some, but I'm not sure...

23:08 sritchie_: anthony__: one second, one that one

23:08 brehaut: sritchie_: if existence is your requirement, then use a set

23:09 ,(#{[4 5] [5 3]} [4 5])

23:09 clojurebot: [4 5]

23:09 brehaut: ,(#{[4 5] [5 3]} [23 12])

23:09 clojurebot: nil

23:10 brehaut: or, if you really care about a bool ##(contains? #{[4 5] [5 3]} [4 5])

23:10 sexpbot: ⟹ true

23:10 sritchie_: anthony__: (fn [str substrings] (some #(substring? % str) substrings))

23:10 brehaut: okay, that makes sense

23:12 anthony__: sritchie: Awesome -- I knew there was a beautiful way to do it. Thanks a lot.

23:13 sritchie_: no problem

23:16 brehaut: I think you joked about this some other day -- what does sexpbot do if you ask it to realize an infinite sequence?

23:17 brehaut: sritchie_: it runs things in a timeout sandbox

23:17 it shouldnt ever run forever

23:17 there are some cases where it doesnt alert you to the timeout failure though

23:18 sritchie_: brehaut: got it, I suppose there's no reason it should be expected to run longer than some sort time, given its environment

23:18 s/sort/short

23:18 sexpbot: <sritchie_> brehaut: got it, I suppose there's no reason it should be expected to run longer than some short time, given its environment

23:18 brehaut: yup

23:18 also its capped to never realize a large sequence to the channel

23:19 $(range 10000000)

23:19 ##(range 100000000)

23:19 sexpbot: java.lang.OutOfMemoryError: Java heap space

23:19 brehaut: that was surprising

23:20 sritchie_: busted

23:21 brehaut: Raynes is probably going to give me some grief for that now :P

23:21 sritchie_: it tried to go the extra mile for you, and look what happened

23:21 Raynes: brehaut: I have the heap setting fairly low. That isn't that uncommon.

23:21 $kill

23:21 sexpbot: KILL IT WITH FIRE!

23:21 Raynes: You didn't break him yet.

23:21 brehaut: phew

23:23 out of curiousity, why does it blow stack? holds onto head?

23:26 ekoontz: anyone tried redis or mongodb with clojure?

23:26 hiredman: not limiting the print level

23:31 sritchie_: brehaut: if I'm building a set from multiple collections, is there a way to apply across all collections?

23:31 let me give an example:

23:31 ,(apply conj [] (for [x (range 2) y (range 2)] [x y]))

23:31

23:31 clojurebot: [[0 0] [0 1] [1 0] [1 1]]

23:31 sritchie_: that works great

23:32 ,(apply conj [] (for [x (range 2) y (range 2)] [x y]) (for [x (range 3 5) y (range 3 5)] [x y]))

23:32 clojurebot: [([0 0] [0 1] [1 0] [1 1]) [3 3] [3 4] [4 3] [4 4]]

23:32 sritchie_: but here, conj gets applied to all elements of the first for, plus the entire second for

23:33 brehaut: first up

23:34 (vec (for [x (range 2) y (range 2)] [x y]))

23:35 sritchie_: brehaut: okay, internalized

23:35 brehaut: secondly, arent you wanting sets?

23:35 sritchie_: yeah, I wanted to build up a collection to pass to set

23:36 brehaut: sets support fast unions

23:36 (union (set (for [x (range 2) y (range 2)] [x y])) (set (for [x (range 3 5) y (range 3 5)] [x y])))

23:36 (union is in clojure.set)

23:37 sritchie_: that's perfect, of course that's it

23:37 brehaut: the proper function always exists

23:37 brehaut: it does

23:38 sritchie_: brehaut: it's sort of odd, taking advantage of all of these recursive functions without having to write any of them

23:38 brehaut: yup

23:39 sritchie_: brehaut: I've been working with scheme, too, and the worlds are very different. Though I did find something today that needed loop/recur, and a cond statement

23:39 brehaut: cond is not infrequent in clojure

23:51 cemerick: ~max

23:51 clojurebot: maxine is http://research.sun.com/projects/maxine/

23:51 cemerick: oh well

23:51 maxine is cool, though

23:54 Raynes: $max

23:54 sexpbot: The most users ever in #clojure is 317

23:54 Raynes: cemerick: lrn2bot

23:55 * cemerick will always be a bot noob

Logging service provided by n01se.net