#clojure logs

2008-12-26

00:30lisppaste8holmak pasted "Math/sqrt failure" at http://paste.lisp.org/display/72665
00:30holmakClojure won't let me use Math/sqrt from the Java library - any idea why that would happen?
00:31holmakIt 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.
00:31holmakI have the latest version of Clojure, 1162.
03:03yangsxI've come across this strange error java.lang.IncompatibleClassChangeError after defining a function and evaulating it at slime-repl
03:04hiredmanwhat function
03:05hiredmanlisppaste8: url
03:05lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
03:05yangsxIs it a bug with my function or the compiler?
03:05hiredmanbug your function
03:06hiredmanit manes you tried to use something as something it cannot be
03:06hiredmanmeans
03:14yangsxhiredman: thanks, I'll review my code once more.
03:16hiredman,(name *ns*)
03:16clojurebotjava.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0)
03:42yangsxhiredman: my error was due to use disj as dissoc by mistake
03:43yangsxbtw, is there a Clojure counterpart of CL's subseq?
03:46hoeckyangsx: there is subvec for vectors
03:48hoeckyangsx: and subseq :)
03:51yangsxhoeck: my data structures happen to be a vector, thanks. I was looking for samething general for seq in vain.
04:12Lau_of_DKGood morning all
04:15hoeckgood morning Lau_of_DK
04:55Lau_of_DKSince assoc doesnt work, how do I change a key/val pair in a PersistantArrayMap ?
05:10hoeckLau_of_DK: not shure what you mean, assoc works on PersistantArrayMap too
10:46hiredmanclojurebot: ping
10:46clojurebotPONG!
12:16chrisnhello?
12:19hiredmanclojurebot: java?
12:19clojurebothmm... sounds like your out of heap space
12:20hiredmanclojurebot: java is <reply>?
12:20clojurebotRoger.
12:37danlarkinclojurebot: java
12:37clojurebot?
12:37wwmorganDoes 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:08Lau_of_DKSlow night... anyone working on anything interesting? :)
14:10Kerris7 Lau_of_DK: I'm planning to port Lisp in Small Pieces to Clojure
14:10Lau_of_DKHow do you mean ?
14:10Kerris7I just want universities to start teaching Lisp again :(
14:10Lau_of_DKBut you do realise that Clojure is a Lisp right? :)
14:11Kerris7Yeah, it's mostly a syntax thing
14:11Kerris7I daresay Clojure is the most accessible Lisp at the moment
14:11Lau_of_DKk, got a public repo somewhere?
14:11Kerris7therefore* it would be a boon to have educational material using Clojure syntax
14:12Kerris7*just had dinner, can't really think straight
14:13Kerris7Lau_of_DK: would something like Stuart Holloway's Practical Lisp port do?
14:13Lau_of_DKIn terms of providing teaching-material?
14:14Kerris7yeah, also in terms of public repo, i.e. using github
14:15Lau_of_DKoh... In terms of the material I dont know, havent read the book, but Github is :)~
14:27chrisndon't mix opengl and lazy evaluation
14:28chrisnnext thing you know you get a hardcore crash because the opengl calls get evaluated in a thread with no active context
14:30chrisnI have a couple buddies working through "the structure and interpretation of computer programs" http://mitpress.mit.edu/sicp/full-text/book/book.html
14:31chrisnThey are doing it in scheme, I think. If we had that, we wouldn't need much else.
14:35Lau_of_DKchrisn: You said OpenGL and SICP in the same sentense ?
14:35chrisnnope
14:35chrisnfirst two comments were exasperation
14:35chrisnsecond two were chiming in
14:35chrisnsry
14:41Lau_of_DKclojurebot: SICP?
14:41clojurebotPardon?
14:41Lau_of_DKchrisn: I think I remember seeing an whole site with conversions from Scheme/SICP to Clojure
14:42Kerris7Lau_of_DK: http://codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages ?
14:42chrisnhah
14:42chrisnyep
14:45Lau_of_DKThat looks like it... though they ported it to C++ I see... they really must have missed the point of that lecture
14:45Kerris7I'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:46Lau_of_DKIm looking forward to seeing what you come up with
14:47chrisnC++ involved a lot of extremely smart people who were amazingly adept at missing the point.
14:48chrisnSo did Java.
14:48Lau_of_DKhehe, looks like that happend to Ruby as well
14:58aperottehello all
15:06Lau_of_DKHi aperotte
15:08aperotteseems like things are a little slow on the channel today
15:11Lau_of_DKVery, almost unbearable :)
15:11aperottehahaha
15:12aperottehave you been working on a clojure project?
15:14Lau_of_DKyea
15:21aperottewhat kind of project is it ... if you don't mind me asking
15:25aperotteLau_of_DK: I'll be back in a few
15:32Lau_of_DKaperotte: Me and kotarak have been hacking away at ClojureQL, an attempt at turning SQL statements into higher order functions
15:33Lau_of_DKdk.bestinclass.clojureql> (execute (sql (query [id name language iq]
15:33Lau_of_DK developers.employees
15:33Lau_of_DK (< iq 100))))
15:33Lau_of_DK{:iq 85, :language Python, :name Frank, :id 1}
15:33Lau_of_DK
15:34aperotteLau_of_DK: haha ... very nice
15:34aperotteLau_of_DK: I haven't used SQL much or done much web programming at all, but sounds cool
15:35Lau_of_DKyea it'll be nice when its done
15:36aperottehave you looked at compojure at all?
15:37Lau_of_DKOf course
15:40Lau_of_DKDid you think that the two are related aperotte ?
15:41dudleyfLau_of_DK: Is the source up anywhere?
15:41aperottenot really, I've been keeping an eye on compojure
15:41aperotteI'd like to try my hand at web programming once there's more documentation
15:41Lau_of_DKdudleyf: http://github.com/Lau-of-DK/clojureql/tree/master
15:41ChousukeLau_of_DK: do you have any plans regarding input sanitisation with clojureql
15:42dudleyfLau_of_DK: Thanks
15:42aperotteI hadn't seen any mention of clojureQL on their site, so I didn't think it
15:42Lau_of_DKaperotte: In this game, I wouldnt wait for the docs :)
15:42Lau_of_DKBut Compojure is cool, so you can dig into it
15:42Lau_of_DKClojureQL is not web-related, its only for databases, so that
15:42Lau_of_DKSELECT id,name FROM database1 WHERE id = 5
15:42Lau_of_DKbecomes
15:43Lau_of_DK(sql (query [id name] database1 (= id 5)))
15:43Lau_of_DKChousuke: In which way to you mean sanitisation ?
15:44Chousukelike, if you wanted that 5 to depend on user input somehow
15:44chrisnhow do I type my variables in clojure again?
15:45chrisnI think I am running into some lag doing generic lookups on an interface where I know the type
15:45ChousukeI guess you could use clojureql to generate SQL with placeholders
15:45Lau_of_DKChousuke: We're implementing it with unquote, so that you could do (let [x 5] (sql (query id table1 (= id ~x))))
15:45ChousukeLau_of_DK: yes but that's dangerous
15:45Lau_of_DKWhat do you fear ?
15:45Chousukex being something like bobby tables' name :P
15:46Lau_of_DKhaha
15:46Lau_of_DKBut 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:47dudleyfLau_of_DK: Since databases have mechanisms for avoiding injection like that,
15:48dudleyfif you're implementing a database library, it is your concern, I think
15:48ChousukeI mean constructs like INSERT INTO foo VALUES (?,?,?,?) and then using some programming language function to execute that query with supplied values
15:49chrisn (for [#^float i (range -50 50) #^float j (range -50 50)]
15:49chrisnSomething like that?
15:50dudleyfI guess it depends on whether your library is a database interface or just a sql string generation library
15:50dudleyfBut I imagine that line gets pretty blurry
15:50Lau_of_DKdudleyf: We're sending everything through with JDBC, if that makes a difference
15:51Lau_of_DKChousuke: 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:51dudleyfLau_of_DK: Then I would think you'd want to allow for PreparedStatements and such
15:52ChousukeLau_of_DK: but what kind of sql does that generate?
15:52Lau_of_DKI mean, even JDBC will let you destroy your DB if you want, I really dont see why I should police that
15:52Lau_of_DKThat 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:52ChousukeLau_of_DK: if it generates INSERT INTO foo values (x, y, z) then it's dangerous unles x, y and z are all "?"
15:53Lau_of_DKdudleyf: Everything gets fitted into a preparedstatement
15:53Lau_of_DKWhy dangerous? they're all seperately stored when you unquote them
15:53Chousukeseparately stored?
15:53Chousukethey're dangerous becuase they become part of the SQL string
15:54Chousukeuser-supplied values should never be part of the SQL string. That's why placeholders exist.
15:54Lau_of_DKI think we end up paramterizing (?) them, so that in the SQL string theyre @x @y @z
15:54Lau_of_DKAnd then we add them to a prepared statement
15:54Chousukeah, that sounds like it's safe.
15:57Chousukeso 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:58Lau_of_DKYes
15:59Lau_of_DKI can dig it up for you if you want, one sedc
15:59Chousukesounds good
15:59Lau_of_DKSqlConnection conn = new SqlConnection(_connectionString);
15:59Lau_of_DKconn.Open();
15:59Lau_of_DKstring s = "SELECT email, passwd, login_id, full_name " +
15:59Lau_of_DK "FROM members WHERE email = @email";
15:59Lau_of_DKSqlCommand cmd = new SqlCommand(s);
15:59Lau_of_DKcmd.Parameters.Add("@email", email);
15:59Lau_of_DKSqlDataReader reader = cmd.ExecuteReader();
15:59Lau_of_DK
15:59Chousukeright.
15:59Lau_of_DKCan I stamp it "Approved by the Chousuke" ? :)
16:00Chousukeyes.
16:00Lau_of_DKSweet
16:00Chousukeseriously though, that looks really cool :)
16:01dudleyfWait, where did that come from?
16:02Lau_of_DKI got the idea/link from someone in here a few days ago
16:02Lau_of_DKhttp://www.codinghorror.com/blog/archives/000275.html
16:03dudleyfI was looking for it in the github repo you posted earlier, but I didn't see that
16:03Lau_of_DKOh, We've only just got Query working, now moving on to INSERT :)
16:03Lau_of_DKBut Query actually works almost perfectly now, which is sweet
16:04dudleyfAwesome
16:04Lau_of_DK(execute (sql (query [id name iq] developers.employees (or (and (> id 3) (< id 5)) (and (> id 8) (< id 10))))))
16:04Lau_of_DK{:iq 100, :name Mark, :id 4}
16:04Lau_of_DK{:iq 100, :name Arnold, :id 9}
16:05Lau_of_DKThats a pretty nested WHERE clauses, yet is compiled like it should
16:29chrisnfound an awesome bomb in gllpanel
16:29chrisnIt destroys the gl context sometimes when resizing.
16:29chrisnMeaning you have to reload all buffers; be they textures, glsl programs, etc.
16:31Lau_of_DKAny egg users here?
16:35tyusupovquit
17:48nomothetisHi all. Can someone help me with setting up classpaths for some tests that I'm trying to write for my application?
17:49Lau_of_DKShoot
17:49nomothetisok.
17:49nomothetisSo right now, I have a folder that contains the source file rumi-logic.clj.
17:50nomothetisI want to write tests using the fact.clj library.
17:50nomothetisWhich i've put in ext/fact.clj
17:50nomothetisand I want to write tests for my functionality in test/rumi-logic-test.clj
17:50nomothetisI'm trying to run rumi-logic-test.clj from the REPL that I started in the ~ folder.
17:51nomothetis(~ being the root development folder, where rumi-logic.clj is)
17:51nomothetisI thought taht this:
17:51nomothetis(ns rumi-logic-test
17:51nomothetis (:require rumi-logic ext.fact))
17:51nomothetiswould work.
17:52nomothetisBut it tells me that it cannot locate rumi_logic_init.class or rumi_logic.lj.
17:52nomothetis(the code is in the rumi-logic-test.clj file).
17:52nomothetisI'm obviously completely misunderstanding how things work, so I was hoping someone would explain it to me.
17:52Chousukenomothetis: the file must use underscores instead of dashes
17:52Chousukefile name that is
17:53nomothetisreally? Interesting.
17:53nomothetisok, let me try that.
17:53Chousukeso namespace foo.bar-zonk = foo/bar_zonk.clj
17:53Lau_of_DKif ~/ 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:53Lau_of_DKIf Im mistaken, The Chousuke can correct me
17:54Chousukeotherwise correct, but it must be ~/src/ in the namespace :)
17:54Chousukeer
17:54Chousukeclasspath
17:54nomothetis@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:55Lau_of_DKkthxbye
17:56Chousukenomothetis: use the directory layout and naming here as an example: http://github.com/Chousuke/clojurebot
17:57Lau_of_DKChousuke: Are you now maintaining the clojurebot, or have you just forked it?
17:57Lau_of_DKFor your own coding pleasure
17:58Chousukewell I made the github project of it, and hiredman forked it to make a github project for himself too :P
17:58Lau_of_DKoh :)
17:58Lau_of_DKclojurebot: where are you ?
17:58clojurebothttp://github.com/hiredman/clojurebot/tree/master
17:58Lau_of_DKaha
17:59Chousukethe clojurebot here is still "version 1" unless I'm mistaken
17:59Lau_of_DKclojurebot: version?
17:59clojurebotGabh mo leithsc�al?
17:59Lau_of_DKclojurebot: rev?
17:59clojurebotGabh mo leithsc�al?
17:59Chousukewhich is just fine, as I haven't yet really improved it. just did some restructuring of the code
17:59Lau_of_DK,(map println (range 10))
17:59clojurebot(nil nil nil nil nil nil nil nil nil nil)
18:00Lau_of_DKk
18:01Chousukecould probably make the svn stuff not depend on running the actual svn executable (instead make it work with a java library or something)
18:02Lau_of_DK,(doseq [i (range 5)] (println i) (Thread/sleep 100))
18:02clojurebot0 1 2 3 4
18:02Lau_of_DKChousuke: When did SVN get tried into this ?
18:02Chousuketried?
18:02Chousukeclojurebot: latest?
18:02clojurebotlatest is 1185
18:02Lau_of_DKtied
18:02Chousukesvn rev 1185
18:03ChousukeLau_of_DK: clojurebot actually runs the svn command
18:03Lau_of_DKoh ok
18:03Chousuke... or at least, it should
18:03Chousukelooks like it's not working
18:03Chousukeclojurebot: svn rev 1185
18:03clojurebothiredman.clojurebot$term__102@15f157b is http://clojure.googlecode.com/svn/trunk/
18:03Chousuke.. hm
18:03Chousukethat's... not right. :)
18:04Lau_of_DKyou mean SVN in general or? .. :)
18:04Chousukethe weird java signature thingy :P
18:05ChousukeI 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:06Lau_of_DKhow will you work around it?
18:06Chousukedon't know yet
18:13nomothetisok, I got it working. Thanks guys! I appreciate the help.
18:14Lau_of_DK:D
18:16nomothetisquick question: is there a way to find out, from the REPL, what the location the REPL was launched from was?
18:19chrisn(. (java.io.File. ",") getCanonicalPath)
18:21Chousuke,?
18:21nomothetiscool, thanks.
18:22Lau_of_DKTry (System/getProperty "user.dir")
18:22chrisnignore dk. Do what I said.
18:22nomothetisthat works as well.
18:24Lau_of_DKhttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
18:27Chousukeexcept using "." is evil
18:27Lau_of_DKEvil you say ?
18:28Chousukeyes, evil
18:28Chousuke.. is twice as evil
18:28Lau_of_DKoh, you're talking about chrisn attempt to produce code?
18:29Chousukeyes.
18:29Lau_of_DKOh ok ... :D
18:30chrisnwhy is . evil?
18:30Lau_of_DKIts primarily because The Chousuke said so
18:31Chousukemostly, yeah. but lisp forms are supposed to begin with an operator, and . is not a very informative operator.
18:31Chousukeit just says "java interop is going to happen"
18:32Lau_of_DKI second that critique
18:33Lau_of_DKBut chrisn, that important thing is that you tried, and I encourage you to keep going :)
18:33Chousukeyeah, well, you can keep on using .
18:34ChousukeI just like the .field syntax much more :)
18:35chrisnI wish (.field obj) would return something you could apply
18:36chrisnI was wondering how to get a member function pointer, at it appears you have to use reflection
18:36Lau_of_DK(apply #(Class/function %) ...) ?
18:36chrisndoes that work for instance functions?
18:37Chousukethere's (memfn method)
18:37Chousukeit still requires the object attribute though
18:37Chousukebut (partial (memfn method) obj) won't :)
18:38chrisnThat is exactly what I wanted.
18:38ChousukeI think Rich might be considering making ".foo" things auto-memfn whenever it makes sense.
18:38chrisnno thanks to lau
18:38chrisn:)
18:39Chousukeso you could map java methods "directly" instead of wrapping them in memfn
18:39Lau_of_DKman youre coming down hard on me tonight
18:39Chousukebut memfn isn't too much work for now
18:40chrisnhttp://gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example
18:40chrisnI just got that working on clojure
18:40chrisnin
18:40Chousukehmm
18:40Lau_of_DKPost the code
18:40chrisnBut the code looks like shit because the jogl gl interface is difficult to work with
18:41chrisndude.
18:41Chousukeopengl is probably not the best fit for a functional language either :)
18:41Lau_of_DKAlternative, modify the wiki page with your code, and remove the old
18:41chrisnhttp://github.com/cnuernber/lambinator/tree/master/src/lambinator
18:42chrisnthere is the code. I am trying to set up a good environment for trying out some different ideas I have about rendering
18:42chrisnProbably nothing that actually does anything is a good fit for a functional language
18:43Lau_of_DKthanks
18:43Chousukechrisn: hah
18:44Chousukefuncctional style actually works with many problems.
18:45Lau_of_DKchrisn: you're code compiles fine but dont run
18:45chrisnI can't believe it compiled.
18:45Chousukea big problem with functional programmin is that it's very different from imperative style; you don't actually control the machine directly.
18:45Lau_of_DK java -jar lambinator.jar
18:45Lau_of_DKFailed to load Main-Class manifest attribute from
18:45Lau_of_DKlambinator.jar
18:45Lau_of_DK
18:45chrisnYou have to just run from the repl
18:45Lau_of_DKwhich one of those ~100 files do you want me to run ?
18:45Chousukeor rather, that's not a problem with functional programming; it's a problem with programmers.
18:45chrisnget it loaded into the repl, ensure have have jogl
18:45chrisnthe jar file
18:46chrisncheck out the repl test file
18:46Lau_of_DKk
18:46Chousukethe bigger problem is that most existing code is not really compatible with a functional programming style
18:46chrisnit contains some halfway stuff.
18:46chrisnThat seems like an assumption, Chousuke.
18:47Chousukewell, it is.
18:47Chousukebut I'm fairly sure it's true enough
18:47chrisnlau: you have to create an app frame
18:47chrisn(def fm (lambinator.ui/create_app_frame "lau is crazy"))
18:47chrisnGet that far.
18:48Lau_of_DKchrisn: Sorry I have to get to bed, I'll check it out tomorrow
18:48chrisnThen go to the about box and check out your opengl extensions
18:48chrisnlates.
18:48Lau_of_DK:|
18:48chrisnLau is nonplussed.
18:48chrisnI think the larger problems is all the bullshit people hear about functional programming
18:49chrisnI have tried to evangelize it in various places.
18:49chrisnUsually I get really strange responses.
18:50chrisnIts time has come, however.
18:50chrisnThe largest problem with programming is how popular C-based languages are in general.
18:50chrisnPeople all think about problems in only very certain ways.
18:50Chousukewell, yeah
18:51Chousukelanguages 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:51Chousukenowadays, that's no longer true.
18:52Chousukebut the damage is done
18:52chrisnIt 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:53chrisnno kidding
18:53Chousukeyeah, but they simply didn't have to tools to make functional languages go as fast as imperative, direct-control languages.
18:54chrisnonly in very certain cases. LISP has had types and binary compilation forever.
18:54chrisnalthough it isn't functional, I guess.
18:54ChousukeI guess that wasn't early enough :/
18:54chrisnheh
18:55Chousukethe growing number of multicore systems might help functional programming style gain more followers though
19:36chrisnIs there a function that returns both the passing and failures of a filter function?
19:36chrisnIn two separate seqs?
19:36gnuvincechrisn: there's something in clojure-contrib
19:36chrisnI have that
19:36chrisn?
19:36chrisnname?
19:36gnuvincehang on
19:36gnuvincelooking for the name
19:36gnuvinceseparate
19:37gnuvince(doc separate)
19:37clojurebotI don't understand.
19:38chrisnheh
19:38chrisnthanks
19:38gnuvincehappy to help
19:48gnuvincehmmm
19:48gnuvinceweird...
19:48gnuvinceI can't use it...
19:52nomothetisIs anyone familiar with the Fact unit testing library?
19:52gnuvinceHow come i don't see anything with (ns-publics 'clojure.contrib.seq-utils)
19:52gnuvince?
20:09mib_4tvgjgnrhello?
20:13gnuvincemib_4tvgjgnr: hi
20:14danlarkinmib_4tvgjgnr: greetings!
20:15mib_4tvgjgnrmmm it's my first time on the clojure room
20:15mib_4tvgjgnris it usually pretty lively?
20:35danlarkinpeople always leave before I can answer them :-/
20:57kabnyIm 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:58kabnyalso, 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:00chrisnIf you use swing then you can use openGL later if you want more pizzaz
21:04kabnybut opengl seems so complicated to just the simpel stuff even
21:04chrisnit is
21:04chrisnthe key word was later
21:05chrisnswing has a 2d rendering library
21:05chrisnYou don't have to use widgets.
21:06chrisncreate a jpanel with nothing in it and overload the paint method with something you care about