#clojure logs

2009-07-24

00:58mebaran151what's the best way to convert an integer to a byte array in bigendian notation?
01:42replaca_anyone here no something about ring and jetty?
01:43replaca_I'm trying to understand how to parse posted form data
01:43replaca_without writing my own parser for it!
01:44arbschtI think they are held in :form-params in the request map. is that what you mean?
01:45replaca_I think that's what I mean, but they don't seem to be there
01:45replaca_(map doesn't have that key)
01:46replaca_the post is x-www-form-urlencoded fwiw
01:49replaca_hmm, that key doesn't exist anywhere in ring. Is it a compojure thing?
01:52replaca_yes, I see that it is now
02:00hiredmanI think ring doesn't parse form stuff for you, it operates below that "level"
02:01PatrickCHello.
02:08PatrickCHello
02:42Lau_of_DKTop of the morning gents
03:10Fossihi
04:00AWizzArd~seen kotarak
04:00clojurebotkotarak was last seen quiting IRC, 587 minutes ago
04:19Lau_of_DK~get kotarak
04:19clojurebotI don't understand.
04:25AWizzArdMaybe you can write a patch Lau, so that the bot can run that function?
04:40Lau_of_DKNp - It does require some cooperation on the part of the one who is being fetched though - I'm thinking phone app or something similar
04:52Fossi"emacs" question: is there an easy way to find out what file a method is in?
04:53Lau_of_DKWell... :) M-! grep -nr "foo" *, would do it
04:54Lau_of_DKAre you on Linux?
04:54Lau_of_DK@ Fossi
04:54Fossiwell, that isn't really so helpful in jars
04:54Lau_of_DKOh, you mean by way of reflection ?
04:54Fossiit would show up, but i'd like the namespace or such
04:55Fossi(source foo) is great, but unfortunately doesn't give the file either
04:56Lau_of_DKI'm blank, never had that question before
04:56Lau_of_DKWhy would you want the filename?
04:57Fossiwell, more the namespace, but it's kinda the same
04:57Fossisay, i (use 'compojure), but really only call start, so i would like to find out, where that is defined
04:58Fossiand a hundred other small use-cases like that
05:00Fossiit's also a bit annoying there's no automatic import cleanup :)
05:01Chousuke,(:file ^#'vec); It should be in the metadata
05:01clojurebot"clojure/core.clj"
05:01Fossiah, nifty
05:01Lau_of_DKvery
05:01Chousuke:line, too :P
05:01Chousuke,^#'vec
05:01clojurebot{:ns #<Namespace clojure.core>, :name vec, :file "clojure/core.clj", :line 241, :arglists ([coll]), :doc "Creates a new vector containing the contents of coll."}
05:02Lau_of_DKAwesome tip
05:02Lau_of_DKChousuke, I hereby grant you the title of Tipster !
05:03Fossithat make a nice addition to repl-utils imho
05:03Chousuke:P
05:03Fossi'd
05:03Chousukewhat would? that's just metadata :P
05:12cschreiner...
05:13Lau_of_DK;;;
06:41rottcoddhow do I checkout the par branch?
06:42Chousukegit checkout -b par origin/par
06:42Chousukethat sets up a local par branch to track the par branch on origin
06:42Chousukeie. rhickey's github repo.
06:43rottcoddthanks
06:44Chousukeif you don't need a tracking branch, git checkout origin/par works too, but you won't be able to commit in it :)
08:35djpowell`which jsr166y.jar do I need for the par branch?
08:35rhickeythe one in the downloads section on github
08:36djpowell`ah, ok
08:36rhickeyhttp://cloud.github.com/downloads/richhickey/clojure/jsr166y.jar
08:39djpowell`what are the current experimental branches? par, chunks, and ensure?
08:40rhickeyyes, and par has everything chunks does
08:40djpowellnice. do they both have mutable collections?
08:41rhickeyyes, exactly
08:41rhickeymutable vectors, and that is all the chunks branch has over master at this point, the actual chunks work is in master now
08:42djpowellis the main effect of the chunks work to speed up things like map over vectors?
08:43rhickeydjpowell: yes, and any other collections that can support block access, like arrays
08:44rhickeynot yet implemented for maps/sets, but possibly useful there too
08:45rhickeyright now only a few ops (map/reduce/filter) have chunk support, but I'm hoping for some contributions (for, doseq etc)
08:46rhickeywhile not every seq op can be parallelized, most can be chunked
09:01ChouserWell, I'm still doing battle with JNI, but now finally to an issue that's Clojure-related. That is, loading me .so and calling a java method works from .java code, but not from .clj code.
09:02ChouserI'm wondering if it's a classloader issue of some sort
09:03rhickeyChouser: almost certainly
09:03Chouserlike perhaps the classloader used to call System/loadLibrary has to have a particular relationship with the classloader used to call the method
09:03rhickeyshouldn't it?
09:04ChouserI tried (do (System/loadLibrary "my_lib") (my.lib/method))
09:04Chouserat the repl, that should be done all in one classloader, right?
09:05Chouseranyway, that fails: java.lang.UnsatisfiedLinkError: my.libJNI.method()I
09:06ChouserShould my goal be to get the root classloader to do the loadLibrary()? Is that possible?
09:07rhickeyChouser: I'm trying to understand the semantics of loadLibrary
09:09rhickeyHave you tried this advice:
09:09clojurebotthis is not a bug
09:09rhickeyIf native methods are to be used in the implementation of a class, a standard strategy is to put the native code in a library file (call it LibFile) and then to put a static initializer:
09:09rhickey static { System.loadLibrary("LibFile"); }
09:09rhickey
09:09rhickeywithin the class declaration. When the class is loaded and initialized, the necessary native code implementation for the native methods will then be loaded as well.
09:09rhickeyfrom: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#loadLibrary(java.lang.String)
09:09ChouserI was just about to paste that.
09:09Chouserso do that in a .java and then try the calls from .clj. I'm on it...
09:09rhickeymanual consumer calls to loadLibrary seem fraught
09:10rhickeythe native library should be an implementation detail of some class, and loading the classes should work as always
09:11rhickeyer, work as well as always, which is not ... always
09:11Chouserheh
09:12rhickeyhave you set java.library.path?
09:12Chouserwoo!
09:12Chouserstatic { } did it
09:13sgtarr_Clojure is awesome, I just need to play around with it for months before I would dare to use it in a commercial / enterprise setting (which is my job).
09:13cemerickut oh, do we need a static init form in clojure now? :-/
09:14Chousercemerick: I don't think so.
09:14sgtarr_rhickey: And you are turning into the new rockstar in Computer Science, no doubt. :-)
09:14ChouserI've already got a pile of .java generated by swig for this JNI stuff. I just need to figure out how to inject a static init into the code it's producing.
09:15Chouseradding it manually to the .java is what just worked. The .java file is already there and already requires compilation, so not much value in moving it to .clj
09:15rhickeysgtarr_: not really, I'm just a toolmaker
09:16sgtarr_That's what James Gosling says too.
09:47ChouserI assume there's no place to put .java code that will run when any class in a package is used, right?
09:48Chouserswig is missing a feature I need. Not really java's fault for failing to make up for it...
09:52cemerickChouser: ServiceProviders will do that, although it's JDK6+ IIRC
09:55ChouserI'm finding javax.imageio stuff, but I assume that's not what you're talking about?
09:57cemerickthat was the original impl of the pattern in JDK5, I think
09:58cemerickhrm, I think the "run when a class in a package is accessed" functionality was tied to the imageio stuff, though.
09:58cemerickwhat I was thinking about that is generally-useful is: http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html
09:58cemerickNo package-level automatic stuff, tho, as far as I can tell.
10:15rzoomas a watcher on assembla, is there any way to not get emailed so often?
10:16rzoomI don't see an "Alerts" tab on the top of the space
10:16djpowellrhickey: how many cores did you have on the machine you did the 'pvmap rocks'?
10:19Chouserrzoom: Stream tab, upper-right corner, "change alert settings"
10:31rzoomChouser: thanks! the assembla FAQ says there is an "Alerts" tab.
10:44rhickeydjpowell: 4 cores
11:05stuartsierraI can't reproduce this out-of-memory error: http://groups.google.com/group/clojure/browse_thread/thread/c0e889d2a6c200ba
11:07hiredmanmaybe he has a small heap
11:07stuartsierraI tried it with -Xmx64m and a 1.5 GB file. No problem.
11:08hiredmanwell
11:08hiredman1.5gb is hardly "really big"
11:10hiredmanand who knows what his line processing function does
11:11stuartsierrahe said it failed on just (write-lines "out" (line-seq (reader "bigfile")))
11:12cemerickrhickey: I forget: have you previously warned me off the idea of having an .isForced() method on Delay?
11:14hiredmanfailed because I don't have 36 gigs free to copy to
11:14hiredmanwait, yes I do
11:14hiredmanjava.lang.RuntimeException: java.io.IOException: Input/output error (NO_SOURCE_FILE:0)
11:14hiredmanhmm
11:18hiredmanjava.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0)
11:18hiredmanthere we go
11:19hiredmanafter writting 1g of the 36g file
11:20stuartsierraNow why don't I get that?
11:24stuartsierraThis also works: (let [lines (line-seq (reader "/tmp/bigfile"))] (write-lines "/tmp/out" lines))
11:24rzoomvery long lines?
11:24stuartsierrahmm, possible. That would have to be a single line larger than the Java head, though.
11:26stuartsierras/head/heap/
11:31stuartsierraduck-streams/write-lines isn't truly lazy; maybe that's the problem
11:32mebaran151is there anyway to hook in test-is with a junit runner so my ide could run them: I'm using the Netbeans plugins and I just want an easy way to run my tests
11:33stuartsierramebaran151: Not yet, want to write one? :)
11:33mebaran151eh I could take a shot at it
11:33stuartsierraThere's a patch for JUnit-style XML output, I need to get that applied.
11:34mebaran151don't need the xml output: I'd just like to integrate it with my ant task
11:35stuartsierraWorking with JUnit from Clojure is difficult because it relies so heavily on Java annotations.
11:35stuartsierraThat's why I didn't try.
11:35clojurebothttp://clojure.org/rationale
11:35mebaran151I always thought annotations were cludgy
11:35mebaran151it seems like a poor man's solution to make things slightly more dynamic
11:36mebaran151I know Scala Specs does it though, and I don't think Scala support annotations yet
11:36cemerickmebaran151: you don't really need junit integration to make test-is tests work nicely with ant
11:36stuartsierracemerick: That's true.
11:37mebaran151ah, how would I set this up
11:37cemericklisppaste8: url?
11:37lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:37lisppaste8cemerick pasted "test-is ant harness" at http://paste.lisp.org/display/84139
11:37cemerick^^ that's what we use. Crude, but it works.
11:38stuartsierraHere's how I do it: http://github.com/stuartsierra/altlaw-backend/blob/5b9edd606df944e5c58e5ad32191b27436201950/build.xml#L95
11:38cemerickthrows an exception on test-is failure, so ant's failonerror="true" will halt the build, etc.
11:38mebaran151also how would I organize my tests in /test?
11:39cemerickmebaran151: however you want :-)
11:39mebaran151no specific sort of dir format mandated from on high?
11:39cemerickI set it up so that all clj files in src/test are munged into namespaces, and passed as args to the class/main method I pasted above
11:40mebaran151I see
11:40cemerickif a particular test ns doesn't define any tests, then the test-ns call is a no-op, so there's no harm in casting a wide net
11:40cemerickstuartsierra: so do you have to manually maintain a list namespaces to load in org.altlaw.load-all?
11:41Chouserok! swig indeed has the features I needed.
11:41Chousernow every java class it generates has "static { module.init() }"
11:42mebaran151I see
11:42Chouserand the java class named "module" has "static { System.loadLibrary("my_lib"); }"
11:42rhickeyChouser: makes sense
11:43cemerickmebaran151: irc being what it is, I can only surmise that you're uneasy ;-)
11:43Chouserso an attempt by java/clojure to use any of the generated java classes causes the moudule's init method to be called which itself does nothing but causes the loadLibrary to happen once.
11:43Chouserthis seems blogworthy. swig makes this much more pleasant than it otherwise would be.
11:43mebaran151a little uneasy
11:44mebaran151right now I've just been manually running my tests from the repl
11:44mebaran151but before I deploy, I love having a test suite I can run just to make sure everything made to the server okay
11:44cemerickyeah, definitely
11:45cemerickFWIW, the mechanism we use is roughly what ant does with junit tests now -- it crawls around your test classpath, looking for TestCases and Suites to run *shrug*
11:45cemerickThere's definitely smarter ways to do it, but hardly any easier ones :-)
11:46stuartsierracemerick: not with the addition of clojure.contrib.find-namespaces
11:46stuartsierracemerick: that was in response to the load-all question
11:46cemerickoh, that's interesting. Never knew it was there. We've got an ant contraption that converts clj filenames -> namespaces
11:47cemerickwe don't do any loading tricks, so we have a 1:1 correspondence
11:47stuartsierrathat's basically what find-namespaces does, but it also parses the (ns...) declaration
11:47cemerickwell, clj code is way better than an ant contraption :-P
11:47stuartsierraI originally had org.altlaw.load-all when I was doing a lot of gen-class stuff, I can probably eliminate in now.
11:48cemerickthe only advantage using ant has is that there's an easy mechanism to prevent recompilation of files that haven't changed since the last build.
11:50stuartsierraYes, that's harder. I just recompile all the .clj files when any of them have changed.
11:51cemerickonce our incremental build process crossed the 1-minute mark (because of clj recompilation), I implemented that. Now it's 12s :-)
11:52stuartsierranice
11:57mebaran151I really wish the json.read wasn't so strict: uneval in mozilla actually creates non-spec json
12:00hiredmanmebaran151: you might checkout clojure-json
12:01mebaran151how to spec is it? I was reading the source code and it looked equally inflexible (I think it demanded quotes around string keys too)
12:02hiredmanit could be even less flexible, dunno
12:05hiredman~def write-lines
12:07mebaran151also is there a quick clojure way to turn an Integer into its big endian byte encoding and back?
12:10hiredman,(Integer/toBinaryString 3)
12:10clojurebot"11"
12:10angermandoes anyone have experineces with clojure on terracotta?
12:11drewrsomeone was making progress with that but I haven't seen any updates
12:11angermanI found a blog that supposidly said it had it running
12:11angermanand someone on the ML said he deployed something like that in a mecial hospital
12:12replaca_angerman: I would go to the clojure google group and do a search. I remember there was some discussion of terracotta support a few months back
12:12angermanreplaca_: yep, as I said :) ... I guess i sould switch vom MailingList to Group :)
12:13replaca_Wow! github has been super-slow the last couple of days
12:13replaca_angerman: someone was working on generalized support and rich was helping him IIRC
12:14replaca_angerman: but I haven't heard anything about it for a while
12:14replaca_angerman: if you're looking for distributed execution you might look at swarmiji too
12:14stuartsierraOk, I put the JUnit XML output in a patch on Assembla. I think I did it right.
12:15angermanreplaca_: I'm basically looking for a solution to kinda split all the parralliyable stuff across the systems we have here
12:15cemerickangerman, replaca_: pjstadig (Paul Stadig) did the initial work, with Rich's help: http://paul.stadig.name/2009/03/clojure-terracotta-update.html
12:16angermanI think there are like 12 nearly idle opertron systems + a few Mainframes for the sun ray system that's employed on the campus
12:16rhickeyangerman: also see: http://github.com/amitrathore/swarmiji/tree/master
12:16hiredmanthere is always hadoop
12:16angermancemerick: ok, i found that blog too. so that's the defacto piece to use :)
12:17stuartsierrahadoop isn't aimed at compute-intensive apps, although it may still work
12:18cemerickooh, swarmiji looks interesting
12:18angermanhmm swarmiji looks nice
12:18cemerickhadoop is so friggin' complicated...
12:19angermancemerick: well I won't bother with the datastore part. I got all the data in a postgresql db already, which did a lot of the prefiltering of the data using pl/R
12:19mattingHi! I came accross a problem I can't solve: I need to use some java gui and therefore i need to reimplement the paint() method. So my guess is to use 'proxy'. But i need more information (here: what stuff to draw) in paint() that is supplied by the arguments.
12:19angermanmatting: ?
12:20replaca_the advantage of swarmiji is that it seems pretty simple, but I haven't had a chance to actually use it yet
12:20mattingi'd like to have a function that draws a path
12:20stuartsierramatting: proxies can be closures
12:20rhickeymatting: (let [other stuff] (proxy ... other))
12:20hiredmanmatting: the "methods" in proxys are fns so they can close over stuff
12:21stuartsierraHa! 3 different forms of the same answer.
12:21matting:)
12:22mattingbut i still don't get it. suppose i have two paths path1 and path2. i'd like to do sth like (draw-path path1) or (draw-path path2)
12:22angermanthough before i tired that I did use a jpanel in a jframe
12:22replaca_hiredman: I have a new json file for clojurebot to chew on that has the pointers to clojure.contrib on github
12:22mattingdoes this mean i need to create a new proxy for each call?
12:22replaca_hiredman: it's at http://github.com/richhickey/clojure-contrib/raw/gh-pages/api-index.json
12:23replaca_hiredman: I think it should be identical to the old old, format-wise
12:23replaca_*old old => old one
12:23hiredmanok
12:27replaca_hiredman: let me know if you have any issues
12:27djpowellpaint is a callback that is called by java - you put the instructions on how to paint the screen in it, and java will call it when it needs to repaint the screen - which you can also trigger by telling it to repaint. so you'd have a single proxy for your window or panel or whatever that overrides paint.
12:27hiredmanreplaca_: it works
12:28hiredman(I have no issues)
12:29djpowellas to what to put in paint - you might structure your application so that another thread updates a ref with the current state of the world, in a loop, that also calls repaint on the component, and sleeps for a bit, and then your paint method renders that state. maybe.
12:30cemerickrhickey: any idea to what degree (if any) cinc will impact the usability of clojure data structures/APIs from the Java side? e.g. will PHM, etc., still have stable names?
12:30stuartsierramebaran151: Re "uneval in mozilla actually creates non-spec json": c.c.json.read is a *JSON* parser, not a *Javascript* parser. It won't parse Javascript objects. That's a design choice; parsing real Javascript is quite a bit harder. You might as well use a real Javascript interpreter like Rhino.
12:31mebaran151heh, I actually am using rhino, but sometimes I want to get the values it generates back into clojure!
12:32replaca_hiredman: cool!
12:32replaca_that was easy
12:32Chousercemerick: interesting question. The intefaces and abscract classes would have stable names of course.
12:32mebaran151I kind of wish Mozilla had included to_json function in their standard distribution
12:32mattingbut how can i make my reimplementation of paint() dependent on the state?
12:32stuartsierramebaran151: ah, should be fairly straightforward to transform Rhino's objects into Clojure types, then.
12:32stuartsierraI do that with JRuby.
12:32mattingi think that's what i don't understand yet
12:33Chousercemerick: but if the concrete classes are defined using newnew (which I would assume) than their actual classnames would be generated I would think.
12:33cemerickChouser: I'm thinking of the impact on RMI, which uses big-S Serialization, which depends on stable names
12:33mebaran151the included scripting JDK isn't very easy to work with
12:33stuartsierraah
12:33hiredmanreplaca_: how difficult would it be to add clojure.core to that?
12:33clojurebotclojure is the brand
12:33mebaran151I did end up swapping it out for Rhino proper
12:33hiredman~botsnack
12:33clojurebotthanks; that was delicious. (nom nom nom)
12:34mebaran151but I wouldn't have had to if Mozilla hadn't thought in their infinite wisdom to produce adhoc JSON instead of real JSON
12:34stuartsierrayeah
12:34Chousercemerick: hm... that brings up print-dup as well. I guess we'll either need stable constructor names (still seems unlikely to me) or print-dup will have to use the factory functions (hash-map, sorted-set-by, etc.)
12:35cemerickthe latter seems most reasonable
12:35replaca_Q: does anyone know where there's a regexp pattern or something for finding links in raw text? I'm trying to take docstrings and convert the embbeded things like http://json.org to <a> tags when I render them in HTML. This seems like a *very* solved problem, but I can't come up with a google search for it :-)
12:35cemerickThere's always writeObject and readObject overrides to get proper Java Serialization (presumably using print-dup)
12:36mattingyou see, if i would reimplement paint() in java paint() would also depend on the internal state of the object. i don't know how you can get the same thing done with clojure.
12:36replaca_hiredman: shouldn't be hard at all. Would it be OK if it were in a separate file?
12:36cemerickBut that puts serialized clojure objects out of the reach of the various tools that expect "normal" serializations.
12:36hiredmanreplaca_: that would be fine
12:36stuartsierramatting: your proxy function needs to close over a variable representing the state. If it's mutable, then it should be one of Clojure's mutable types, probably a Ref.
12:36replaca_cool, i'll put it on the todo list
12:37rottcoddwith 2 packages p1 and p2, is it possible to have p2 export p1/foo as p2/foo?
12:37hiredmanreplaca_: clojurebot uses #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" to snag urls out of irc
12:37djpowellor, you could just make the variable a global ref I guess
12:38replaca_hiredman: works pretty well?
12:39hiredmanseems to
12:39replaca_hiredman: I worry about links at the end of a sentence
12:39hiredmanwhat do you mean?
12:39mattingstuartsierra: can you point me to some clojure source where i can see how this is done?
12:40replaca_"For more information, see http://json.org/overview.html.&quot;
12:40replaca_want to get the middle period, but not trailing
12:40hiredman,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" "For more information, see http://json.org/overview.html.&quot;)
12:40clojurebot"http://json.org/overview.html.&quot;
12:40hiredmanhmmm
12:41replaca_that tends to be pretty common in docs
12:41djpowellmatting: in http://clojure.googlegroups.com/web/ants.clj the state is just held in global vars that hold refs (eg world), they are manipulated by lots of threads, and the paint method calls the render function, which shows how to call methods on the Graphics object in order to draw stuff
12:41opqdonut,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" "For more information, see http://json.org/overview.html.&quot;)
12:41clojurebot"http://json.org/overview.html.&quot;
12:41opqdonutgah, sorry
12:41opqdonut,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^. ]+" "For more information, see http://json.org/overview.html.&quot;)
12:41clojurebot"http://json.org/overview&quot;
12:42Chouserirc-log-to-html.clj uses #"(?:https?://|www\.)(?:<[^>]*>|[^<>\s])*(?=(?:&gt;|&lt;|[.()\[\]])*(?:\s|$))"
12:42clojurebotsee logs
12:42stuartsierramatting: not a great example, but here's one: http://tinyurl.com/lwqbhq
12:42mattingthanks
12:42hiredman,(re-find #"(?:https?://|www\.)(?:<[^>]*>|[^<>\s])*(?=(?:&gt;|&lt;|[.()\[\]])*(?:\s|$))" "For more information, see http://json.org/overview.html.&quot;)
12:42clojurebot"http://json.org/overview.html.&quot;
12:43hiredman:/
12:43replaca_Chouser: now there's a regex!
12:43hiredman,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" (.replaceAll "For more information, see http://json.org/overview.html.&quot; "\.$" ""))
12:43clojurebotUnsupported escape character: \.
12:43djpowellstuartsierra: re your jmx server - do you think it is worth using OpenMBeans instead of straight DynamicBeans?
12:43hiredman,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" (.replaceAll "For more information, see http://json.org/overview.html.&quot; "\\.$" ""))
12:43clojurebot"http://json.org/overview.html&quot;
12:44stuartsierradjpowell: not mine
12:44djpowelloh - oops
12:44cemerickreplaca_: java regexes also support forward non-capturing assertions, which are generally cleaner than the alternatives, IMO
12:44stuartsierradjpowell: Stuart Halloway, I think
12:44djpowellah
12:44replaca_cemerick: yeah, that might be part of the sol'n
12:44Chouseroh, you know what -- my regex is meant to operate on html. that's why it's so crazy
12:45replaca_hiredman: $ loses because this doesn't necessarily happen at the end of the source text
12:45Chouserthat is, it's skipping over tags and entities embedded in the url.
12:45replaca_Chouser: yeah, makes sense
12:46replaca_when I was doing the autodoc on the google code wiki, it did this for me (its one nice feature), but in the new autodoc, I've got to do it myself
12:46hiredman,(re-find #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+" (.replaceAll "For more information, see http://json.org/overview.html. foo bar" "(\\.$|\\.\\s)" " "))
12:46clojurebot"http://json.org/overview.html&quot;
12:47replaca_hiredman: which finds it at some cost to my source text
12:47replaca_:)
12:48replaca_the idea is to be able to transform "For more information, see http://json.org/overview.html. foo bar"
12:48Chouser,(map second (re-seq #"(\w+://.*?)[.>]*(?: |$)" "For more information, see http://json.org/overview.html. foo bar"))
12:48clojurebot("http://json.org/overview.html&quot;)
12:49replaca_into "For more information, see <a href="http://json.org/overview.html&quot;&gt;http://json.org/overview.html&lt;/a&gt;. foo bar"
12:50replaca_Chouser: nice!
12:50replaca_thanks guys, I think I have a good starting point now.
12:53Chouser(str2/replace "For more information, see http://json.org/overview.html. foo bar" #"(\w+://.*?)([.>]*(?: |$))" (fn [[_ url etc]] (str "<a href='" url "'>" url "</a>" etc)))
12:53Chouser,(require '[clojure.contrib.str-utils2 :as str2])
12:53clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/str_utils2__init.class or clojure/contrib/str_utils2.clj on classpath:
12:55replaca_Chouser: beautiful!
12:55replaca_why think when you have #clojure?! :-)
12:58beutdeucehow does cons work?
13:01hiredman(fn [a b] (fn [c] (c a b)))
13:02stuartsierrabeutdeuce: (cons x s) adds the object x to the *front* of the sequence s
13:02beutdeuceah, like the Haskell : operator?
13:03stuartsierramore or less, yes
13:03stuartsierra,(cons 1 (cons 2 (cons 3 nil)))
13:03clojurebot(1 2 3)
13:03beutdeucethnx
13:04hiredman,(let [_cons (fn [a b] (fn [c] (c a b))) car (fn [a b] a) cdr (fn [a b] b)] (car (_cons 1 nil)))
13:04clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3535$car
13:05hiredmanbar
13:05hiredman,(let [_cons (fn [a b] (fn [c] (c a b))) car (fn [c] (c (fn [a b] a)) cdr (fn [c] (c (fn [a b] b))] (car (_cons 1 nil)))
13:05clojurebotUnmatched delimiter: ]
13:05hiredmanbah
13:05hiredmanforget it
13:06beutdeuce:P
13:06stuartsierrahiredman: what are you trying?
13:06hiredman,(let [_cons (fn [a b] (fn [c] (c a b))) car (fn [c] (c (fn [a b] a))) cdr (fn [c] (c (fn [a b] b)))] (car (_cons 1 nil)))
13:06clojurebot1
13:06hiredman,(let [_cons (fn [a b] (fn [c] (c a b))) car (fn [c] (c (fn [a b] a))) cdr (fn [c] (c (fn [a b] b)))] (cdr (_cons 1 nil)))
13:06clojurebotnil
13:06RaynesO_o
13:07hiredmancons cells as lambdas
13:07hiredmanor lambdas as cons cells
13:08stuartsierraah
13:13hiredman,(let [_cons (λ [a b] (λ [c] (c a b))) car (λ [c] (c (λ [a b] a))) cdr (λ [c] (c (λ [a b] b)))] (car (_cons 1 nil)))
13:13clojurebot1
13:15beutdeuce,(filter (fn [x] mod x 2 == 0) (range 1 100 1))
13:15clojurebot(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99)
13:16beutdeucehm
13:16stuartsierraYou're not writing in lisp!
13:16replaca_,(filter (fn [x] mod x 2 == 0) (range 1 100 1))
13:16clojurebot(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99)
13:17stuartsierra,(filter (fn [x] (= 0 (mod x 2)) (range 1 100 1))
13:17replaca_,(filter (fn [x] (= (mod x 2) 0) (range 1 100 1))
13:17clojurebotEOF while reading
13:17clojurebotEOF while reading
13:17stuartsierra,(filter (fn [x] (= (mod x 2) 0) (range 1 100 1)))
13:17clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$filter
13:17replaca_,(filter (fn [x] (= (mod x 2) 0)) (range 1 100 1))
13:17clojurebot(2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98)
13:17hiredman
13:17stuartsierrathat's it
13:17beutdeuceright, i'm forgetting about the prefix evaluation
13:17mebaran151,(doc import)
13:17clojurebot"([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."
13:18mebaran151cool so that's how the clojurebot works
13:18mebaran151I'd never actually thought about it before
13:18durka42,(filter even? (range 1 100))
13:18clojurebot(2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98)
13:18hiredmancan't you just tell range to step by 2?
13:18hiredman(doc range)
13:19clojurebot"([end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0 and step to 1."
13:19durka42that would work too
13:19hiredmanI guess not
13:19durka42,(range 1 10 2)
13:19clojurebot(1 3 5 7 9)
13:19hiredman,(take 10 (iterate (partial + 2)))
13:19clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$iterate
13:19hiredman,(take 10 (iterate (partial + 2) 0))
13:19clojurebot(0 2 4 6 8 10 12 14 16 18)
13:19durka42TIMTOWTDI
13:20beutdeuceCan clojure do lazy evaluation of infinite lists in list comprehensions?
13:21mebaran151it should be able to
13:21hiredmaninfinte sequences
13:21beutdeuceright, they are referred to as sequences
13:21hiredmansequences are lazy and can be infinite
13:21mebaran151,(take 10 (repeatedly 5))
13:21clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
13:21hiredmanbeutdeuce: lists and sequences are not the same thing
13:22hiredmansequences are a list like interface over most collection types
13:22mebaran151,(take 10 (repeat 5))
13:22clojurebot(5 5 5 5 5 5 5 5 5 5)
13:22hiredman,(class (repeate 5))
13:22clojurebotjava.lang.Exception: Unable to resolve symbol: repeate in this context
13:22hiredman,(class (repeat 5))
13:22clojurebotclojure.lang.LazySeq
13:23hiredman,(count (repeat 5))
13:24clojurebotExecution Timed Out
13:27mebaran151is there anyway to sandbox Clojure btw?
13:28mebaran151such as turning off its java interop and such
13:28stuartsierranot in Clojure itself, but Java sandbox tools will work
13:28mebaran151ah you mean the security domain and such
13:28hiredman,(.getContents (java.net.URL. (java.io.File. "/etc/passwd")))
13:28clojurebotjava.lang.ClassCastException: java.io.File cannot be cast to java.lang.String
13:29hiredman,(.canRead (java.io.File. "/etc/passwd"))
13:29clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /etc/passwd read)
13:31beutdeucehttp://pastie.org/557925 => runs forever, though i specified that an empty list returns 0
13:31hiredmanbeutdeuce: no
13:31hiredman[] means no args
13:31beutdeuceo
13:31hiredmanclojure does not have pattern matching, it has destructered binding which does some similar things
13:32beutdeucehow would that work?
13:32mebaran151beutdeuce, you need to apply your mylen
13:32mebaran151right now you just continually pass in a length
13:33beutdeuce(doc apply)
13:33clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
13:33mebaran151pass in a list I mean
13:33hiredmanuh
13:33hiredmanmebaran151: I doubt that is what he wants
13:34hiredman(defn length ([lst] (length lst 0)) ([lst count] (if (seq lst) (recur (rest lst) (inc count)) count)))
13:37hiredman,(reduce (fn [a b] (inc a)) '(1 2 3))
13:37clojurebot3
13:37hiredman,(reduce (fn [a b] (inc a)) '())
13:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3744$fn
13:37hiredman:/
13:38hiredmanoh
13:38hiredmanduh
13:38hiredman,(reduce (fn [a b] (inc a)) 0 '())
13:38clojurebot0
13:38hiredman,(reduce (fn [a b] (inc a)) 0 '(1 2 3))
13:38clojurebot3
13:39beutdeuceso reduce is haskell's fold ?
13:39hiredmanbut strict
13:39beutdeuceah
13:39hiredmanno lazy reduce in clojure
13:39clojurebotlazy is hard
13:41hiredmaneverything in clojure is strict, except lazy sequences
13:42hiredmansome operations are sequences are lazy and some are not, generally if it returns another sequence (map, filter, etc) it is lazy
13:43beutdeucek
14:38rzoomis there a standard "default" case for cond?
14:38Chouseryes, any true expression will do. :else is used by convention
14:38hiredman,(cond (= 1 0) :foo :else :bar)
14:38clojurebot:bar
14:39rzoomnice!
14:39rzoomthanks
14:39hiredmanYEAH!
14:39hiredmanTO THE MAX!
14:41danlarkinaw you guys... having all this fun
14:41rzoomis dmiles_afk ever here?
14:42hiredman~seen dmiles
14:42clojurebotdmiles was last seen quiting IRC, 759 minutes ago
14:44dmiles_afki am here. clojure is in my tyodo pipeline for what i am coding
14:45dmiles_afkwhich is a secondlife client for clojure
14:45dmiles_afkbut right now still using DotLisp.. but will soon enough use ClojureCLR
14:46dmiles_afkDotLisp was what rhickey wrote right before Clojure.. actually has a few nice extras that the JVM didnt offer
14:53mebaran151what does it have that the JVM can't offer?
16:42wlrMention of real world Clojure ~3/4 thru article: http://www.expresscomputeronline.com/20090727/technology01.shtml
17:27angermanwhee I just wrote my first macro
17:27angermanallows me to write (query "Item" where (= :name nil)
17:29RaynesCongratulations.
17:33AnniepooJust a note to rich to say thanks for such a cool language
17:33Anniepoo8cD
17:35angermanthough there is one thing I don't like so much. Descruturing in macros does not work :/
17:36angermani couldn't do this: (defmacro [kind _ (op a b)] ...)
17:39AnniepooI'm not getting the 'why is this cool?' of destructuring
17:40angermanAnniepoo: the cool part about destructuring is that it's short
17:41Anniepoohmm....
17:41angermanfor an extreme example take Prolog. If you couldn't do destructuring in the head it would be very painful
17:41duck1123it saves you a few let statements, and having to think up new names
17:41Anniepoodon't know Prolog
17:42Anniepoook, duck, but you're saying it's not really theoretically powerful, it's a 'typing' level convenience
17:42hiredmanangerman: uh, destructured binding in clojure does not use parens
17:43angermanhiredman: that's what I guessing towards ...
17:43angermanwell ... bedtime
17:43hiredmanugh
17:43hiredman~destructuring
17:43clojurebotdestructuring is http://clojure.org/special_forms#let
17:44AnniepooI can see that clojure will be an insanely great language to write graphic programs in
17:45Anniepoocause they usually bog down in the details of breaking down and packaging up small data structures
17:46AnniepooI've had an idea for graphics and never had a good language to express it in.
17:46Anniepoomost bugs in graphics code turn out to be using the wrong coordinate system
17:46Anniepooso a way to 'enforce type' on coord systems would be insanely cool
17:47duck1123Clojure gives you loads of tools to make your code as close to the actual idea as possible
17:47duck1123destructuring is just one of those tools
17:49Anniepooyah, I want to have some (move-widget-to [pt] and have it cope with a point in any format and coordinate system without a bunch of code in move-widget
17:50Anniepooideally, so you just say (cast-coord widget-frame 'Point pt) and you get a java.awt.Point in the widget's frame of ref
17:50duck1123sounds like a job for multimethods
17:51Anniepoodefinitely
17:51duck1123there was a blog post where the guy was making a raytracer in clojure, you might want to check that out,
17:52Anniepooah, interestiing
17:52duck1123http://www.fatvat.co.uk/2009/01/ray-tracing-in-clojure.html
17:53Anniepoonice, thanks
17:53Anniepoothat acutally kind of answers my question about destructuring
17:54hiredmanhttp://tu.be/graphics/ <-- this a more recent attempt by someone
17:56Anniepoonice
17:56hiredmanhe went by fsm and was in here a few days ago looking for performance tips for array operations if I recall
17:58AnniepooIn a curly brace language it's good style not to 'pass the world' around. Does destructuring make that advice more or less apt?
17:59Anniepooright now I'm making a swing GUI editor for bunch of widgets
17:59hiredmandestructuring has nothing to do with that
17:59hiredmanit jsut makes binding forms shorter
18:00Anniepooexample, right now I'm writing the call in paintComponent that will acutally draw the widgets
18:00Anniepoo(draw-laid-out-widgets (.state this) g)
18:00hiredman(let [a (first lst) b (second lst) c (rest (rest lst)] ) becomes (let [[a b & c] lst] )
18:01AnniepooAh!!!!!
18:01Anniepoo8cD
18:01AnniepooDestructuring, it's not just for defn any more
18:01Anniepoosorry, I didn't get it before, somebody mentioned let
18:02Anniepoonow I see
18:02Anniepoolike the first raytracer posted, the guy has a bunch of (:x pt) (:y pt) stuff
18:04duck1123that one of the great uses, you can pull those values out into their own variables to make the rest of the code shorter
18:04Anniepoohe could have (let [[x y z] pt] ... x y ...
18:04Anniepoogot it! thanks!
18:04AnniepooY'all are wonderful
18:05duck1123actually (let [{x :x y :y z :z} pt] ... I believe
18:05Anniepoooops
18:06duck1123check out the let section of the special forms page
18:06Anniepoomy own code has a bunch of positional args
18:06duck1123it shows all the things you can do
18:07Anniepooyah, reading now
18:07replaca_you can try (let [{:keys [x y z]} pt] ... ) and get the same effect
18:07duck1123(let [{:keys [x y z]} pt] works too
18:07Anniepoothat's nice, and shorter
18:08AnniepooI'm shocked at the power of all this
18:08AnniepooI'm making a swing GUI - not a promising candidate for shortening, one would think
18:08duck1123it's never worth it to be shocked by the power of clojure, you'll wear yourself out.
18:10duck1123I've never played with swing, but isn't there some contrib libraries for doing gui stuff? Have you checked those out?
18:10AnniepooI started writing this in java, thinking I didn't know Clojure well enough to use it on a real project
18:10codyKany examples of dealing with circular references?
18:11hiredman,(doc declare)
18:11clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
18:11codyKderef on a object that contains circular references seems to unroll the whole thing & blow the stack
18:11Anniepoosure, if you print it
18:11codyKeven in code
18:12duck1123"don't do that then" :)
18:12codyKhahaha
18:12codyKyeah, so, in languages i'm familiar with, if youre say writing a serializer, its not too big a deal to deal with circular references
18:12codyKbut clojures printer doesnt seem to deal with them
18:13codyKand searching for examples or discussion of it isn't very helpful
18:13duck1123how do the other languages deal with them? just elide the recursion?
18:13Anniepooyou can't deal with it in general
18:14Anniepooit requires solving the halting problem
18:14codyKeh?
18:14codyKjust keep a list of addresses you've seen
18:14codyKcheck it before you deref a pointer
18:14codyKonly deref one level down at a time
18:14hiredmanuh
18:15hiredmansure sure, pointers
18:15hiredman
18:15hiredmanof course the jvm being designed to stop you from dealing with raw pointers sort of throws a monkey wrench in that
18:16Anniepooor mark and sweep
18:16codyKthe language clearly has reference types
18:16hiredmansure
18:16Anniepoocody, you don't even need to do that
18:16Anniepooadd a bit to each object
18:16hiredmanbut it doesn't let you touch pointers
18:17Anniepooreset them all, if you have some global list of stuff
18:17Anniepoothen traverse and print but say 'oh, I visited'
18:17codyKthe issue i'
18:17codyKm having is that deref seems to be all or nothing
18:18Anniepooit's reasonable to blow up on a circ ref for something general like print
18:18codyKi dont think its reasonable
18:18codyKcommon lisp handles it for instance
18:18Anniepoothre's a way to set the max depth of printing
18:18Anniepoo~println
18:18clojurebot,(println "clojure bot is the best!")
18:18hiredman,(let [a (ref 10)] (deref (ref a)))
18:18clojurebot#<Ref@94f797: 10>
18:18hiredman^- not all or nothing
18:19durka42,*print-depth*
18:19clojurebotjava.lang.Exception: Unable to resolve symbol: *print-depth* in this context
18:19codyKok, maybe my code is bad
18:19hiredmanit only derefs one layer
18:19durka42it was something like that...
18:19durka42,*print-level*
18:19clojurebot30
18:19hiredmancodyK: anyway, IDerefable things are not printable
18:20hiredmanand not readable
18:21codyKthe things they reference are / could be
18:21hiredmansure
18:21hiredmanso deref before you print
18:26codyK;; (def *a* (atom [0]))
18:26codyK;; (def *b* (atom [1]))
18:26codyK;; (compare-and-set! *a* @*a* (conj @*a* *b*))
18:26codyK;; (compare-and-set! *b* @*b* (conj @*b* *a*))
18:27Chouseryou can do the same thing with java collections and their .toString() method
18:28Chouserbut that just crashes instead of respecting *print-level*
18:29hiredmancodyK: so?
18:29codyKI would expect to be able to get some unique identifier for *b* without unrolling it
18:30hiredmanunique how?
18:30codyKwell, i'm currently trying to add it to a set
18:30codyKso that I can compare it for set membership
18:30hiredmanacross all possible jvms which might run clojure and read it in?
18:30codyKno
18:31hiredmana unique identifier for a mutable thing like an atom or a ref is not worth much
18:31codyKbut the act of comparing it for set membership blows the stack
18:31codyK(afaict anyway)
18:31hiredman*b* is an atom
18:31hiredmanatoms are designed to mutate
18:32codyKagain, if i have a pointer, the address of that pointer doesnt change
18:32blbrown_winChouser, are you the owner of clojure and me
18:32hiredmanyou don't have a pointer
18:32codyKeven though the contents of that address might change
18:32hiredmanthis is not C or C++
18:32hiredmanyou do not have a pointer
18:33codyKlook, i'm not having a language argument
18:33codyKi promise you
18:33codyKs/pointer/reference/
18:33codyKclearly there is something consistent about *b*, because i can refer to it with the same name
18:33Chouserblbrown_win: no
18:33codyKso whats the correct operator to get that name?
18:35Chouser codyK: by default printing an IDeref also derefs and prints that value. But = doesn't do that
18:35hiredmancodyK: how are you adding *b* to a set?
18:35blbrown_winChouser, oh, I just followed you on twitter,
18:35Chouser= on reference types should be just 'identical?'
18:35codyKMy code doesnt even get to the point of adding it to a set
18:35hiredman(conj #{} *b*) will print the results to the repl
18:35blbrown_winahh, he is cgrand
18:35hiredmancodyK: so add some prns and figure out where it actually stops
18:36codyKif my set is *seen*, bound to an empty set, doing (*seen* some-circ-ref)
18:36codyKalone
18:36codyKseems to blow the stack
18:36codyKi'm willing to bet its bad code on my part
18:37codyKjust curious about examples
18:37hiredmanall works fine for me
18:38hiredmanuser=> (#{} *b*)
18:38hiredmannil
18:38hiredmanuser=>
18:38codyKyeah i just tried it
18:41codyK(and ((conj #{} *b*) *b*) 'thing)
18:41codyKseems to work ok
18:41codyKso like I said, bad code
18:41akhudekHi, I'm fairly new to clojure and failing at figuring out the right way to do this. I need to store a map of positions to counts that is updated roughly at random. There are typically around a million positions. In other languages I'd implement this as a vector of ints where the position in the vector is the 'key'. But looking at clojure vectors, perhaps this is not the right way to go about it? A big hash map doesn't seem like a good i
18:44hiredman,(do (vec (range 1000000)) nil)
18:44clojurebotnil
18:44hiredmanwhat is the problem with clojure vectors?
18:44akhudekI can't figure out a way to update a single position.
18:44hiredman,(assoc [1 2 3] 0 5)
18:44clojurebot[5 2 3]
18:45Anniepoooooh
18:45akhudekah, thanks, I didn't see how assoc worked on vector given the docs
18:46hiredman,(doc assoc)
18:46clojurebot"([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
18:46Anniepoook, what's going the other way, how do I get the 593rd element?
18:47Chousernth
18:47Anniepoo,nth
18:47clojurebot#<core$nth__4198 clojure.core$nth__4198@13e38a7>
18:47hiredman,((vec (range 1000000)) 593)
18:47clojurebot593
18:47akhudekI should read more thoroughly, I saw map in there and didn't read the last part. :/
18:47hiredman,(nth (vec (range 1000000)) 593)
18:47clojurebot593
18:47hiredmanvectors are functions of their indices
18:48akhudekright, so I guess they are a type of map
18:48hiredmannot really
18:49hiredmanbut they implement a few of the same interfaces
18:49Chousermaps and vectors are both associative -- can get and set elements based on a key
18:49hiredman,(ancestors (calls []))
18:49clojurebotjava.lang.Exception: Unable to resolve symbol: calls in this context
18:49hiredman,(ancestors (class []))
18:49clojurebot#{clojure.lang.IPersistentStack clojure.lang.Seqable java.util.List clojure.lang.Reversible clojure.lang.Sequential clojure.lang.AFn clojure.lang.Obj clojure.lang.Counted java.util.concurrent.Callable clojure.lang.APersistentVector java.io.Serializable java.util.Collection clojure.lang.IObj clojure.lang.IPersistentCollection clojure.lang.IMeta clojure.lang.IPersistentVector clojure.lang.IFn java.lang.Iterable java.lang.Ob
18:49Anniepoo,([1 3 15 4] 2)
18:49clojurebot15
18:50Chouser,(instance? clojure.lang.Associative [])
18:50clojurebottrue
18:50Chouser,(instance? clojure.lang.Associative {})
18:50clojurebottrue
18:51akhudekThere are so many clever things in clojure. It really is a joy to use.
19:09blbrown_winAnyone know where the widefinder input is. The input log file .I am running widefinder in clojure.
19:17hiredmanhttp://svn.effbot.org/public/stuff/sandbox/wide-finder/getdata.py is apparently a python script to download the logs
19:22blbrown_winso you can't just dow the download
19:22blbrown_winhiredman, did you google that, I couldn't find it apparently
19:22hiredmanit looks like you can
19:23hiredmanjust copy the url out of the python script
19:26blbrown_winisn't kind of a crappy benchmark
19:28hiredmanhave you read the rationale behind it?
19:29blbrown_winthere seem to be volumes out there? it also seems to be centered around ruby
19:29blbrown_winbut not really, I guess just a random test for processing data. How do other languages compare
19:29hiredmanhttp://blogs.zdnet.com/Murphy/?p=1030
19:31hiredmanhttp://www.hanselman.com/blog/TheWeeklySourceCode9WideFinderEdition.aspx some C# widefinders
19:33hiredmanman
19:33hiredmanI wish I had a T2
19:37krumholt__is there an api for quote?
19:37hiredmanuh
19:38hiredmanlike ' quote?
19:38krumholt__yes
19:38hiredmanwhat's there to say about it?
19:38hiredmanit supresses evaluation
19:38krumholt__for example why does (quote 123) evals to 123 a number
19:39hiredmanbecause the reader readers 123 as a number
19:40hiredmanand emits the list (quote 123) which is a two element list, the first element is the symbol quote and the second is the number 123
19:40hiredmanthen when (quote 123) is evaluated, 123, a number, is the result
19:41JAS415in a macro, how should I handle java classes... for example i have a code that looks like `(. ~URLEncoder (encode ~string "UTF-8")) should I be importing the URLEncoder in the macro code and escaping it with ~ or should I be importing the URLEncoder in the code that the macro goes with?
19:41krumholt__hiredman, seems strange that (= 123 '123) => true
19:42hiredman'123 is not a symbol
19:42hiredman(class '123)
19:42hiredman,(class '123)
19:42clojurebotjava.lang.Integer
19:42JAS415is because numbers evaluate to themselves
19:42hiredman' does not make symbols
19:42hiredman' quotes the following form, which is often a symbol
19:42JAS415,(= true 'true)
19:42clojurebottrue
19:42JAS415(= false 'false)
19:43JAS415,(= false 'false)
19:43clojurebottrue
19:43krumholt__seems wrong to me :)
19:43JAS415think of quote as a way of delaying evaluation
19:44hiredmankrumholt__: so when the reader comes across the string "(quote 123)" it goes "oh look, a paren, that means I am reading a list!"
19:44hiredmanso then it gets into list reading mode
19:45hiredmanit reads in the string "quote" says "well this is a symbol" and the string "123" and says oh, this is a number
19:45hiredmanso out of the reader you get a list, (quote 123) where quote is a Symbol and 123 is an Integer
19:46hiredmanthen the list is evaluated
19:46krumholt__ok i get it thanks
19:46hiredmanthe evaluater looks at the list and says "this is a list, so it could be function application, but quote is a special form"
19:46hiredmanreally?
19:47hiredmanI was having fun anthropomorphizing the repl
19:47hiredmanman
19:47clojurebot☝(^_^)☝
19:47krumholt__:)
19:47hiredmanI could get some puppets
19:47cemerickhiredman: been a long week? :-)
19:47hiredmanand do a video
19:47hiredmancemerick: come to think of it, it has
19:48cemerickyeah. Been a long year so far, too.
19:48hiredmanI don't even think _why has done puppets
19:49cemerickI don't get the appeal of his stuff at all.
19:49JAS415oh man
19:49cemerickthough, I don't generally enjoy instructional material anyway
19:49JAS415puppets to explain clojure would be awesome
19:50hiredmansomeone did some kind of alagator toy lisp thing
19:51hiredmanhttp://visual-languages.blogspot.com/2009/07/alligator-eggs-revisited.html
19:53krumholt__i have another question. how can i estimate the cost of a recur? in the documentation it says it will only use constant space. whats the difference to tail call optimization?
19:53hiredmantco is more general
19:54hiredmanrecur only recurs to the closest loop or fn
19:54Chouserthere is no tail call optimization in clojure
19:54hiredmantco would allow you to call any function
19:55hiredmanfrom tail call position, and not build up stack frames
19:55krumholt__ok thanks
20:21blbrown_winhttp://paste.lisp.org/display/84158 anyone see the error here. I got the code from a blog (cgrand-rec, hehe). I can't find 'val' created either
20:24lisppaste8Anniepoo pasted "compile error" at http://paste.lisp.org/display/84159
20:25Anniepoome, meanwhile, I've just reached the end of my wits trying to figure out why the compiler is complaining
20:26JAS415that's weird
20:26Anniepoowhat's weird?
20:27JAS415if you use fn instead of # does it work?
20:27Anniepoofor the # in draw-laid-out-widgets?
20:28durka42filter's fn only gets one argument
20:28JAS415ah yeah
20:28JAS415that is it
20:28Anniepooah!
20:28Anniepoothanks
20:28durka42you can destructure it however
20:28Anniepooyes, meant [[_ lvl _]]
20:28durka42precisely
20:28Anniepoothanks
20:31Chouserfwiw I make that mistake frequently
20:31krumholt__what does _ do?
20:32ChouserAnniepoo: that's yours
20:35Anniepoosorry?
20:35Anniepoowhat's mine?
20:36Chouserkrumholt__'s question is yours to answer. time to step up! :-)
20:36Anniepoounderscore is idiomatic for an argument that you will ignore
20:36Anniepooyes, you're right
20:37Anniepookrumholt, if you need a function that takes 3 args, because that's what the caller expects, but
20:37krumholt__ah ok so i could write (foo nil a nil) or (foo _ a _) ?
20:38Anniepoosuppose you have a bunch of places that hang onto a function and call it
20:39Anniepoolike, I'm making a thing where each widget is constrained to others, so each widget has a reference to it's constraint function
20:39krumholt__ok i get it i can only use _ in function definiton
20:39Anniepooit's not actually part of the language, it's just an idiom
20:40Anniepoo(defn foo [x x x] ... something....) is valid Clojure, just not very useful
20:40Anniepoo(foo 1 2 3)
20:40Anniepoomeans x is 3 inside
20:41Anniepoo_ is, by convention, what you use to mean 'I'm not using this'
20:41Anniepoobut you're right, it normally only appears in a defn or destructuring in a let
20:41krumholt__oh ok so _ is just a normal symbol. it has no special syntax. you just use it so a human reader knows you will ignore the parameters
20:41Anniepooyes
20:41krumholt__ok thanks
20:42Anniepoook, now, looking upwards in the Clojure food chain
20:42lisppaste8Anniepoo annotated #84159 "vec" at http://paste.lisp.org/display/84159#1
20:43Anniepoo259 is the last line of draw-laid-out-widgets
20:43AnniepooI assume I'm somehow cdr'ing off the end of the list
20:43Anniepoobut don't understand how
20:45ataggartit might make things clearer to use a struct instead of relying on position
20:46ChouserAnniepoo: is there more to that exception?
20:47ChouserThat doesn't look like the root cause trace
20:47AnniepooI'll paste the whole thing
20:47ChouserI wonder if somewhere you have 'vec' when you want 'vector'
20:48ataggartbtw where are these "widgets" created?
20:48ataggartI infer a widget is some vector or list
20:49ataggartbut I never see it get created in that code
20:49Anniepoono, this is a fragment
20:49ataggartso we may be missing some crucial info
20:49Anniepooyes, but I can't paste the entire project in
20:50ataggartif I had to guess, the code we aren't seeing is being indirectly realized intoa vec during the destructuring, but it can't so it blows up
20:50AnniepooChouser is right, there's other stuff highter in the stack trace
20:51lisppaste8Anniepoo annotated #84159 "more of the code" at http://paste.lisp.org/display/84159#2
20:52Anniepoo240 is this let in draw-a-laid-out-widget
20:52Anniepoo(let [[x y w h] (as-screen state r)]
20:52Chouservec only takes 1 arg
20:52Chouser,(vec (list 1 2 3 4))
20:52clojurebot[1 2 3 4]
20:52ataggart(vector, not vec
20:52Chouserif you want a vector of 4 things, use (vector 1 2 3 4) or just [1 2 3 4]
20:52ataggartya, what chouuser said
20:53Anniepooah, ok
20:53Anniepoothe vec in as-screen
20:53ataggart(defstruct screen :x :y :z :w :h) imo
20:53Anniepooincidentally, it's obvious there's a more idiomatic way to write that lanie
20:54Anniepoobut I don't know what it is
20:55ataggart(map #(* scale %) [ x y z])
20:55Anniepoothanks!
20:55ataggartexcept with the right names hehe
20:55Anniepoodoh!
20:55Chouserand then you do want vec to get a vector
20:55ataggartno need
20:55ataggartunless you need to manipulate it
20:56ataggartleave it as a lazy seq
20:56ataggartif that grouping is important, it might be better to make use a struct instead of a vector
20:57Anniepooyes, I understand
20:58ataggartthough the input looks to be some kind of list, so it might be irrelevant
20:58AnniepooI have a bunch of 'widgets' - rectangles essentially
20:58Anniepoothey're constrained to each other - I'm effectively making a layout manager
20:58ataggart(defn scale [factor values] (map #(* scale %) values))
20:58ataggarterm
20:59ataggart(defn scale [factor values] (map #(* factor %) values))
20:59ataggartthen it'll take anything
21:00Anniepoothere's a root widget, it has 'children' and 'slaves', so there's an n-ary tree that has two kinds of parent-chi
21:00Anniepoochild relationship
21:00ataggartya I just mean you can avoid the "x y w h" stuff
21:01Anniepoooh, I see
21:01Anniepooactually, there's a stylistic reason to leave it in this instance
21:01ataggartk
21:02Anniepooin this case we've got a lot of different small structs with coordinates running around
21:02Anniepoo[x y w h] is pretty clear compared to widget-location
21:03ataggartyou can have both
21:03ataggarte.g., have one call the other
21:03ataggartbut, yeah it's a style thing now
21:05AnniepooI write lots of graphics stuff so I see this issue with representing points and rects all the time
21:06Anniepooit's the main reason I'm excited by Clojure, I can see a cure for all that
21:06krumholt__is clojure compiling to java or directly to bytecode?
21:06Anniepoobytecode
21:07ataggartisn't there an easier way to do something like (reduce #(let [[k v] %2] (assoc %1 k (* 2 v))) {} {:a 1 :b 2})
21:08ataggartesenatially applying a function to the values of a map
21:10krumholt__(map foo (vals{:a 1 :b 2}))
21:10krumholt__?
21:10ataggartbut end up with a new, altered map
21:10ataggartnot a seqence of the values
21:11ataggart,(reduce #(let [[k v] %2] (assoc %1 k (* 2 v))) {} {:a 1 :b 2})
21:11clojurebot{:b 4, :a 2}
21:11cschreiner(trying really hard to understand agents)
21:12ataggartit's easy, they're just like theads, except totally different ;)
21:12cschreinerright..
21:13cschreinerthey are just values?
21:13ataggartthey hold a value
21:13ataggartthen you send it an action to update that value, and that action will be run in a thread pool
21:13cschreinerand when you want to change the holded value, you send off a function?
21:14ataggartsend or send-off, yeah
21:14cschreinerthats it?
21:14ataggartyup
21:14ataggartwell, sort of
21:14cschreinerjebuz
21:14ataggartthe "neat" part is how they work within a transaction
21:15cschreinerhow they operate with the STM
21:15ataggartin fact the one agent I've ever used, the value never changed since it was used to generate output
21:15ataggart~agents
21:15clojurebotHuh?
21:15ataggarthttp://clojure.org/agents
21:15ataggartgrep for transactin
21:15ataggartexcept spelled correctly
21:16cschreiner_,agents
21:16clojurebotjava.lang.Exception: Unable to resolve symbol: agents in this context
21:16cschreiner_,agent
21:16clojurebot#<core$agent__4304 clojure.core$agent__4304@171a8f6>
21:17cschreiner_to look at an agent as a generator is odd
21:17ataggartyep, who does that?
21:17cschreiner_you do
21:18ataggartsorry, "generator" means something specific to me
21:18cschreiner_ok
21:18ataggartsince you can't have side effects in a transaction (such as outputting logging) you do it via an agent
21:18cschreiner_so its like a monda?
21:18cschreiner_monad?
21:18ataggartor rather, any side effects will reoccur
21:18ataggartit's an agent
21:18ataggartthink of it as an agent, and it'll be easier
21:19cschreiner_i can speak to the agent, I can also receive something
21:19cschreiner_the agent is independent from me, that is, it runs in another thread?
21:20ataggartI suggest reading the link I posted above
21:20cschreiner_I have
21:20hiredmanhttp://www.amazon.com/Multi-agent-systems-introduction-distributed-intelligence/dp/0201360489 found this today for $2 at goodwill
21:20Anniepoook,what if it's the side effect that has to succeed for the transaction to succeed?
21:21ataggartha! where do you live that suck would appear in goodwill
21:21ataggart*such
21:21hiredmanAnniepoo: no
21:21cschreiner_ah, great find!
21:21hiredmanseattle
21:21ataggartah ok then
21:21ataggartAnniepoo: I misspoke earlier
21:22ataggartit's not that you can't have sideeffects, it's that if the transaction needs to be rerun, those side effects will occur again
21:22ataggarte.g. logging may get printed multiple times
21:22AnniepooI found a palm pilot at goodwill a few weeks ago that had been 'experimented' on - they'd messed with the IR
21:22hiredmanbut sends to an agent are held unto the transaction completes
21:22Anniepoook, so suppose I have a machine that punches a hole in a paper tape and advances
21:23hiredmanAnniepoo: ah, a late model turing machine
21:23cschreiner_ah, i was thinking of an agent in the spy-movie setting, now, when put into a manager-for-someone, it makes more sense...
21:23ataggartlol
21:23Anniepooand some call that initiates the hole punching
21:24Anniepoo8cD that's a side effect for sure
21:24ChouserAnniepoo: yeah. don't do that in a transaction.
21:25ataggartif you can't roll it back...
21:25Anniepoonot without sticky tape!
21:26Anniepoo(initiate-range-safety)
21:40hiredman(pl (λx.x 1))
21:40hiredman,(pl (λx.x 1))
21:40clojurebot1