#clojure logs

2008-12-21

00:06jawolfeI've gotta run, never mind ... I'll post in the newsgroup instead. thanks!
00:10hiredman(doc concat)
00:10hiredmandamn it
00:11jawolfeHrm, i suppose apply is evaluating the arguments (duh).
00:12hiredmanthere is clojure.core/concat and clojure.core/lazy-cat both are lazy
00:12jawolfehiredman: thanks
00:12jawolfehiredman: i have looked at both
00:12dhayajawolfe: Looks like concat is lazy except for the first 3 colls, try (take 1 (apply concat (map (fn [x] (prn x) (list x)) (range 1 20))))
00:13jawolfedhaya: that's what it looks like to me too
00:13jawolfefor my application, I need something that is lazy for all (but the first, perhaps)
00:14jawolfei.e. a fn that takes a lazy seq of seqs
00:15jawolfeand only forces each inner seq when its first element is needed
00:18lisppaste8jawolfe annotated #72461 with "solution?" at http://paste.lisp.org/display/72461#1
00:19jawolfeThanks, gotta run
03:32poiuythow can I conj or cons just a parenthesis?
03:33hiredmanexample?
03:33poiuytiwant (conj [+ 2 3] ( )
03:33poiuyt-> [+ 2 3 (]
03:34hiredmanyou want the paren character
03:34poiuytys
03:34hiredmancharacter literals in clojure are characters proceeded by \
03:34hiredman\(
03:34hiredman\)
03:38poiuytok
03:38poiuytbut i cant eval (clojure._PLUS___221@e5ace9 2 3 \( clojure.___247@5ed853 12 3 \))
03:39hiredmanuh
03:39hiredmanheh
03:40hiredmanno
03:40karmazillahe want's to conj a list of things
03:40hiredman(eval `(+ 1 3))
03:40hiredmankarmazilla: want he wants is different then what he wants to do
03:41hiredmanpoiuyt: eval takes a list of things, a data structure
03:41hiredman(eval (seq [+ 1 3]))
03:51hiredmanso weird that clojurebot is still here
03:51hiredmanthe server it runs on has been down for hours
03:52poiuytlol
03:52poiuythe has come alive
03:52poiuytkurzweils predictions has been preceeded by reality
03:52poiuytclojurebot
04:05poiuytif i have a vector of arbitrarily nested vectors, what is the best way to visit them all?
04:05poiuytloop recur and call the function again for each subvector?
04:05poiuytis there such a function already?
04:07hiredmanmaybe in contrib?
04:08poiuytwhat is the best html-parsing lib available in clojure?
04:17hoeckpoiuyt: http://sourceforge.net/projects/nekohtml worked for me
04:34poiuythow can i ask (operator? x)
04:34poiuytor the common name for +-/*
04:38poiuytcan I doc multimethods?
04:42Lau_of_DKpoiuyt: I dont know of any built in method for testing for operators, but this works
04:42Lau_of_DK(= '* (or '* '/ '+ '-))
04:49meredyddheya
04:49meredyddHow do you get a backtrace off a REPL exception these days, without wrapping the whole line in (try (catch...))
04:49meredydd?
04:51leafw*e
04:51leafwor (.printStackTrace *e)
04:51leafwor (.printStackTrace (.getCause *e))
04:51meredyddJoy. Okay, I'll make a macro.
04:52leafwmeredydd: all 3 are different levels of detail on the Exception, notice.
04:52meredyddI'm aware.
05:01traskois it possible to define my own exceptions and then print the line number hwere it happened?
05:03leafwtrasko: yes, you can define your own exceptions. And they will automatically show where they were thrown.
05:04leafwsee (doc throw)
10:03klinkershow do i call a method like
10:03klinkersConnection con = DriverManager.getConnection
10:03klinkers ("jdbc:derby:eltesto1;create=true", "flonk", "plonk");
10:03klinkerslet [conn (new DriverManager.getConnection...?
10:05leafwklinkers: use namespace syntax, since it's static
10:06leafw(def con (DriverManager/getConnection "jdbc:derby:eltesto1;create=true" "flonk" "plonk"))
10:06klinkersah
10:42klinkershow dio im import java.sql.*; ?
10:42klinkers(import '(java.sql *)) doesnt work
10:42kotarakklinkers: you can't import everything.
10:44klinkershow do i append 2 strings?
10:44klinkers(+ "hello" " there")?
10:45kotarak(str "Hello" " " "there")
10:53klinkershow do I break a line?
11:10kotarakklinkers: ?? In the output? (newline)
11:52Lau_of_DKrhickey: Regarding the new initiatives like the wiki and such, would you consider tracking clojure on http://www.pivotaltracker.com/ ?
14:36Lau_of_DKrhickey_: I didnt check my log before I shut down emacs, but did you get a chance to look at pivot tracker?
15:02Lau_of_DKBoys, can I provide doc strings for multimethods in some clever way ?
15:02kotarakOnly we (defmulti #^{:doc "bla"} foo ...)
15:05Lau_of_DKThanks Mr. Brandmeyer
15:07Lau_of_DKHmm, that doesnt connec with (doc foo)
15:17lisppaste8drewr pasted "agent queue" at http://paste.lisp.org/display/72487
15:18drewrI've created a queueing mechanism for incoming and outbound messages over a socket.
15:19drewrThe first time a couple of these gets created, everything works fine. Agents are dispatched, actions are called, stuff is logged.
15:19drewrThe next time around, perhaps when a SocketException is caught, make-queue will get called again.
15:19drewrThe agent is created and returned.
15:19drewrHowever, the action does not seem to be called (i.e., nothing is logged at least).
15:21drewrIs there anything obvious that I'm missing?
15:23mehrheitmaybe it's blocking indefinitely?
15:24drewrWhat would cause it to block so as not to run f?
15:25drewrSpecifically, the log on line 14 *is* printed, but the one on line 4 is not.
15:26mehrheitright, I missed that one
15:26drewrI even tried a throw in there to make sure there wasn't an I/O issue with stdout on subsequent calls.
15:27mehrheitdoes sending other functions to the returned agent work?
15:30drewrmehrheit: I'm not sure I understand.
15:30drewrTo the agent after it's created?
15:31drewrThe only way I interact with the agent is (.put (:q @a) "msg...").
15:51chrisnhello?
15:52replacachrisn: good afternoon
15:52kotaraksalut?
15:56mehrheitdrewr: yes, after creation
15:57drewrmehrheit: I found out that the action runs later after I close the connection, so there is definitely something blocking the agent from running dispatchAction().
16:00drewrI wonder if LockingTransaction.getRunning() is blocking since this agent gets spawned from another agent.
16:03rhickeydrewr: how do you know it's not blocked in take?
16:04rhickeydrewr: I don't see how transactions come into it, but getRunning() doesn't block in any case
16:05drewrrhickey: I suppose it could be, but why wouldn't it print the log message? I'm flushing *out* in my log fn.
16:06rhickeydrewr: you saw "queue stopped" from prior action?
16:06drewrYes.
16:07rhickeydrewr: no agent errors?
16:07drewrconn is essentially a map like {:sock ... :inq (make-queue ...) :outq (make-queue ...) listener: (listen ...returns an agent too...}
16:08drewrThe listen agent catches the SocketException and eventually calls (connect) which creates another conn, with new :inq and :outq.
16:08drewrIt's these new queues that get blocking behavior I don't see the first time.
16:12drewrActually, the log I'm looking at is to a file, but each line is written with (with-open) so it should be flushing on each close.
16:13rhickeydrewr: "should be" famous last words :)
16:13drewrHeh, true.
16:14rhickeyagents don't use locks/blocking, so I'd look carefully at the use of blocking queues
16:16drewrAnd you don't see any inherent danger in agents calling other agents ad infinitum?
16:16chrisnAm am building a rendering system. I know Rich *hates* mock objects, but I need to make a mock jogl opengl interface. This requires managing some minimal state (textures allocated as well as FBOs allocated for now). I could do this using atoms behind the scene to handle the state. Is this a valid way to go?
16:17rhickeydrewr: no, the whole point is that, because they can't wait on each other, they can't deadlock
16:17kbarrosbesides performance, is there a semantic difference between "3" and "(int 3)"?
16:17drewrrhickey: OK, that's what I figured.
16:19kbarrosit looks like operations on int's promote them to more general numeric values
16:19rhickeykbarros: yes, if you say (let [x (int 3)] ...) then arithmetic involving x and other ints will be 32-bit primitive math
16:19Chousukerhickey: I sent a CA to you on friday. Hopefully it'll arrive safely.
16:20rhickeyuser=> (* 1000000 1000000)
16:20rhickey1000000000000
16:20rhickeyuser=> (* (int 1000000) (int 1000000))
16:20rhickeyjava.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
16:20drewrrhickey: If I look at the LinkedBlockingQueue, it's filled with stuff from the socket's input stream. It seems to indeed be that the agent's action isn't running to start .take-ing.
16:23kbarrosuser=> (def a (int 1000000))
16:23kbarrosuser> (* a a)
16:23kbarrosdoes not overflow
16:25rhickeykbarros: the types have to be accessible to the compiler - there's no type on a, so generic arithmetic
16:25rhickeyprimitives are limited to let locals and args
16:26rhickeydrewr: you need to make sure the queue you are looking at is the one the agent is
16:27kbarrosok, thanks. when using literal numbers could the compiler, as an optimization, generate primitive operations? i.e., could it fall back to generic arithmetic when necessary?
16:30drewrrhickey: I'm (fairly) sure of it. All the messages flush out after I "stop" the queues.
16:30rhickeykbarros: that's kind of what the generic math is, also there is an interaction with boxing, which dominates over the dispatch. A local with a primitive type is unboxed, a literal is boxed
16:31drewrI just don't understand why the ones for the first connection act "normally" and then subsequent ones block.
16:31drewrThey're different agents, actions, and states.
16:31drewrEach call to make-queue creates a different BlockingQueue.
16:34rhickeydrewr: you sure you're not being fooled by the logging not flushing?
16:37drewrYes, because the logging acts like I expect with a fresh connection -- (read-line) returns line, .puts it into queue, agent .takes it, dispatches on it, logs it, etc.
16:38drewrBesides, I put a (throw) in the action just to make sure it wasn't a buffering issue, and the agent didn't report any errors.
16:42rhickeydrewr: can you make an isolated reproducing test case?
16:42drewrI'm thinking of how I can do that. :-)
16:42chrisnwhy are there specific setters for arrays of different types, but not different getters?
16:55klinkershmm lets say you have a bunch of functions that operate on some structure. lets say they all take 4 params. now for all these functions the 1st param will always be the same. can i somehow write a macro that changes function-definitions? hmm does this make any sense?
16:55kbarrosI get a "class cast exception" for the following expression: (double 1e500) . Is this the appropriate compiler error? It confused my emacs mode.
17:03RSchulzkbarros: I think it might be a bug. Witness:
17:03RSchulz(double 1e500)
17:03RSchulzjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number
17:03RSchulzuser=> 1e500
17:03RSchulzInfinity
17:04RSchulzuser=> (class 1e500)
17:04RSchulzclojure.lang.Symbol
17:04RSchulzI think that's the problem. You get a symbol when you give a floating (or double) numeric literal that is out-of-range for a double.
17:09RSchulzPerhaps it's deliberate to ensure that no computation takes place using an unrepresentable number.
17:09RSchulzIt could be argued that it should be converted to one of the arbitrary-precision formats.
17:14gnuvince_RSchulz: by the way, did you start a blog? I saw you asked about blogging services on the mailing list.
17:15kbarrosrschulz: thanks
17:15RSchulzgnuvince_: Not yet. I think it might have been a passing fancy.
17:16kbarrosi was expecting (double 1e500) to be the double representation of infinity
17:16gnuvince_That's too bad, you seem to have very good knowledge, it would've been a nice boost to the community.
17:23Lau_of_DKIn a try/catch, how do I print the exception trapped?
17:25Lau_of_DKNevermind, I got it
17:28RSchulzgnuvince_: I haven't definitely decided not to. I'm just worried about being able to sustain a blog long enough for it to be meaningful.
17:29drewrrhickey: FYI, I switched that .take to a .poll (which shouldn't block), and get the same behavior.
17:29klinkersif i make a new namespace, cant i def taken names there?
17:29RSchulzPart of my problem (psychologically...) is that as soon as I've accomplished something, it no longer seems special to me and hence no longer worth writing about.
17:30gnuvince_RSchulz: you're not alone ;)
17:30drewrIs there any reason why an agent won't fire an action ASAP after instantiation?
17:37rhickeydrewr: agent sends don't dispatch until agent action returns
17:38rhickeysee #5 here: http://clojure.org/agents
17:39drewrFrom what I'm seeing, #1 is what is postponed.
18:16replacahow do I add stuff from a jar in the classpath to the repl? I've been trying stuff like (load "/clojure/contrib/lazy-xml") but this doesn't seem to get it.
18:16replaca(Up til now, I'd just been going straight from Slime)
18:17dreishadd-classpath
18:17rhickeyreplaca: the stuff is a lib?
18:17rhickey(load 'clojure.contrib.lazy-xml)
18:18replacayeah, in a jar. The jar is already on my classpath
18:18rhickeyload takes the name of the lib as above
18:18Chouserload takes a string, doesn't it?
18:19rhickeybut you really want require don't you?
18:19Chouser(require 'clojure.contrib.lazy-xml) or (use 'clojure.contrib.lazy-xml) should work.
18:19replacathere we go!
18:20replacarhickey: thanks for the noob answer
18:20replacamy lisp skills and my java skills haven't quite jelled into the clojure mindset :-)
18:21replacarequire is exactly the button I was looking for
18:21rhickeyChouser: you're right, so would need slashes and -/_ translation
18:22Chouserbut not the .clj extension. ...far too low-level to bother explaining. :-)
18:30replacaAnother Q: is there a standard way now of doing AOT compiles from the command line (or ant tasks)? I saw the group thread, but it still seems unresolved.
18:30replacaOr should I just write a clj helper for ant?
18:35Nafaireplaca: That would be useful, if there isn't one already
18:38replacaNafai: yeah, it seems necessary eventually for packaging things. But it might not be today's most important problem for anybody. :-)
18:38Nafaireplaca: I was considering doing that myself
18:39NafaiBecause I was going to try to write Android apps with Clojure
18:39NafaiBut I ran into some snags :)
18:39replacaYeah, to be really useful it needs to be in the core
18:40replacaI think we need command line tools that let you "ignore" the jvm
18:40replacaThis has been discussed at some length in the group and I don't really have a lot to add to that discussion
18:41replacanafai: what kind of snags did you run into?
18:41Nafaireplaca: A couple: 1) the compiler for dalvik, the Android vm, won't compile the existing Clojure jar
18:42Nafai2) Clojure still uses a runtime dynamic classloader and that won't work with dalvik either
18:42NafaiSo my snags weren't related to making the ant task :)
18:42replacaoh, you wrote about that in the group, right?
18:42NafaiI've just discussed that here
18:43replacaI'd love to see android work too. It seems like it would be awesome to write clojure apps targeted at mobile devices
18:43replacaNafai: I guess I read it while lurking one day :-)
18:44NafaiYeah, me too
18:45klinkerscan someone give me an example of how i should name my namespace
18:45klinkersi stil dont get how to refer tot hem from others
18:46klinkersi want like python: import numpy as N; N.f
18:47replacaklinkers: mostly you don't use import to pull in other clojure stuff, you use (require) or :use if you're in an ns statement
18:48replacaLike this:
18:48replaca(ns foo (:use com.infolace.format))
18:49replacaor
18:49replaca(require 'com.infolace.format)
18:49replacathe java babble of the inverted domain name is completely optional (just convention)
18:50hiredmanI just put everything under hiredman
18:50hiredmanhiredman.clojurebot
18:51klinkersbut where does :require look?
18:52klinkersim a in a dir datstructures now
18:52klinkersim a in a dir datastructures now
18:52klinkersi have one file (ns datstructures.stack)
18:52replacaIn the classpath
18:52klinkersah i see
18:53replacaso the "." is typically a directory boundary
18:53replacaso that would look for datastructures/stack.clj
18:54replaca(again the inheritacnce of java/jvm)
20:04replacaAnswering my own earlier question (in case anyone cares): You can compile from the command line with java -cp ... clojure.lang.Compile foo bar
20:04replacawhere foo and bar are the names of namespaces to compile
20:05replacaThere is an ant task in the latest clojure build.xml
20:36Chouserrhickey: {} constructs an ArrayMap -- is that documentable, or incidental?
20:37rhickeyChouser: when does it matter?
20:42RSchulzuser=> (class {})
20:42RSchulzclojure.lang.PersistentHashMap
20:43RSchulzuser=> (ancestors (class {}))
20:43RSchulz#{clojure.lang.IObj java.lang.Iterable java.util.concurrent.Callable clojure.lang.IPersistentCollection java.lang.Object clojure.lang.APersistentMap clojure.lang.Obj java.lang.Runnable clojure.lang.AFn java.io.Serializable java.util.Map clojure.lang.IFn clojure.lang.Associative clojure.lang.IPersistentMap}
20:45Chouserrhickey: It doesn't much, but the ArrayMap docs could mention that {} is one way to construct one.
20:45ChouserRSchulz: try (class {:a 1 :b 2 :c 3})
20:46rhickeyChouser: apparently it isn't, currently
20:46Chouserdepends if it has any entries. I guess I'll skip it.
20:47rhickeyChouser: and number of entries
20:47rhickeyuser=> (class {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8})
20:47rhickeyclojure.lang.PersistentArrayMap
20:47rhickeyuser=> (class {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9})
20:47rhickeyclojure.lang.PersistentHashMap
20:48Chouserok
21:42DmisenerHow do I programmatically what the current version of clojure that is running?
21:43DmisenerAs you can imagine Google "Clojure version" isn't much help {grin}
21:46ChouserDmisener: did you download a release, or use svn?
21:50DmisenerDownloaded the release... I know what version it is ... but was wonder if I was to make version sensitive code.. how would I determine the current running version.
21:50Chouserno such capability yet.
21:53DmisenerThanks...
23:50replacaQ: what sorts of things can *out* be bound to and have print/pr work?
23:50hiredmanwriters
23:50hiredmanfilewriter, printwriter
23:51replacathanks, hiredman