#clojure logs

2008-12-18

00:00triddellok, I'll try that
00:01arohnertriddell: the html function in compojure is very simple. (html [:foo [:bar 3]]) => <foo><bar>3</bar></foo>
00:01arohnerit only returns strings
00:01arohneryou can easily call it multiple times
00:02triddellyes, but inside the function you can run other functions right?
00:02arohnerdefinitely
00:03arohner(html [:body (foo) (bar)])
00:29bradbevIs LispPaste working?
00:30bradbevI'm trying to use JNA & gen-interface. I am compiling using ANT. My code basically boils down to
00:31bradbev(gen-interface
00:31bradbev :name libwinmm
00:31bradbev :extends [Library]
00:31bradbev :methods [['waveOutSetVolume [Integer Integer] Integer]])
00:31bradbev (def winmm (. Native (loadLibrary "winmm" libwinmm)))
00:31bradbevhowever, at compile time libwinmm is not defined
00:33bradbevhow do I get the Class object that gen-interface created?
00:35arohnermy familiarity with JNA comes only from reading examples, but how does libwinmm get defined?
00:35bradbevin is the :name option to gen-interface
00:35bradbevI have a libwinmm.class file in my classes dir
00:36arohneroh, sorry
00:36bradbevnp
00:38bradbevah - after I gen-interface I need to then import that class :)
00:38arohnerthat makes sense :-)
00:39bradbever, forget that - compiled in the wrong window :(
00:50arohnerbradbev: did you try using load rather than import?
00:50bradbevum, no
00:51bradbevload is looking for Clojure code - foo.clj or foo__init.class
00:52NafaiHas anyone tried to use the new AOT compiler to use code to run on the Android platform?
00:56arohnerbradbev: is your classes directory in your class path?
00:56bradbevarohner: yes
00:56arohnersorry, I've only played with gen-class, and that was a little while ago
00:58bradbevwere you using the gen'd classes from java or from Clojure?
01:00arohnerfrom clojure
01:01arohnerI was loading them without the original source
01:02arohnerwhat is the error you are getting?
01:04bradbevimport is failing to find the class. [java] java.lang.NoClassDefFoundError: java/lang/Library (server.clj:35) I'm building with ANT, so the callstack is silly
01:08arohnertry using the fully qualified name for Library
01:09bradbevarohner: that's the funny thing. what should the fully qualified library name be?
01:10bradbevI'm a bit of a neophyte
01:10arohnerwell, you say :extends [Library]. That's looking for a specific java class name
01:11arohnersimilar to saying in java
01:11arohnerclass libwinmm : Library
01:11bradbevyes, Library's full name is com.sun.jna.Library
01:12arohnerso use that in the extends line
01:12arohnerI think I remember seeing a bug that gen-class does not pay attention to imports yet
01:12bradbevoh crap, forgot that needed to be fully qualed
01:12bradbevwoohoo
01:12bradbevthat's it - awesome
01:12arohnergreat
01:13bradbevwell - it compiles at least :)
01:13arohnera good start :-)
02:59Lau_of_DKTop of the morning gents
03:00fffejhi - quick question - am I going mad or is there no function is the standard library to get the length of a sequence?
03:00Lau_of_DK(doc count)
03:00clojurebotReturns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps; arglists ([coll])
03:00Lau_of_DKfffej: How about count ?
03:01fffejcount looks good to me, was expecting to see it on the sequences api page on the web :)
03:01fffejand I've been searching for size / length etc!
03:01fffejthanks!
03:03Lau_of_DKYoure not the first one to ask that question... this week :)
03:10hiredman,(count "foo")
03:10clojurebot3
03:10hiredman,(println "hello world")
03:10clojurebothello world
03:10hiredman*tada*
03:11hiredmandon't break it
03:28hiredmanwhat is the best way to control which namespace (eval ...) evals in
03:42hiredman,(println *ns*)
03:42clojurebot#<Namespace foo>
03:42hiredmanguess that works
03:52Lau_of_DK,(println "/part #clojure")
03:52clojurebot/part #clojure
03:52Lau_of_DK:)
03:52Lau_of_DKOne of these days I'll get it :)
03:52hiredman*snort*
03:52hiredmanyeah
03:52hiredmanI bet you will, I am pretty sloppy
03:52Lau_of_DKIs it running on a hosted system somewhere, or you got it at home?
03:53hiredmanit is running on a webserver somewhere in sumner, wa
03:53Lau_of_DKok, s� crashing it is not really a good idea
03:54hiredman*shrug*
03:54hiredmanthe webserver has a tendency to crash any time it rains anyway
03:54Lau_of_DKnot good
03:55Lau_of_DKI actually found a pretty great hosting service where you could get a virtual server for next to no money
03:55hiredman*shrug*
03:55Lau_of_DK,(doseq [i (range 5)] (println i))
03:55clojurebot0 1 2 3 4
03:56Lau_of_DK,(println (System/getProperty "java.class.path"))
03:56hiredmanright now it is just running in a jvm sandbox
03:56hiredmanI should do some filtering of "naughty" forms
03:56Lau_of_DKHow did you set it up ?
03:57hiredmanclojurebot: sandbox?
03:57clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
03:57Lau_of_DKperfect
03:58Lau_of_DK,(println (iterate inc 1))
03:58hiredmanhmm
03:58Lau_of_DK,(println "still here")
03:58clojurebotstill here
03:58hiredmancool, I kind of expected that to break it
03:59hiredmanwhoop
03:59hiredmans
03:59hiredmanhah
04:00hiredmanthat does run in the sandbox, but it blows the heap, so nothing gets sent to the channel
04:01hiredmanthe latest clojurebot, with the sandbox stuff is pushed out
04:01hiredmanclojurebot: where are you?
04:01clojurebothttp://gist.github.com/27733
04:02Lau_of_DKhiredman: So it blows the heap but the Bot still runs ?
04:02hiredmanyeah
04:02Lau_of_DKIt threads out the evals ?
04:03hiredmanguess so
04:03Lau_of_DKhehe
04:03Lau_of_DKpretty robust
04:03hiredmanOutOfMemoryError: Java heap space
04:04Lau_of_DK,(map #(println (iterate inc %)) (iterate inc 3))
04:04Lau_of_DK,(println "still here")
04:04clojurebotstill here
04:04Lau_of_DKhehe, thats cool
04:04Lau_of_DKand he even held the tension there for about 10 secs
04:05hiredmanblew the heap again
04:06hiredman,(.getContents (java.io.URL. "http://google.com&quot;))
04:07hiredmanI guess I should catch exceptions and throw an error
04:08Lau_of_DKWhich class does getContents belong do ?
04:08Lau_of_DKHere the URL is in Java.net
04:08hiredmanI maybe misremebering
04:08hiredmanyeah
04:08hiredmannet
04:09Lau_of_DKWhere did you find getContents ?
04:09hiredmanjava.net.URL
04:10hiredmangetContent
04:10hiredmanno s
04:11Lau_of_DK,(.getContent (java.net.URL. "http://www.google.dk&quot;))
04:11Lau_of_DK,(println (.getContent (java.net.URL. "http://www.google.dk&quot;)))
04:12Lau_of_DK,(print (/ 2 0))
04:12Lau_of_DKclojurebot: where are you?
04:12clojurebothttp://gist.github.com/27733
04:24hiredman,(java.util.Date.)
04:24clojurebotThu Dec 18 01:24:10 PST 2008
04:29tsdhHi. I'm pretty new to clorjure and play a bit with it now. I want to access a java class, so I did "(ns jg (:import (de.uni_koblenz.jgralab JGraLab)))" and am now in namespace jg at the REPL. What's the correct way to access the static member JGraLab.version now? I tried "JGraLab/version" but got "java.lang.Exception: No such namespace: JGraLab (NO_SOURCE_FILE:0)".
04:29hiredmanwhat does JGraLab return at the repl?
04:31tsdhde.uni_koblenz.jgralab.JGraLab
04:31hiredmanhmmm
04:31nagnalscan I see the implementation of a function from the interactive prompt?
04:32hiredmannagnals: there is a function in contrib somewhere for that
04:32hiredmannever used it, not sure where it is
04:32hiredmanrepl utils or something
04:32nagnalswhen writing a function like sort or reversed, do i have to use multimethods if i want them to return the same sort as they were passed?
04:32hiredmantsdh: what exactly did you type at the prompt to get the no such namespace error?
04:32nagnalsand is it possible to cons to a vector and keep it a vector?
04:33hiredmannagnals: use conj
04:33hiredman,(conj [] :a :b)
04:33clojurebot[:a :b]
04:33hiredman,(conj [:a] :b)
04:33clojurebot[:a :b]
04:33hiredmanetc
04:33tsdhhiredman: JGraLab/version RET (and version is a public static String in JGraLab)
04:33hiredmantsdh: parens
04:33hiredmanmaybe
04:34tsdhhiredman: No parens
04:34hiredmanthat wasn't a question
04:34hiredmanare you running a recent svn?
04:35tsdhhiredman: Sorry. ;-) With parens I get "java.lang.NoSuchFieldException: version (NO_SOURCE_FILE:1)" and now I see that the error sits in front of the monitor. version is private...
04:35nagnalshiredman: yes but i want to cons to the beginning of the list/vector, not the end
04:35hiredmannagnals: vectors grow at the end
04:35hiredmanlists at the begining
04:36hiredman,(conj `(:a) :b)
04:36clojurebot(:b :a)
04:36nagnalsyes
04:37hiredman,(println "Yes.")
04:37clojurebotYes.
04:39hiredmanhttp://clojure.org/sequences <-- the text blob at the beginning
04:47tsdhIs it possible to redirect System.out to the repl?
04:48hiredmanuh
04:48hiredmando you mean out -> in
04:48hiredmanbecause System.out should print out at the repl
04:49hiredman(println "foo")
04:51tsdhThat works, but (JGraLab/main (make-array String 0)), which only prints the version and some other infos using System.out.println() didn't produce any visible output.
04:51nagnalscan I hide a function in a file or namespace?
04:52hiredman(doc defn-)
04:52clojurebotsame as defn, yielding non-public def; arglists ([name & decls])
04:53hiredmantsdh: are you sure it is outputing anything?
04:54tsdhhiredman: Yes, at least when run with java.
04:55tsdhhiredman: With (JGraLab/main (make-array String 0)) it returns nil, but no output.
04:56nagnalsis slurp a common name to use to read in files, ie not just on Clojure but it is a general saying in programming?
04:56hiredman*shrug*
04:57dhayatsdh: are you using the repl in emacs?
04:58tsdhdhaya: Yes, with slime and swank-clojure.
04:58nagnalshiredman: ok but defn- defs so i can call it from the prompt but I cant call it if i import a file o use load-file?
04:58dhayatsdh: check the *inferior-lisp* buffer.
04:59tsdhdhaya: Oh, indeed, there it is.
04:59hiredmanslangan: I believe it stops you from calling the function from outside the namespace it is defined in
05:00hiredmanI have yet to use it for anything
05:00hiredmanclojurebot: hiredman is also lazy
05:00clojurebotYou don't have to tell me twice.
05:02slanganyeah because if i put it in user.clj i can still call it
05:05hiredmannamespaces ~= java pacakages, defn- is like a private method
05:08hiredmaner
05:08hiredmannot private
05:08hiredmanprotected
05:16slanganwould it be possible to run clojure on a cellphone that can run the JVM? or would the dynamicy create to much overhead at runtime? or does AOT-compilation solve that so I can create execs from clojure-scripts?
05:17slanganAndroid use the Dalvik Vm, that means Cloure can't be run on it right?
05:17hiredmanit depends
05:17hiredmanit is a topic of on going interest
05:18hiredmana lot of java phones really have the j2me not full java
05:19hiredmanI think scala is running on android
05:19hiredmanclojure uses a dynamic class loader deal (sometimes) which the phones and also applets don't like
05:27slanganhmm, oh well im writing a web/mobile app i can have the webapp in clojure and write the mobile part in java. no biggie.
05:28slanganif i want to host a webapp for free, where should i do it?
05:29hiredmanuh
05:29hiredmanthere are at least two frameworks for doing web stuff in clojure
05:30hiredmanclojurebot: webjure
05:30clojurebotwebjure is http://code.google.com/p/webjure/
05:30hiredmanclojurebot: compojure
05:30clojurebotcompojure is http://github.com/weavejester/compojure/tree/master
05:31AWizzArdMoin moin
05:32hiredman,(println "Hello")
05:32clojurebotHello
05:35AWizzArdclojurebot: max people
05:35clojurebotmax people is 113
05:35AWizzArduh, yesterday it was 116
05:35hiredmanyeah, stuff happened
05:35AWizzArdclojurebot: max people is 116
05:35clojurebotIk begrijp
05:35hiredmanthe dumpdicts agent was running
05:35hiredmanare
05:35hiredmanwas not running
05:36hiredmanso some data was lost when I restarted the bot
05:36AWizzArdic
05:36AWizzArdclojurebot: max people
05:36clojurebotmax people is 116
05:36AWizzArddanke
05:36hiredmanbut now the dumpdicts agent starts its self
05:36hiredmanso I won't forget to run it
05:36hiredmanbut sandboxing works now!
05:37hiredman,(conj {:a} :b)
05:37hiredmaner
05:37hiredmanit was
05:37hiredmandamn it
05:37AWizzArd,(format "C:\")
05:39hiredmansomething broke it
05:41hiredman,(println :foo)
05:41clojurebot:foo
05:42hiredman,(format)
05:42clojurebot:DENIED
05:45Lau_of_DK,(map #(print %) (range 5000))
05:45clojurebot(nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
05:45AWizzArd,(eval 1)
05:45clojurebot1
05:46hiredmanbtw
05:47hiredman,(println *ns*)
05:47clojurebot#<Namespace foo>
05:47AWizzArd,((resolve (symbol "format")) "Hello Moon")
05:47clojurebotHello Moon
05:47AWizzArd(format "Hello World")
05:48hiredman(doc format)
05:48clojurebotFormats a string using java.lang.String.format, see java.util.Formatter for format string syntax; arglists ([fmt & args])
05:48AWizzArd,(format "Hello World")
05:48clojurebotHello World
05:48hiredmansays :DENIED for an exception
05:49AWizzArd,(Thread/sleep 5000)
05:49AWizzArd,(format "Hello World")
05:49clojurebotHello World
05:50hiredmanI need to filter out stuff like Thread, recur, etc
05:51AWizzArd,(.getCanonicalPath (java.io.File. "."))
05:51clojurebot:DENIED
05:51hiredmanno io
05:51AWizzArdgood
05:51hiredmanclojurebot: sandbox
05:51clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
05:54hiredman,(def bedtime (Date.))
05:54clojurebot#'foo/bedtime
05:54hiredman,bedtime
05:55hiredmanhmm
05:55hiredman,(str bedtime)
05:55clojurebotThu Dec 18 02:54:46 PST 2008
06:08Chousukehiredman: maybe you should disallow def; it should be rather easy to cause clojurebot to run out of memory if I can def arbitrary stuff.
06:09AWizzArdCould would be to (send-off) every form entered here in chat into its own thread, with a timeout of max 5 secs.
06:09AWizzArdSo, small calculations would be allowed.
06:11AWizzArdand every 3 minutes without any def should clear the namespace
06:11Chousuke,(defn hello [name] (println "Hi " (str name) ", welcome to #clojure!"))
06:11clojurebot#'foo/hello
06:11Chousuke,(hello 'test-person)
06:11clojurebotHi test-person , welcome to #clojure!
06:11Chousukehm. too manu spaces.
06:12AWizzArdthis hello could be auto-deleted after 3 minutes without input
06:12Chousukesometimes you want to keep the stuff though
06:14leafwis there any built-in efficient way to get a list of repeated entries in a vector?
06:15Chousuke,(defn hello [name] (println "Hi" (str name ",") "welcome to #clojure!"))
06:15clojurebot#'foo/hello
06:15AWizzArdhiredman: something like (doseq [obj (ns-interns 'your.namespace)] (ns-unmap obj))
06:15AWizzArd,*ns*
06:15Chousukeleafw: not into a vector, but you can get a sequence.
06:15leafwthat would do
06:15AWizzArd,(print *ns*)
06:15clojurebot#<Namespace foo>
06:15leafwcan only think of this: (reduce #(conj %1 %2) #{} [1 2 3 4 4 4 3 3])
06:15AWizzArd,(ns-interns 'foo)
06:15leafwwhich gives me the non-repeated ...
06:15clojurebot{bedtime #'foo/bedtime, g #'foo/g, hello #'foo/hello}
06:16AWizzArd,(ns-unmap 'foo 'hello)
06:16AWizzArd,(ns-interns 'foo)
06:16clojurebot{bedtime #'foo/bedtime, g #'foo/g}
06:17AWizzArdhiredman: in my above suggestion I forgot the namespace argument to (ns-unmap ...)
06:18Chousukeleafw: oh, I misunderstood your question. hmm
06:19leafwI would like to count the repeated entries, really
06:21AWizzArdleafw: what do you know about the structure of this vector? Is it sorted?
06:21AWizzArdor could it be [1 2 3 1 2 3 1 2 3]?
06:21hiredmanChousuke: *shrug*
06:22hiredmanI can just restart it
06:22leafwnot sorted
06:22leafwa list of random integers
06:22AWizzArdleafw: maybe then simply (- (count coll) (count (set coll)))
06:23leafwaha, turning a collection into a set ..
06:23AWizzArdobviously it's not a highly performant solution
06:23Chousuke,g
06:23hiredmanChousuke: needs ,(
06:23leafwthanks AWizzArd
06:24Chousuke,(eval g)
06:24clojurebotfoo$g__718@a6cbf7
06:24Chousukewell that doesn't tell me much :p
06:24Chousuke,(g)
06:24clojurebot:DENIED
06:24hiredman,(meta g)
06:24hiredman,(meta #'g)
06:24clojurebot{:ns #<Namespace foo>, :name g, :file "NO_SOURCE_FILE", :arglists ([x]), :line 0}
06:24Chousuke,(doc prn)
06:24clojurebot------------------------- clojure.core/prn ([& more]) Same as pr followed by (newline). Observes *flush-on-newline*
06:24Chousukehmm :)
06:25hiredmang is identity
06:25hiredman,(g :x)
06:25clojurebot:x
06:29AWizzArd,(in-ns 'user)
06:29clojurebotuser
06:29AWizzArd,(print *ns*)
06:29clojurebot#<Namespace foo>
06:30AWizzArd:-)
06:30hiredmanit is subvertable
06:30lisppaste8leafw pasted "no locks" at http://paste.lisp.org/display/72339
06:30AWizzArdphat h@ck
06:31leafwthat paste: some of the results indicate it worked fine, but the count of repeated entries suggests that it didn't
06:31leafw.. which is puzzling: dosync calls should prevent it.
06:32leafwif there were any repeated entries, the next available id wouldn't be 1000000.
06:33Chousukehm
06:33Chousukemaybe they're skipping IDs.
06:33leafwthe length is 1000000 as well.
06:35leafwit was a simple test for synchronization ... and I don't understand the contradictory results.
06:37AWizzArdleafw: you set next-id to the result of what the commute produces
06:37AWizzArdYou must not read the direct result of commute.
06:37leafwAWizzArd: true
06:38AWizzArdIf you want to do this you should use alter
06:38Chousukecommute may return a different value than what commute eventually sets the id to it seems.
06:38leafwaha
06:38leafwok, this makes sense
06:39leafwso alter would work in the same sense as commute, but return the newly added value?
06:40AWizzArdleafw: you want to read this thread: http://groups.google.com/group/clojure/browse_frm/thread/e575db4718c1f85/c2cb536f9500d31f?tvc=1&amp;fwc=1
06:40leafwthe doc says it returns the in-transaction-value of ref ...
06:41AWizzArdjust run your code again with (let (alter ..
06:42leafwI'm reading the thread. I am not sure that alter garantees continuous ids ... will try now
06:42AWizzArdalter guarantees continous ids
06:43leafwgreat
06:43leafwit does. Thanks AWizzArd
06:43AWizzArdyup
06:43AWizzArdjust never read the direct result of commute
06:45leafwwell: sometimes it may be useful. But I see that it has no place here.
06:54AWizzArdif you want the direct result use alter
07:00leafwdo vectors have structural sharing?
07:31nagnalsclojurebot: git is http://www.github.com
07:31clojurebotRoger.
07:31nagnalsclojurebot: git
07:31clojurebotgit is http://www.github.com
07:41Chouserleafw: yes
07:55leafwChouser: I guess that was a 'yes' to "do vectors have structural sharing" ?
07:56Chouseryes, vectors have structural sharing.
07:59leafwthanks
08:01AWizzArdChouser: Good morning. Do you always scroll up and read what was said since you went to bed? Or was it just an "accident" that you saw leafws question? ;-)
08:03nagnalshow do I get the string from running time?
08:04nagnalsi playa round with geentic programming and i want to include execution in the fitnessfunction.
08:04AWizzArdYou mean the (time) macro?
08:05AWizzArdnagnals: do you do GP or GA?
08:08AWizzArdIf you want to catch what (time ..) reported you will have to bind *out* to your own output string stream. This is trivially done by using (with-out-str (time (+ 1 2)))
08:09jdzwhy not use the difference between start time and end time instead?
08:09Lau_of_DKAWizzArd: I think he usually skims the logs
08:19nagnalswhy cant errors return what row IN MY PROGRAM the error happened? it makes debugging hell
08:19nagnalsnot getting that infp
08:49slanganhmm, perhaps a dumb question but if i have a lets say 10 variables and sometime si pass 5 of them to a function and sometimes 10, does it amke sense to use a hashmap and store them there and just pass that around instead? it just means i can pass around less variables which perhaps is a pointless win? is there any runtimepenaly of looking up stuff ina hashmap compared to just referring to a passed var?
08:49slanganWhy can't errors return what row IN MY PROGRAM the error happened? It makes debugging hell not getting that info.
08:50rhickeyslangan: they can
08:52slanganbut not always?
08:52rhickey(.printStackTrace *e)
08:53duck1123slangan: if you're using the REPL, that'll mess things up
08:54duck1123slangan: Are you doing this from the command line, or using an editor? (ie. emacs+slime)
08:54slanganrhickey: thats what i mean already get that but it doesnt say where in MY PROGRAM it happened?
08:55rhickeyslangan: how did you load your program?
08:55slanganemacs+clojure-mode
08:55slanganC-c C-l
08:57rhickeyit might have to do with the specific error, most times you'll get the line in your file, can you paste your stack trace?
08:58rhickeylisppaste8: url
08:58lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
09:19acieroidow, functions must be defined before calling it into another function
09:20rhickeyacieroid: you can (declare foo) (defn bar [] ... foo) (defn foo [] ...)
09:20acieroid'kay rhickey
09:30ChouserAWizzArd: most of the time I scroll back and read the log from overnight.
09:30AWizzArdnice :-)
09:30ChouserAWizzArd: ...unless I find it to be an overwhelming amount of traffic.
09:35RSchulzFWIW, I usually go back over the night's exchange in the morning, too. It seems traffic is picking up.
09:40Chouserindeed.
09:40Chouserbut I have trouble shaking the compulsion to hunt down and root out misinformation.
09:41Chouser...so I skim growing logs.
09:43Chousukehmm
09:44Chousuke,(def *persistent-defs* #{})
09:44clojurebot#'foo/*persistent-defs*
09:44Chousuke,(defn clear-defs [] (binding [*persistent-defs* (into #{'clear-defs '*persistent-defs*} *persistent-defs*)] (doseq [obj (ns-interns *ns*)] (when-not (*persistent-defs* (first obj)) (ns-unmap *ns* (first obj))))))
09:44clojurebot#'foo/clear-defs
09:45Chousuke,(ns-interns *ns*)
09:45clojurebot{bedtime #'foo/bedtime, status #'foo/status, clear-defs #'foo/clear-defs, g #'foo/g, *persistent-defs* #'foo/*persistent-defs*}
09:45Chousuke,(clear-defs)
09:45Chousuke,(ns-interns *ns*)
09:45clojurebot{clear-defs #'foo/clear-defs, *persistent-defs* #'foo/*persistent-defs*}
09:47Chousukenow there's at least a way to reset clojurebot if it accumulates too many global defs.
09:48AWizzArdexactly, good good
10:02lisppaste8triddell pasted "Compojure Error" at http://paste.lisp.org/display/72345
10:02Chousuke,(do (defn make-persistent [sym] (assert (symbol? sym)) (def *persistent-defs* (into *persistent-defs* #{sym}))) (make-persistent 'make-persistent)
10:03Chousukeoops
10:03Chousukehmm
10:03Chousuke,(do (defn make-persistent [sym] (assert (symbol? sym)) (def *persistent-defs* (into *persistent-defs* #{sym}))) (make-persistent 'make-persistent))
10:03clojurebot#'foo/*persistent-defs*
10:03triddellAnyone know why I'd get "java.lang.IllegalArgumentException: Wrong number of args passed to: LazilyPersistentVector" in the above paste?
10:04Chousukewhy is your vector wrapped in parentheses?
10:04Chousuke(doseq [value '(a b c)] ([:record value])) here, around [:record value]
10:06triddellok, I can see how that isn't necessary
10:06ChousukeI don't think doseq is what you want, since it returns nil.
10:06mibutriddell: doseq is good for side-effects
10:06Chousukeyou might want to use for
10:07mibutriddell: not for the functional style you're (rightly) using.
10:07RSchulzhiredman: Did you consider implicitly switching to a namespace equal to (or derived from to make valid) the poster's IRC nick?
10:07triddellah, ok, that's the issue, I need the vectors returned to the outer function
10:07Chousukeor map: (map (fn [val] [:record val]) '(a b c))
10:09mibuor (map #(vector :record %) '(a b c))
10:10mibumap is so much fun.
10:11triddellChousuke and mibu: this is a simplified version of what I really need to do, what I need to do is open a file for value in the seq, get a value, and then return the vector with the value... any suggestions for approaches based on that?
10:11Chouser,(for [x '(a b c)] [:record val]) ; or this
10:12clojurebot([:record #<core$val__3238 clojure.core$val__3238@152bdc7>] [:record #<core$val__3238 clojure.core$val__3238@152bdc7>] [:record #<core$val__3238 clojure.core$val__3238@152bdc7>])
10:12Chouserhm.
10:12Chouseroh
10:12Chouser,(for [x '(a b c)] [:record x]) ; or this
10:12clojurebot([:record a] [:record b] [:record c])
10:12Chousukeis for lazy?
10:12mibutriddell: the values are on separate lines?
10:12ChouserChousuke: yes
10:13Chousuketriddell: you can use map or whatever with side-effects too; you'll just have to force the calculation with (doall)
10:14mibutriddell: I think chouser's version with for is more idiomatic than map. you should use the for version
10:14ChousukeI wonder how clojurebot handles infinite loops :/
10:15triddellactually I have to generate an xml/html block with about 3 elements (2 of them nested) for a variable amount of files
10:15Chousukesomething like (defn foo [] (recur))
10:15Chousukeand then (foo)
10:16Chouserjust (loop [] (recur)) should do it. poor clojurebot.
10:16mibutriddell: you can use line-seq for sequencing a file, if the values are on separate lines.
10:16triddellThe files are in YAML format and I'm using jyaml
10:16ChousukeChouser: I dare not try :P
10:16Lau_of_DK,(loop [] (recur))
10:17ChouserLau_of_DK!
10:17Lau_of_DKYes sir?
10:17Lau_of_DKThat wont kill it
10:17triddellmibu: but I'm new to clojure too
10:17Lau_of_DKclojurebot: where are you ?
10:17mibuLau_of_DK: thanks for satisfying our curiousity. ;-)
10:17Chousuke,(prn "It's alive!")
10:17Chousuke... it's not :)
10:17Lau_of_DKhmm..
10:17ChouserLau_of_DK: seriously, what did you think would happen?
10:17Lau_of_DKI tried a few of those earlier today, and although the heap blew, it lived through it
10:18Chouseryou've now pegged hiredman's server.
10:18ChousukeLau_of_DK: recur doesn't blow the heap
10:18Lau_of_DKI thought it would thread it, see that the thread was gone bad and kill it
10:18Lau_of_DKOh thats true
10:18Lau_of_DKGuess I made an oppsie :(
10:18Lau_of_DKAppologies to all who loved the bot
10:19Chousukewell, obviously hiredman will want to protect against this somehow.
10:19Chouseryes.
10:19mibutriddell: does jyaml returns some sort of a collection?
10:19ChousukeI guess AWizzArd's proposition about running in a separate thread with a timeout should do.
10:19Lau_of_DKeasy (if (not (= @name "Lau_of_DK") ...
10:19AWizzArdYes
10:20Lau_of_DKbtw shouldnt Clojure have a "!=" operator?
10:20mibuchousuke: he should simply write a function to check whether code terminates or not. :-)
10:20Chousukemibu: yeah, simply.
10:20Chouser(doc not=)
10:20duck1123is that possible?
10:20Lau_of_DKChouser: You dare taunt the bot ?
10:20RSchulzduck1123: No. That's the joke. It's the "Halting Problem."
10:20mibuduck1123: no.
10:21Chouserbut starting a new Thread for each expression and killing it after a few seconds ought to work.
10:21RSchulzIf this thing is going to run in the wild, here on IRC, then it's going to have to be made a lot more robust, naturally.
10:21RSchulzBut it's a good start.
10:22RSchulzChouser: You're our FP expert. Are there not some purely functional programs for which the Halting Problem is deciable?
10:22RSchulz"decidable."
10:22duck1123didn't think so... (require 'clojure.contrib.prescience)
10:22RSchulzBy "some" I mean a categorical subset of arbitrary programs.
10:23RSchulzThat's one of the thing ACL2 can do (for restricted or annotated Applicative Common Lisp programs, of course)
10:23ChouserI'm not an FP expert. I imagine some programs provably terminate.
10:23Chouserprograms with no looping or recursion, for example.
10:23mibuRSchulz, Chouser: only a trivial uninteresting subset.
10:23RSchulzI'm not so sure that's really true.
10:24RSchulzLook into ACL2.
10:24slanganhow do I raise a specific java-exception?
10:24RSchulz(throw (new SpecificJavaException ...))
10:24slanganwhat is the idiomtic wya to ahndle exceptions in clojure anyway? return nil if failing?
10:25RSchulzIf you're going to catch an exception, it's because you know how to handle it, even if you end up re-throwing when you're done with that handling.
10:25RSchulzIf you don't know what to do with an exception, don't catch it.
10:25duck1123triddell: how well has jyaml been working for you in clojure? Looks like it might be useful when I get around to porting from my ruby code.
10:25mibuI think exceptions are not idiomatic to clojure. they are just a java interop mechanism.
10:25RSchulzClojure renders all exceptions the equivalent of Java's "unchecked" exceptions, so you never _have_ to catch an exception.
10:26RSchulzmibu: Exception handling is something all programs potentially have to do. They're part of software, not Java or C++, though different languages call them different things and support them in different ways, of course.
10:26Chouserthere are some places in clojure where exceptions are specifically called for.
10:26Chouservalidators, for example.
10:26mibuchouser: you consider FP and exceptions to be compatible?
10:27RSchulzI do. What would the conflict be?
10:27slanganwhat is the appropriate exception to throw for a dsl where the typre pssed doesnt match?
10:27AWizzArdmibu: why not?
10:27AWizzArdThe only thing that is not very lispy is that there are no restarts.
10:27slanganlike :of should be passd and soemthing else is passed instead
10:27RSchulzOne way to think of them, at least some of them, is that they reflect the response to the application of a partial function to a value outside its domain.
10:28AWizzArdExceptions know only one direction: up the stack. CL can go back if needed, and Exceptions are only a subset of its Condition System.
10:28mibuexceptions shutter the computation. I think they're essentially a side-effect. am I wrong?
10:28RSchulzNo. They're not side-effects.
10:29RSchulzIn fact, I'd say that if your language is dynamically typed, like Clojure, then you're going to make _more_ use of exceptions if you want a robust system.
10:29RSchulzWhat if Clojurebot didn't catch exceptions at its top loop? It would die the first time someone submitted something erroneous.
10:29AWizzArdmibu: if we want to take it seriously then we must find that it is impossible to do something in computers without sideeffects. All function calls consume time. This is not true for mathematics.
10:30mibuAwizzard: I'm also not for pure functional programming, but I do think the side effects should be kept to the front-end of computations and not for the core.
10:30AWizzArdyes, sounds fair
10:31mibuI see java in clojure as a gateway to the real world. you use it at the edges, and completely avoid it in the middle.
10:32ChouserI don't think it's necessary to stand off from Java that much
10:32slanganif i want: (if x (do-thise) else (do-a) (do-b)), how do i do that?
10:33slanganarent there just a way to branch ifs with several statements for each branch?
10:33ChouserThere are good parts of java that can and should be used in the core of an app
10:33mibuslangan: use do
10:33AWizzArdlike arrays
10:33Chousukeslangan: (if x (foo) (do (this) (and-that)))
10:33Chousukeslangan: or you can use cond
10:34Chousermibu: a couple examples off the top of my head: BlockingQueues and String
10:34duck1123it's too bad that many of the java libraries just don't "feel right" in clojure. Working with them is easy, but they were designed with a completely different mindset
10:34mibuchouser: I'm not shunning java completely as a code base. but I do try to avoid it because it's not compatible with FP and the immutability notions of clojure.
10:34AWizzArdduck1123: yes
10:35ChousukeString is, though :)
10:35Chousermibu: good enough.
10:35Chouserit's common to want to completely wrap all Java calls -- banish dots as much as possible -- but I don't think that's actually useful.
10:37Chouserfor the parts of Java that are indeed thread-safe or immutable, with sufficiently convenient APIs, why not just use them? Less code, easier to understand, better.
10:37RSchulzslangan: Put your two (or more) else forms in a (do ...) form.
10:37duck1123does wrapping them cause much overhead?
10:38RSchulzOops. I see you already got that answer.
10:38RSchulzduck1123: I would guess none at all. Why would there be?
10:38RSchulz(do ...) is a special form, so the compiler is handling it.
10:38RSchulzAnother oops? You were referring to "wrapping" Java libraries for Clojure?
10:38Chouserduck1123: wrapping a java method call like (defn split [a b] (.split a b)) probably costs almost nothing at runtime.
10:39duck1123RSchulz: I was referring to wrapping a native java call in a clojure fn
10:39ChouserHotspot will take care of you, I expect.
10:39AWizzArdalthough that would be a wrapper that still means doing java in clojure. Interesting would be useful wrappers.
10:39RSchulz(Right) I've been wondering about that. Most of the time reflection is involved, but I'm wondering if it has to happen for ever single call or if the JVM's super-fancy optimizations can eliminate it in many or most cases?
10:39ChouserBut it's more code and mental overhead for everyone reading your code.
10:40AWizzArdFor example for adding an event handler to a swing component. A clojurish way would be to do that without (proxy ...).
10:40ChouserRSchulz: the JVM will not remove reflection that Clojure puts in.
10:40duck1123I try not to create wrappers unless it makes it much nicer to use, but sometimes it's hard to resist that urge
10:41RSchulzChouser: How sure are you? HotSpot can in-line polymorphic calls (even at the native machine code level) and the re-generalize them if new types appear on later calls.
10:41mibuduck1123: my rule is: if it doesn't add logic, don't do it.
10:41Chouserduck1123: that's an appropriate struggle. keep it up! :-)
10:42RSchulzBut if the reflection at the point of calling Java methods is, for practical purposes, uneliminable, then we should be considering type tags wherever they're happening in critical loops.
10:43mibuI'm interested to know, what you guys use clojure for?
10:44RSchulzI'm working towards an "executive" for automating complex (and possibly concurrent) tasks in a theorem prover.
10:44RSchulzI also want to produce a shell-like environment for composing and scripting a growing set of logic tools.
10:46RSchulzSpeaking (thinking) of which... Does anyone know what the state of Rich's new "streams" stuff is? I see the type system seems to be pretty well flushed out, but he hasn't said much about it.
10:46RSchulz.... _fleshed out_ !
10:47ChouserRSchulz: I'm pretty sure, but I'd be happy to be proved wrong.
10:47RSchulzWell, I wouldn't count on it, but I'd like to image the day when the JVM / HotSpot is so sophisticated it can do that sort of thing.
10:47RSchulzDefinitely not holding my breath, though.
10:47RSchulzWhich is why I wonder about when / where / how much to type-tag my method calls.
10:48mibuRSchulz: why type-tag your calls?
10:48RSchulzE.g., character-at-a-time I/O calls?
10:48Chousukemibu: eliminates reflection
10:48RSchulzTo avoid reflection when invoking them.
10:48triddellduck123: jyaml seems like it will work fine, I always liked yaml for the bit of Ruby I did so I used it for my config files
10:48mibuRSchulz: premature optimization is the root of all evil.
10:49RSchulzYeah. I know that one. Which is why it's _a question_ of when / where / ...
10:49Chousukeafter you're profiled it's a problem :)
10:50triddellduck1123: see above... got your nick wrong
10:50mibuRSchulz: only on inner loops, when you have absolutely determined that they are bottlenecks, which means rarely ever.
10:50Chousukeor if you know it's going to get called a million times with the same type.
10:50RSchulzWhich is why I brought up the character-at-a-time example.
10:50RSchulz... character-at-a-time _I/O_ ...
10:51duck1123triddell: have you been using the new standalone compojure library, or are you using the older code?
10:51duck1123I was using the whole framework version, but I got sidetracked by trying to get it working in Tomcat
10:52RSchulzAm I the only one with a IRC client that auto-completes nicks (avoiding typos)?
10:52duck1123RSchulz: it's still possible with the members of this channel. (too many similar nicks)
10:53triddellduck1123: I actually just grabbed the html piece, which also needs a few other files. I'm only doing code generation with it right now for an eclipse plug-in I'm porting from Groovy code.
10:53RSchulzYeah, but mostly only those Chous* guys. And the occasional _ suffix duplicate / variant bit.
10:57slanganim writing a DSL and I have some trouble with the repl. I want to read a line but neither read or read-line does the job very well.
10:57slangani want to read in a line and get it as a slist(read-line returns a string).
10:58slanganand read stops at a space
10:58RSchulzslangan: Why don't you let the reader handle it? Which means, don't deal in lines and bytes, but in S-Expressions.
10:59RSchulzIt imposes some constraints on your DSL (like enclosing outer-most parentheses, for one thing).
11:01slanganbut one of the points f the DSL is allowing 2 + 3
11:01slanganhow do i use the reader anyway?
11:01gnuvinceChange the DSL not to allow that :)
11:01RSchulzThen you're going to need a parser.
11:02slanganyes
11:02RSchulzIs infix _really_ necessary for your end users?
11:03slanganso the parser should hand�e strings?
11:03slanganand yes infix is necessary
11:03RSchulzThat's a choice you have. You could still use the Clojure reader if it's rules for interpreting character streams is consistent with your requirements.
11:03RSchulzIf it's not, you'll have to work up from the character level.
11:04RSchulzI've heard tell of people working on parser combinator libraries, so you might want to ask on the list what's available as a starting point.
11:08RSchulzslangan: Of course, a convetional ANTLR or JavaCC parser could be used, too, given the relative easy of integrating Java libraries into Clojure programs.
11:20slanganok thanks for the tips
11:20slanganhow do I throw a syntax-error-exception? what is the name of that error?
11:20RSchulz(throw (new ExceptionName ...)) I'm not sure what specific exception you're thinking of, but they all work the same way with (throw ...) and (try ... (catch ...) (finally ...))
11:21slanganhmm I cant extend Clojur with new types, is that the expression problem?
11:21Chousukewhat new types do you mean?
11:21Chousukeyou can write java classes.
11:21Chousukebut in general that's only needed to interface with java libraries.
11:23RSchulzslangan: Keep in mind that Clojure's types are Java types.
11:23RSchulzYou can extend them, should you find the need, though I'd expect that to be rare.
11:23RSchulzAnd you can use pre-existing Java types, though not all equally easily, I suppose (very generally speaking).
11:23Chousukemost "types" you can simply model using vectors or maps or something
11:23RSchulzWhat do you mean by "the expression problem?"
11:51slanganwhat is mod again?
11:51slangan(% 46 5)
11:51cgrand(rem 46 5)
11:53Chousukeclojurebot: awake yet?
11:53Chousuke:(
11:53AWizzArdstill having fun in its for-ever loop
12:13RSchulzWhat timezone does hiredman live in?
12:13triddellAny ideas why when I try to compile a ns I get "No such file or directory seq_utils.clj... I am using duck_streams and I see this file is in contrib but that jar is on my classpath... does it need access to the clj files?
12:14RSchulzThe contents of a JAR file in your classpath is like having all its individual file content directories on your classpath.
12:15replacaQ: Is the theory that the wikibook is going to move to the google code wiki? Or are there going to be two different things?
12:15RSchulzWhat (use ...) form or :use clause are you using (no pun).
12:15triddell(:use (clojure.contrib duck-streams))
12:16RSchulzTry (:use [clojure.contrib.duck-streams])
12:16triddellI'm *really* new to the gen-class.. just figuring it out... I am a Java guy though
12:17RSchulzLikewise, except I haven't ventured into gen-class territory, yet.
12:33Lau_of_DKWhat on earth happend to our Wiki ?
12:35replacaIt lloks like queued changes might have finally been approved
12:35replaca*looks
12:35Lau_of_DKEverything worth reading has been removed
12:36replacaNo, I think it's all there - it's just not all one page anymore
12:36replacabut maybe I have a different view because I'm "logged in"
12:37slanganhow do I do if i need to return a ( but that givrs unclosed parameter...
12:37slangani quoteed it and sitll the same problem
12:38replacaLau_of_DK: does it look ok when you click through links?
12:39Lau_of_DKYea all the info is there
12:39Lau_of_DKBut I think its better to have it all on one page
12:39replacacool
12:39replacathat only works for so long
12:39replacaand then that page goes crazy
12:40replacahopefully clojure is going to generate more than one page of good stuff :-)
12:41replacaAnd there's going to be a new FAQ (rhickey was discussing in the google group) that will cover FAQ-y type stuff
12:41replacaso the wiki can be much more comprehensive
12:42replacaBut I know there's a wiki at google code too, so I'm wondering if we're gooing to move the wiki there
12:43Lau_of_DKProbably not
12:43replacaOK
12:44replacadoes someone "own" the approval process on this wiki
12:44replacait seems to take a long time
12:44replaca?
12:45replacaI added some stuff about unit test frameworks the other day but it was on top of a whole bunch of unapproved edits
12:45replacathat eventually got approved
12:45slangannow i need to convert "(" to (...butusing ( ina function without closing it doesnt work.,..
12:50Chousukehm
12:50ChousukeI modified clojurebot some but I can't test my changes as I don't have pircbot installed ;/
12:52Chousuke<3 gist
12:52Chousukehttp://gist.github.com/37563
12:52Chousuke(the wrap-execution function)
12:52Chousukehiredman: you may want to check that out too :)
12:53ChousukeI make no guarantee that it even works, as it was the simplest solution I could come up with based on the docs and as I said I haven't done any testing :P
12:56hiredmanclojurebot: ping?
12:56Chousukeit's still running an infinite loop :)
12:59hiredmanjava is only at 50%
12:59hiredmanwhich is nice
12:59RSchulzslangan: If you want to deal in characters, the notation for char literals is to precede them with a backslash.
13:00RSchulzhiredman: Do you have a dual-core, dual CPU or HT processor?
13:00hiredmannope
13:00RSchulzThen what's throttling it at 50%?
13:00hiredmanspoke too soon, it spiked back up to 80%
13:00RSchulzI've noticed heavy GC causing lowered CPU utilization, though I've never understood why that should be so.
13:01clojurebotsvn rev 1174; Copy or release 20081217
13:02hiredmanclojurebot's jvm is running with a small stack and heap, so it needs that gc
13:02waltersRSchulz: probably stop-the-world collections
13:02hiredmanclojurebot: how much do you know?
13:02clojurebotI know 105 things
13:02RSchulzwalters: But I don't see how that explains lower CPU utilization? Why doesn't the CPU shift from user threads to the GC thread at the same full-bore demand?
13:03RSchulzclojurebot: Do you know not to chase your own tail?
13:03clojurebotIt's greek to me.
13:03hiredman,(println "No")
13:03clojurebotNo
13:03RSchulzI think even Bender got caught in one of those loops, once...
13:03waltersRSchulz: well it depends on how many active app threads you have...some GC phases could be single-threaded, a lot comes down to which collector you're using, what flags, etc.
13:04RSchulzNot that I'd try it, but does clojurebot protect itself from, say System/exit?
13:04hiredmanclojurebot: sandbox?
13:04clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
13:04RSchulzwalters: But what could be happening that causes periods during which the JVM makes _no_ demand on the CPU?
13:04hiredman,(System/exit)
13:04clojurebot:DENIED
13:04waltersRSchulz: possibly parts of the heap got swapped out and it's blocking on disk IO?
13:05RSchulzSo, hiredman, you're challenging us to find ways to harm Clojurebot??
13:05RSchulzwalters: That's at least plausible, though I think when I've seen it there hasn't been any swapping / paging going on.
13:05hiredmanRSchulz: no
13:05RSchulzJust checking...
13:06Chousuke,(throw Exception "hmm")
13:06clojurebot:DENIED
13:07Chousukehiredman: this version isn't running my modifications yet, is it+
13:07RSchulz,(.. (new ProcessBuilder) (.command "sh" "-c" "ls -l") (.start))
13:07clojurebot:DENIED
13:07RSchulzDamn!
13:08RSchulz,(.. (Runtime/getRuntime) (.maxMemory))
13:08clojurebot:DENIED
13:09RSchulzJeez. What _will_ it let us do??
13:09Chousukeinfinite loops!
13:09RSchulzYeah. We got that...
13:09Chousuke,(+ 1 1)
13:09clojurebot2
13:09RSchulzWoo-Hoo!
13:09Chousukeremember that it also supports defining functions
13:09RSchulz,(meaning 'Life)
13:09clojurebot:DENIED
13:09RSchulz,(find-question '(:answer 42))
13:09clojurebot:DENIED
13:09Chousukemeaning = undefined function = exception = :DENIED
13:10RSchulzThat's rude.
13:10hiredman,(def status (ref {}))
13:10clojurebot#'foo/status
13:10hiredman,(dosync (commute status assoc "hiredman" "attempting the summit"))
13:10clojurebot{"hiredman" "attempting the summit"}
13:11Chousuke,(eval status)
13:11clojurebotclojure.lang.Ref@2016b0
13:11Chousukeoops
13:11hiredmanderef
13:11Chousuke,(eval (deref status))
13:11clojurebot{"hiredman" "attempting the summit"}
13:11Chousukehooray
13:11hiredmanwhy the extra eval?
13:12Chousuke... I just edited the previous line :P
13:12nagnalshmm i need patternmatching. should impelment attermathicng ofr clojure?
13:13RSchulzhiredman: Did you get my idea about evaluating submissions from each IRC nick in a namespace derived from that nick?
13:13hiredmanI saw it
13:14triddellok, another question: I have now compiled my source clj file with the basic :gen-class symbol. My namespace is "solo.core" and I now have core__init.class and the rest of the support classes. What am I missing to be able to call one of my functions (statically hopefully) from Java?
13:15triddellI made a jar of all the class files...
13:26triddellok, I got the core.class file now
13:31Lau_of_DKhiredman: I applogize for nuking your bot, I honestly did expect it to recover
13:40Chousukehm
13:40Chousukedid some testing with my mods
13:40Chousukenot quite working, but close
13:48cemerickI've returned to looking at zip again. Am I right in thinking that, because make-node is the way it is, the current zipper impl doesn't lend itself to trees whose branches maintain aggregate data about their siblings?
13:49cemericki.e. using a 'replace' primitive rather than make-node would enable you to return new parent nodes that contain updated aggregate information, rather than recalculating it each time a parent is created.
13:58Chousercemerick: you're talking about a particular piece of data being copied in several places in the tree?
14:00Chousukehooray
14:00Chousukewait. wuh
14:01cemerickChouser: No -- consider a tree structure whose leaves are vectors that contain integers (e.g. [1 6 28 3]), and the branches/parents are maps like {:children [...] :max XX}, where :children are the node's children, and :max is the maximum value that may be found among the descendant leaves.
14:02RSchulzcemerick: I think you could record the derived / aggregate data (max, e.g.) in node metadata which could be replaced on any given node rather than replacing the node (thereby creating a new tree)
14:02Chousukeokay, I managed to get my own clojurebot instance to return from an infinite loop but the thread still remains :>
14:03cemerickmake-node would require a full traversal of the new children to determine the new :max at a given branch. Replacement semantics would allow you to only adjust the :max if a child being replaced had a value equal to the branch's current :max.
14:03Chousercemerick: ok, I think I'm understand your question.
14:04cemerickRSchulz: but in a replacement operation (remove then add), I still need to perform a full traversal rooted at the modified branch in order to maintain that aggregate data, regardless of where it's stored.
14:04RSchulzAre you chaning the actual tree data, or just computing derived information _about_ that tree's contents?
14:04cemerickRSchulz: actually changing the tree's data
14:05Chousercemerick: yes, it looks like you'd have to traverse to the node, replace, traverse back up.
14:05cemerickfwiw, this is in the area of "online" spatial indexing -- it's very important to be able to modify the tree, and then support reasonably fast queries over it (which rely upon various pieces of aggregate data at different levels of the tree)
14:05RSchulzI have situations like this processing logical formulas (which are tree-structured). I have traversers and transformers that embody the traversal logic. The transformers allow the distinguishing of the top-down phase from the bottom-up phase.
14:06cemerickChouser: That's what I'm doing now -- I put together a little xpath-esque transformer for tree structures that gets the job done.
14:06karmazillaI have noticed *1 mentioned a couple of places, but what is it?
14:06cemerickI've got some breathing room now, so I thought I'd see if zip could help me out long-term. :-)
14:06RSchulzIt's the value most recently evaluated at the REPL.
14:06RSchulz*2 is the second-most-recent value; And there's a *3, too.
14:07karmazillaok
14:07cemerickRSchulz: so you're doing a traversal on every operation as well?
14:07Chousercemerick: they're immutable trees?
14:08cemerickChouser: Yeah. Surely you're not suggesting I start set!-ing refs? ;-)
14:08RSchulzMy point is that by distinguishing the top-down from the bottom-up, two kinds of algorithms are acommodated: Those that produce new sub-formulas during top-down traversal and those that produce them during the retreat from the bottom. (And those that do both)
14:08RSchulzcemerick: Surely you dont' have a Ref for every node in your tree, do you?
14:09cemerickRSchulz: no, no -- I thought that's what Chouser was asking about, though.
14:10RSchulzI should point out that my Formula classes are immutable, so I don't have a choice in how I implement transformers. They must produce new formulas, though they can share unaltered structure in the downward direction. (They're linked downward.)
14:12cemerickRSchulz: Yeah, all of my operations produce new trees as well. But if I were to implement them in terms of zip, I'd end up recalculating aggregates all over the place (since most of the aggregate data I maintain are min/max of some value(s) of a node's descendants).
14:13RSchulzI wonder if Huet was assuming some kind of "hash-consing" scheme to minimize duplication?
14:14cemerickNot sure, but I think an assumption of "dumb" nodes is made.
14:14RSchulzOne thing I do use to my advantage in Java code is the IAI pattern: Immutable After Initialization. It allows me to incrementally build up a node in a formula tree, say, but not change it thereafter.
14:14Chousercemerick: that's what I was asking. zip is my only experience with immutable trees -- I don't know how else to do it.
14:16cemerickChouser: if how you descend through the tree is deterministic based on intermediate/aggregate values stored in branches, then it's a simple bubble-up of updates
14:18RSchulzAre these quadtrees or octtrees or something of the sort?
14:21cemerickRSchulz: I used to use quadtrees, yes. I use r-trees sometimes now, as well as a bidirectional interval trees (which I don't think are specified in the literature -- I hacked those together for use with highly regular spaces, where r-tree node splitting quickly becomes degenerate).
14:22RSchulzAnd you're using basic Clojure data structures to implement them?
14:22RSchulzPerhaps this is just an application where a mutable approach is called for?
14:24cemerickRSchulz: For now, yes, I'm just using struct-maps for the branches.
14:24RSchulzYou mean for the nodes.
14:25cemerickSure.
14:25RSchulzEach association within a map being an arc?
14:25cemerickNot sure why I would slip back to using anything mutable -- that's where these things *came* from :-)
14:25RSchulz"Exigent circumstnaces?"
14:26cemerickno, everything is rectilinear
14:26RSchulzBy "arc" I mean Vertex (node) vs. Arc (link)
14:27CardinalFangI'm about to try using Clojure to write code for Android. I welcome advice and interjections.
14:27cemerickah. No, these aren't graphs, they're trees.
14:28RSchulzTrees are graphs!
14:28cemericka subset with specific characteristics, yes
14:29RSchulzDirected Acyclig Graphs in which each node (except one) has in-order equal to one and one node (the root) has in-order equal to 0.
14:29RSchulzSo the terminology of vertex and arc are still applicable.
14:29cemerickforgive me, I'm not classically trained...
14:30RSchulzYeah, and I'm a pedant. I can't help it...
14:31RSchulzAnyway, the immutable / mutable thing is pragmatic. If it works against you to use it, I'd say do something else, realizing the tradeoffs that ensue.
14:32cemerickYeah. I had an r-tree impl in Java for years. It was a pretty painful API.
14:33RSchulzSpecifically because of mutability?
14:33RSchulzI've been very happy with my decision to make my formula structures immutable.
14:34cemerickand because of Java itself. No easy predicates for specifying queries, filtering results by nonspatial characteristics, etc.
14:34RSchulzAnd if I were to be totally honest, I put in some mutability "back-doors," and ultimately got bitten by them more than once.
14:34hiredmanclojurebot: ping?
14:34clojurebotGabh mo leithsc�al?
14:34hiredmanclojurebot: ping is <reply>PONG!
14:34clojurebotOk.
14:34RSchulzclojurebot: ping-pong?
14:34clojurebotPONG!
14:34cemerickwell, I also need things to be pure so I can easily backtrack to prior transformation states
14:35RSchulzBut there are intermediate states during the transformation of generation N of the tree from generation N-1 that you fear will proliferate to undesirable magnitudes?
14:36RSchulzWhat scale are you operating at? How many nodes in these trees?
14:36hiredman,(dosync (commute status assoc "hiredman" "made the summit, awaiting rescue"))
14:36clojurebot{"hiredman" "made the summit, awaiting rescue"}
14:36cemerickno, not particularly -- why?
14:36RSchulzAnd you said "online," so I take it responsiveness is important?
14:36cemericknot many -- many thousands of data elements, so whatever that works out to in a mostly-balanced tree
14:37RSchulzSo what aspect of using the Zipper concerns you?
14:37cemerickthat the current impl requires the recalculation of aggregate data
14:38RSchulzRedundantly?
14:38cemerickit's not a problem, per se -- just that my requirements are orthogonal in one aspect to its impl.
14:38RSchulzWhy would that be?
14:38RSchulzCould you not generate the new tree in one pass and then in another compute the aggregate data?
14:39cemerickwell, that's the difference between an offline and online data structure -- in the former, you can bulk-load the tree, and maintaining aggregate data is unimportant since you've calculated it once and won't touch it again
14:40cemericks/touch/modify
14:56hiredmanugh
14:56hiredmanI think it maybe time to move clojurebot from gist to a proper github deal
15:11danlarkinhiredman: I'd like that
15:24Chousukehiredman: I've been trying to get clojurebot working but it appears that it refuses to even connect to IRC if I enable the security manager.
15:24Chousukehiredman: do you have a default permissions file for it?
15:25hiredmanyes
15:25ChousukeI managed to make it interrupt runaway computations
15:26hiredmanhttp://gist.github.com/37639
15:26hiredmanChousuke: yeah, very nice
15:26hiredmanI saw your gist
15:26Chousukethat doesn't quite work though.
15:26hiredmanyeah, I noticed :P
15:27Chousukehiredman: but hm, isn't running it like that equivalent to not having a securitymanager at all? :P
15:27hiredmanChousuke: yes, but the sandbox creates a new security context
15:27hiredmanor something
15:28Chousukeah
15:28Chousukehm
15:28hiredmanugh
15:28hiredmanlame
15:31Chousukehm, right
15:31Chousukenow it works, but
15:32Chousukefor some reason, *ns* is clojure.core
15:33Chousukeand it allows creating new threads :P
15:33hiredmanyeah
15:33hiredman*ns* is thread locally bound
15:34Chousukebut isn't it inherited?
15:34hiredmandunno
15:34hiredmanI am seeing the this right now with *out*
15:34hiredmanmy deal runs, but it prints out to system.out instead of the stringwriter
15:36Chousukehm
15:36hiredman(binding [*ns* 'foo] (.start (Thread. #(println *ns*))))
15:36hiredman^- clojure.core
15:36hiredmanweird, and lame
15:37Chousukewonder if there's a way to prevent spawning threads
15:37Chouserof course a new Thread will see the root binding.
15:37Chouserbinding only works within a given thread
15:37hiredmanChouser: I sort of figured that out :P
15:37Chouseryeah. :-)
15:38Chousukecan't have a clojure evaluator if it's able to spawn threads ;(
15:38hiredmanChousuke: *shrug*
15:38Chouserwhy's that? applets can spawn threads.
15:39Chousukewell, they'd have access to the clojure.core namespace of the bot
15:40hiredmanChousuke: you have access anyway
15:40Chousukeeven if hmm
15:40Chousukeoops
15:40hiredman,(do (in-ns 'clojure.core) (naughty stuff))
15:40clojurebot:DENIED
15:40hiredman,(do (in-ns 'clojure.core) (println *ns*))
15:40clojurebot#<Namespace clojure.core>
15:40Chousukewell I guess the evaluated code has to be wrapped in a threadgroup as well
15:41Chousukeso that all spawned threads can be killed.
15:41hiredmanthis is getting very complex
15:45Chousukehttp://gist.github.com/37563 I refactored this so many times it probably doesn't make much sense anymore, but here goes.
15:46hiredmanChousuke: the wrap-exceptions deal is useful
15:46hiredmanI should have written something like it at the outset
15:47Chousukethe wrap-execution stuff runs the thing in a separate thread so that it can be killed
15:48hiredmanwill need to move the *ns* and *out* binding stuff into that thread
15:48Chousukeyeah
15:49mehrheitanybody know why inner classes are only accessible by package-qualified names? (even if the parent class is imported)
15:49hiredmanmehrheit: you can import the inner classes
15:49mehrheitoh, yeah. I forgot
15:50mehrheitthank you
16:00karmazillaI recently had a need for some "case" expression and came up with this: http://gist.github.com/37651 - I wonder if it can be written in a more elegant way
16:00kotarakkarmazilla: clojure.contrib.fcase
16:03kotarakkarmazilla: also using 'val is bad, bad, bad. This can lead to clashes with the user code in the expansion use `(let [val# ...] ..). This generates automatically a symbol, which cannot be in the user code.
16:11lisppaste8kotarak pasted "karmazilla: modified case" at http://paste.lisp.org/display/72363
16:12kotarakkarmazilla: this should be save against variable capture, but clojure.contrib.fcase is of course more robust and flexible and...
16:16karmazillaah yes, I knew that there was something or other looking like "~@" but I could not find it on the website
16:24kotarakkarmazilla: just think Scheme: , => ~ and ,@ => ~@
16:27karmazillaI don't know Scheme so that doesn't help
16:28kotarakah. ok. never mind.
16:33hiredman,(loop [] (recur))
16:33clojurebotExecution timed out
16:33hiredmanclojurebot: botsnack
16:33clojurebotthanks; that was delicious. (nom nom nom)
16:34mehrheit,1;?
16:34hiredman,(println "hello")
16:35clojurebothello
16:35mehrheit,(prn 1)
16:35clojurebot1
16:35mehrheit,(dotimes x 2 (prn x))
16:36Chousukehiredman: did you merge my changes to your gist repo properly or just by copy&paste? :)
16:36hiredmanChousuke: copy and paste
16:36Chousuketoo bad, means I can't merge your changes back into mine.
16:37hiredmanuh, well, I am not using git "internally"
16:37hiredmanthe sandboxing stuff deserves its own lib
16:37RSchulzhiredman: You know, now that clojurebot does Clojure code, it's probably going to need to be fed a lot more.
16:38hiredmanmehrheit: dotimes takes a [] for binding now
16:38Chousuke (just in case you'll ever need something like it: in your git clone dir: git remote add chousuke git://gist.github.com/37563.git; git fetch chousuke; git merge chousuke; git push # (to push to github))
16:38RSchulzDid you do the sandboxing in Clojure or in Java?
16:39hiredmanjvm and clojure
16:41hiredmanfatal: 'chousuke' does not point to a commit
16:44mehrheit,(dotimes [x 2] (prn x))
16:44clojurebot0 1
16:45Chouser,(doseq [i (.split "I am a bot" " ")] (println i) (Thread/sleep 3000))
16:46clojurebotExecution timed out
16:46Chouser,(doseq [i (.split "I am a bot" " ")] (println i) (Thread/sleep 500))
16:46clojurebotI am a bot
16:47drewr,(System/exit 0)
16:47Chouserclojurebot: hi!
16:47clojurebotHuh?
16:47drewr,(System/getProperty "user.dir")
16:47Chouser,(class *out*)
16:47clojurebotclass java.io.StringWriter
16:48mehrheit,(prn *ns*)
16:48clojurebot#<Namespace foo>
16:48hiredman,(System/getProperty "user.dir")
16:48hiredmanman, I hope I did not just break it
16:49drewr,foo
16:49hiredmandrewr: needs a paren
16:49drewrAh.
16:49danlarkin,(slurp "/etc/group")
16:49hiredmanno io
16:49danlarkinclojurebot: rude!
16:49clojurebotI don't understand.
16:50karmazilla,(loop [] (recur))
16:50hiredmandunno why it is swallowing exceptions again
16:50drewrHeh.
16:50clojurebotExecution timed out
16:50drewrDoes it fire each one in a thread?
16:50Chousukeyeah
16:50karmazillamay I try to break that threading?
16:50Chousukeand then it waits for it to finish, so no concurrent stuff :P
16:51Chousukethere's still a problem with it.
16:51hiredmanmany problems
16:51Chousukeyou can spawn your own threads that will not get killed.
16:52hiredmanChousuke: sshhh
16:52Chousukethough that'll just require wrapping the thing in a threadgroup so that all its chidren threads can be killed as well :P
16:52hiredmanloose lips sink ships
16:52karmazilla,((fn john_mcclane [] (try (loop [] (recur)) (catch Throwable _ (apply john_mcclane)))))
16:52clojurebotExecution timed out
16:52hiredmanwhen you ride alone you ride with hitler
16:52mehrheit, (prn 1)
16:53mehrheit,(println ",(println 1)")
16:53Chousukehm.
16:53hiredmanuh
16:54Chouser,(prn :still-here)
16:54hiredmanlocked
16:54karmazillakill -QUIT?
16:54Chouserthis is probably a very good way to clean up a sandboxing implementation.
16:55Chousukemaybe we should make a #clojurebot-playground channel
16:57AWizzArdhiredman: on what level does this io blocking happen? On the byte code level?
17:00karmazillaI think john_mcclane caught your Thread.stop call :)
17:01hiredmanjava has 0 load
17:01hiredmanAWizzArd: however the jvm does it
17:01hiredmanbut the repl is locked
17:04hiredmananyway
17:04hiredmanI have stuff to do, so if you break clojurebot, I will not be here to restart him
17:07karmazillaalso, since a new thread is started for every input line, then it shouldn't matter much that one thread was hijacked :/
17:08karmazillathat is, if it was
17:10Chousukehm
17:16Chousukeit seems clojurebot's code evaluation is completely broken at the moment. I did some tests in query and all it gives me are exceptions :/
17:16Chousukeoh well
17:31rfgpfeiffer()
17:32hiredmanwhoopd
17:32hiredmanfixed
17:33hiredmanlooks like some one shook up a snow globe outside
17:34drewrhiredman: Where are you?
17:35lisppaste8mmcgrana pasted "get source file and line" at http://paste.lisp.org/display/72369
17:35mmcgranacan anyone figure out a simpler way to do this?
17:35hiredmandrewr: seattle
17:36drewrWe had our share last week in TN.
17:36hiredman,(loop [] (recur))
17:36clojurebotExecution timed out
17:37mmcgranacan the clojurebot run code now?
17:37drewrmmcgrana: Yup! It even writes code for you. Just tell it your problem.
17:37Chousukehiredman: there should be some way to prevent people from redefining the sandboxing function :P
17:38mmcgranacool
17:39danlarkinclojurebot: I need to go grocery shopping. Please give me code for that
17:39clojurebotHuh?
17:39mmcgranalol. btw is there some place that all of clojurebot's functionality is documented? is his implementation open source?
17:39drewrclojurebot: I need a statistical model for a linear regression whatsamadozit.
17:39clojurebotPardon?
17:39drewrSee, it even recognizes bs.
17:39Chousermmcgrana: ha! clever.
17:40danlarkinclojurebot: where are you?
17:40clojurebothttp://gist.github.com/27733
17:40danlarkinmmcgrana: ^
17:41Kerris7clojurebot: what is your relationship with lispbot?
17:41clojurebotHuh?
17:41Kerris7clojurebot: don't deny it, we have evidence!
17:41clojurebotTitim gan �ir� ort.
17:41Kerris7wha?
17:41mmcgranadanlarkin: thanks
17:41RSchulzhiredman: What's the time limit? 10 seconds?
17:44Chousukeyeah
17:44Chousermmcgrana: the top-level 'let' isn't doing anything for you.
17:45Chouserwell, nothing that 'do' wouldn't do.
17:46hiredman,((fn john_mcclane [] (try (loop [] (recur)) (catch Throwable _ (apply john_mcclane)))))
17:46clojurebotGabh mo leithsc�al?
17:46hiredman:)
17:47hiredmandoesn't accept stuff with catch in it
17:47karmazillano more action movie heroes, then
17:48mmcgranahmm is there a function like multiget on maps? (mget {:foo :1 :bar 2} [:foo :bar]) => (1 2)
17:51hiredmankarmazilla: cute
17:52Chousermmcgrana: map
17:52mmcgranao good call
17:53Chouser(doc ns-unmap)
17:53clojurebotRemoves the mappings for the symbol from the namespace.; arglists ([ns sym])
17:53RSchulzShouldn't it filter?
17:53lisppaste8mmcgrana annotated #72369 with "more concise" at http://paste.lisp.org/display/72369#1
17:53Chouser,(doc ns-unmap)
17:53clojurebot------------------------- clojure.core/ns-unmap ([ns sym]) Removes the mappings for the symbol from the namespace.
17:53Chouserhehe
17:55lisppaste8Chouser annotated #72369 with "with more reader macros" at http://paste.lisp.org/display/72369#2
17:56mmcgranabut am i right to think that one can't do this file-line business without using a (def in there?
17:56mmcgranaChouser: nice
17:56Chousermmcgrana: there is *file* which doesn't seem to work for repl-ln, but does work in read files.
17:57ChouserBut there's no equivalent *line* -- there is a Var with the value you want (it's what 'def' uses), but it's not available to Clojure code.
17:58mmcgranaok
17:58Chouseroh!
17:58Chouser(var-get clojure.lang.Compiler/LINE)
17:59Chouserthere it is, it just isn't in any namespace.
17:59clojurebotsvn rev 1175; make sure find returns entry with original key
18:00mmcgranaalso SOURCE, which is a little confusing because it doesn't correspond to *file*
18:00mmcgranathe name i mean
18:00karmazillahiredman: do you also prevent ((fn john_mcclane [] (try (loop [] (recur)) (finally (apply john_mcclane))))) ?
18:01lisppaste8mmcgrana annotated #72369 with "with help from Compiler" at http://paste.lisp.org/display/72369#3
18:01Chouserrhickey: arg, I had that except for the RT change.
18:02ChouserWhich only became a problem when Clojure maps became java.util.Maps.
18:02rhickeyChouser: right, that was my first thought
18:02rhickeybut as you saw there were a couple of fabricated entries
18:03rhickeythanks for looking into it
18:03Chouseryeah, I found those, but was stumped as to why that didn't fix the problem.
18:03rhickeySo, how do I get that into the branch of the release I made?
18:05ChouserI'm afraid this is where svn is going to start hurting you.
18:05RSchulzrhickey: Which version of IDEA are you using?
18:05rhickeyIt all looks promising - there are menu options for integrate into branch
18:05rhickeyRSchulz: 8.0
18:05rhickeylooks like it wants me to have a working copy of the branch?
18:05RSchulzMe, too. But I do my version control from the command line.
18:06rhickey8.0.1
18:06RSchulzRight. 8.0.1. I made the mistake of trying the first EAP of 8.1. Messy.
18:07Chousercan't help now, but I'd recommend keeping careful notes of which versions you merge in which direction.
18:07ChouserMy understanding is that you may need this information in later merges.
18:08mmcgranao man svn merges
18:08rhickeyChouser: my idea was: cut a release, create a branch of it, continue working on trunk, move bugfixes into branch, never go the other way
18:08rhickeyno real merging
18:19clojurebotsvn rev 1176; make sure find returns entry with original key
18:19hiredmanclojurebot: uh?
18:19clojurebotIt's greek to me.
18:20rhickeyseemed to work ok
18:21rhickeymight be trickier when I want to move fixes but not features
18:35lisppaste8drewr pasted "macro & namespace" at http://paste.lisp.org/display/72375
18:36drewrWhy does "in" in the binding form get namespaced?
18:37Chousukeit needs a ~
18:37drewrWhen I do that, line can't be used in the expansion.
18:38drewrIt becomes foo.bar/line too.
18:38Chousukeyou need to force name capture
18:38Chousukewith ~'line
18:38Chousukemake sure to document the implicit binding as well.
18:39drewrDo I do that in the when test?
18:39Chousukeboth instances of line
18:39kotarakBetter: let the user provide a name for the variable.
18:39kotarakAvoids the capture.
18:39drewrkotarak: OK, that's a good idea.
18:40RSchulzOr use line#, since why would the invoker care what a local name is?
18:40Chousukeyeah, something like (defmacro with-each-line [[name-to-bind source] & body] ...)
18:40ChousukeRSchulz: the idea is to give the user access to each line in the body
18:40RSchulzOh, I see. Evaluating the body.
18:41Chousukethough that looks like something you could just use line-seq for :)
18:43drewrChousuke: Hm, possible. The input stream is from a socket in this case though.
18:43Chousuke(doseq [line (line-seq (BufferedReader. (FileReader. "foo.txt")))] whatever)
18:43RSchulzWhether it souces a socket or a file or an internal stream really doesn't matter.
18:43RSchulzAt least Java does _that_ for you.
18:43Chousukedrewr: line-seq just wants a BufferedReader :)
18:43drewrRSchulz: *Shouldn't* matter. :-)
18:43RSchulzCan you think of a case when it would?
18:44Chousukethough hm
18:44Chousukedoes line-seq close the file when it's done?
18:44RSchulzHopefully not.
18:44RSchulzThat would be presumptuous.
18:44drewrChousuke: No, just creates a lazy-cons.
18:45RSchulzSome Streams / Readers / Writers are seekable.
18:45Chousukein that case you might want to use (with-open) too :)
18:47drewrRSchulz: You raise a good point. I would definitely prefer line-seq.
18:47drewrMuch more functional and less Java-y.
18:47RSchulzWhich point?
18:48drewrThat the reader shouldn't matter if it's network-dependent.
18:48RSchulzAs long as you don't assume that once you've managed to open a stream (etc.) that you won't get errors, you'll be OK.
18:49RSchulzEven local files can present errors during I/O.
18:49RSchulzBut they're distinctly more likely when reading from a network endpoint, of course.
18:49drewrMy concern was related to the fact that I won't get things any particular order like in a file.
18:50drewrBut I think I would still be OK in this case because I'm just responding to what comes across, which can be in any order anyway.
18:50RSchulzWell, ordering is independent, and if you're using TCP, then guaranteed by the underlying protocol.
18:51drewrYep, TCP.
18:51RSchulzAnd if you don't trust that, then you'll need your own application-level protocol with redunancy of some sort to detect when the stream has become corrupted.
18:52RSchulzIf you're consuming multiple inbound networks streams, then of course ordering will be unpredictable and you'll have to account for that.
18:52drewrSingle input stream; just one socket.
18:55RSchulzWhat is the granularity of the items you process? Bytes? Characters? Forms? Native (int / long / etc.)??
18:58drewrText-based protocol with \r\n line termination.
18:58drewrcrlf, rather
18:58RSchulzThen using a line-oriented reader seems appropriate.
19:01drewrOK, (doseq [line (line-seq in)] ...) it is. :-)
19:56Chousukehm
19:57RSchulzhm? His Majesty?
20:03ChousukeRSchulz: I just patched my local version of clojure with a with-open that supports multiple bindings.
20:03Chousukejust wondering whether it'd make sense to close the opened streams in reverse order.
20:06RSchulzI thought with-open already did support multiple bindings... Nonetheless...
20:06ChousukeRSchulz: no, it doesn't.
20:06RSchulzI don't think it really matters the order in which they're closed.
20:06Chousukeit silently only closes the first binding
20:06RSchulzThat's not cool!
20:07Chousuketoo bad I don't have a CA :/
20:07RSchulzUnder the (I think reasonable) assumption that each output stream targets a different ultimate destination, the implicit flush upon close _could_ be signicicant...
20:08RSchulzBut I'm not sure that is something that is more correct one way than the other.
20:08RSchulzIs there an issue with submitting a CA from outside the U.S.?
20:09ChousukeI don't know :/
20:09RSchulzGack. What I said was nonsense. If each stream is independent, order doesn't matter. If two or more target the same output stream, then the implicit flush would matter, but I don't think that's something that factors into the definition of the with-open macro.
20:09RSchulzJust state the order and leave it at that.
20:09RSchulzWith-open is in the core?
20:10RSchulzIf the CA is an issue, you could just report the problem to Rich and let him fix it.
20:10hiredmanclojurebot: rhickey?
20:10clojurebothe works hard so you don't have to
20:10RSchulzclojurebot: hiredman?
20:10clojurebothiredman is an evil genius.
20:10RSchulzI _KNEW_ it!
20:11hiredmankarmazilla was mucking with clojure.asm through clojurebot
20:13RSchulzSounds kind of like performing neurosurgery.
20:13ChousukeI suppose I can't just release a patch to the public domain either :P
20:13RSchulzCurious notion... Would the quoting of the original content to be changed considered fair use?
20:14RSchulzStill, you could just post it to the list and let the chips fall where they may. I assume the change is straightforward and not voluminous?
20:15Chousukepretty much
20:15RSchulzMuch ado about nothing (or little)??
20:15RSchulzNot to denigrate your contribution.
20:15RSchulzWhy don't you just send off a signed CA?
20:15ChousukeI should, I suppose.
20:15RSchulzI hear they have air mail for the trans-Atlantic route now!
20:16Chousukeunfortunately I don't have time to do so until sometime in January :P
20:16RSchulzWhen I was an SWL kid, I had to send IRC (that's International Reply Coupons) to get air-mail replies!
20:16RSchulzHow long does it take to print a PDF, sign it and put it in the mail??
20:17Chousukewell, I don't own a printer.
20:17RSchulzSurely there's _something_ available to you? Some equivalent to Kinkos (copy shop that has computers for printing and such)?
20:17Chousukeand I'll be busy tomorrow leaving this place to spend christmas vacation with family :P
20:18RSchulzWell, at a minimum, you could post the issue / request for change to the list.
20:18Chousukeyeah
20:18RSchulzWhere do you travel for your christmas vacation?
20:18RSchulzYou live in Finland, right?
20:19Chousukeyeah.
20:20RSchulzShort daylinght hours these days, huh?
20:20RSchulzI hate the cold!
20:20RSchulzI left Wisconsin 'cuase of the awful winters.
20:35Chousukehmmhmm
20:36ChousukeI can probably get a CA sent tomorrow if I'm quick. in the meantime, there's an issue on the google code tracker now.
20:36Chousukeand it's way past my bedtime :)
20:41lgasHi all. I'm new to Clojure and relatively new to lisp in general. I have a seq of items and I want to process them in groups of three... I'm sure there's an easy way to do this but it has me stumped. What functions should I be looking at?
20:44lgasNevermind... I just found partition.
20:44lgas:)
20:48hiredman(doc partition)
20:48clojurebotReturns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap.; arglists ([n coll] [n step coll])
21:21francois__Hey all!
21:21francois__Just wondering if my style is correct: http://gist.github.com/37764
21:21francois__I want to extract the unique words of a string of text
21:21francois__The string will be Twitter status update messages
21:24dhayafrancois__: how about this? (distinct (re-seq #"\w+" "hello world world"))
21:25francois__dhaya: Hmm, yes, that would be much simpler, yes
21:25francois__Besides, it would probably work better than what I'm getting at the moment: java.lang.ClassCastException: clojure.lang.PersistentList (NO_SOURCE_FILE:0)
21:25francois__This message is very cryptic
21:25francois__No stack trace, nothing
21:25francois__I don't even know what's wrong
21:28francois__dhaya: The regexp trick works just fine
21:29francois__I had to modify the regexp slightly #"[#@\w]+" so it caught everything I needed, but this is perfect
21:29francois__Thank you
21:40Chouserfrancois__: for a stack trace: (.printStackTrace *e)
21:41francois__Ah, but I'm at the REPL, so there's not much of a stack trace anyway :(
21:43dhayafrancois__: I have never used read, it seems its typically used for reading in and emitting clojure data structures. For instance, all your "words" are emitted as clojure.lang.Symbol objects.
21:43francois__Yes, that's what I wanted initially
21:43francois__Using strings will achieve the same effect in the end for me
21:47Chouserfrancois__: for what it's worth, removing the parens around (word) got your original working.
21:47francois__Oh wow...
21:47francois__So, Clojure was trying to evaluate the symbol, and failing
21:48francois__I thought if required parens around the condition
21:48francois__But I remember now: symbols evaluate to themselves
21:48francois__If I put parens, that's a function call
21:48Chouserhm, well ... in this case, I don't think it's the "symbols evaluate to themselves" rule that's in play
21:49francois__I really want to know if it's nil or not
21:49francois__Since nil is false, I just wanted to use that
21:49Chouser'word' is evaluating to the value of the local named 'word'
21:49francois__Which is a symbol, such as I
21:50francois__as in (def status "I read a book")
21:50francois__(I) would fail
21:50francois__(I) from the REPL returns: java.lang.Exception: Unable to resolve symbol: I in this context
21:51Chouserit's more like (let [word 'my] (word))
21:51dhayafrancois__: Symbols are functions of map, so that (word) is expecting an map argument to be passed. In fact, thats the stack trace I get if i try yours. "Wrong number of args passed to symbol."
21:52francois__Were you at the REPL?
21:53dhayafrancois__: yes
21:53francois__And which revision of Clojure?
21:53francois__I'm using r1149
21:57dhayar1160. I am using emacs repl with slime and swank.
21:58francois__Hmmm, compiling 1160 fails for me with deeply nested exceptions
21:58dhayadid you try ant clean?
21:59francois__Ah, had to clean before
21:59francois__I still get a PersistentList error: java.lang.ClassCastException: clojure.lang.PersistentList
22:00francois__rHEAD has the same error (1162
22:02dhayafrancois__: I doubt if the difference is because of clojure versions. AFAIK, nothing much changed with exception reporting in the last few days.
22:02francois__I didn't expect that too
22:03francois__I'm straight at the command line on Mac, using Java 1.5.0_16
22:03Chouserfrancois__: you get that exception while 'ant' is running?
22:04francois__Chouser: The PersistentList error? No, at the REPL, right after executing the (distinct (loop [] ...))
22:04Chouseroh
22:04francois__Here's a paste of the session: http://gist.github.com/37856
22:05francois__clj is a script that sets the classpath to clojure + clojure.contrib and jline
22:06Chouserfrancois__: run (.printStackTrace *e) after that and paste it too?
22:06Chouseroh, you're giving it different input
22:06Chouserit's still trying to evaluate whatever object 'read' is returning first
22:07francois__Possibly, yes
22:07francois__The first word ends up being a deref
22:07francois__http://gist.github.com/37856
22:07francois__I updated again, this time with the real content
22:09Chouserthe @foo is expanded by the reader to a list (clojure.core/deref foo)
22:10francois__Correct, and (word) ends up evaluating that list, right?
22:10Chouserthen it tries to evaluate that list as a function
22:10Chouserright
22:10francois__Yeah, problem solved!
22:10francois__Not a problem in fact :)
22:10francois__Thank you for the help
22:10francois__I very much appreciate
22:10francois__I'm very new at Clojure in general, although I have years of imperative programming experience behind me
22:12Chousergreat! how are you liking it?
22:12francois__I like it very much
22:12francois__It's interesting
22:12francois__I needed to find something to challenge myself
22:12francois__I did try Common Lisp a while ago
22:12Chouserwrong kind of challenge?
22:12francois__I knew how to read basic lists, but didn't devote enough time
22:12triddellquick thoughts from anyone? I need to build a sorted-map of sorted-sets while processing a set (seq) of files... doing this functionally with immutable data structures is daunting.... any tips?
22:12francois__Had to get back to paying work :)
22:13triddellbasically, look if the key exists, if so add an entry to the set (value), otherwise add a new key and create a new set
22:14francois__triddell: loop/recur ? Isn't that the solution?
22:14triddellhaven't used that yet... I'll check that out... thx
22:15Chouserloop/recur is almost always sufficient, but it's close to the biggest hammer
22:15Chouseroften 'reduce' or 'into' works well for building maps and sets
22:16dhayatriddell: I have also found update-in, assoc-in to be helpful when working with nested structures.
22:16triddellI read about that on the group, where you and Rich gave examples, but it didn't seem sufficient in this case
22:17triddelldhaya: ok, yes, I was looking at assoc but need to deal with the immutability
22:19Chousertriddell: (reduce (fn [smap file] (if (smap file) (assoc (smap file) ...) (assoc smap ... (sorted-set)) (sorted-map) fileseq)
22:19Chouseror something
22:21triddellChouser: thanks! I'll study that approach