#clojure logs

2009-03-19

00:07Rayneshttp://www.qconlondon.com/london-2009/file?path=/photos/speakers/Rich_Hickey.png Rich needs to grow a beard :(
00:11Raynespstickne: What are you doing in #Scala you traitor :|
00:19pstickneRaynes: :-)
00:25replacaChouser: are you still online?
00:26RaynesHe has shifted into sleep mode. He is idle I'm afraid. You would have to hack into his brain and garbage collect his sleep bytes.
00:27durka42be careful, he might throw an InterruptedException at you
00:27durka42those have undefined behavior, and are hard to catch
00:27replacaRaynes: thx. I thought he might have wake-on-LAN set :-)
00:27Raynes;)
00:28replacaAt this hour, #clojure is full of folks who are either (a) up too late or (b) from California and therefore just plain weird
00:28replaca(I'm in the latter category)
00:29durka42i am in the former
00:29replacaI'll be there later tonight, I'm sure
00:30RaynesIt is only 11:29 :(
00:31replacaRaynes: are you Chouser's neighbor (CDT)?
00:31RaynesYup.
00:31RaynesAlabama.
00:32replacaAhh, one of my work buddies is from Alabama. He's happy to be out here, but his family can't understand how he spent $1M for a 2 bedroom condo
00:42pstickneis there a way to treat *(* or similar as a symbol?
00:45durka42,(symbol "*(*")
00:45clojurebot*(*
00:45durka42trying to break people's syntax highlighting? :p
00:46pstickneerr, without making it more complicated :p
00:46replacapstickne: basically, no
00:46pstickneI'm playing with fnparse now, and it's be nice to be able to "make it look more like EBNF")
00:46psticknefair enough
00:47replacapstickne: you can do what durka42 did, but you can't run it through the standard reader
00:47replacaso I don't think you'll get what you want
00:47durka42nope, you have to do really ugly things like (eval `(def ~(symbol "*(*") 42))
00:47durka42(don't do that)
00:47replacayou can always write your own reader for grammars, though :-)
00:47psticknenah... :)
00:48replacanot sure you really want to go there, though there may be times
00:48pstickneI'm already lost enought as it is
00:48replacawhen something like that makes sense
00:48durka42(var-get (resolve (symbol "*(*"))) ; not worth it
00:49replacalike trapeze without a net!
00:52RaynesLike a trapeze without a net or a rope because you get the power to fly only you have to keep eating magical flying beans to stay in the air and if you aren't careful you could forget to eat one and fall to your death.
00:55durka42it's better than the alternative, which is carrying all these construction materials so you can build scaffolding to work around the inability to fly
00:56replacaI think these metaphors might be teetering a little bit
00:56durka42a stack-based game in a stack-based language
00:57RaynesThat language is awesome. I just can't bring myself to learn it when I'm told that the easiest way to learn it is "Read libraries". :\
00:57durka42heh
00:57psticknewell, that's a bummer, I can't copy this epsilon from the PDF :(
01:00Raynespstickne: They make you read PDF's because then you have to type out examples yourself.
01:01durka42you can, however, treat it as a symbol :)
01:01durka42,(let [? 2 ? 3] (+ ? ?))
01:01clojurebot5
01:03Raynes...
01:03Rayneso_o
01:03pstickneRaynes: I'm not interested in copying over the EBNF by hand :)
01:04hiredmanthat? amazing�
01:04psticknemaybe I could find nice unicode characters for ... ;-)
01:04hiredman...
01:04hiredman?
01:04pstickne(which would mean I would need to learn how to use unicode input)
01:05hiredmanI have irssi setup to change "..." into the unicode ...
01:05hiredman?
01:06pstickneI could use a snowman for a ';'! :-)
01:06durka42,?
01:06clojurebotjava.lang.Exception: Unable to resolve symbol: ? in this context
01:06pstickneand there might be subscripted numbers for expr1... exprn :)
01:07hiredman??
01:07durka42well you will just have to write an OCR engine/EBNF parser combo
01:07psticknehiredman: those "flop" when they are highlighted here...
01:07hiredmanwall�e
01:07hiredmanflop?
01:08psticknehiredman: they "change places" -- a glitch in xchat or something
01:08hiredman�benchmark
01:14pstickneoh, lame
01:15psticknenow I get an EOF while reading but emacs tells me everything is ok :(
01:15pstickneoh, I lie
01:15durka42that means paren mismatch
01:17pstickne:p
01:17pstickneis there a way to forward-declare functions?
01:17durka42(doc declare)
01:17clojurebotdefs the supplied var names with no bindings, useful for making forward declarations.; arglists ([& names])
01:17psticknethanks!
01:20pstickneerm. it seems like they aren't really bound?
01:20pstickne(declare a) (def b a) ;; kaboom!
01:21durka42(declare a) a will now resolve to a var, but has nothing bound to it
01:21durka42what are you trying to do?
01:22pstickneWrite something using fnparse. I would like to write it like it looks in EBNF, where a production comes before the productions it uses
01:22pstickne(def prog (conc stmt)) (def stmt ...) etc.
01:22durka42the point of declare is so you can write (defn f [x] (/ (g x) 2)) and write g later
01:23durka42hmm
01:23durka42maybe you have to use something other than def...
01:24pstickneohh, I need a good read on the differences between all the def* forms :(
01:25replacapstickne: I think you may be out of luck. I just skimmed fnprse the other day and it looked like the macros realy want to use the data you give them
01:26pstickneman, I didn't even know it used macros ^^
01:26psticknesneaky lisp
01:27replacanow I've lost it. Where is fnparse?
01:28hiredman~fnparse
01:28clojurebotNo entiendo
01:28pstickneI found it in a link out of the 'libraries' section of clojure.org
01:28replacaahh, github
01:28hiredmanugh I think my ~ is acting weird
01:28hiredmanclojurebot: fnparse
01:28clojurebotHuh?
01:28psticknehiredman: too squigly?
01:28hiredmanmaybe not
01:28hiredman~parse
01:28hiredmanhmm
01:31replacapstickne: I eat my words, it's all just func calls, but the values are all intepreted as you go
01:31hiredman~parse
01:31clojurebotparser is http://github.com/joshua-choi/fnparse/tree/master
01:32replacahiredman: boy, clojurebot is helpful. I'd already found it and read most of the source :-)
01:32pstickneoh, fnparse does the forward-declare by using #'production
01:33hiredmanreplaca: there was a bug in it's lookup code
01:33pstickne(declare prod) (rule (alt ... #'prod)) ;eg
01:33replacahiredman: just givin ya a hard time!
01:33psticknehiredman: a ... bug?
01:34hiredmanyeah, it was swallowing the response
01:34replacapstickne: oh, and then it interprets the var later? Interesting. I must read code more closely
01:34psticknereplaca: I dunno :)
01:35replacaI'm looking forward to spending a *lot* more time reading clojure code
01:35replacaI haven't done nearly enough (got to write enough that I learn from reading, but I think I'm at that point now)
01:38cmvkkare lazy-seqs 'thread safe'? actually what i mean is, is there a 'guarantee' that a lazy-seq will only be called once for each element in the sequence? what if two threads call seq on the same object at the same time?
01:39cmvkki want to know if it's okay to have side-effecting code in a lazy-seq. (other problems with that concept notwithstanding)
01:39replacacmvkk: well they're thread safe but not in the way you're thinking
01:39cmvkkwell yes. i know they're thread safe in some sense, as i hope every clojure-native construct is
01:40replacaif I give the same lazy-seq to two threads and as for (first ls) I'll get the *same* value in both threads
01:40replacathat's the functional thing
01:40hiredman,(doc lazy-seq)
01:40clojurebot"([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. Any closed over locals will be cleared prior to the tail call of body."
01:41replacaso in fact, in that sense, you're guaranteed to get the object twice
01:41hiredman? says once
01:41cmvkkhmm...i read that too, and it did seem to indicate that to me, but i wonder if that's what it really means?
01:41cmvkkor rather, i wonder if it was written with this scenario in mind.
01:41hiredmanit depends on which once that is
01:41replacayeah, but not on different threads because each thread will actually have it's own lazy-seq, once it modifies it, I think
01:42replacabut I might be wrong
01:42cmvkkif you put a lazy-seq in a var, and then call (take 10 foo) on it twice, then code inside will only run the first time. that's what i take the doc to mean.
01:42cmvkkreplaca, not if that lazy-seq is in a ref!
01:42cmvkkactually...
01:42replacacmvkk: yes, that's right
01:43cmvkki assume if you put a lazy-seq in a ref, then have three separate threads call (take 20 foo) on it or whatever, that the code will only run once as long as those calls aren't concurrent.
01:43hiredmanthat sounds like a bad assumption
01:44cmvkki mean, as long as you do them 5 seconds apart or whatever, so that they definitely don't overlap.
01:44replacayeah, interesting.
01:44hiredmanassuming things aren concurrent is a bad idea
01:44replacaI think I need to read even more code :-)
01:44cmvkkoh yeah hiredman, i'm not assuming that at all.
01:44cmvkkthat's why i'm asking this...because in my case, i don't know if the calls won't be concurrent or not.
01:45hiredman~bat signal
01:45clojurebot/summon Chouser
01:45cmvkkheh
01:45hiredman~bat signal
01:45clojurebot/summon rhickey
01:46cmvkkthis is such a weird question, i might just have to look at the java code myself
01:48hiredmanso you have side-effects in a lazy-seq and you want to make sure they only happen once?
01:48stuhood(doc cache-seq)
01:48clojurebotGabh mo leithsc�al?
01:48hiredman,(doc seque)
01:48clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
01:48cmvkkin theory, the lazy-seq body would be making changes to atoms and stuff.
01:49hiredman~def lazy-seq
01:49cmvkkin practice, there might be other problems with this idea other than just concurrency...
01:50cmvkkin general: what i want is an object that works like a stream, but that can have as many consumers as possible, and interim values would be cached.
01:50cmvkkas needed*
01:51cmvkkseveral callers on a lazy-seq would produce that possibility, i think...since anything past the slowest caller could be garbage collected, and anything above the fastest caller wouldn't be generated yet.
01:51hiredmanerm
01:52hiredmansomething about that doesn sound right
01:52cmvkkheh
01:52hiredmanI suggest a LinkedBlockingQueue
01:53cmvkkI in fact am already using those, thanks to you from earlier.
01:53hiredmanhah
01:53cmvkkbut they can't have multiple consumers I don't think
01:53hiredmanoh
01:53hiredmanuh
01:53replacacmvkk: Looking at the source, it doesn't seem to do anything to protect you
01:53hiredman~jdoc java.util.concurrent.LinkedBlockingQueue
01:54cmvkkreplaca, i think yo're probably right, although i can't tell
01:54cmvkkmostly because i don't know what the 'synchronized' keyword means in front of a java method
01:55stuhoodit means that if one thread is inside a synchronized method, no other thread may enter a synchronized method for the same object
01:56cmvkkstuhood, aha thanks. do other threads block until the method is finished?
01:56stuhoodyes
01:56cmvkkthat indicates to me that in fact seqs ARE thread safe in the way that i mentioned: two threads couldn't call seq on the same lazy-seq at the same time.
01:57cmvkkbecause seq is a synchronized method.
01:57replacaoh yeah, I forgot about java synchronized, read right over it and looked for a lock :-(
01:57hiredmancmvkk: all threads would block on the slowest item in the lazy-seq
01:58cmvkkhiredman, what do you mean?
01:58stuhoodif each thread was generating the items in the lazy seq independently, they'd all be racing eachother
01:58replacahiredman: I don't think so, because different threads would be at different points which would be represnted by different java instances
01:59hiredmanreplaca: to get to a point in a lazy seq you have to pass through the previous points
02:00replacaright, so if the lazy seq were the bottleneck, all the threads would "catch up"
02:00stuhoodyea
02:00replacabut if something else were the bottleneck they'd live happily and (more or less) independently
02:01hiredmanyou might want a sequeue, to keep the lazy-seq calculating ahead of teh consumers
02:01replacawith the first thread to get to any point doing the actual work
02:02cmvkkhiredman, that's true...although in practice, i'm probably going to have dozens of these seqs, and not that many separate threads.
02:02cmvkkthe thread-safe issue here is just in the off chance that a seq has two different callers in two different threads (i don't actually think this is very likely to happen)
02:02cmvkkbut i'd like to make sure that the program doesn't die weirdly if it does.
02:04cmvkkanyway, thanks for your help guys...i think i'm a bit closer to figuring out how i want to do this.
02:09psticknewell, what a pesky bug
02:09psticknefnparse wasn't working correctly because I was using 'ident' as a def name
02:10pstickneI have no idea what was really happening -- just that it never worked :(
02:14replacapstickne: ugh. that's lousy.
02:16hiredmanthat? why you use require :as instead of use
02:16hiredmanthat's
02:16hiredman' then s results in ? I have to press ' then space then s to get 's
02:17psticknehiredman: I only use fnparse and fnparse only uses except only throw-arg :(
02:18pstickneoh, and I use seq-utils, but only flatten
02:18hiredmanugh, this is driving me nuts, " then u becomes � I have to type " then space then u to get "u
02:19hiredmanuse or (use ...)
02:20replacausing a euro-keyboard?
02:20hiredmannope
02:20hiredmanis that "euro-keyboard" behaviour?
02:20replacayour irc client doing something funny?
02:20cmvkkyou're just using a weird charset. i've seen that behavior on webpages before
02:20replacaYeah, in some configs
02:20hiredmanhmmm
02:21cmvkkit's really obvious when 's gets changed, because it's so common
02:21replacayeah, when you're typing in spanish, that's a feature not a bug
02:22replacacause they don't really use apostrophes
02:22replacabut they use *tons* of accents
02:23replacado you get the right chars over the numbers (!@#$%^&*...)?
02:28cmvkkwhat's your IRC client?
02:33pstickneoh, I'm dumb -- my problem with ident was I was re-declaring it later :(
03:36Raynes(apply str (reverse (reverse (reverse (reverse (reverse (reverse (reverse (reverse (reverse (reverse (reverse (reverse "Hello, World!"))))))))))))))) ; We can safely say that this poor string has been through hell!
07:34rhickeycgrand: looks like there's a typo in your patch: Unable to resolve symbol: righmost in this context
08:16tbbhi guys
08:16tbbis there anybody here familiar with compojure?
08:17tbbi'm having some trouble posting (POST) some xml and retrieving it again from the 'params' map
08:17tbbtheres an & in the xml and it becomes a separate key in the map
08:30maacltbb: where does it occur in the xml ? &amp is a entity reference in xml
08:32tbbhi maacl
08:32tbbxml is
08:32tbb"<action action_name='defn' application='clojurep' project=''><attribute name='function' data=''/><attribute name='arglists' data='([&amp; m])'/><attribute name='file' data=''/></action>"
08:32tbbpost message becomes:
08:33tbb"action=<action action_name='defn' application='clojurep' project=''><attribute name='function' data=''/><attribute name='arglists' data='([&amp; m])'/><attribute name='file' data=''/></action>"
08:33tbbcompojure map;
08:34tbbsomething like this:
08:34tbb{:action "<action action_name='defn' application='clojurep' project='nl.tbb.clojurep'><attribute name='function' data='testcljp'/><attribute name='arglists' data='([", :amp; x])'/><attribute name "'file' data='NO_SOURCE_FILE'/></action>"}
08:34tbbwith an :action key and a :map key
08:34tbbi mean an :amp; key :)
08:36tbbi'm now trying to get the content directly from the request, that should be a solution
08:44maacl:tbb looks like an error - does it really change m to x ?
08:47tbboh no, sorry, i pasted the wrong map
08:47tbbbut the &amp; becoming a key is the problem
08:47cgrandrhickey: sorry :-( I shouldn't have rushed this patch before lunch (and copy/pasted the typo from the REPL).
08:49rhickeycgrand: is it ok wit hthe typo fixed? I fixed here but don't have test cases
08:49rhickeyready to check in
08:49maaclhm, wonder what compojure uses to parse the xml
08:53tbbi guess the xml syntax is messing up the getParameters function of jetty
08:54tbbi'm going the (.getReader request) way :)
08:54tbbthanks though :)
08:59cgrandrhickey: it's ok
08:59jsankeyrhickey: is there an existing test suite for zip? as mentioned on the group i'd be happy to contribute cases for this if you like.
09:00rhickeyjsankey: I'm not sure if there are tests for zip in contrib yet
09:00rhickeyyou'll need a CA to contribute tests
09:01jsankeyrhickey: i've been poking around and don't see any yet
09:01jsankeyi see, a CA is no problem
09:02jsankeythe acceptability of my clojure code might be atm, though ;)
09:40AWizzArdrhickey: would it be difficult to add unchecked versions of <, >, <= and >=?
09:43cgrandrhickey: (pure curiosity) is it still necessary for the one-shot closures in LazySeqs to perform closed-over clearing or is this a remnant from when LazySeqs were functions?
09:44Drakesonis there an `indexed' function as in: (for [[x y] (indexed (range 5 10))] [x y]) ?
09:45ChousukeI think there is one in contrib
09:45Chousukebut I'm not sure. :/
09:45AWizzArdin clojure-contrib.seq-utils
09:46AWizzArd(indexed (range 5 10)) ==> ([0 5] [1 6] [2 7] [3 8] [4 9])
09:46DrakesonAWizzArd: oh, thanks
09:51rhickeycgrand: Nope
09:51rhickeyAWizzArd: what's not to check? No overflow possible. Do you just want inlining?
09:54AWizzArdrhickey: yes, nothing to check, but it could generate bytecode that uses the primitive Java < and >?
09:56rhickeyAWizzArd: that already happens
09:57jsankeyrhickey: thanks for the super-fast patch to zip!
09:57rhickeyjsankey: thanks to cgrand
09:57jsankeyindeed
09:58AWizzArdgood
09:58jsankeyrhickey: another question: would you be interested in me setting up a ci server to build/test clojure and contrib on every change?
09:58rhickeyAWizzArd: you only need unchecked- when you want bad/wrapping ops
09:59rhickeyjsankey: sounds neat
10:00jsankeyfyi it would be using my company's commercial ci product, but there are no strings and i won't try to sell anyone anything :)
10:00Chouserisn't there one of those already?
10:01Chouserhttp://groups.google.com/group/clojure/browse_thread/thread/5f5f63bb0ac6dbd/876a18070bc65f40
10:01rhickeyhttp://tapestry.formos.com/bamboo/browse/CLJ
10:02jsankeyfair enough, looks like it has been done
10:02rhickeysays no tests found, though
10:02rhickeyso probably only verifying buildability
10:02jsankeyi guess they don't know how to read the test results
10:03Chouserthere was talk of one fro contrib as well, but I don't see it.
10:03jsankeywell, the offer is there: i can set up one for clojure and contrib if you desire
10:04jsankeywith a bit of extra work i could add a plugin to read the test results (not sure what format they come in?)
10:04ChousukeI think it just prints stuff to stdout.
10:05jsankeyok - if it's matchable with regexes i might not even need a plugin
10:05Chousukeor does the contrib test suite support custom formatters?
10:05Chouserjsankey: test for clojure are in clojure.contrib.test-clojure
10:06rhickeycgrand: I take that back - clearing closed-overs is needed so they are not held while closure runs its tail call
10:06jsankeyi'll give it a run and see what it shouts at me
10:06Chouserjsankey: that's the place to try what already exists, and also where to add tests for the zip change if you care to.
10:07Chouserjsankey: if you do write something to go into contrib or clojure itself, please take a look at http://clojure.org/contributing
10:07rhickeyhrm, shouldn't Clojure testing libs produce read-able data?
10:08jsankeyChouser: thanks, i have printed out a CA already
10:08AWizzArdbtw, are the issues of clojure-contrib often checked?
10:08cgrandrhickey: ok thanks
10:08Chouserjsankey: and thanks for digging up the zip bug
10:08jsankeyhey, np
10:09Chousukeah, hm
10:10Chouserclojure.contrib.test-is/test-ns returns a map of the test counters
10:10Chousukereading test-is documentation, it seems to support customised output by rebinding the "report" function
10:10jsankeyit's pretty terse by default
10:11HolcxjoIf (compare [1 2] [1 2]) works why doesn't (compare '(1 2) '(1 1)) work as well?
10:11HolcxjoAnd if (compare [1 2] [1 2]) works, why doesn't (< [1 2] [1 2]) work?
10:11Chouserlooks like you can do (test-ns (all-ns)) and get a seq of test result maps, one for each namespace.
10:12rhickeycmvkk: still here?
10:13jsankeyChouser: ah, ok. i should be able to pretty easily emit it as xml and then suck it into the ci server
10:17Chouseras of last night I have a function that finds the smallest set of methods from among all currently imported classes that match a given unhinted or partially-hinted method invocation form.
10:18rhickeyChouser: cool!
10:19Chouseryeah, I'm excited to use it. too bad there's so much more analyze and emit between now and getting to use it.
10:19rhickeyapropos this thread: http://groups.google.com/group/clojure/browse_frm/thread/2590ee3c75c04e91/6d34e274fe0c5e5d
10:19rhickey?
10:19Chouseryes, at least as I understand that thread, which of course could be faulty.
10:20Chouserso (.compareTo x y) where neither are hinted finds a dozen or more methods. But hint either x or y as Enum, and only one method matches -- no runtime reflection needed.
10:20rhickeyvery neat - I'm imagining that is would be efficient enough to generate multiple paths when the number of possibilities is less than maybe 4
10:21Chouserok, I was thinking there might be a threshhold like that.
10:21Chouser*warn-on-reflection* can report how many are found if it's more than 1
10:22rhickeycould be even more if classes are final
10:23Chouserif we want to emit the minimum number of 'instance?' checks at runtime to correctly choose among the matching methods, a bit more clever logic will be needed.
10:31dnolenand idea: what about allowing people to provide a function in the metadata of a map to be run if a key is not found? this would work around some of the current limitations that you cannot add metadata to functions themselves.
10:33rhickeydnolen: I don't see how the two are related
10:33AWizzArdSo, is there some preparation for type-inference and/or optional static type checking (such as Gradual Typing)?
10:34rhickeyAWizzArd: we're skipping right to automated program correctness checking - will make sure the program does what the customer wants and will make money
10:34rhickey;)
10:34Chousukeoh, that would be fun, wouldn't it.
10:35rhickeywhy fool around, I say
10:35AWizzArdsure, we will get there one day
10:35Chousuke(assert (makes-money? code))
10:35rhickeythere you go
10:35rhickeythe fact that that is funny implies something
10:37Chouserit implies that programmers have a reason to exist
10:37vdrabmakes-money can be a lazy stream
10:37Chousukethen you should name it "income" :/
10:38rhickeyChouser: ha! I guess so
10:39rhickeyvdrab: I think makes-money is a delay, or a future, in any case it's blocking
10:39ChouserI had prof in college that would frequently address the fear that eventually computers would program themselves. Perhaps others had such a fear, but I've never bought it.
10:40duck1123when makes-money doesn't return anything, it stops everything
10:41vdrabrhickey: it implements the interface "conj" for "conjure"
10:41p_lChouser: the problem is not whether they will learn to program themselves, but whether they won't turn universe into Office Paperclip
10:42ChousukeChouser: perhaps computers can program themselves, the self-programming algorithm require maintenance.
10:42Chousukealgorithms*
10:42Chousukealso, +but
10:42vdrabrhickey: maybe you should have used agents
10:43ChouserChousuke: yes, that was my prof's assertion as well.
10:44p_lChouser: except that there's nothing that stops them from self-maintenance
10:44Chousukethough it might be that we invent a true AI at some point.
10:45Chousukeand if it were smarter than us, then it could program itself to be even smarter :P
10:46p_land if we did it wrong, it might model the universe based on MS Bob
10:46Chousukethen it'd just give up and destroy itself.
10:46Chouserrhickey: how is (makes-happy clojure) doing though?
10:47rhickeyChouser: pretty well
10:47p_lChousuke: No, it would optimize forever to get to that goal
10:48duck1123http://www.xkcd.com/534/
10:49rhickeyworking on my slides for ILC - any requests?
10:49jsankeyok, i have a start: http://pulse.zutubi.com/browse/
10:50jsankeyit builds clojure and clojure.contrib
10:50jsankeyboth are triggered on code changes, the latter also on successful builds of the former
10:50jsankeythe contrib project uses the latest jar from the main project
10:51jsankeythe tests are run in contrib, but i need to do more work to get them to turn up in the ui
10:51dnolenrhickey: actually you're right. sorry, I'm trying to figure out a way return a fn where elsewhere I want to know something about this fn (but can't because I need metadata about it). Keeping a reference to this fn is not viable because it is temporary and there will be a lot of them.
10:51dnolenis there a good way to fake metadata on fns that I'm just not considering?
10:51AWizzArdSo, is there no serious interest in (completely optional but fully functional) static/gradual typing?
10:52jsankeyif you like, you can hit the login link in the top right corner, and the signup link to get an account
10:53jsankeywith an account you can subscribe to email notifications
10:53Chouserdnolen: I think there are a couple somewhat hacky options.
10:53dnolenChouser: I'm all ears if it can be done without creating a Java class ;)
10:54Chouserdnolen: you could have the function take an unusual number of args to return the "metadata"
10:54stuhoodrhickey: request: don't make them feel too ashamed of their implementations =)
10:54Chouserdnolen: (fn ([x] ..normal code..) ([_ _ _ _ _ _] {:some :metadata}))
10:54dnolenChouser: unfortunately this is for the cl-cont port, so using the number of args isn't doable :(
10:55Chouserwhat's cl-cont?
10:55dnolendelimited continuations for common lisp, I'm porting it Clojure.
10:55rhickeydidn't we recently talk about proxy AFn - then you can pass metadata to ctor
10:56dnolenrhickey: ooh, is this a thread I missed on the list?
10:57AWizzArdrhickey: btw, I think the money-making part with Clojure is just a question for time. I think first Clojure users will profit, and with some delay, you.
11:01rhickeydnolen: was here on IRC but I can't find it
11:02dnolenrhickey: thx for looking, will give a shot at figuring it from the docs, don't mean to distract from slide work.
11:03cgranddnolen: http://clojure-log.n01se.net/date/2009-02-20.html#11:18a
11:04rhickeyuser=> (def f (proxy [clojure.lang.AFn] [{:my :meta}] (invoke [] 42)))
11:04rhickey#'user/f
11:04rhickeyuser=> (f)
11:04rhickey42
11:04rhickeyuser=> ^f
11:04rhickey{:my :meta}
11:04dnolenfantastic thanks!
11:07Chouser(def f (clojure.lang.Var/create (fn ([x] (inc x)) ([x y] (+ x y)))))
11:07Chouser(f 4) ==> 5
11:07Chouser(f 10 5) ==> 15
11:07Chouser(alter-meta! f assoc :foo :bar) ==> {:foo :bar, :ns nil, :name nil}
11:08rhickeyChouser: hrm - breaks fns as values, since vars aren't values
11:08ChouserI just hope I'm not idicted for var-abuse
11:08rhickeyguilty!
11:08rhickeyI'd rather see with-meta throw than see that
11:09rhickeyis after-the-fact with-meta needed for most fns when people say they want fn metadata? if not, supporting meta on construction is pretty easy
11:10ChouserI see, because I'm mutating to get new metadata, or to change the fn inside. :-/
11:13brianh2rhickey: hopefully the (makes-money clojure) has at least supplied you with enough caffeine (or stimulant of choice) to see this thing through...???
11:19rhickeyChouser: have you got a DOT file for your Clojure chart?
11:19Chouseryes, but I think they're all missing future.
11:20rhickeyit might help me with my slides
11:20rhickeyrather than recreate in OmniGraffle
11:20Chouserhttp://github.com/Chouser/clojure-classes/blob/d79f20fbd3b5bddbee0520afb7b3871953e949c8/graph.dot
11:21Chouserthat's the dot file, but I can run a new one to make sure it's up to date
11:21Chouseryou'll be adjusting it in omnigraffle?
11:22rhickeyprobably just using subsets of it - it's huge
11:23Chouseryeah
11:24Chouserlet me run you a new one with future and with LazySeq not extending AFn
11:25rhickeyok
11:25rhickeyOmniGraffle pulls it in fine - cool
11:27Chouserupdated .dot: http://github.com/Chouser/clojure-classes/blob/master/graph.dot
11:28rhickeyooh, and it lets me do ancestors/descendants selection
11:28rhickeyChouser: thanks!
11:29Chouseryou're quite welcome.
11:47karmazillalittle experiment with code readability: http://github.com/karmazilla/literate-clojure neat or horrible?
11:53rsynnottkarmazilla: whatver about the syntax itself (I don't really see the point), you spelled 'literally' wrong :)
11:53karmazillatoss! I knew I should have looked it up
11:55ChouserI haven't found the arguments for using things before they're defined to be particularly compelling, so I'm not your target audience.
11:57karmazillaUncle Bob notes in passing in Clean Code that Logo uses TO to define functions and that it has an interesting effect on how functions are defined and named, and I wanted to explore that a bit
11:58karmazillabut the example may be too contrived to judge
12:11replacakarmazilla: I would claim that this isn't really "literate programming" in the accepted definition of creating something that can be part of a document as well as being a program.
12:13karmazillaI know I'm taking a pretty big liberty in using that word :)
12:14duck1123should I be copying clojure-slim.jar into my project as well?
12:15duck1123I've been spending the day setting up an ant script to compile and set up everything I need
12:15karmazillaIt picked it on a whim thinking that the webbing might be introduced later if I cared
12:19rhickeyChouser: question on the chart - would it be possible to get one without the [legends] and with those classes in (IMeta, Counted etc) the mix?
12:20Chouseryes
12:20rhickeythanks, since I'm subsetting I can handle those
12:21Chouserok. no [badges] at all?
12:21rhickeyright
12:23lisppaste8Chouser pasted "graph-nobadge.dot" at http://paste.lisp.org/display/77275
12:25ChouserI can leave out predicates or add in ctor fns too, if you want.
12:29rhickeythanks - that one crashes OmniGraffle: *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: badges)
12:30rhickeycould be on their side
12:30Chouseroh. well...
12:34lisppaste8Chouser pasted "graph-nobadge2.dot" at http://paste.lisp.org/display/77276
12:35rhickeyChouser: fantastic - thanks again!
12:41Chousercan a Java class have to methods that differ only in their return value?
12:41Chousertwo
12:41jsankeyChouser: return type? no.
12:41Chousersorry "type", yes. ok.
12:49Chouserbut a derived class can override a method that is the same in every way except a derived return type.
12:50pjstadiga subclass can change the return type of a method as long as the new return type is a subclass of the old return type
12:52Chouseryes, ok. but .getMethods will show both
12:56karmazillawill it only show one if the return type were the same?
12:58Chouseryes, apparently. Or if the derived class specifies a superclass return type.
12:59jsankeycovariant returns are only supported in java 5 onwards (if it matters)
13:00Chouserclojure only supports 5 onward, so I don't need to look up "covariant" again.
13:00jsankeyand afaik you can't do contravariant (return a supertype) at all
13:02rhickeyjsankey: contravariance is usually only for args
13:02jsankeyyes, indeed
13:03jsankeycovariant returns, contravariant args, but not the other way around
13:08marklarI'm trying to port a java game to Clojure, and am running into a problem with a class that handles the drawing surface. In Java, the constructor registers the class to handle the callbacks for the drawing surface. I'm at a loss since there is no 'this' to reference in the :init function. How could I handle this?
13:09Chousermarklar: issue and patch for :post-init here: http://code.google.com/p/clojure/issues/detail?id=45
13:09marklarChouser: ah, thanks
13:10marklarthat looks perfect, thanks again
13:10Chouserbut without that you could still provide a function that everyone promises to use to construct your class
13:11Chouserthat fn would do the (new MyClass) and then do any post-init work
13:12marklarChouser: I think I will look at the patch, since there are several different classes that will run into this problem
13:12ChouserIt's also possible that rather than gen-class and (new MyClass) you might be able to get away with just proxy, which doesn't require an AOT step.
13:12marklarIts android, so AOT only afaik
13:12Chouseroh ok
13:12marklarChouser: Thanks again!
13:12Chousernp
13:20triddellmarklar: just curious, how is clojure working/performing for you on Android? I'm thinking about diving into Android myself and was wondering whether I should use clojure or just stick to java.
13:21triddellmarklar: is the fork of clojure still required? is was when I first looked into it.
13:23RaynesAs far as I know Clojure is fine on Android, I hear a lot of people talking about it.
13:24ChouserI assume you still have to comment out 'bean'?
13:26triddellThere is a fork at: http://github.com/remvee/clojure/tree/master which seems to stay current with the necessary android mods
13:30RaynesWhat is so hip about Android ._. I want it.
14:16Lau_of_DKHey guys
14:16durka42hi lau
14:16blbrown_ltwhat is up homie
14:20ozzileeI'm having trouble trying to get a Compojure app to run on Tomcat. I think I've got Tomcat set up correctly (5.5, on Debian), I deployed the war, but trying to pull up the app I only get a 404.
14:21ozzileeI copied the instructions at wikibooks exactly: http://en.wikibooks.org/wiki/Compojure/Getting_Started
14:21ozzileeAnybody else get that example to run?
14:21Lau_of_DKozzilee, The hardest thing I've found about compojure, is that no-one ever answer my questions regarding it. I suggest your scour the wik/group :)
14:22ozzileeLau_of_DK: Heh, bugger. I'll commence searching...
14:22Chouserasking on the compojure google group may be your best bet
14:23Lau_of_DKoh right, why didnt I think of that...
14:23ozzileeYeah, I'll give that a shot if I can't find anything.
14:30danlarkinsee... if you were using madison you'd have me to answer your questions!
14:32Lau_of_DKdanlarkin, how DO you get Madison Square Clabango up and running om a Tomcat 5.5 ?
14:32danlarkinummmm proxy it to jetty
14:33stuhoodlol
14:33rsynnottwhat is clabango, exactly?
14:34Chouser~eveyone wanted another web framework, and suddenly
14:34clojurebotCLABANGO!
14:34Chouser~clabango
14:34clojurebothttp://www.clabango.com/
14:35rsynnottI saw that site
14:36rsynnottit's rather unhelpful :)
14:36rsynnottbut yes, web framework
14:36rsynnottyay!
14:36rsynnottcan never have too many
14:36Chouserhttp://github.com/danlarkin/madison/tree/master
14:37danlarkinprogress coming, I promise! been busy IRL lately
14:38rsynnotthmm, is it run inside a web server, or does it run its own?
14:39danlarkinmadison? it uses ring, which uses jetty
14:39Lau_of_DKclojurebot clabango is http://github.com/danlarkin/madison/tree/master
14:40Lau_of_DKclojurebot: clabango is http://github.com/danlarkin/madison/tree/master
14:40clojurebotRoger.
14:40Lau_of_DKnoob
14:40Lau_of_DK...
14:40danlarkinbut I think the idea for ring is that it should support other containers.. or whatever they're called
14:40rsynnottah, NOW you're in trouble
14:41rsynnottah, cool
14:42rsynnottwhy's it called madison and/or clabango?
14:42rsynnott(the art of library naming was one I never aquired)
14:42Lau_of_DKhehe
14:42Lau_of_DKAllow me to explain
14:43Lau_of_DKDanlarkin had this cool project going, but he didnt have a name, it was a port of Django so I suggested Clabango - Dan wasnt happy, so he postponed the upload for something like 2 months, because he didnt have a name for it
14:43Lau_of_DKSo I started telling everybody that it was called Clabango, and that it was coming right up (you know, just to put the pressure on him)
14:43Lau_of_DKThen he finally names it Madison - uploads it, and hides for a few days
14:44danlarkinhahah
14:44Lau_of_DKDuring those few days, I constantly refer to the project as Madison Square Clabango
14:44Lau_of_DKAnd its really catchy, so people pick it up and start thinking that its the name for the project.
14:44Lau_of_DKSo thats the story of Clabango... :)
14:45rsynnottah :)
14:46kotarak~and suddenly...
14:46clojurebotCLABANGO!
14:46rsynnottwhat, precisely, are us cl people supposed to call our potential django clone, then?
14:46rsynnott:)
14:46Lau_of_DK... Madison Square Clabango ofc
14:46p_lrsynnott: COMMON-LISP-BANGO
14:47p_lrsynnott: COCOJAMBO sounds nice too ;-)
14:47Lau_of_DKCOCACABANGO
14:48p_lanother nice name would GTFO to comply with LOL/LMAO/ROFL/WTF/FTW combo
14:48p_l*would be
14:48Lau_of_DKBut dan, consider this, night after night, we sit here joking about Clabango - GRAB THE NAME!!
14:48danlarkinhaha
14:48danlarkinbut it's not a good name!
14:48Lau_of_DKIts the BEST name
14:49triddelldanlarkin: to complete the story... why Madison?
14:50rsynnottno, COCACABANGO would be a terrifying ObjC django clone
14:50stuhoodhahaha
14:50p_lrsynnott: ... I think I just hit the nail on how full package of Lisp-on-lines and related stuff should be called. ``/b/''
14:50danlarkinwhy madison? I suppose it just sounded nice to me
14:51triddellCOCACABANGO needs a Barry Manilow theme song
14:51rsynnottfortunately, nobody has ever used lisp-on-lines
14:51Lau_of_DKWhat is lisp-on-lines?
14:51rsynnottis was created just to annoy the the reddit people
14:51rsynnottwell, exactly
14:51rsynnottpseudo-ruby-on-rails library for common lisp, never used for anything
14:51triddelldanlarkin: ok, cool... didn't know if you were from there... had a child named that, etc.
14:52Lau_of_DK~sofiaba?
14:52clojurebotsofiaba is http://wiki.github.com/Lau-of-DK/sofiaba
14:52Lau_of_DKtriddell, Thats named after a child :)
14:52p_lrsynnott: well, wasn't it actually in production for few years, except never released? :D
14:52kotarak"Oh Mandy, you gave without taking..."
14:53triddellLau_of_DK: saw that one day here... very nice
14:53triddellLau_of_DK: are you an Ubuntu user?
14:53Lau_of_DKyea
14:54Lau_of_DKNot by free choice, its company policy, and Arch lacked the drivers for my new laptop :(
14:55triddellcheck this out: http://riddell.us/tutorial/slime_swank/slime_swank.html ... two other tutorials are linked to in the top section... I thought I might also add a tutorial for Git/Egg in the future.
14:55p_lLau_of_DK: anyway, the author had a lot of fun with names. Lisp-on-Lines, Relational-Objects-For-Lisp, I don't remember what MAO standed for, Working-Test-Framework, FTW was the name for proposed package manager for cl libraries...
14:55Lau_of_DKah ok
14:55Lau_of_DKtriddell, Git/Egg is phat
14:57triddellLau_of_DK: yep, I'm liking it as well... any other emacs goodies you use frequently? I used muse to author those tutorials and I've also checked out the emacs-android stuff which I might write up
14:58Lau_of_DKtriddell, Org-Mode, Egg, Clojure-mode, jfly-2, dabbrev-expand and yasnippit2 will get you along ways :)
14:59triddellLau_of_DK: I've done a bit with org-mode... thx for the tips on the others
15:00Lau_of_DKno probs :)
15:14jhawk28Clabango is a catchy name, but not sure I could sell it as a serious framework to my management
15:14ChouserMSC (TM)
15:14jhawk28MSC maybe
15:14jhawk28sort of like Apache POI
15:15jhawk28and HSSF
15:15cmvkkdo closures close over locals that they don't refer to?
15:16rhickeycmvkk: no
15:16cmvkkthanks.
15:17replacaLau_of_DK: Egg is superior to magit? I've been holding off really learning an emacs interface to git, but I need to pick one and learn it.
15:17rhickeycmvkk: to your question last night about lazy-seqs and threads - they are completely safe for simultaneous access from multiple threads, all of which will see the same thing, and the generating fns will be called only once per node
15:18cmvkkthanks. that should be very helpful
15:18Lau_of_DKreplaca, Yes, Egg is a fork of magit, and on top of that fork Bololisk has built a very nice UI - so the UI is the major difference
15:18Lau_of_DKSidenote: He's very quick to get back to you if you mail him with questions/suggestions
15:19replacaLau_of_DK: Thanks! Is the UI conatined in the egg package itself or separate?
15:25pjstadigdanlarkin: if you're not using the clabango name because you want the website, i'll give it to you
15:25pjstadigit's really too cool of a name to lay unused
15:25danlarkinwhy not make clabango the flagship app using madison
15:26pjstadigi'll have to do something with the site (and name if you don't)
15:26pjstadigmaybe i'll come up with an idea and it'll be the name of my startup
15:26jhawk28does it have an admin interface yet?
15:27danlarkinjhawk28: no
15:38Chouser(.foo x) when x is unhinted could be meant to refer to either an instance field or an instance method
15:39rhickeypublic instance fields are pretty rare
15:39Chousercurrently it's always analyzed as a InstanceFieldExpr, but at runtime will use reflection and may discover it's a method, and call that.
15:41Chouserwith this new analysis code, it can discover at compile time that the only member named foo in any imported class is a field
15:41danlarkinoooooo
15:42Chouserdanlarkin: don't get too excited, there's a long way to go before this can be used. :-)
15:42Chouseranyway, to allow this, I've got all instance-like exprs running through the same code path
15:43rhickeyyou'll never be able to elide the slow path in case the type you've inferred isn't what you got
15:44Raynesrhickey: You should grow a beard. :)
15:44Chouserbut that means that (. x (foo)) may be analyzed as an instance field. Is that unacceptible?
15:44durka42what if i haven't imported (class x)?
15:44rhickeyRaynes: unlikely
15:45RaynesHistory says you'll be totally successful if you do, but you're doing a damn good job at that already :D
15:45rhickeyChouser: hmm, that's the one way to force the issue when you've got both and want the method
15:46Chouserrhickey: hm, good point about keeping the slow path. Does that mean I still need to note exact (as opposed to unambiguous) matched methods?
15:46rhickeybut if public fields are rare, public field and method of same name are rarer
15:46rhickeynot sure what you mean exact vs unambiguous
15:47Chouserjust had an idea for threading a must-be-method indicator through -- might not be as bad as I was thinking.
15:47dnolencurious in the future will Clojure support Common Lisp control structures like go, tagbody, block, return-from etc?
15:48dnolenin fact is there any way to exit a fn early?
15:48Chouserexact meaning I don't need a slow path emitted, vs. unambiguously finding a single auto-hinted solution that matches but still requires a slow-path just in case.
15:48Chouserdnolen: throw or something built on throw
15:49rhickeyChouser: how could you not emit a slow path - duck typing is still possible
15:49dnolenChouser: throw is slow tho right? so not something you generally want to use?
15:49Chouserrhickey: (.length #^String s) <-- exact match, so no slow path needed?
15:50WizardofWestmarcman, be away for a few days and find out DanLarkin released his framework and I missed it >(
15:50rhickeydnolen: no way to exit early, structured programming only, and yes, exceptions for normal flow control considered bad
15:50rhickeyChouser: oh, that's hinted, so not inferred at all
15:50Chouservs. (.readLine x) where java.io.BufferedReader has the only match, but still need slow path.
15:51dnolenrhickey: thx, a lot of things I don't have to worry about then.
15:51rhickeyChouser: I was only talking about cases where you are guessing the type based on imports
15:52rhickeyChouser: You seem to be skipping ahead a bit if you are up to this already - one thing to think about is something I had early on, which was inference flowing both ways - not only what types could be generated by the caller, but what were desired by the receiver
15:53Chouser(.compareTo x #^Enum y) will guess exactly one fast-path but require a slow path as well. (.compareTo #^Enum x y) doesn't require slow path? Or do I need (.compareTo #^Enum x #^Enum y) to avoid slow path.
15:54rhickeyslow path is strictly about guessing type of 'this'
15:54rhickeyIf you are told, no guess
15:55Chouseryeah, I may be getting ahead of myself, but I needed getMatchingParams and realized there were plans to change related behavior so off I went...
15:56rhickeyit will be hard to validate the new compiler if it has new semantics as well, maybe better to wait until after parity with current is achieved and we switch over
15:58Chouserthat's what user codebase is for!
15:58rhickeyI have ideas about emitting a specifically-typed invoke in addition to the object one, metadata will let the compiler see it and use if it has matching args. This will allow for fast fns taking primitives
15:59rhickey(defn #^float foo [#^float x #^float y] ...) yields float invoke(float,float) as well as Object invoke(Object, Object)
16:00Chouserdoes that have implications for re-def'ing foo?
16:00rhickeyyes
16:00rhickeyso would changing arity though
16:01pjstadigChouser: what are you working on?
16:01RaynesHe's working on the Chouserbot of death.
16:02Chouserpjstadig: playing at rewriting Compiler.java in clojure.
16:02pjstadigah
16:02pjstadigi thought that might be it
16:02pjstadigsweet!
16:02Chouserit's a fantastic learning exercise, and it eventually gets used for something, all the better. :-)
16:03Chousers/and/and if/
16:07Chousertossing this guessing code and replacing it with a more rote translation of the .java is unappealing.
16:10StartsWithKwhat would be a best way to do a deep merge on maps? {:a {:b 1}} {:a {:c 2}} -> {:a {:b 1 :c2}}
16:12WizardofWestmarcStartsWithK: merge-with not do what you need?
16:12WizardofWestmarchaven't tried it for deep ones so not sure
16:12StartsWithKWizardofWestmarc: no, if :a exists in bot maps it will use only value of second map
16:13StartsWithKso you'll get {:a {:c 2}}
16:13WizardofWestmarcah ha
16:13WizardofWestmarcright
16:13cmvkk(merge-with merge ...) would do it for one layer i think
16:13cmvkkfor two layers: merge-with merge-with merge
16:13cmvkkmaybe?
16:14cmvkk,(merge-with merge {:a {:b 1}} {:a {:c 2}})
16:14clojurebotjava.lang.NoClassDefFoundError: clojure/core$merge_with__3866$merge_entry__3868
16:14StartsWithKfor two layes i do destructuring on keys (works ok for know keys) and then merge submaps
16:14cmvkkwhat's wrong with clojurebot?
16:14StartsWithKcmvkk: thanks, that works for one level
16:15StartsWithKi don't need deeper than that
16:15StartsWithKbut it would be nice if something like that would exist
16:15cconstantineIs there a method like (some) that returns the position in the sequence instead of the element?
16:16StartsWithKcconstantine: (first (filter ...))
16:16cmvkkthat won't return the position though
16:16cconstantineStartsWithK: will the (rest (first (filter ...))) have the filter applied?
16:17StartsWithKcconstantine: only to coll given to filter
16:18cmvkk(rest (first (filter ...))) is probably not what you want.
16:18WizardofWestmarccan't believe I forgot to install clojure until now
16:19cconstantineI don't want the filter after I've found the location that matches my constraints
16:19cmvkkare you saying you want the index of the first item that matches your predicate?
16:19cconstantine(first (filter ...)) appears to be the same as (some ...)
16:20cconstantinecmvkk: I want the sequence object that contains the element that matched my predicate
16:20cconstantinethe sequence object who's (first ...) matched the predicate
16:20Chouser(defn deepmerge [f & ms] (apply (fn m [& ms] (apply merge-with (if (every? map? ms) m f) ms)) ms))
16:20Victorrhi, is there a Clojure irc bot yet?
16:20Chouser,(println "nope")
16:20clojurebotnope
16:20pjstadigclojurebot: introduce yourself
16:20clojurebotHuh?
16:20pjstadigbah
16:21Victorr,help
16:21clojurebotjava.lang.Exception: Unable to resolve symbol: help in this context
16:21Victorr:-)
16:21Victorr,(help)
16:21clojurebotjava.lang.Exception: Unable to resolve symbol: help in this context
16:21kotarak,(doc doc)
16:21clojurebot"([name]); Prints documentation for a var or special form given its name"
16:21cconstantineChouser: was that for me?
16:21cmvkkoh i see constantine, you want to drop elements from a seq until you get to one that matches your predicate.
16:22cconstantinecmvkk: yes :)
16:22kotarak(drop-while (comp pred) the-seq)
16:22StartsWithKChouser: dosn't work for all combinations
16:22StartsWithK(deepmerge {:a {:b {:c 1 :d 2} :e 3} :f 4} {:a {:b {:z 3 :c 2}}})
16:22Chousercconstantine: no, that was for StartsWithK
16:22Chousercconstantine: this is for you:
16:22cmvkkwow
16:22Chouser(some #(and (= (first %) 'd) %) (iterate next '(a b c d e f)))
16:22StartsWithK{:a {:b {:z 3, :c 2}}}, no :d
16:22cmvkkkotarak, i was about to say i didn't think there was a builtin that could do that...
16:23cmvkkthere's builtins for everything
16:23Chouserkotarak: nice
16:23kotarakuh? Or was it complement?
16:23kotarak(doc complement)
16:24clojurebotTakes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value.; arglists ([f])
16:24cconstantineChouser: so that wrapps my sequence in another one and the 'element' returned is the location in sequence I want?
16:24kotarak(drop-while (complement pred) the-seq), then
16:24Chousercconstantine: yeah, but listen to kotarak. his is better.
16:25cmvkk,(drop-while (complement number?) [:a :b 1 2 3])
16:25cconstantineChouser: hehe, ok :)
16:25clojurebotjava.lang.NoClassDefFoundError: clojure/core$drop_while__3810$step__3812
16:25cmvkkclojurebot is choking on all of my input today
16:26cconstantinekotarak: so, is (complement pred) called when iterating through the result of that drop-while?
16:26cmvkk(complement pred) is called on each element of the input seq.
16:27kotarakcconstantine: (complement pred) returns a function, which is - well - the complement of the pred. This functions is applied to the elements of the sequence.
16:27cconstantineI think I just need to test this with a (println)
16:27kotarakcconstantine: *meeep* !!! PROBLEM AHEAD !!!. drop-while is lazy. So take care to use dorun or doall to force the sequence.
16:27cconstantineor, rephrased: is 'pred' called after drop-while finds the first element to return?
16:28kotarakcconstantine: pred is called to find the first element to return.
16:28cconstantinekotarak: ah, but the sequence is infinite :)
16:28cmvkkbetter make sure something in it matches your predicate, then...
16:29cconstantinecmvkk: I've been playing that kinda game all day :)
16:29kotarakcconstantine: well if there is no element satisfying pred..... good luck. :)
16:29cconstantineI like living on the edge
16:29kotarakcconstantine: cmvkk's example above will return (1 2 3)
16:29cconstantineand, when I'm done here I should have a fast prime number generator :)
16:30kotaraknumber? will be called on :a, :b and 1.
16:30cconstantineyeah
16:30ChouserStartsWithK: (defn deepmerge [f & ms] (apply (fn m [& ms] (if (every? map? ms) (apply merge-with m ms) (apply f ms))) ms))
16:30Chouser(deepmerge + {:a {:b {:c 1 :d 2} :e 3} :f 4} {:a {:b {:z 3 :c 2}}})
16:31StartsWithKChouser: thanks, works, and now.. put in core.clj :)
16:32StartsWithKmaybe seq-utils in contrib?
16:32StartsWithKi think that one will be needed by someone
16:32Chousermore of a map util, isn't it?
16:33Chouserhey look at that -- a map-utils
16:33StartsWithKyes, is there such a thing as a map-utils
16:34StartsWithKfor now i didn't need to use contrib after lib was integrated with core
16:35StartsWithKmap-utils :) hehe, you have it all
16:39StartsWithKwhat is a criteria for entering contrib?
16:39StartsWithKwrite access to repo?
16:39StartsWithKor lib needs peer review
16:39kotarakIt should at least be discussed on the list.
16:41StartsWithKwell, this is personal interest, i have a cell implementation, how did dataflow get in contrib
16:41kotarakI think, it had Rich's blessing.
16:41StartsWithKi think that was datalog
16:41Chouserif you don't have write access to contrib, bring it up on the google group, ask for it to be included in contrib.
16:43Chouserif someone with write access wants it, they'll ask you to make an issue, so then make sure your CA is in and create a contrib issua and attach your code. whoever asked for it should then move it into contrib.
16:43StartsWithKi see
16:43Chouseror perhaps rhickey will give you write access and then you can do it yourself.
16:44kotarakThere is a growth of math stuff lately. Maybe this could be more organised? clojure.contrib.math clojure.contrib.complex clojure.contrib.probabilities.dist ....
16:44StartsWithKi didn't ask this for libs in general, but as i started new code for neman.cells, i looked what can other three implementations do
16:44StartsWithKto see what others are doing
16:45StartsWithKand, dataflow, like neman.cells can't be used for anything at this stage
16:45StartsWithKso, if i for instance request inclusion of neman.cells in contrib, how will they be judged
16:46ChouserThere's no set policy on that kind of question, as far as I know. These things just have to be worked out as we proceed.
16:47StartsWithKmaybe for larger libs (that are not directly aproved by rich) something like boost peer review should be done
16:48StartsWithK2-3 people to use it in the wild for at least day or two
16:49ChouserI assume more formal structure will have to be introduced eventually, but when and what it should look like I have no ida.
16:50StartsWithKhmm.. i know, to early for formalisation
16:50kotarakChouser: If clojure.contrib keeps to be advertised as idiomatic Clojure, it should have some form of quality assurance, I think.
16:51kotarakBut don't ask me when, how, what, ....
16:51Chouser:-)
16:51StartsWithKwhen i first presented neman.cells here, few people asked to be moved to contrib, i sad it needs more work (and it realy needs more work)
16:52kotarakAnd it should have some form of control what goes in. I would hope for some community approval process. But the reactions on the contrib->core survey takes away all illusions....
16:52StartsWithKbut even then it had more than datalfow, so you see why im confused how something like that entered
16:52kotarakStartsWithK: which module is dataflow in?
16:53StartsWithKkotarak: ns clojure.contrib.dataflow
16:53kotarakOk. May copy is outdated it seems.
16:54StartsWithKim looking with googles svn browser
16:54ChouserStartsWithK: there have now been a small handful (2? 3?) cases where a contrib lib and a non-contrib lib could be said to be competitors. Presumably this will happen more in the future, and it does seem desirable to have a good process for resolving that.
16:54kotarakOne time someone said, he uploaded "an experiment" to contrib....(IIRC) I think that should not be the way to go.
16:55Chouserresolving either by including all such competitors that want to be in contrib, merging their features, or something.
16:55StartsWithKChouser: right, don't get me wrong, i don't care if i 'win', thers not much to win, but this in a way looks like artifular monopolly
17:00Chouseryes, the appearance of fairness is important
17:00Chouserer, I mean, fairness is important.
17:00danlarkinbut not fairness itself :)
17:00waltersheh
17:01StartsWithK:)
17:08Mecis there a simple way to flatten a list of maps into 1 map?
17:09StartsWithKMec: merge, merge-with, or deepmerge
17:09Chouserheh
17:09StartsWithKis deepmerge in map-utils :)
17:09Mecthanks
17:10WizardofWestmarcneed to double check but reduce merge-with should work
17:11Meci dont see a deepmerge but merge will work
17:11Mecapply merge unless merge is a macro
17:11StartsWithK<Chouser> StartsWithK: (defn deepmerge [f & ms] (apply (fn m [& ms] (if (every? map? ms) (apply merge-with m ms) (apply f ms))) ms))
17:12StartsWithK<Chouser> (deepmerge + {:a {:b {:c 1 :d 2} :e 3} :f 4} {:a {:b {:z 3 :c 2}}})
17:12StartsWithKjust created :)
17:13Chouserit's called deep-merge-with in contrib.map-utils
17:15Mecif a function takes & args, then shouldnt passing a list and passing a bunch of args work the same?
17:15StartsWithKno
17:15Mecsomething's not clicking right
17:15StartsWithK(apply f '(1 2 3)) if f takes & args
17:16Mec,((fn [& args] args) 1 2 3)
17:16clojurebot(1 2 3)
17:16Mec,((fn [& args] args) '(1 2 3))
17:16clojurebot((1 2 3))
17:16StartsWithK& args will make args a sequence, so (f '(1 2 3)) will get one argument ((1 2 3)), sequence with one element that is a list sent
17:16Mecah
17:26Raynes((fn [x & args] (reduce + (conj args x))) 3 1 2 3 4)
17:26Raynes,((fn [x & args] (reduce + (conj args x))) 3 1 2 3 4)
17:26clojurebot13
17:26RaynesAlways forget that darn comma. :\
17:31tbbhi guys
17:32tbbwhat would be the preferred way of splitting a namespace into multiple files (:load-resources, load-file, etc.)?
17:38Lau_of_DKtbb, I guess that depends on what you prefer - I use (:load "debug") for instance - but not because of careful consideration - it just works :)
17:39erohtaris there any way to know what version of clojure is needed for the latest clojure-contrib
17:41tbblau_of_DK, that works great, i was actually looking for something like that :)
17:41Lau_of_DKcool
17:41tbbfits my asdf way of thinking i guess :)
17:42kotarakLau_of_DK: (:load "foo") is the Right Way. ;)
17:45WizardofWestmarc...I just looked to see what you guys had put on Clabango.com
17:45Lau_of_DKhaha :)
17:45Lau_of_DKGood ol' pjstadig
17:46erohtarchouser: u there?
17:46WizardofWestmarchere I figured it'd be pointing at http://github.com/danlarkin/madison/tree/master
17:46Lau_of_DK~clabango?
17:46clojurebotclabango is http://github.com/danlarkin/madison/tree/master
17:46WizardofWestmarchah
17:47WizardofWestmarctonight I may have to download and play with it
17:47Chousererohtar: a bit
17:47erohtarchouser: ok - i will try to be brief - how do you keep up with versions of clojure vs clojure-contrib ?
17:48ChouserI almost always have the latest clojure and contrib.
17:49Chouseron the rare occasion that clojure has breaking changes, I may hold back updating it and contrib until the things I need from contrib are up to date with clojure, then update both
17:49erohtarchouser: is there a quick way to test their compatibility? some tests or something?
17:49hiredmanclojurebot: latest?
17:49clojurebotlatest is 1335
17:49hiredmanhmmm
17:50Chousererohtar: well, there's clojure.contrib.test-contrib, but I can't say I rely on that.
17:50Chouserbreaking changes in either clojure or contrib are pretty rare, so most likely if your clojure is up to date you'll be ok.
17:51Chouserif you try to update contrib without clojure, you may have a feature mismatch, so I keep clojure very up to date and contrib nearly so.
17:52digashi am off to see Rich at http://semweb.meetup.com/25/calendar/9016252/
17:53Chousercool
17:53hiredman:D
17:53digashclojure with semantic web, sexpy combination.
17:56WizardofWestmarcoh man semantic web and clojure? I REALLY hope that's getting taped, at least audio
18:04erohtarim getting this strange error - unable to resolve symbol: frest
18:04erohtarchouser: im getting this strange error - unable to resolve symbol: frest
18:06Chousukeit has been renamed
18:06Chousuke(doc fnext)
18:06clojurebotSame as (first (next x)); arglists ([x])
18:09Raynes,(next [1 2 3])
18:09clojurebot(2 3)
18:10RaynesNext replaced rest? O.o
18:10RaynesI guess I missed that part of the memo.
18:10Raynes(doc rest)
18:10clojurebotReturns a possibly empty seq of the items after the first. Calls seq on its argument.; arglists ([coll])
18:10kotarakRaynes: http://clojure.org/lazy
18:11RaynesI know about the switch to fully lazy sequences.
18:11kotarakRanyes: rest may now return (), next will still return nil
18:11RaynesI noticed.
18:11Raynes:p
18:12kotarakOk. Then I don't understand your remark. Sorry.
18:12RaynesNo, I mean, I just noticed.
18:12RaynesI was messing with it in my REPL.
18:12RaynesI got confused about which he said was which when I read it.
18:14danlarkinWizardofWestmarc: I'm heading out for a bit but I'll be back later on if you have questions about madison
18:14WizardofWestmarcdanlarkin: \m/
18:14WizardofWestmarcit'll be a while as I have to get off work first
18:15WizardofWestmarcthe downside to MST, most of the country gets off work before I do ;-)
18:16danlarkinit's okay, you get to sleep later :)
18:16WizardofWestmarctrue
18:16WizardofWestmarcexcept for those dirty California hippies <_<
18:29stuhood,(let [intrange (range 0 10000)] (doseq [anint intrange] (+ anint anint)))
18:29clojurebotnil
18:29stuhoodthat will "hold onto the head", right?
18:30stuhoodbecause the let is still holding the original seq?
18:30kotarakstuhood: I would think so.
18:30stuhoodugh... it bit me =(
18:30stuhoodkotarak: thanks
18:35stuhoodso is the only solution to define the sequence within the doseq?
18:35stuhoodor use (recur) instead?
18:38kirisis Clojure interpeted by Java or does it compile directly to the JVM (I'm pretty sure it's the latter)
18:38stuhoodkiris: compiled to JVM bytecode
18:38kirisso there's no intermediate Java layer?
18:39kotarakno
18:39kirisI didn't think so
18:39slashus2stuhood: In that code, do you need to hold on to the original sequence?
18:40stuhoodslashus2: no, i don't
18:41stuhoodslashus2: so i suppose i could just define the sequence in the doseq... but i find that binding a few locals cuts down on nesting and makes things easier to read
18:41slashus2(doseq [anint (range 0 10000)] (+ anint anint))
18:41slashus2like that?
18:41stuhoodyea... that would work
18:42slashus2Don't really need the zero there.
18:42stuhoodexcept that the (range) example is much shorter than the real code
18:43kotarakstuhood: you can make a function returning the seq. (let [intseq #(range 10000)] (doseq [anint (intseq)] ...))
18:43stuhoodhmm, yea... that's an interesting approach
18:44stuhoodthe bug will still catch people at least once or twice
18:44slashus2What is causing the bug?
18:45kotarakstuhood: yeah, laziness has its issues, but I don't want to miss it anymore.
18:45kotarakslashus2: It's not really a bug. More a gotcha.
18:45stuhoodslashus2: the fact that (let) holds onto the head when it is no longer needed
18:47stuhoodfor instance, if (let) was implemented as a macro, you'd want it to inline the definition of the sequence if it was only being used once
18:55WizardofWestmarclater guys
18:56erohtarwhat is the replacement of rrest in the latest clojure?
18:57kotarak(doc rnext)
18:57clojurebotIt's greek to me.
18:57kotarakhmmm
18:57erohtar,(doc rnext)
18:57clojurebotjava.lang.Exception: Unable to resolve var: rnext in this context
18:57kotarak(doc nth-next)
18:57clojurebotexcusez-moi
18:57kotarak(doc nthnext)
18:57clojurebotReturns the nth next of coll, (seq coll) when n is 0.; arglists ([coll n])
18:58kotarak,(nthnext 2 '(1 2 3))
18:58clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
18:58spacema__erohtar: man, you gotta start putting line breaks into capjure =]
18:58kotarak,(nthnext '(1 2 3) 2)
18:58clojurebot(3)
18:58kotarakIt's getting late... -.-
18:58erohtaryes - yes, i know: :) i will clean it up in the next couple few days and release it properly
19:00spacema__excellent, looking forward to it. I'm still trying to wrap my head around the code, particularly the encoding / decoding bits
19:30duck1123does anyone know what: java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V might mean?
19:31duck1123the trace isn't giving me any files that I could look at
19:31duck1123I just upgraded clojure, clojure-contrib, and compojure and I know a lot has changed since i last upgraded
19:56RaynesGridBagLayout is complicated. :|
19:58RaynesI'll pay the first guy who writes a comprehensive Swing tutorial for Clojure.
19:58RaynesI might even kiss him.
19:59keithbRaynes: GridBagLayout is despised and not used by most Swing experts I know of.
20:00keithbI've found it better to use various layouts in a nested fashion.
20:00Rayneskeithb: Add another one to the list, 'cause I'm not using it.
20:00keithbOh, ok.
20:00blbrownuse SWT
20:00Rayneskeithb: My calculator example uses GridLayout and BoxLayout. \o.
20:00Raynes\o/*
20:00blbrowneverytime I see swing examples, I go, use SWT
20:01keithbRaynes: BorderLayout is extremely helpful too.
20:01Raynesblbrown: You don't know the hell I've been through learning what Swing I know without knowing Java. I'm not doin' it again for SWT ._.
20:01Rayneskeithb: It's my knight in shining armor.
20:02keithbIf anyone's interested, I did a Swing app in Java and ported it to JRuby and Clojure. Articles at my blog at http://krbtech.wordpress.com. There are nested layouts used there.
20:02blbrownJust saying, in a couple of years of swing hell, you will come back to SWT
20:03RaynesI'm interested! :D
20:03keithbblbrown: I used Swing for several years. My feeling is, it has a steep learning curve, but once you've climbed it, it's more full featured than SWT.
20:03RaynesI'm going to write a little notepad replacement for myself using Swing soon. Just for fun. I can use all the examples I can get.
20:04blbrownkeithb, where is that pluggable Swing web browser widget... oh yea, doesn't exist
20:04keithbRaynes: and others...I'm signing off, but if you want to get in touch in the future, I can be reached at kbennett at bbsinc dot biz.
20:04RaynesKay.
20:05keithbblbrown: I'm not saying that Swing is always better than SWT, but my impression is that for serious desktop apps, Swing is better. I know about Eclipse, but NetBeans and Intellij Idea are Swing apps.
20:05keithbI just came from New York today -- yesterday I attended Sun Community One, and the New York Java SIG -- and there were presentations about JavaFX.
20:05keithbInteresting, but not yet very mature, and more a Flash type thing than a Swing type thing.
20:06keithbbye
20:06blbrownwell javafx is a different story
20:14gnuvince_For those interested, I posted the details of my application's performance woes to the Google group.
20:18blbrowngnuvince_, did the hprof stuff help
20:19gnuvince_blbrown: well I found that clojure.lang.Var.deref seems to take a lot of time
20:20blbrowngnuvince_, awesome info. One more question, what args did you run hprof with, because I need to profile an app also
20:20stuhoodalmost everything is contained in a var, right? i think that makes sense
20:21gnuvince_blbrown: -Xrunhprof:cpu=times
20:21stuhoodoooh: i see now. didn't realize the hprof output contained Var.deref multiple times
20:22slashus2gnuvince_: How expensive is one dereference in your experiments?
20:23gnuvince_slashus2: I have not tried it.
20:23blbrownalso from a Java perspective, you want to increase the min-heap/max-heap. and avoid garbage collections.
20:24blbrownnormally Java is slow is when it is doing more garbage collections than it should, so you might want to look at memory usage as well
20:24gnuvince_And when it's within the greater context of the application, Var.deref still is way high up there, even with all the map assoc'ing going around
20:32blbrowngnuvince, are you running off of clojure from subversion (from the source) or the latest build
20:33gnuvince_Subversion
20:33blbrownyea, I was trying to run it
20:35stuhoodgnuvince_: why not be lazy in null-string? i haven't been able to grok how big your buffers tend to be
20:37gnuvince_stuhood: The buffers are fixed at a certain length in the context of my application
20:37gnuvince_(25, 32 and 40 bytes IIRC)
20:37stuhoodgnuvince_: gotcha
20:38gnuvince_And they need to be read completely, otherwise you'll end up with incorrect data for the next fields.
20:38stuhoodgnuvince_: so why not use the bulk get(byte[]) methods to get the length you are expecting?
20:39gnuvince_I could probably try that
20:40gnuvince_But that'll probably not be a big fix to the problem since there are very few (maybe 4-5) strings read and tens of thousands of reads of bytes, words and dwords.
20:40stuhoodgnuvince_: i trust rhickey's primitive support reasonably well, but using a list comprehension on a chars doesn't seem optimal
20:40stuhoodahh
20:40blbrowngnuvince_, do you mind running hprof with the default settings, I was curious what the memory stats were
20:40gnuvince_just -Xrunhprof?
20:42gnuvince_holy schmoly
20:42gnuvince_53,000 lines, 34 MB
20:43blbrowncan you post the bottom, the memory part
20:43gnuvince_You want the percentages?
20:43blbrownyea
20:43gnuvince_http://gist.github.com/82150
20:44blbrownand if you are really interested, if your process takes minutes, you can run jconsole to see memory and execution. http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
20:45blbrownyou also have a memory problem. look at all of that data. 15 MBs for Cons, 8 for anonymous functions, on and on
20:47hjleeare there any method to convert character seq/collection to string?
20:47gnuvince_hmmm
20:47gnuvince_hjlee: (apply str coll)
20:47hiredman(partial apply str)
20:48gnuvince_,(apply str [\h \e \l \l \o])
20:48clojurebot"hello"
20:48hjleethanks!
20:51hjleei'm reading sections in clojure home. after checking "interpose", i want to do something like:
20:51hjlee(apply str (interpose \- "abcde"))
20:51hjlee"a-b-c-d-e"
20:55hiredman,(apply str (interpose \- "abcde"))
20:55clojurebot"a-b-c-d-e"
20:58Chousergnuvince_: greatest-least is in, thanks.
20:58gnuvince_Chouser: thank you
20:59Chousergnuvince_: are you using any of it at the moment?
20:59gnuvince_Not currently no
20:59Chouserok
20:59gnuvince_If you want to hack it, feel free :)
21:01stuhoodgnuvince_: another minor change: you coerce to int in (get-byte), but you should be able to coerce to byte, right?
21:01stuhoodsame in get-short
21:01gnuvince_stuhood: Java's integer types are all signed. The format I analyze uses unsigned integers.
21:04stuhoodgotcha
21:04stuhoodshould only need twice as much space, so a short, but yea
21:04mattreplhow ugly is it to use a function for creating a backquoted structure instead of a macro? I have an instance where I'm passing in a sequence to a macro, but I need to have that sequence evaluated and not just the symbol in order to build up the expansion
21:05Chousukemattrepl: hmh
21:06Chousukemattrepl: using functions that return code in macros is just fine.
21:07duck1123I'm curious, what version of swank-clojure are people using? still the jochu version, or a fork?
21:08gnuvince_jochu's for me.
21:08Chousukemattrepl: are you trying to make a macro that is called like (macro foo [a vector of things]) and generate the same piece of code for every item in the vector?
21:08Chousukemattrepl: in such a case, a helper function is just the right thing :)
21:08duck1123it seems that the kreg version has a build.xml file, which I think might be better
21:09mattreplChousuke: exactly. I'm actually building up condp cases
21:09Chousukeyou'll end up having something like ~@(map helper forms) in your macro then.
21:09gnuvince_stuhood: using shorts makes no apparent improvement, the speed remains the same.
21:10stuhoodgnuvince_: yea, sorry... i'm failing to see the big picture: looking at micro optimizations instead =x
21:11mattrepl*nod* thanks!
21:11gnuvince_stuhood: well we're pretty much *in* micro-optimizations, but I still haven't put my finger on the one that's gonna make a difference
21:16blbrowngnuvince_, I am only going by my java experience, but you want to make sure that you aren't creating too many objects in loops, as well. More time to garbage collect
21:17gnuvince_blbrown: ok
21:17blbrownand maybe find a way to cache objects that you think you can.
21:21stuhoodgnuvince_: read-field-aux creates a new var to represent your get-* functions, could that be made more efficient
21:23Chousukeyou're also creating the byte array you parse 10000 times.
21:24Chousukeor actually since some of it's mutable, just the (map byte [whatever]) part
21:25gnuvince_Hmmm
21:25Chousukethough you don't seem to be mutating the byte array either.
21:25stuhoodChousuke: that part only take 242 ms on my machine
21:25stuhoodfor all 10K iterations
21:25gnuvince_I could probably move that out to just be executed once
21:26blbrownis the compujure guy on freenode
21:27gnuvince_~seen weavejester
21:27clojurebotno, I have not seen weavejester
21:27gnuvince_Apparently not
21:27blbrownOK
21:28arohner_blbrown: do you have a compojure question?
21:29blbrownjust some general questions
21:29arohner_I might be able to answer them
21:29gnuvince_Moving the creation of the array doesn't seem to do much regarding memory usage and only marginally improves total performance
21:30slashus2hiredman: I think I found a way around the sandbox created in your bot.
21:30durka42uh oh
21:30blbrownhehe
21:31Chousukehmm
21:32slashus2,((fn [] (file-seq (File. "/opt/"))))
21:32clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
21:32slashus2,((fn [] (file-seq (java.io.File. "/opt/"))))
21:32clojurebotjava.lang.NoClassDefFoundError: clojure/core$file_seq__4543$fn__4545
21:32blbrown,((fn [] (file-seq (java.io.File. "/opt/"))))
21:32clojurebotjava.lang.NoClassDefFoundError: clojure/core$file_seq__4543$fn__4545
21:32Chousuke:p
21:32slashus2hmm
21:33durka42,((fn [] 42)
21:33slashus2I guess you have to fully qualify file-seq?
21:33clojurebotEOF while reading
21:33durka42,((fn [] 42))
21:33clojurebot42
21:34slashus2,((fn [] (clojure.core/file-seq (java.io.File. "/opt/"))))
21:34clojurebotjava.lang.NoClassDefFoundError: clojure/core$file_seq__4543$fn__4545
21:34hiredmanhold on
21:34blbrownfunny, that all the vultures are ready to jump on clojurebot and hiredman gets em every time
21:34slashus2blbrown: I wasn't jumping on it, just trying to help.
21:35hiredmanI seriously doubt anything using file-seq would get around teh sandbox
21:35slashus2I am using his sandbox on my bot, I was just playing around with it.
21:35slashus2hiredman: Try to create a file object using the method I just tried.
21:36hiredman,((fn [] (clojure.core/file-seq (java.io.File. "/opt/"))))
21:36clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /opt read)
21:36Chousuke,(let [a (agent 1 :validator #(do (System/exit 1) &%))] (send a inc))
21:36clojurebotjava.lang.Exception: Unable to resolve symbol: & in this context
21:36Chousuke,(let [a (agent 1 :validator #(do (System/exit 1) %&))] (send a inc))
21:36clojurebotjava.lang.RuntimeException: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)
21:36Chousukeboo ;(
21:37hiredmanclojurebot: latest contrib?
21:37slashus2Wonder why it works on my bot.
21:37Chousukeslashus2: maybe the sandbox on your bot is not effective
21:38Chousukeslashus2: did you enable the security manager?
21:38slashus2Chousuke:
21:38slashus2yes
21:38Chousukeyou sure? :)
21:38slashus2no
21:39ChousukeI think you need to pass an argument to java and a policy file for starters.
21:39Chousukethen you need to call the method to set the security manager.
21:39hiredmannah
21:39Chousukeand if your slime does not explode when you do that, it might be working.
21:40hiredmaneither you pass the argument to java, or you call the function to enable it
21:40Chousukeah
21:40Chousukeslime does some really funky stuff if you enable the security manager without a policy file allowing clojure to do certain things :P
21:41gnuvince_Can you put a type hint in a let? (let [#^ByteBuffer buf (...)] ...)?
21:41Chouseryes
21:42Chousukeit throws an exception and then because slime tries to use clojure to process the exception it throws another exception... etc.
21:42gnuvince_Chouser: I must be doing something wrong then, cause it keeps telling me that I have reflexion on that line.
21:43slashus2Sorry for the false alarm. I think I am having troubles with the security policy and manager.
21:43Chouserif it says it's on that line, it's probably the init expression
21:43Chouserthe (...) part
21:44gnuvince_#^ByteBuffer -buf (.get buf arr)]
21:44gnuvince_That's what I got
21:44gnuvince_I should type-hint the array?
21:44Chouserit's the (.get buf arr) part, then.
21:44Chousermake sure that buf and arr are hinted sufficiently.
21:45gnuvince_ah
21:45gnuvince_#^bytes arr ... did the trick
21:45slashus2Seems to be working now.
21:45hiredmanI gotta say I wasn't really alarmed :P
21:46hiredmanI have close to absolute faith in the IO part of the sandbox provided by the jvm
21:46hiredmanI believe there are some exploits, but I think you have to go to the bytecode level to exploit them
21:47cp2hiredman: there was an exploit
21:47cp2to do with applets/images
21:47cp2but that was an old version of java 5
21:47cp2long since patched
21:47slashus2((fn [] (file-seq (File. "/")))) <--- This works for mine...
21:48slashus2When other directories don.?
21:48cp2there was a jnlp exploit discovered in 07
21:48slashus2don't
21:48hiredmantoo bad the sandbox doesn't let you read system properties so you can't find out what java version I am using
21:48cp2heh
21:48hiredman, ((fn [] (file-seq (File. "/"))))
21:48clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
21:48hiredman, ((fn [] (file-seq (java.io.File. "/"))))
21:48clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission / read)
21:48slashus2You know what it is...
21:48slashus2I have a debug statement.
21:48slashus2So it is accessing my hard drive.
21:49slashus2*facepalm*
21:49slashus2I was executing thunk
21:49slashus2:-D
21:49stuhood,(count *facepalm*)
21:49clojurebotjava.lang.Exception: Unable to resolve symbol: *facepalm* in this context
21:51slashus2My excuse is that I am lacking sleep from recent tests.
21:51slashus2exams*
21:55slashus2I am experimenting with java's ScriptEngineManager trying to incorporate other languages into the bot. It appears that the sandbox method works for those scripts too.
21:57Chouserwhich languages?
21:59slashus2jython Jaskell?
21:59hiredman~sandbox
21:59clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
21:59slashus2https://scripting.dev.java.net/
21:59hiredman^- this is where I cribbed the sandbox from
22:00slashus2hiredman: It is a good method.
22:00slashus2maybe scheme?
22:00hiredmanit is used in a scala bot, that I think also uses the scriptengine stuff for jruby, etc
22:00hiredmanabcl
22:00hiredman:P
22:00slashus2maybe
22:01slashus2I don't know if the Scripting manager supports it.
22:19stuhoodgnuvince_: whats up with this line:
22:19stuhood3 0 97 0 98 0 99 ; 3 Shorts
22:20stuhood7 bytes?
22:21gnuvince_stuhood: I have a mecanism to have a variable number of bytes/shorts/ints
22:22gnuvince_[:field-name [1 Byte] Short] ; read one byte which will be used as the length to read shorts
22:28blbrownhiredman, so sandboxing is a java protection mechanism, interesting
22:29blbrownI just don't understand why people bash java, there seems to be useful stuff there sometimes
22:32hiredmanwell
22:33hiredmanthe jvm and the library it comes with is great, the language is :(
22:35blbrownthat is one part yes, but there is a whole world out there where a lot of interesting work has been done. Every time I go to other technologies (Haskell, Erlang, common lisp, etc, etc) I always end up coming back
22:36blbrownbut I haven't willingly written Java code since 8 years ago
22:37hiredmanword
22:46stuhoodg'night everyone
23:08Mecis there a better function than (rem x 1) to tell if x has a decimal?
23:09cmvkki don't think so. integer? won't work, because it returns false for 1.0 etc
23:09cmvkkunless you want that behavior
23:10Mecnope
23:10danlarkinthere couldn't really be a better function, by definition
23:10Meci thought integer? would work but starting getting strange results until i realized it didnt like doubles
23:10cmvkkwell it could be easier to write. since you have to test if that equals 0.
23:11cmvkk(defn whole? [n] (= (rem n 1) 0)) or something
23:11Meczero? is faster than = 0
23:11hiredmaninteresting
23:11hiredman~def zero?
23:11danlarkinmodulus is a processor instruction, so it'll be as fast as an operation could be
23:11danlarkin*should be*
23:12cmvkkwow, i didn't know zero? existed.
23:12cmvkki think i'm just going to read through core.clj from start to finish.
23:12Mecyup its usefull because = does a lot of extra stuff
23:16Raynes,(time (zero? 0))
23:16clojurebottrue
23:16clojurebot"Elapsed time: 0.124 msecs"
23:16Raynes,(time (= 0 0))
23:16clojurebottrue
23:16clojurebot"Elapsed time: 0.102 msecs"
23:16cmvkki find your benchmarks highly unscientific.
23:17cmvkk:)
23:17Raynes= 0 was faster in this case on my REPL as well.
23:17durka42,(time (dotimes [i 1000] (zero? i)))
23:17clojurebot"Elapsed time: 0.797 msecs"
23:17durka42,(time (dotimes [i 1000] (= 0 i)))
23:17clojurebot"Elapsed time: 1.905 msecs"
23:17RaynesI'm not saying it's slower...
23:17RaynesI said it was slower in this case, to be a smartass.
23:17jhawk28hiredman: everytime I see something new with clojurebot, I saw, wow thats cool.
23:19hiredmanme too
23:19Raynesme too
23:23Mechmm i blew my heap space but it doesnt tell me where, any way to find out?
23:23jhawk28visualvm is the easiest
23:23jhawk28you can see what grows
23:24jhawk28as long as you are on Java 1.6
23:26Mecsomething like (reduce + (range 1000000000000)) shouldnt do it right?
23:26hiredmanwhy wouldn't it?
23:26Mecits not actually making the whole range in memory, just 1 bit at a time and dumping the rest
23:27hiredmanmakes sense to me
23:28cmvkkif you did (reduce * (range 1000000000000000)) that might blow the heap
23:28Mecheh probably
23:28Mecwow just doing the reduce + is taking a very long time
23:28cmvkki know i'm running it too heh
23:29Mecmy memory is staying constant tho
23:29jhawk28using alot of cpu
23:30cmvkkas expected.
23:31Meci've got 4 computers in my house, ill need to figure out a way to split a java program to run across them all :D
23:31cmvkkisn't that what terracotta will allow us? or something? i haven't been paying too close attention to all that.
23:31jhawk28yes, terracotta
23:31Mecno idea i havnt even looked into it yet
23:33jhawk28http://www.infoq.com/news/2009/01/clojure_production
23:33eeewhen will computers be able to figure out closed forms to things?
23:33durka42closed forms?
23:34eee1 + 2 + 3 + 4
23:34eeeetc
23:34Meci still dont follow
23:34eeethat's the one problem with composing things via risc
23:34eeen(n+1)/2
23:34eee(reduce + (range 1000000000000))
23:34durka42oh
23:35eeerisc is evil that way
23:35eeeeach little piece is too dumb
23:35Mecmathematica can figure a lot of stuff like that out
23:35eeethat's cool
23:36Mechmm i bet my memoize function that i passed 1000000 values is what blew my stack
23:38Meci dont suppose there's a way to cache just the last value passed to a function, perhaps i can just rewrite memoize to do it
23:38psticknewhy would that ... oh, nvm :)
23:38Mec?
23:38pstickne... touch the stack.
23:40durka42i thought you blew your heap
23:40Mecsame diff
23:40cmvkkheh
23:40psticknenot quite :(
23:41Mecso a function within a function may or may not be continuously redefined, is there a way to figure out if it is or keep it from being?
23:41pstickneMec: but if you already have a memoize function it should be trivial to implement it to just remember the last call and/or apply LRU or similiar.
23:42durka42pstickne: he's using clojure.core/memoize
23:42pstickneoh, I have no idea then :)
23:42Chousercontinuously redefined?
23:42Mecits pretty straightforward, it just puts calls and returns into a map
23:42durka42luckily, core/memoize uses the obvious implementation, so it shouldn't be too hard to rewrite
23:43Mechmm can the compiler tell if an inner function makes use of a closure and not redefine if it doesnt?
23:44Chouserwhat do you mean by redefine?
23:44Mec(fn adder [x] (fn [y] (+ x y))
23:44durka42as in, construct the AFn object again every time the function is called?
23:44Chouserthat creates two classes at compile time
23:44Mecya
23:44cmvkkthe question is, if you call adder twice with the same value, will you get an identical object back
23:45cmvkkor rather, will it be the SAME object
23:45Mecthe function adder needs its inner function remade every time its called, but (fn bleh [x] (fn [y] (inc y)) doesnt
23:45Chouserwhen you call adder, a new instance is created for the inner fn
23:45pstickneit sucks having to map thinking into Java :(
23:45durka42,(let [adder (fn [x] #(+ x %))] (type (adder 3)))
23:45clojurebotsandbox$eval__1081$adder__1083$fn__1085
23:46hiredmanman
23:46Chouser,(let [f (fn [] (fn [y] (inc y)))] (identical? (f) (f)))
23:46clojurebotfalse
23:46hiredmanhow does amazon know to recomend me real world haskell? all I ever buy is science fiction
23:47durka42wait, is the class redefined too
23:47cmvkkwell, that's how it knows.
23:47durka42,(let [adder (fn [x] #(+ x %))] (type (adder 3)))
23:47clojurebotsandbox$eval__1100$adder__1102$fn__1104
23:47durka42the classname is being gensymmed a couple of times
23:47Chouserdurka42: that'sonly because you're recompiling the whole thing
23:47psticknehiredman: and what data-mining conglomerations are going on...? ;)
23:47durka42oh
23:47Chouserif you defn'ed adder and called it a couple times, you'd get the same class name
23:47Chouser,(let [f (fn [] (fn [y] (inc y)))] (identical? (class (f)) (class (f))))
23:47clojurebottrue
23:48Mec,(let [adder (fn [x] #(+ x %))] (do (println (type (adder 3))) (type (adder 3)))))
23:48clojurebotsandbox$eval__1119$adder__1121$fn__1123
23:48clojurebotsandbox$eval__1119$adder__1121$fn__1123
23:48Mecbah why overcomplicate, ill just make a helper function
23:49eeeanyone going to lispcon?
23:49Mecany chance it's in chicago?
23:49Chousereee: ilc? I am!
23:49eeecool
23:50eeethey gonna be selling clojure books there?
23:50Chouserno idea
23:50Chouserthe only clojure book I know of isn't out yet, so probably not.
23:51eeeoh yeah. that's right
23:51Chouserok, bedtime. later, folks.
23:51RaynesNight Chouser.
23:51RaynesChrissstofur :)