#clojure log - Dec 26 2008

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

0:30 lisppaste8: holmak pasted "Math/sqrt failure" at http://paste.lisp.org/display/72665

0:30 holmak: Clojure won't let me use Math/sqrt from the Java library - any idea why that would happen?

0:31 It works perfectly well when I type it directly in the REPL, but not if I try to defn a function or use it in a file.

0:31 I have the latest version of Clojure, 1162.

3:03 yangsx: I've come across this strange error java.lang.IncompatibleClassChangeError after defining a function and evaulating it at slime-repl

3:04 hiredman: what function

3:05 lisppaste8: url

3:05 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

3:05 yangsx: Is it a bug with my function or the compiler?

3:05 hiredman: bug your function

3:06 it manes you tried to use something as something it cannot be

3:06 means

3:14 yangsx: hiredman: thanks, I'll review my code once more.

3:16 hiredman: ,(name *ns*)

3:16 clojurebot: java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0)

3:42 yangsx: hiredman: my error was due to use disj as dissoc by mistake

3:43 btw, is there a Clojure counterpart of CL's subseq?

3:46 hoeck: yangsx: there is subvec for vectors

3:48 yangsx: and subseq :)

3:51 yangsx: hoeck: my data structures happen to be a vector, thanks. I was looking for samething general for seq in vain.

4:12 Lau_of_DK: Good morning all

4:15 hoeck: good morning Lau_of_DK

4:55 Lau_of_DK: Since assoc doesnt work, how do I change a key/val pair in a PersistantArrayMap ?

5:10 hoeck: Lau_of_DK: not shure what you mean, assoc works on PersistantArrayMap too

10:46 hiredman: clojurebot: ping

10:46 clojurebot: PONG!

12:16 chrisn: hello?

12:19 hiredman: clojurebot: java?

12:19 clojurebot: hmm... sounds like your out of heap space

12:20 hiredman: clojurebot: java is <reply>?

12:20 clojurebot: Roger.

12:37 danlarkin: clojurebot: java

12:37 clojurebot: ?

12:37 wwmorgan: Does a function already exist that does this? (foo 3 [:a :b]) => ((:a :a :a) (:a :a :b) (:a :b :a) (:a :b :b) (:b :a :a) (:b :a :b) (:b :b :a) (:b :b :b))

14:08 Lau_of_DK: Slow night... anyone working on anything interesting? :)

14:10 Kerris7: Lau_of_DK: I'm planning to port Lisp in Small Pieces to Clojure

14:10 Lau_of_DK: How do you mean ?

14:10 Kerris7: I just want universities to start teaching Lisp again :(

14:10 Lau_of_DK: But you do realise that Clojure is a Lisp right? :)

14:11 Kerris7: Yeah, it's mostly a syntax thing

14:11 I daresay Clojure is the most accessible Lisp at the moment

14:11 Lau_of_DK: k, got a public repo somewhere?

14:11 Kerris7: therefore* it would be a boon to have educational material using Clojure syntax

14:12 *just had dinner, can't really think straight

14:13 Lau_of_DK: would something like Stuart Holloway's Practical Lisp port do?

14:13 Lau_of_DK: In terms of providing teaching-material?

14:14 Kerris7: yeah, also in terms of public repo, i.e. using github

14:15 Lau_of_DK: oh... In terms of the material I dont know, havent read the book, but Github is :)~

14:27 chrisn: don't mix opengl and lazy evaluation

14:28 next thing you know you get a hardcore crash because the opengl calls get evaluated in a thread with no active context

14:30 I have a couple buddies working through "the structure and interpretation of computer programs" http://mitpress.mit.edu/sicp/full-text/book/book.html

14:31 They are doing it in scheme, I think. If we had that, we wouldn't need much else.

14:35 Lau_of_DK: chrisn: You said OpenGL and SICP in the same sentense ?

14:35 chrisn: nope

14:35 first two comments were exasperation

14:35 second two were chiming in

14:35 sry

14:41 Lau_of_DK: clojurebot: SICP?

14:41 clojurebot: Pardon?

14:41 Lau_of_DK: chrisn: I think I remember seeing an whole site with conversions from Scheme/SICP to Clojure

14:42 Kerris7: Lau_of_DK: http://codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages ?

14:42 chrisn: hah

14:42 yep

14:45 Lau_of_DK: That looks like it... though they ported it to C++ I see... they really must have missed the point of that lecture

14:45 Kerris7: I'm only planning the Lisp in Small Pieces port at the moment, the strongest candidate I'm considering for a Lisp to Clojure port would be Simply Scheme

14:46 Lau_of_DK: Im looking forward to seeing what you come up with

14:47 chrisn: C++ involved a lot of extremely smart people who were amazingly adept at missing the point.

14:48 So did Java.

14:48 Lau_of_DK: hehe, looks like that happend to Ruby as well

14:58 aperotte: hello all

15:06 Lau_of_DK: Hi aperotte

15:08 aperotte: seems like things are a little slow on the channel today

15:11 Lau_of_DK: Very, almost unbearable :)

15:11 aperotte: hahaha

15:12 have you been working on a clojure project?

15:14 Lau_of_DK: yea

15:21 aperotte: what kind of project is it ... if you don't mind me asking

15:25 Lau_of_DK: I'll be back in a few

15:32 Lau_of_DK: aperotte: Me and kotarak have been hacking away at ClojureQL, an attempt at turning SQL statements into higher order functions

15:33 dk.bestinclass.clojureql> (execute (sql (query [id name language iq]

15:33 developers.employees

15:33 (< iq 100))))

15:33 {:iq 85, :language Python, :name Frank, :id 1}


15:34 aperotte: Lau_of_DK: haha ... very nice

15:34 Lau_of_DK: I haven't used SQL much or done much web programming at all, but sounds cool

15:35 Lau_of_DK: yea it'll be nice when its done

15:36 aperotte: have you looked at compojure at all?

15:37 Lau_of_DK: Of course

15:40 Did you think that the two are related aperotte ?

15:41 dudleyf: Lau_of_DK: Is the source up anywhere?

15:41 aperotte: not really, I've been keeping an eye on compojure

15:41 I'd like to try my hand at web programming once there's more documentation

15:41 Lau_of_DK: dudleyf: http://github.com/Lau-of-DK/clojureql/tree/master

15:41 Chousuke: Lau_of_DK: do you have any plans regarding input sanitisation with clojureql

15:42 dudleyf: Lau_of_DK: Thanks

15:42 aperotte: I hadn't seen any mention of clojureQL on their site, so I didn't think it

15:42 Lau_of_DK: aperotte: In this game, I wouldnt wait for the docs :)

15:42 But Compojure is cool, so you can dig into it

15:42 ClojureQL is not web-related, its only for databases, so that

15:42 SELECT id,name FROM database1 WHERE id = 5

15:42 becomes

15:43 (sql (query [id name] database1 (= id 5)))

15:43 Chousuke: In which way to you mean sanitisation ?

15:44 Chousuke: like, if you wanted that 5 to depend on user input somehow

15:44 chrisn: how do I type my variables in clojure again?

15:45 I think I am running into some lag doing generic lookups on an interface where I know the type

15:45 Chousuke: I guess you could use clojureql to generate SQL with placeholders

15:45 Lau_of_DK: Chousuke: We're implementing it with unquote, so that you could do (let [x 5] (sql (query id table1 (= id ~x))))

15:45 Chousuke: Lau_of_DK: yes but that's dangerous

15:45 Lau_of_DK: What do you fear ?

15:45 Chousuke: x being something like bobby tables' name :P

15:46 Lau_of_DK: haha

15:46 But thats not really my concern is it? If you choose to fire a script with unvalidated data, then thats your call as a developer

15:47 dudleyf: Lau_of_DK: Since databases have mechanisms for avoiding injection like that,

15:48 if you're implementing a database library, it is your concern, I think

15:48 Chousuke: I mean constructs like INSERT INTO foo VALUES (?,?,?,?) and then using some programming language function to execute that query with supplied values

15:49 chrisn: (for [#^float i (range -50 50) #^float j (range -50 50)]

15:49 Something like that?

15:50 dudleyf: I guess it depends on whether your library is a database interface or just a sql string generation library

15:50 But I imagine that line gets pretty blurry

15:50 Lau_of_DK: dudleyf: We're sending everything through with JDBC, if that makes a difference

15:51 Chousuke: Your statement would be (sql (insert foo [x y z] [~x ~y ~z])) But what you bind those vars to, is totally up to you

15:51 dudleyf: Lau_of_DK: Then I would think you'd want to allow for PreparedStatements and such

15:52 Chousuke: Lau_of_DK: but what kind of sql does that generate?

15:52 Lau_of_DK: I mean, even JDBC will let you destroy your DB if you want, I really dont see why I should police that

15:52 That would expand into INSERT INTO foo VALUES (x, y, z) ' and then the literal evalutated values of those vars, at the time of using (sql ..)

15:52 Chousuke: Lau_of_DK: if it generates INSERT INTO foo values (x, y, z) then it's dangerous unles x, y and z are all "?"

15:53 Lau_of_DK: dudleyf: Everything gets fitted into a preparedstatement

15:53 Why dangerous? they're all seperately stored when you unquote them

15:53 Chousuke: separately stored?

15:53 they're dangerous becuase they become part of the SQL string

15:54 user-supplied values should never be part of the SQL string. That's why placeholders exist.

15:54 Lau_of_DK: I think we end up paramterizing (?) them, so that in the SQL string theyre @x @y @z

15:54 And then we add them to a prepared statement

15:54 Chousuke: ah, that sounds like it's safe.

15:57 so you do something like PreparedStatement("INSERT INTO FOO VALUES (@x, @y, @z)").executeWithParameters(x,y,z)? (pseudocode, I can't remember the api right now)

15:58 Lau_of_DK: Yes

15:59 I can dig it up for you if you want, one sedc

15:59 Chousuke: sounds good

15:59 Lau_of_DK: SqlConnection conn = new SqlConnection(_connectionString);

15:59 conn.Open();

15:59 string s = "SELECT email, passwd, login_id, full_name " +

15:59 "FROM members WHERE email = @email";

15:59 SqlCommand cmd = new SqlCommand(s);

15:59 cmd.Parameters.Add("@email", email);

15:59 SqlDataReader reader = cmd.ExecuteReader();


15:59 Chousuke: right.

15:59 Lau_of_DK: Can I stamp it "Approved by the Chousuke" ? :)

16:00 Chousuke: yes.

16:00 Lau_of_DK: Sweet

16:00 Chousuke: seriously though, that looks really cool :)

16:01 dudleyf: Wait, where did that come from?

16:02 Lau_of_DK: I got the idea/link from someone in here a few days ago

16:02 http://www.codinghorror.com/blog/archives/000275.html

16:03 dudleyf: I was looking for it in the github repo you posted earlier, but I didn't see that

16:03 Lau_of_DK: Oh, We've only just got Query working, now moving on to INSERT :)

16:03 But Query actually works almost perfectly now, which is sweet

16:04 dudleyf: Awesome

16:04 Lau_of_DK: (execute (sql (query [id name iq] developers.employees (or (and (> id 3) (< id 5)) (and (> id 8) (< id 10))))))

16:04 {:iq 100, :name Mark, :id 4}

16:04 {:iq 100, :name Arnold, :id 9}

16:05 Thats a pretty nested WHERE clauses, yet is compiled like it should

16:29 chrisn: found an awesome bomb in gllpanel

16:29 It destroys the gl context sometimes when resizing.

16:29 Meaning you have to reload all buffers; be they textures, glsl programs, etc.

16:31 Lau_of_DK: Any egg users here?

16:35 tyusupov: quit

17:48 nomothetis: Hi all. Can someone help me with setting up classpaths for some tests that I'm trying to write for my application?

17:49 Lau_of_DK: Shoot

17:49 nomothetis: ok.

17:49 So right now, I have a folder that contains the source file rumi-logic.clj.

17:50 I want to write tests using the fact.clj library.

17:50 Which i've put in ext/fact.clj

17:50 and I want to write tests for my functionality in test/rumi-logic-test.clj

17:50 I'm trying to run rumi-logic-test.clj from the REPL that I started in the ~ folder.

17:51 (~ being the root development folder, where rumi-logic.clj is)

17:51 I thought taht this:

17:51 (ns rumi-logic-test

17:51 (:require rumi-logic ext.fact))

17:51 would work.

17:52 But it tells me that it cannot locate rumi_logic_init.class or rumi_logic.lj.

17:52 (the code is in the rumi-logic-test.clj file).

17:52 I'm obviously completely misunderstanding how things work, so I was hoping someone would explain it to me.

17:52 Chousuke: nomothetis: the file must use underscores instead of dashes

17:52 file name that is

17:53 nomothetis: really? Interesting.

17:53 ok, let me try that.

17:53 Chousuke: so namespace foo.bar-zonk = foo/bar_zonk.clj

17:53 Lau_of_DK: if ~/ is in your classpath, then you can put test.clj in ~/src/nomo/rumi/test.clj, then you can require nomo.rumi.test), and test.clj but also start with (ns nomo.rumi.test)

17:53 If Im mistaken, The Chousuke can correct me

17:54 Chousuke: otherwise correct, but it must be ~/src/ in the namespace :)

17:54 er

17:54 classpath

17:54 nomothetis: @Lau_of_DK: Alright, i'm going to change the names, and then I'll try what you said. I'll let you guys know how it coes. Thanks.

17:55 Lau_of_DK: kthxbye

17:56 Chousuke: nomothetis: use the directory layout and naming here as an example: http://github.com/Chousuke/clojurebot

17:57 Lau_of_DK: Chousuke: Are you now maintaining the clojurebot, or have you just forked it?

17:57 For your own coding pleasure

17:58 Chousuke: well I made the github project of it, and hiredman forked it to make a github project for himself too :P

17:58 Lau_of_DK: oh :)

17:58 clojurebot: where are you ?

17:58 clojurebot: http://github.com/hiredman/clojurebot/tree/master

17:58 Lau_of_DK: aha

17:59 Chousuke: the clojurebot here is still "version 1" unless I'm mistaken

17:59 Lau_of_DK: clojurebot: version?

17:59 clojurebot: Gabh mo leithsc�al?

17:59 Lau_of_DK: clojurebot: rev?

17:59 clojurebot: Gabh mo leithsc�al?

17:59 Chousuke: which is just fine, as I haven't yet really improved it. just did some restructuring of the code

17:59 Lau_of_DK: ,(map println (range 10))

17:59 clojurebot: (nil nil nil nil nil nil nil nil nil nil)

18:00 Lau_of_DK: k

18:01 Chousuke: could probably make the svn stuff not depend on running the actual svn executable (instead make it work with a java library or something)

18:02 Lau_of_DK: ,(doseq [i (range 5)] (println i) (Thread/sleep 100))

18:02 clojurebot: 0 1 2 3 4

18:02 Lau_of_DK: Chousuke: When did SVN get tried into this ?

18:02 Chousuke: tried?

18:02 clojurebot: latest?

18:02 clojurebot: latest is 1185

18:02 Lau_of_DK: tied

18:02 Chousuke: svn rev 1185

18:03 Lau_of_DK: clojurebot actually runs the svn command

18:03 Lau_of_DK: oh ok

18:03 Chousuke: ... or at least, it should

18:03 looks like it's not working

18:03 clojurebot: svn rev 1185

18:03 clojurebot: hiredman.clojurebot$term__102@15f157b is http://clojure.googlecode.com/svn/trunk/

18:03 Chousuke: .. hm

18:03 that's... not right. :)

18:04 Lau_of_DK: you mean SVN in general or? .. :)

18:04 Chousuke: the weird java signature thingy :P

18:05 I still need to work on the dispatch stuff for my version though. it selects the first method that matches, so the order of lookup matters :/

18:06 Lau_of_DK: how will you work around it?

18:06 Chousuke: don't know yet

18:13 nomothetis: ok, I got it working. Thanks guys! I appreciate the help.

18:14 Lau_of_DK: :D

18:16 nomothetis: quick question: is there a way to find out, from the REPL, what the location the REPL was launched from was?

18:19 chrisn: (. (java.io.File. ",") getCanonicalPath)

18:21 Chousuke: ,?

18:21 nomothetis: cool, thanks.

18:22 Lau_of_DK: Try (System/getProperty "user.dir")

18:22 chrisn: ignore dk. Do what I said.

18:22 nomothetis: that works as well.

18:24 Lau_of_DK: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html

18:27 Chousuke: except using "." is evil

18:27 Lau_of_DK: Evil you say ?

18:28 Chousuke: yes, evil

18:28 .. is twice as evil

18:28 * Chousuke has strong opinions about things.

18:28 Lau_of_DK: oh, you're talking about chrisn attempt to produce code?

18:29 Chousuke: yes.

18:29 Lau_of_DK: Oh ok ... :D

18:30 chrisn: why is . evil?

18:30 Lau_of_DK: Its primarily because The Chousuke said so

18:31 Chousuke: mostly, yeah. but lisp forms are supposed to begin with an operator, and . is not a very informative operator.

18:31 it just says "java interop is going to happen"

18:32 Lau_of_DK: I second that critique

18:33 But chrisn, that important thing is that you tried, and I encourage you to keep going :)

18:33 Chousuke: yeah, well, you can keep on using .

18:34 I just like the .field syntax much more :)

18:35 chrisn: I wish (.field obj) would return something you could apply

18:36 I was wondering how to get a member function pointer, at it appears you have to use reflection

18:36 Lau_of_DK: (apply #(Class/function %) ...) ?

18:36 chrisn: does that work for instance functions?

18:37 Chousuke: there's (memfn method)

18:37 it still requires the object attribute though

18:37 but (partial (memfn method) obj) won't :)

18:38 chrisn: That is exactly what I wanted.

18:38 Chousuke: I think Rich might be considering making ".foo" things auto-memfn whenever it makes sense.

18:38 chrisn: no thanks to lau

18:38 :)

18:39 Chousuke: so you could map java methods "directly" instead of wrapping them in memfn

18:39 Lau_of_DK: man youre coming down hard on me tonight

18:39 Chousuke: but memfn isn't too much work for now

18:40 chrisn: http://gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example

18:40 I just got that working on clojure

18:40 in

18:40 Chousuke: hmm

18:40 Lau_of_DK: Post the code

18:40 chrisn: But the code looks like shit because the jogl gl interface is difficult to work with

18:41 dude.

18:41 Chousuke: opengl is probably not the best fit for a functional language either :)

18:41 Lau_of_DK: Alternative, modify the wiki page with your code, and remove the old

18:41 chrisn: http://github.com/cnuernber/lambinator/tree/master/src/lambinator

18:42 there is the code. I am trying to set up a good environment for trying out some different ideas I have about rendering

18:42 Probably nothing that actually does anything is a good fit for a functional language

18:43 Lau_of_DK: thanks

18:43 Chousuke: chrisn: hah

18:44 funcctional style actually works with many problems.

18:45 Lau_of_DK: chrisn: you're code compiles fine but dont run

18:45 chrisn: I can't believe it compiled.

18:45 Chousuke: a big problem with functional programmin is that it's very different from imperative style; you don't actually control the machine directly.

18:45 Lau_of_DK: java -jar lambinator.jar

18:45 Failed to load Main-Class manifest attribute from

18:45 lambinator.jar


18:45 chrisn: You have to just run from the repl

18:45 Lau_of_DK: which one of those ~100 files do you want me to run ?

18:45 Chousuke: or rather, that's not a problem with functional programming; it's a problem with programmers.

18:45 chrisn: get it loaded into the repl, ensure have have jogl

18:45 the jar file

18:46 check out the repl test file

18:46 Lau_of_DK: k

18:46 Chousuke: the bigger problem is that most existing code is not really compatible with a functional programming style

18:46 chrisn: it contains some halfway stuff.

18:46 That seems like an assumption, Chousuke.

18:47 Chousuke: well, it is.

18:47 but I'm fairly sure it's true enough

18:47 chrisn: lau: you have to create an app frame

18:47 (def fm (lambinator.ui/create_app_frame "lau is crazy"))

18:47 Get that far.

18:48 Lau_of_DK: chrisn: Sorry I have to get to bed, I'll check it out tomorrow

18:48 chrisn: Then go to the about box and check out your opengl extensions

18:48 lates.

18:48 Lau_of_DK: :|

18:48 chrisn: Lau is nonplussed.

18:48 I think the larger problems is all the bullshit people hear about functional programming

18:49 I have tried to evangelize it in various places.

18:49 Usually I get really strange responses.

18:50 Its time has come, however.

18:50 The largest problem with programming is how popular C-based languages are in general.

18:50 People all think about problems in only very certain ways.

18:50 Chousuke: well, yeah

18:51 languages grew up in an environment where software had to be fast and the only way to be fast was to control the hardware directly.

18:51 nowadays, that's no longer true.

18:52 but the damage is done

18:52 chrisn: It was never true as true as people thought it was unless you were on a commodore 64 or something like that. A complex system is never fast due to the language. If it is fast, it is due to good design.

18:53 no kidding

18:53 Chousuke: yeah, but they simply didn't have to tools to make functional languages go as fast as imperative, direct-control languages.

18:54 chrisn: only in very certain cases. LISP has had types and binary compilation forever.

18:54 although it isn't functional, I guess.

18:54 Chousuke: I guess that wasn't early enough :/

18:54 chrisn: heh

18:55 Chousuke: the growing number of multicore systems might help functional programming style gain more followers though

19:36 chrisn: Is there a function that returns both the passing and failures of a filter function?

19:36 In two separate seqs?

19:36 gnuvince: chrisn: there's something in clojure-contrib

19:36 chrisn: I have that

19:36 ?

19:36 name?

19:36 gnuvince: hang on

19:36 looking for the name

19:36 separate

19:37 (doc separate)

19:37 clojurebot: I don't understand.

19:38 chrisn: heh

19:38 thanks

19:38 gnuvince: happy to help

19:48 hmmm

19:48 weird...

19:48 I can't use it...

19:52 nomothetis: Is anyone familiar with the Fact unit testing library?

19:52 gnuvince: How come i don't see anything with (ns-publics 'clojure.contrib.seq-utils)

19:52 ?

20:09 mib_4tvgjgnr: hello?

20:13 gnuvince: mib_4tvgjgnr: hi

20:14 danlarkin: mib_4tvgjgnr: greetings!

20:15 mib_4tvgjgnr: mmm it's my first time on the clojure room

20:15 is it usually pretty lively?

20:35 danlarkin: people always leave before I can answer them :-/

20:57 kabny: Im reading the wikipedia article on monte carlo methods(implemented the pi-approximation algorithm before) http://en.wikipedia.org/wiki/Monte_Carlo_method. but what Im not sure of is if it makes any sense to generalize the algorithm. ie is it possible to abstract out most of it or do I kind of have to rewrite everything for each different monte carlo simulation I want to do?

20:58 also, which is the best java lib for doing simple 2d graphics(still and moving)? like pythons pygame... is it swing or that is just GUIs?

21:00 chrisn: If you use swing then you can use openGL later if you want more pizzaz

21:04 kabny: but opengl seems so complicated to just the simpel stuff even

21:04 chrisn: it is

21:04 the key word was later

21:05 swing has a 2d rendering library

21:05 You don't have to use widgets.

21:06 create a jpanel with nothing in it and overload the paint method with something you care about

Logging service provided by n01se.net