#clojure log - Dec 25 2009

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

0:47 piccolino: _ato: did you get clojars working on couchdb yet?

1:07 tolstoy: ERROR: No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0

1:07 Oh, boy.

1:24 hiredman: http://github.com/hiredman/Repl

1:25 so back to feature parity with what I had before I rewrote it all

1:26 (but now you can set! *font*)

3:20 tolstoy: adadasd

3:20 asdasd

3:21 Oops. Sorry. Thought I was in my test channel.

4:14 lithper1: i have a file in /root/com/mem.clj, and i include /root as part of the classpath when i launch the REPL using java -cp "..." clojure.jar. However, when i require com.mem, it says it can't find mem.clj in the classpath. am i setting the classpath incorrectly?

4:16 hiredman: what is the exact exception?

4:16 lithper1: FileNotFoundException

4:16 _mst: you're not using "-jar clojure.jar" or anything like that?

4:16 lithper1: could not locate com/mem_init.class or com/mem.clk on classpath

4:17 hiredman: how are you setting the classpath?

4:17 lithper1: java -cp "/root:clojure.jar" clojure.lang.Repl.

4:18 hiredman: use clojure.main not Repl

4:18 (not that it will solve you problem)

4:19 what does (System/getProperty "java.class.path") say?

4:20 lithper1: .

4:21 it says "/root:clojure.jar"

4:22 i might have an idea

4:22 hiredman: what does the namespace declaration in mem.clj look like?

4:23 lithper1: ok it works now. i made a small typo in the namespace name. i'm going to go hide in the corner.

4:25 i remember once when i tried to include a path in the classpath, i had this error Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath

4:26 do i really need clojure.contrib?

4:39 hoeck: lithper1: there is a lot uf useful stuff in there, you mentioned duck-streams already

4:39 lithper1: almost all my namespaces use except and pprint

4:40 lithper1: i'm just adding a directory to the classpath, why is it looking for the clojure.contrib library?

4:42 hiredman: you don't need contrib, but some library you are using might depend on it

4:43 * hiredman almost never uses contrib

4:43 lithper1: does it scan the classpath to find which files use other libraries?

4:44 hiredman: eh?

4:44 it doesn't have to

4:45 when you load a file that use's or "require's another namespace it looks for a file providing that namespace on the classpath

4:45 lithper1: i'm getting that error when i just try and add a path to the classpath, without requiring anything.

4:46 hiredman: then you are loading a clojure file that trys to use contrib

4:47 lithper1: it can't be the case that the clojure jar is loading clojure-contrib?

4:47 hiredman: nope

4:47 are you using any other libraries?

4:48 pastebin your file?

4:48 lithper1: no, i'm just adding a path without using anything else. i'm literally just luanching the REPL with an additional classpath.

4:49 hiredman: what command are you using?

4:49 lithper1: java -cp "directory:clojure.jar" clojure.lang.Repl. also tried it with clojure.main.

4:50 hiredman: and what is in directory?

4:51 lithper1: there's one .clj file, and other dictories.

4:52 hiredman: where did you get your clojure.jar?

4:52 lithper1: code.google.com

4:52 hiredman:

4:53 lithper1: http://code.google.com/p/clojure/

4:53 hiredman: 1.0?

4:53 lithper1: 1.0.0

4:55 hiredman: and what is the exact exception?

4:55 don't type something out, copy and paste to a pastebin

4:56 lithper1: ok

4:59 http://pastebin.com/d24456523

5:04 hiredman: where is utils.clj?

5:04 and what is line 1 of utils.clj?

5:05 do you have a file named user.clj?

5:05 lithper1: yes it's inside one of the directories in code/ and it starts with (ns examples.utils (:user [clojure.contrib.duck-stream ...

5:06 hiredman: and user.clj?

5:06 lithper1: user is inside code/ and it starts with (user 'examples.utils'), which refers to user.clj i just mentioned.

5:08 hiredman: you mean it refers to utils

5:08 lithper1: sorry, yes utils

5:08 hiredman: ok, well at start up clojure looks for a user.clj on the classpath and loads it

5:08 the idea being you stick some useful utility functions in there

5:10 lithper1: i see. i just found the same thing being mentioned in the manual, but somehow it's missing from the book i'm reading. thanks for pointing it out.

5:13 probably jumped too quick into loading libraries. thanks for the help.

7:10 Drakeson: how should I turn (seq "abc") back to "abc" ?

7:11 hiredman: apply str

7:11 Drakeson: thanks

7:56 emacsen: Morning folks (of afternoon where you are)

9:18 liebke, were you part of the Clojure study group last year?

9:18 liebke: emacsen: no

9:38 emacsen: I was hoping Lao_of_Dk would be on

10:33 fliebel: Is an observer pattern suitable for implementing a simple plugin system in a Clojure app? And how would I do that?

10:52 cp2: mornin guy

10:52 s

10:59 ambient: i thought design patterns were only needed for oop languages to fix their defincies

11:00 ...well, in this case design patterns specifically designed for oop

11:10 cp2: ambient: just shutup and add another layer of indirection

11:10 ;)

11:13 ambient: im just a noob who thinks immutability and lisp will save us all. who needs patterns when you have lambdas and macros? :\

11:14 functions that swing other functions

11:14 do we really need a higher level of abstraction?

11:14 cp2: well, the ideal 'design pattern' in a mostly pure functional language such as clojure is... functional programming

11:15 ambient: i personally dont think the GoF book or others are highly useful with clojure

11:21 fliebel: I don't know if obeserver is the way, but I need to notify plugins that an event occurred.

11:24 Is there a way I can do something like (apply -> [#(print "some") #(print "functions")])? I know I can not apply to a macro, but I need to thread a value to a vector of functions.

11:36 Hmm, reduce seems to work. This is my observer for now: http://gist.github.com/263669

13:22 quizme: what's the difference between an array, vector, and a list?

13:30 ambient: arrays are mutable, and i would like to know myself the differences between vector and list when it comes to the implementation details and performance characteristics

13:33 quizme: arrays are the naughty java data structure

13:33 tolstoy: http://clojure.org/data_structures

13:41 quizme: vectors are indexed by integers, lists are not (?)

13:43 tolstoy: That's kinda what I gathered.

13:46 Not sure why you'd prefer one over the other in general programming. I always use List because that's just generally how I think.

13:48 emacsen: tolstoy, In Clojure one generally uses indexes because it's easier to visually differentiate

13:48 quizme: are vectors arguments to functions (the stuff between [ ])?

13:48 emacsen: LauJensen, are you actually here? I have a question for you

13:49 tolstoy: ,(:2 ["a" "b" "c"])

13:49 clojurebot: nil

13:49 LauJensen: emacsen: Actually I'm just passing by, so can we either make it real quick, or meet up in about 15 hours? :)

13:49 emacsen: quizme, the bound symbols are inside the function, so yes

13:49 LauJensen, quick one then...

13:49 LauJensen: k

13:49 emacsen: LauJensen, Are you going to put sqlite support in ClojureQL soon?

13:49 you mention it in the docs, but no backend in the git repo

13:49 LauJensen: No plans, for 1.0, the Derby support is actually a mutated sqlite support, so it should be very quick to fit it for sqlite

13:50 I gotta run - send me an email if you got more questions :)

13:50 emacsen: ok

13:50 thx

14:01 quizme: what's the difference between conj and into ?

14:07 tolstoy: conj can take a non-list thing and add it to a list, while into adds one list into another?

14:10 quizme: sounds good to me

14:12 into strips off a set of parens

14:12 tolstoy: I'm not really sure, but I think I've seen conj use when you're building up a list, and into used when you're transforming a collection.

14:13 (into {} (map some-transform original-map)) ; something like that

14:17 quizme: i bet you could write an xml parser in just a few lines of code

14:18 hiredman: ,(doc clojure.xml/parse)

14:18 clojurebot: "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"

14:51 quizme: Are there any wrappers for more aesthetically pleasing access syntax for, say, an rss feed?

14:51 e.g. something prettier than: (((((((clojure.zip/xml-zip (clojure.xml/parse "http://rss.slashdot.org/Slashdot/slashdot")) 0) :content) 0) :content) 0) :content)

14:53 e.g. something like this would be nice: ((parse "http://rss.slashdot.org/" ) :channel :title)

14:58 hiredman: http://richhickey.github.com/clojure-contrib/zip-filter-api.html

15:23 quizme: hiredman: how do you get the channel title using that api, for example?

15:29 nm i see an example in the halloway book

15:33 lisppaste8: Anniepoo pasted "why no stream?" at http://paste.lisp.org/display/92641

15:33 Anniepoo: ok, my brains obviously got a short. Why isn't that picking up stream?

15:34 #<CompilerException java.lang.Exception: No such var: http/stream (test_sui_client.clj:11)>

15:35 fliebel: Huh, I'm doing something strange again… I got a clj file referred by :use in the ns declaration. When I print loaded-libs the thing shows up, but using a def in that file results in an exception. Using the same def from another file does work. How is it possible that a namespace is imported but… not working?

15:40 Anniepoo: is http-agent broken, or not work with 1.0?

15:43 silence on the wire

15:45 merry Christmas Clojurebot

15:45 fliebel: hm, most people are celebrating christmas I guess...

15:46 Anniepoo: I'm celegrating christmas by writing code that's not for work

15:46 8cP I've gone over the edge

15:48 anybody on using clojure.contrib.http.agent?

15:50 fliebel: Not me...

15:50 Anniepoo: ok, thanks fliebel

15:50 fliebel: Anyone knows if using load-file breaks things? I'm stuck with a strange import problem...

15:51 Anniepoo: what dev environment are you using?

15:51 fliebel: vim

15:51 Anniepoo: I'm having similar weird problems with Enclojure

15:52 PrinceOfA: how do i redefine a function?

15:52 hiredman: fliebel: lets see some examples and some exceptions

15:52 clojurebot: how can PrinceOfA redefine a function

15:52 clojurebot: a is b

15:53 hiredman: I see

15:53 fliebel: hiredman: coming…

15:53 Anniepoo: @PrinceOfA, just use defn again

15:54 ,(defn foo [] 7)

15:54 clojurebot: DENIED

15:54 * Anniepoo waves wildly at hiredman 8cD

15:54 fliebel: hiredman: utterson.plugin.tesplugin prints #{clojure.main utterson.plugin} when using (loaded-libs) but when I access a function in there I get: Exception in thread "main" java.lang.Exception: Unable to resolve symbol: register in this context (testplugin.clj:4)

15:55 hiredman: fliebel: lets see the code

15:55 fliebel: hiredman: When I access the same def (register) from another file in them same dir as plugin.clj it works

15:55 Anniepoo: ah! fliebel, you're confusing 'require', which makes clojure know about the namespace, with 'use', which eliminates the need to qualify it

15:55 I bet

15:55 hiredman: have you loaded this all in a fresh repl?

15:56 ieure: http://clojars.org/ is down. :(

15:56 fliebel: hiredman: http://github.com/pepijndevos/utterson/blob/master/src/utterson/plugin/testplugin.clj http://github.com/pepijndevos/utterson/blob/master/src/utterson/plugin.clj

15:56 PrinceOfA: i tried to redefine clojure.contrib.test-is/report by writing (defn report [event]...) but i got "Name conflict, can't def report because namespace: test.run refers to:#'clojure.contrib.test-is/report"

16:00 fliebel: hiredman: I don't feel very confident about my namespace setup… sometimes it works and sometimes it does not.

16:01 (load "utterson.plugin") does not work, but (require 'utterson.plugin) does *puzzled*

16:02 hiredman: fliebel: some kind of println in that doseq

16:03 fliebel: hiredman: what should I print?

16:04 hiredman: fliebel: whatever

16:04 maybe file

16:04 Anniepoo: tired of slamming head against bad clojure docs. Work on it later.

16:05 fliebel: hiredman: you know what… I solved it my moving the doseq below the functions! How stupid of me!

16:05 hiredman: I think you must have a problem with that doseq

16:05 PrinceOfA: so how do i redefine function that are not in the same namespace?

16:05 fliebel: By the time those plugins are imported those functions do not yet exist!

16:05 hiredman: thanks for setting me on the right track… by mentioning the doseq things began to connect again in my head.

16:07 ordnungswidrig: hi all!

16:19 fliebel: Is there a way I can get a script running on both repl and jar? I need to get around *warn-on-reflection* and *command-line-args*

17:57 jweiss: any compojure folks here? i'm a newbie, problem is i want to use the "session" variable, and it seems to be nil when i go to put stuff into it

17:57 is there a way to initialize it

17:58 Anniepoo: I'm baffled that clojure-contrib isnt' available as a jar file

18:03 sorry jweiss

18:07 liebke: Anniepoo: http://build.clojure.org/job/clojure-contrib/lastSuccessfulBuild/artifact/clojure-contrib.jar

18:09 lisppaste8: Anniepoo pasted "why no stream?" at http://paste.lisp.org/display/92650

18:09 Anniepoo: .

18:10 odd, I just pasted at http://paste.lisp.org/+1ZHM

18:10 it didn't announce here

18:14 hiredman: http://github.com/richhickey/clojure-contrib/blob/clojure-1.0-compatible/src/clojure/contrib/http/agent.clj <-- no string

18:20 Anniepoo: Thanks liebke!

18:22 Ah!

18:23 thanks

18:23 figured it was the version

18:24 8cP Enclojure's broken with the latest RC

19:05 neotyk: New blog post "Clojure Start Again" http://bit.ly/4CHKFq

19:29 the-kenny: Has anyone playes with lejos (the pc api) and clojure?

19:29 s/playes/playes/

19:33 pdk: last semester one team in our AI class used it for their mindstorms bot i believe

19:33 i imagine it wouldn't be much harder to use it with clojure cause you can just call functions from java code directly

19:46 somnium: are there any implementations of seq or list with types/protocols?

19:49 emacsen: somnium, types?

19:49 and list is a type of seq

19:49 somnium: emacsen: deftype

19:50 emacsen: oh that's all the new stuff :)

19:50 somnium: emacsen: deftype Cons [car cdr] ...

19:51 emacsen: every time someone says cdr in a modern lisp, an elf has his toenails pulled out

19:51 somnium: :)

19:51 Cons would be used internally by list/seq presumably

19:51 at least everyone (here) knows what it means

19:54 pdk: we like to think of ourselves as cons artists

19:54 ba dum tschh

20:01 somnium: ah, looks like Rich used first and more in the .java

20:02 I sincerely apologize for uttering the profane 'car' and 'cdr' in these halls

20:20 tolstoy: Can't take value of a macro? Hm.

20:29 somnium: clojars is down?

20:46 the-kenny: somnium: 503 here

20:46 somnium: same here :/

21:07 ohpauleez: holidays everyone

21:08 awhile back someone in here was trying to optimize euler #14

21:08 I have a pretty good one that uses primitive types and transients for intermediate steps

21:17 tolstoy: ohpauleez: I think that was qed.

21:17 ohpauleez: ah, yes, thank you

21:25 qed: ping me or pm me if you want to see my latest attempt

Logging service provided by n01se.net