#clojure logs

2010-04-09

00:00technomancyLicenser: right, dependency on leiningen is implied for plugins; you don't need to add it explicitly
00:00defnaww i dont wanna give up my swank-clojure-project
00:01Licenserhmm didn't worked for me on the other hand it seems I don't need the refference any more due to changes in code :)
00:01technomancy(defun swank-clojure-project () (interactive) (shell-command "lein swank") (slime-connect 4005)) ;; =)
00:01defnhaha technomancy
00:01defnwell played
00:01defnand thank you
00:03Raynes$walton juxt
00:03sexpbotRaynes: http://getclojure.org:8080/examples/juxt
00:03RaynesAw.
00:03defnhaha yes, juxt is broken atm
00:03defn$walton concat
00:03sexpbotdefn: http://getclojure.org:8080/examples/concat
00:04Raynesdefn: Does walton not use any examples that don't get through clj-sandbox?
00:04RaynesIf so, I imagine a whole bunch of everything is broken.
00:04RaynesAnd if that's the case, I might have motivation to go through most of the clojure.core API tonight.
00:04RaynesSo that Licenser can push a new release tomorrow.
00:04Raynes:p
00:05defnRaynes: they're supposed to if no good examples are found -- there is a bit of logic that needs some TLC in walton to make that work properly i think
00:05technomancyLicenser: "lein-search" might be a general enough name
00:05technomancysince the other tasks seem to also involve searching
00:05RaynesBecause sexpbot's evaluation is generally useless at the moment.
00:05Licensertechnomancy: heh I came up with exactly that name :D
00:06technomancyI'm going to have to do a "plugin roundup" blog post soon
00:06technomancythis is good stuff
00:06Licenserand it seems to work, this plugin stuff, if you don't need lein internal deps (they don't seem to like me) works great :)
00:07Licenserlein search clj-sandbox
00:07LicenserResults for clj-sandbox:
00:07Licenserclj-sandbox/clj-sandbox: 0.2.9-SNAPSHOT, 0.2.8-SNAPSHOT, 0.2.7-SNAPSHOT, 0.2.6-SNAPSHOT, 0.2.5-SNAPSHOT, 0.2.4-SNAPSHOT, 0.2.3-SNAPSHOT, 0.2.2-SNAPSHOT, 0.2.10-SNAPSHOT, 0.2.1-SNAPSHOT, 0.2.0-SNAPSHOT, 0.1.3-SNAPSHOT, 0.1.1-SNAPSHOT, 0.1.0-SNAPSHOT
00:07Licenser:)
00:07Raynes$((juxt (partial + 3) (partial + 4)) 5)
00:07sexpbotDENIED!
00:07Raynes:(
00:07technomancycools
00:07Raynesshowertime
00:08pandawaSOWERTIME
00:08brian__noob question on macros > a macro to do this: (def <exp> 1) -> (defmacro useless [expr ] (it works) but I would like to see the actual code from macroexpand, but I just get ( macroexpand-1 (useless b))
00:08brian__#'user/b , any way to do that?
00:08brian__
00:08brian__(list 'def expr 1))
00:10brian__sorry , the macro is: (defmacro useless [expr ]
00:10brian__(list 'def expr 1))
00:10carkhyou miss a quote in your macroexpand
00:10brian__ok
00:10carkh( macroexpand-1 '(useless b))
00:10brian__thx
00:15Licenserhmm there is no version 2.1.0 of clojure.contrib :P
00:16Licenserthere we go [lein-search/lein-search "0.1.0-SNAPSHOT"] in the dev dependencies and many worries are gone :D
00:16defntomoj: still can't get it to work
00:16defntomoj: how did you include the js?
00:16tomojI didn't, I just got it to work in my toy example
00:17defnright, but when you did your toy example, what path did you use to include your dummy js
00:17tomoj(wrap-file my-app "resources/public"), resources/ on the classpath, js file in resources/public/foo/bar.js, then /foo/bar.js will serve the js file
00:18tomoj(I didn't have any dummy js)
00:18defni give up for now
00:18tomojjust take out the ..'s
00:18defnyeah, did that, still nothing
00:19tomojalso take out the resources/public/
00:19tomojbut I guess you probably tried that too
00:20carkhwhat is wrap-file returning ?
00:21tomoja ring app
00:21defn#<file$wrap_file__2697$fn__2698 ring.middleware.file$wrap_file__2697$fn__2698@3d80ac61>
00:22carkhso there's no way to inspect the underlying file object ?
00:22tomojyou don't have an underlying file object at that point
00:22carkhmaybe by calling the function with a fake request object
00:22carkhwell that funtion is returning something
00:22tomojwrap-file returns a function which knows how to get at the underlying file object
00:22carkhand that thing has a path
00:23tomojthat function returns a ring response.. dunno what's in it
00:23carkhif it's like older compojure must be a function looking like this : (fn [request] ...returns something in a pure way ..)
00:24tomojyeah
00:25carkhso maybe try calling it like this (my-returned-function {:uri "/foo/blah"})
00:25carkhthat's all based on compojure knowledge, which might not apply anymore =/
00:26tomojlooks like there's a file object indeed
00:26carkhah then just inspect it and you can test easy !
00:26tomojthe :body of the response will be a File I think
00:26carkhoh but that's defn not you ....hum sorry
00:27defnyeah i really have no idea what to do here -- the code is on github carkh if you're interested
00:27defnhttp://github.com/defn/walton
00:28carkhwell you have to investigate what's the path of that file object
00:28defnoh, how?
00:28carkhhum
00:29tomojyou were right about :uri
00:29tomojthat might work
00:29tomojyou also need :request-method :get though
00:29carkh((wrap-file my-app "resources/public") {uri "the/path/as/in/browser"})
00:29carkhah right
00:29carkhjust build a fake request =P
00:29tomojneed a / in front though
00:30carkhand uri is a keyword
00:30tomoj(walton-web {:uri "/foo/bar.js" :request-method :get})
00:30tomojnot sure if some middleware is going to barf on that though
00:31tomojthough, if the
00:32tomojif the File object were coming through, the path would be correct
00:32tomojand if the path were correct, it would work :)
00:32carkhit might be pointing to a place that does not exist
00:32carkhyou can create any goofy File object you want
00:33carkh,(java.io.File. "c:/hello/world")
00:33clojurebot#<File c:/hello/world>
00:33tomojyeah, but it checks to see whether the file exists
00:33carkhwrap-file does the chack ?
00:34carkhcheck*
00:34tomojif the file doesn't exist, it just defers to the app it's wrapping
00:34tomojyeah
00:34hiredmanhttp://weblogs.java.net/blog/2009/06/11/asm-now-supports-invokedynamic oooh
00:34tomojwell, the function wrap-file returns does, anyway
00:36carkhlast ressort : you could copy the wrap-file code into your own wrap-fil and instrument it to see what's hapenning
00:38defntomoj: carkh: wrap-file does complain when the path doesn't exist
00:38tomojwe're talking about different paths
00:39tomojif the root path doesn't exist wrap-file will barf at compile time
00:40tomojif the path the http client requests doesn't exist under the root path, it should just run your app, not complain
00:51Licenserdefn: you share?
00:51defnLicenser: go on and stick your head in!
00:52Licenserwoooh
00:54defntomoj: i think i fixed it
00:55defnim created a route which will match a regex for .js and .css and serves up a static file using (file-response)
00:57defnnow i just need to remove these pesky line numbers...
00:57defntomoj: carkh: thanks for your help
01:00tomojwrap-file is supposed to do that stuff for you :(
01:00tomojoh well
01:03defnhow can i turn a string into executable clojure?
01:03defnlike "(+ 1 2 (+ 3 4))" => (+ 1 2 (+ 3 4))
01:03Licenserread?
01:04tomoj,(read-string "(+ 1 2 (+ 3 4))")
01:04clojurebot(+ 1 2 (+ 3 4))
01:04defnoh right, thanks
01:05defnwhat about if I want to take the value returned by (read-string "(1 2 3)"), and quote it? I can't (quote (read-string "(1 2 3)"))
01:08Licenserit is already quoted
01:10scottjsay you want to share setup and tear down among several tests, how would you do that? right now I have a let inside a deftest and I have a bunch of is statements that actually test different stuff bc I want to share the let. I don't want a let around all the tests bc then it won't happen each time test is executed
01:21lancepantzscottj: fixtures in clojure.test
01:29brian__wondering why I get this 'nil' in a macro: (macroexpand-1 '(useless-3 :toys :count toys))
01:29brian__(defmethod count-cat [:toys :count] [category action value] nil) , the macro is here: http://clojure.pastebin.com/qVsw04Za
01:34hiredman,( 'dosync ( 'alter expr3 'inc ))
01:34clojurebotjava.lang.Exception: Unable to resolve symbol: expr3 in this context
01:34hiredman,( 'dosync ( 'alter 1 'inc ))
01:34clojurebotnil
01:34hiredmanyou are calling the symbol 'dosync as a function
01:35brian__I thought the ' stopped that
01:36hiredmanlists are function calls
01:36hiredman(foo bar) is a list
01:37brian__so you can't create a list in a macro?
01:37hiredmanyou can
01:37lancepantz,(first (re-seq #"\d+" "foo:123"))
01:37clojurebot"123"
01:37lancepantz,(int (first (re-seq #"\d+" "foo:123")))
01:37clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
01:37hiredmanhttp://clojure.org/reader
01:38hiredmanbrian__: quoting quotes the immediately following form
01:38lancepantz^ why does that not work
01:38hiredman'foo is the quoted symbol foo
01:39hiredman('foo) is trying to call the symbol foo as a function
01:39brian__ok
01:39hiredmanlancepantz: what is the output of re-seq?
01:40lancepantz("123")
01:40brian__but in halloways book, he uses 'if to stop if from evaluating
01:40hiredmanbrian__: right, that is what quoting does
01:40lancepantzi guess i need to use parseInt
01:40hiredmanlancepantz: and after you call first on it?
01:40lancepantz"123"
01:40brian__but not in a list?
01:40hiredmanand what does int do?
01:40hiredmanbrian__: sure in a list
01:40lancepantzcoerce to an integer?
01:41hiredmanwhat does the doc say?
01:41brian__then why not ( 'dosync ... ?
01:41lancepantzAt times it is necessary to have a value of a particular primitive type. These coercion functions yield a value of the indicated type as long as such a coercion is possible:
01:42hiredmanbrian__: 'dosync evaluates to the symbol dosync
01:42hiredmanif the symbol was not quoted it would evaluate to the function named by the symbol dosync
01:42brian__so is it possible to put dosync in a macro?
01:42hiredmanyes
01:43hiredman,'dosync
01:43clojurebotdosync
01:43hiredman,dosync
01:43clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/dosync
01:44hiredman,['(+ 1 2) ('+ 1 2) (list '+ 1 2)]
01:44clojurebot[(+ 1 2) 2 (+ 1 2)]
01:47brian__ok, thnks
01:48defnwhen do you use require vs use?
01:50lancepantzuse becomes a pain in the ass if you don't pass :only
01:50Apage43require allows you to alias a namespace instead of pull all of its symbols in
01:51Apage43which allows you to avoid conflicts with their names.
01:53defni think i have circular use deps
01:53Apage43rather, require just loads a lib and makes it available for use. use both loads it and pulls its symbols in.
01:53defnim not sure how to resolve them
01:54Apage43how did -that- happen
01:54defnignorance
01:55Apage43i think the way to deal with that is to move the stuff around such that there aren't circular deps.
01:55lancepantzhahah
01:55defnApage43: yeah but these pieces are logically not supposed to be in the same file
01:56Apage43but they depend on each other?
01:57Apage43if so, there needs to be some abstraction
01:57Apage43of those parts.
01:57defnyes. i have some layout code for an HTML doc which gets used in my -main, and some of the methods from the core which contains -main are used in the layout
01:57Apage43because even if they're 'supposed' to be seperate, they aren't seperate if they have circular deps.
01:57Apage43yeah
01:57Apage43you should probably pass those functions as params to the layout code
01:58defn*nod* -- maybe require :as, and then use them with their namespaces
01:58Apage43instead of have the layout code ref them directly.
02:03defnApage43: nod that makes sense
02:44licoressemorning all
02:53defnis it possible to take a string like "abc", and use it as #'abc?
02:56cemerick,(-> "clojure.core/+" symbol find-var)
02:56clojurebot#'clojure.core/+
02:56cemerickdefn: ^^
02:58defnbooya, thank you
03:20slyphonhrm
03:20slyphonso, there doesn't appear to be a way with clojure.contrib.condition to have a "catch-all"
03:21slyphoni guess i could use "derive"
03:35defnhttp://www.getclojure.org:8080/examples/concat <-- now with fancy syntax hilighting and docstrings (sometimes)
03:42cemerickdefn: very nice :-)
03:42defncemerick: it just died -- it's been acting... unpredictably...
03:43Licenserdefn: sweet!
03:43defnaka it is a bug-ridden festering pile of code garbage :)
03:43cemerickIt might be worthwhile to weight the ordering of samples based on who msg'ed them. e.g. list samples from Rich, chouser, Chousuke, hiredman, et al. ahead of other random people.
03:43cemerickI mean, assuming the number of samples is large
03:44defncemerick: yeah that's something ive considered for sure
03:44cemerickhrm, there's only 7 for seq, so maybe that doesn't matter
03:44defncemerick: it's still building the list
03:44defnif you refresh you can see them crop up
03:44cemerickah
03:44defnbut now it's dead again
03:44Licensercemerick: one reson migt be that the whitelist is still not really entirely full
03:45cemerickoh, there's a whitelist? Close enough, then.
03:47Licensercemerick: yap for functions that are allowed and that are note
03:47Licenserso if seq is used freuqently in a function not in the whitelist all this exampels fall out
03:50Raynescemerick: "Not entirely full" is an understatement. I'll be trying to remedy that situation tonight.
03:50defnRaynes: Ping me with a new clojars sandbox version, would you?
03:51Raynesdefn: Ask Licenser. I don't push new versions.
03:51LicenserI can gladly push 0.2.11
03:52Licenserheh
03:53Licenserpushed 0.2.11
03:53Licenserw/o snapshot since I start to find this silly
03:53defni just got an ebook reader. i htmlized the .core source and and have been reading it front to back
03:54defnLicenser: :)
03:54Licenserheh
03:54esjsalute
03:54defnesj: 'lo
03:54LicenserRaynes: I propably should work backwords on the api but I fear we'll get many ugly conflicts from merging
03:55RaynesLicenser: If you just keep me updated on what letter you're on, I think we can avoid conflicts.
03:56_atodefn: very nice
03:56LicenserRaynes: I talk about merge conflicts, if be both add something to say :list-fns we'll have to sort out later who added which so we can add all together
03:56defn_ato: thanks, but still a lot to do
03:56zmiladefn examples/subseq - the doc is strange and the two examples are the same
03:57defnzmila: the doc is correct
03:58RaynesLicenser: Oh, I see.
03:58defnbut the formatting might make it a little difficult to see they are all related
03:58defnzmila: also, i will be removing duplicates soon
03:58RaynesLicenser: How about this: I'll just bite the bullet and do this as fast as possible. :p
03:58Licenserhad that happen once again, wasn't fun since it means provreading the entire block again to see what changed :P
03:58Licenserheh
03:58Licenseror we agree on me just adding to a different flile or suffix
03:59Licenseror you on a different sufix
03:59_atodefn: looks like you might also need to escape characters like <
03:59Licenserlike :list-fns-lice and :list-fns raynes
03:59defn_ato: hehe, yes, examples/h1 is a good example :)
03:59RaynesLicenser: That would work.
03:59RaynesWe can create two of each category.
04:00RaynesOne for each of us.
04:00RaynesWant to do that?
04:00sparievdefn: very cool stuff, I with I could help somehow, was (and still is) very busy at work
04:00defnoh, maybe not -- since i added syntax highlighting it seems to have escaped the html for me
04:00Licenseryea and every now and then one of us can empty them and merge them together in the real things
04:00Licensersure lets do it that way
04:01RaynesLicenser: Alright. I'll fix that up. Give me a few.
04:01defn_ato: do you have a specific example?
04:01Licensersure sure
04:01_atodefn: subseq
04:01_ato"test(s) one of <, <=, > or"
04:02defnahhh yes
04:02defni see the problem now
04:02Licenser_ato: it shows well for me
04:02defnit shows for me as well actually
04:02_atoit renders cause the browser guesses and unmangles it, but that doesn't mean it's not a problem ;-)
04:02defn:)
04:06RaynesLicenser: You add to the ones without a suffix, and I'll add keys with the same name, with a -r suffix.
04:06LicenserRaynes: better is I think that you add to -r I add to -l that also gives us a proove read effect when adding the other's stuff to the real deal
04:09_atoeg, last example here the browser can't fix for you: http://getclojure.org:8080/examples/pre
04:09Licenseryap true
04:10RaynesLicenser: Okay. I modified the default tester to remove nil values before it constructs the whitelist, this way I can now add the prefixes with a nil value until we modify them.
04:10RaynesI also made it into a pretty -> form. :D
04:10Licensercool :)
04:17defn_ato: thanks
04:20RaynesLicenser: http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox/safe_fns.clj Is this what you had in mind?
04:20Licenseryap that about it :)
04:20Chousukedefn: would it be possible to get the docstrings of things as mouseovers on the symbols?
04:21Licenservery neat
04:21RaynesThis way, we can just copy and paste them into their right place whenever we need to.
04:21RaynesNice idea, man.
04:21slyphongah, a 'let' inside of a handle in handle-condition is causing a NPE
04:22slyphonin clojure.lang.LispReader, no less
04:22slyphongah!
04:25Licenser:)
04:30RaynesLicenser: Should stuff like promises, futures, and other concurrency-related stuff be considered safe?
04:30Licenserhmm I'm not sure about them, I think not since they trick timeout
04:31RaynesOkay. We'll slap them inside of the unsafe fns or something later. Not going to worry about them for now.
04:33Licenser*nods*
04:34LicenserI think for contrib we can whitelist a few entire namespaces since they are non evil
04:34Raynes,(distinct [1 2 3 3 4 5 2 2 3])
04:34clojurebot(1 2 3 4 5)
04:34RaynesOh, that's awesome.
04:34Licenserheh
04:34RaynesHow come I've never heard of distinct?
04:34Raynes:o
04:34RaynesI mean, I think I've written like 5 functions to do the same thing over the past year.
04:34Licenserbecause you'd have called it unique
04:35Raynes:>
04:36RaynesLicenser: I thought we put doc on the safe function list ages ago?
04:36Raynes$(doc doc)
04:36sexpbot------------------------- clojure.core/doc ([name]) Macro Prints documentation for a var or special form given its name
04:36RaynesMaybe I just put it on my own whitelist.
04:36RaynesYeah, I did.
04:37RaynesWas there any reason we didn't put it in safe-functions? I can't remember.
04:37RaynesAll it requires is that print-doc is whitelisted.
04:37RaynesDoesn't seem to be dangerous at all.
04:38Licenserit is a macro :P
04:38RaynesIs that bad? :o
04:38Licenserit will never appear in the test
04:39RaynesUm.. I added the threading macros a while back. >.>
04:39Licenser^^
04:39Licenserwon't make any difference
04:40RaynesI'm confused. :<
04:40Licenserso you're wokring from the api docs on clojure org?
04:40Rayneshttp://richhickey.github.com/clojure/clojure.core-api.html#clojure.core
04:40Licensertry fn-seq on something like a macro
04:40Licenserokay
04:41RaynesLicenser: Your fn-seq wont work on macros? How is it letting the threading macros by then?
04:41LicenserRaynes: it expands the macros to functions
04:41Licenserthat is the truck
04:41Licensererm trick
04:42RaynesOkay, so if print-doc is added, doc will work?
04:42Raynes:o
04:43Licenseryap
04:43RaynesAwesome. Confusing, but awesome.
04:44Licenser,(macroexpand '(doc doc))
04:44clojurebot(let* [m__1734__auto__ (clojure.core/meta (clojure.core/resolve (quote doc))) al__1735__auto__ (:arglists m__1734__auto__) docstring__1736__auto__ (:doc m__1734__auto__)] (if m__1734__auto__ (.replaceAll (clojure.core/str al__1735__auto__ "; " docstring__1736__auto__) "\\s+" " ") (clojure.core/-> hiredman.clojurebot.code-lookup/contrib :vars ((clojure.core/partial clojure.core/filter (clojure.core/fn [a__1737__auto__] (clo
04:44RaynesLicenser: Clojurebot uses a special doc.
04:44Licenserah cool
04:44Licenserthat makes he happy
04:44LicenserI always forge that :P
04:44RaynesHehe.
04:45Licenseras long as doc and var is allowed but I'm not sure if allowing var is nice or not
04:45Raynes,#'var
04:45clojurebotjava.lang.Exception: Unable to resolve var: var in this context
04:45Licenservar is a special form
04:45RaynesOh.
04:45Licenser,(var doc)
04:45clojurebot#'clojure.core/doc
04:45Licenserseems clojure bot thinks it's save enough
04:45RaynesI don't think it will harm anything.
04:46Licenserwell you get the var object which might be sneaky evil
04:46Raynes:p
04:47RaynesIf it hasn't killed clojurebot yet, it's probably safe enough to add. At least until somebody gets murdered by it.
04:47Licensernah clojurebot has holes in it, ask _ato he found one the other day
04:48RaynesWell _ato is a sneaky ba... :|
04:48Licensereven found one in clj-sandbox
04:48Licenserheh
04:48Licenserhe is the reason for removing .
04:48RaynesWell, var is out. :\
04:49_ato,((.get (.findInternedVar (:ns (meta #'inc)) (read-string "eval"))) '(+ 1 1))
04:49clojurebot2
04:50_ato^ that's the one that cause Licenser to remove .
04:50_atoas you can see it uses var
04:50Licenseryea :P
04:50Licenserevil _ato
04:50nteonany philosophical reason PersistentStructMap can't be used with the transient functions? or is it just not implemented yet?
04:51RaynesJust a shame to not be able to whitelist doc. :\
04:51ChousukeI don't think transients would make much sense with structmaps
04:51RaynesSeems like such a benign macro.
04:51RaynesBut has embedded evil.
04:51Raynesx_x
04:52Chousukenteon: if you need them, you can just transform the structmap into a regular map
04:53RaynesLicenser: Speaking of ., have you made any progress with fixing that?
04:55Licensernah still in vacation :P
04:55Licenser+
04:55RaynesHehe.
05:00RaynesLicenser: Where should enumeration-seq go? :o
05:01Licenserwow that is a good question, I'd put it in cast functions
05:02Raynes,(doc error-handler)
05:02clojurebotPardon?
05:03Licenserheh
05:04RaynesNot sure what to make of agent-related functions.
05:04RaynesDon't think I've touched any of them.
05:06RaynesThis is disappointing.
05:07RaynesI can add find-doc, but not doc.
05:07Raynes:>
05:07RaynesI miss the old doc that took a string.
05:08ZabaQIs it possible to use clojure-mode/clojure-swank with the latest slime cvs?
05:12RaynesI don't think so.
05:14BorkdudeI need more chapters from TJoC or CiA
05:14RaynesBorkdude: I agree.
05:15RaynesBorkdude: Annoy chouser.
05:15RaynesAnd _fogus_
05:15RaynesThey're sleeping when they could be writing. Should be illegal.
05:15defnit is in some states
05:16nteonChousuke: thanks, I just rewrote it to use a regular map, since it was pretty isolated
05:16nteontransients speed up my code by about 5x, which is nice
05:17licoresse.
05:18Borkdudewhy not automatically do transients in Clojure in e.g. loops
05:20esjBorkdude: They're teasing us with status updates on the chapters....
05:20ChousukeBorkdude: that's not as easy as it sounds
05:21bsteuberguess we all want to have a clojure compiler that gives output as fast as C :)
05:21ChousukeBorkdude: besides, loops aren't very idiomatic in clojure anyway :)
05:21BorkdudeChousuke, what would be the added value of having a persistent vector in my loop here:
05:21Borkdude(loop [x 0 v (transient [])] (if (> x 5) (persistent! v) (recur (inc x) (conj! v x))))
05:22Chousukenothing, really, but
05:22Chousuke,(into [] (range 6)) uses transients as well :P
05:22clojurebot[0 1 2 3 4 5]
05:23Chousukeexplicit loops are often silly; use existing functions instead
05:23Borkdudeok, so when you are using a lot of persistent things where you might want to use transients you have to consider if something like that already exists?
05:24Borkdude,(doc into)
05:24clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
05:24Chousukeyou should always consider using existing things
05:24Chousukebut the bigger problem is that there's no easy way to tell if auto-transients are safe
05:24Chousukeit's not a trivial code optimisation
05:25Chousukethe compiler might someday do it, but for now I don't think it's beneficial enough justify the effort
05:25Borkdudewhen a function is referential transparent?
05:25Chousukehow do you know that?
05:26Chousukemore specifically, how do you know that the value in the loop will always be something that supports transients?
05:26Borkdudeyou don't ... but maybe you can give warnings like with warn on reflection
05:27Chousukebut the code is valid. You shouldn't warn on valid code :/
05:27Borkdudereflective code is also valid
05:29Chousukethe reflection-warning check is done at compile. there is no way to check at compile time whether a value will be transientable or not
05:29Chousukeat compile time*
05:29Chousukeit would require a static type system :)
05:30Chousukenow, the compiler could do dynamic optimisations and transformations based on profiling and whatnot but that's far from trivial
05:30Borkdudeure. As of Clojure 1.1.0, vectors, hash-maps, and hash-sets are supported.
05:30BorkdudeYou can check for that?
05:31bsteuberchousuke: sometimes there is, if you have control of the calling code or stuff
05:31bsteuberbut in general a lot of hard inference algorithms are needed to do this kind of optimisation right
05:31Chousukeyes. and then you need to ask, is it worth it?
05:31ChousukeI don't think it is, at this point
05:31BorkdudeChousuke, are you involved in developing clojure/contrib?
05:32ChousukeI have a CA, but I haven't done much lately.
05:33ChousukeI'm optimistic that the compiler will become smarter once it gets rewritten in Clojure, though.
05:33Chousukeat least it will be easier to develop
05:36BorkdudeAre transients only meant to be encapsulated by functions, loops, etc?
05:36BorkdudeNot for direct use in a var I mean?
05:36Chousukeyes.
05:36Chousuketransients should never be stored anywhere
05:37Chousukecertainly not in a var, as any operation on the transient would then render the var's content invalid
05:37BorkdudeI can do this:
05:37Borkdude(def g (transient []))
05:37Borkdude(conj! g 3)
05:37Chousukeyou can, but that's invalid code.
05:37Borkdude(persistent! g)
05:38defnis it possible to use ansi-color in a slime repl?
05:38Chousukewell, okay, pointless code :)
05:38Borkdudemaybe the compiler should prohibit it?
05:38ChousukeBorkdude: Again, too much work for little benefit
05:38defnim messing with lazytest and would like to get some color
05:38Borkdudeit's like having safe and unsafe code in C#
05:39ChousukeC# is statically typed
05:39ChousukeBecause Clojure is dynamic, things like this become much more complicated
05:39Chousukeyou can't even tell in the general case whether that code works with transients at all
05:40Chousukesince the transient function, assoc! etc. might be redefined at runtime
05:40Chousukegranted, that's unlikely, but it does show that the optimisations might break in unexpected ways
05:41BorkdudeChousuke, isn't that also the case for a lot of other functions in Clojure?
05:42BorkdudeWhen there are checks for invalid code
05:42ChousukeAre there such checks at compile-time?
05:42ChousukeI can't think of any.
05:42Chousukeexcept some macro form checks
05:43Chousukewhich don't actually care about values at all :)
05:44BorkdudeI was thinking of recur being last in place, but that's a macro form check ;)
05:44Chousukeyeah.
05:44RaynesLicenser: You know, the Clojure API is nearly as large as I thought it was. I'm already over half way through it. :o
05:44Chousukeand recur can't be redefined anyway, since it's a special form :P
05:45Chousukethough...
05:45Borkdudeand a lot of checks are don't by the compiler but go wrong in Java when casting things etc?
05:46Chousuke,(loop [recur 1] (when (< recur 3) (print "hey") (recur (inc recur))))
05:46clojurebotheyhey
05:46ChousukeBorkdude: those are runtime checks, but the JVM does them for us
05:46Borkdudehmm yues\
05:47Borkdudeyes
05:48ChousukeThe clojure compiler is simple and rather stupid for now (it does some optimisations, but AFAIK only if they're necessary for decent performance)
05:48Chousukethe JVM does the rest
05:48Borkdudelike what?
05:49ChousukeWell, there's the locals clearing thing that was added most recently I think
05:50ChousukeI suppose that one is not strictly necessary, but it removed a big gotcha
05:50RaynesDon't call little CC dumb. :( She's so young.
05:50Chousukeheh :P
05:50Chousukeokay, it's willfully ignorant
05:50Borkdudesimple is not dumb
05:50Borkdudewhat is this local clearing thing about?
05:51Chousukepreviously, local references in functions were only cleared on tail-calls (function exit). Now the compiler clears them after their last use.
05:52Borkdudeah ok
05:52Borkdudewhen does that gain performance boost?
05:52BorkdudeI mean, a lot
05:52Chousukewell, it keeps references to things for a shorter time, allowing them to be GC'd earlier
05:52Borkdudeand by cleared, you mean, garbage collected?
05:52LicenserRaynes: sweet
05:52Chousukecleared meaning the reference is nulled
05:53Borkdudeok
05:53Chousukeso that the GC can claim it if there are no more references
05:53RaynesLicenser: In between rocking out in my computer chair to Adam Lambert songs, even. :p
05:53ChousukeI think this was more of an usability optimisation though
05:54Chousukebecause many people (including me) ended up assuming things get cleared at last use and unwittingly held references to sequences that should have been let go, leading to memory leaks
05:55Licenserheh
05:57Borkdudebecause you didn't exit the function? I don't see it before me
06:00ChousukeBorkdude: the problem manifested in functions like (defn foo [aseq] (let [sum (reduce + aseq)] aseq-still-exists-here! ...)
06:01Chousukeeven though the rest of the code doesn't use aseq and reduce could have let it all get garbage collected while it's reducing, the whole sequence ends up in memory because the function parameter refers to it.
06:01BorkdudeChousuke, yes but how long would it take before you would exit the function? I can't imagine causing it very big memory leaks?
06:01nteonis assoc faster on vectors than maps?
06:01nteonis that a silly question?
06:02ChousukeBorkdude: imagine a lazy sequence of 100000000 numbers
06:02defn,(doc assoc)
06:02clojurebot"([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)."
06:02ChousukeBorkdude: without the optimisation, all of those numbers would end up in memory at one time
06:02ChousukeBorkdude: with the optimisation, only a few of them would
06:03nteondefn: yes, I guess I could test for myself.
06:03defnnteon: my guess is faster on a vector
06:03defnbut i dont know for certain
06:03Chousukehmm
06:03BorkdudeChousuke, a reference to the lazy seq would be held, but not all of its items would be realized necessarily?
06:04ChousukeBorkdude: the problem is that if a reference to the seq's head is held, all subsequent items in the seq must be kept as well
06:04ChousukeBorkdude: whereas reduce doesn't actually need to hold the head, it can just go through the rest of the seq and let the head be GCd
06:05ChousukeBorkdude: which allows it to reduce over sequences that would never fit in memory in full
06:05BorkdudeChousuke, so it would depend on what you would do with aseq in the let, still a reference to the head isn't necessary?
06:07ChousukeBorkdude: a reference to aseq is not necessary after it has been passed to reduce, because it's not used in the rest of the function
06:07ChousukeBorkdude: what reduce does with the reference is irrelevant, actually.
06:07BorkdudeChousuke, I know, but even if there was one, it doesn't mean that aseq would be fully consumed into memory?
06:07ChousukeBorkdude: yes it would
06:08Borkdudeah, I don't get that part yet
06:08ChousukeBorkdude: because reduce walks the entire seq
06:08ChousukeBorkdude: and as long as there is a reference to the seq's head outside reduce, the entire seq must be held
06:09Chousukethis is because lazy seqs cache their items
06:09Borkdudeok, but what if there isn't a reference to the head, but to some other elt?
06:09Chousukewalking over a lazy seq twice doesn't actually run the thunks twice
06:09Chousukereferences to the elements themselves are not an issue
06:10Chousukebut if you mean a reference to the tail of the seq, then that might be an issue as well
06:10Chousukethe tail of a list is the head of another list :)
06:11Chousukeif you have a reference to the tail of a list, then the element before the tail can be GC'd, but obviously not the tail
06:12Chousukeeg. (def x (rest '(1 2 3))) allows the list node holding 1 be GC'd
06:13Chousukeat least after x is fully realised :P
06:14Borkdudehmhm, and previously it did not collect '(1 2 3) before the function was exited?
06:14Chousukeit could not, because the aseq reference still existed
06:14Borkdudeisn't there a blog post about this I can read maybe?
06:15RaynesFunfact: Only one function in clojure.core starts with a q.
06:15ChousukeI'm not aware of nay.
06:15Chousukeany
06:15Raynes,(quot 2 3)
06:15clojurebot0
06:15Chousukeheh
06:15Chousukebut there are two operators which start with a q
06:16Raynesorly
06:16Chousukeand one looks like a typo of the other ;(
06:18Chousukehm
06:18BorkdudeI think I'm starting to grasp it now Chousuke
06:18Chousuke,(reduce print nil [1 2 3 4])
06:18clojurebotnil 1nil 2nil 3nil 4
06:18Chousukeoh shoo, it prints nils like that :(
06:21Chousukehm, time to get some food. Later
06:22RaynesLicenser: You haven't added any functions have you? Looks like I'm going to be done by 7-8AM CDT
06:23Raynes(doc repeat)
06:23clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
06:24Raynes(doc replicate)
06:24clojurebot"([n x]); Returns a lazy seq of n xs."
06:24RaynesHow useless. :o
06:26BorkdudeChousuke, suppose I have this example:
06:26Borkdude(defn foo [aseq] (do (print (reduce + aseq)) (last aseq)))
06:27Borkdudein the new situation, what will be collected before (last aseq) if I feed (range 1000000) as aseq into foo
06:27RaynesLicenser: I'm changing list-fns to seq-fns, because most of these fns work for seqs in general.
06:27Borkdudeor at least cleared I mean
06:28_atoBorkdude: nothing will be cleared before (last aseq)
06:29_atoalthough aseq will be cleared while (last aseq) runs
06:29_ato(well the reference is cleared just before entering the call to last aseq)
06:31Raynes,(set [1 2 3 4 2 3 2 5])
06:31clojurebot#{1 2 3 4 5}
06:31RaynesWish I'd know about that yesterday.
06:31RaynesI ended up doing (into #{} ..)
06:31Raynes:(
06:40Raynes,(time (+ 3 3))
06:40clojurebot6
06:40clojurebot"Elapsed time: 0.112 msecs"
06:40Raynes,(macroexpand '(time (+ 3 3))
06:40clojurebotEOF while reading
06:40Raynes,(macroexpand '(time (+ 3 3)))
06:40clojurebot(let* [start__5472__auto__ (. java.lang.System (clojure.core/nanoTime)) ret__5473__auto__ (+ 3 3)] (clojure.core/prn (clojure.core/str "Elapsed time: " (clojure.core// (clojure.core/double (clojure.core/- (. java.lang.System (clojure.core/nanoTime)) start__5472__auto__)) 1000000.0) " msecs")) ret__5473__auto__)
06:42Licenseryea bad news :(
06:43RaynesLicenser: Not like it's that useful from a bot or something anyways.
06:44RaynesLicenser: Anyways, I'm almost done with the entire API, when I am, I'll merge the results and get rid of the suffix duplicates. Don't bother adding any functions yourself.
06:44opqdonuthow can I access static fields through an object?
06:45Borkdudeopqdonut (Object/field
06:45BorkdudeI thikn
06:45opqdonutno
06:45opqdonutonly works for Class/field
06:45RaynesSame way you do normally.
06:45Borkdudeah
06:45opqdonutfor an object i get java.lang.Exception: No such namespace: Object
06:45Raynes(.method obj args) should work.
06:46opqdonutthe doc for the dot special form explicitly says that when the first arg is an object it looks up only instance fileds
06:46RaynesIn that case, just use the class that you made the object out of?
06:46opqdonutwell, you see, I don't know the class
06:47opqdonutsure, I can use java's reflection and that's what I'll do
06:47opqdonutbut it's ugly ugly ugly
06:47RaynesEh? Well. I don't have any magic to help you out. :\
06:48Licenseropqdonut: try java.lang.Object
06:49opqdonuterrr?
06:49opqdonutI can't give both the object and the class
06:50opqdonutit's not a huge thing, it's just weird that clojures . works differently from java's . here
06:50opqdonutin java object.field looks at static fields of the class too
06:52hoeck,(. Integer MAX_VALUE)
06:52clojurebot2147483647
06:53hoeckopqdonut: ^^
06:53Raynes,(. 3 MAX_VALUE)
06:53clojurebotjava.lang.IllegalArgumentException: No matching field found: MAX_VALUE for class java.lang.Integer
06:53Rayneshoeck: ^
06:53hoeckright, sorry
06:54RaynesYou tried, buddy, you tried. <3
06:54opqdonut,(.. 3 getClass (getField "MAX_VALUE") (get nil))
06:54clojurebot2147483647
06:55Borkdudehehe
06:56hoeck,(clojure.lang.Reflector/getStaticField (class 0) "MAX_VALUE")
06:56clojurebot2147483647
07:00RaynesLicenser: I just got to the end of the core API. :D
07:00RaynesAdding final touches and then pushing.
07:00BorkdudeRaynes, what are you doing exactly?
07:01RaynesBorkdude: Adding every function in clojure.core that I deem safe to the clj-sandbox default whitelist.
07:01Borkdudeah ok
07:02Borkdudehello mfex
07:02raekok, this has probalby been asked a thousand time already, but is there any way for making line numbers get passed to the compiler when evaluating in slime?
07:02LicenserRaynes: ayay then I just revert for simplicity
07:11RaynesLicenser: Pushed. After you look it over, please push a new version to clojars.
07:13LicenserI wil
07:13hoeckraek: I'm always using (require '[my.ns :reload]) in the repl :/
07:15hoeckraek: and slime-load-file works too, but only for whole files
07:18hoeckbasically, it should be possible to get accurate line numbers for evaluated expressions without modifying clojure, by using clojure.lang.Compiler/load instead of eval
07:19RaynesLicenser: I'm going to proof-read the docs later. I keep seeing "cause" instead of "course". :p
07:19Licenser:P
07:20RaynesYou foreign people!
07:20Raynes;>
07:21Licenser:P
07:21Licenserwell we can't spell but we can code
07:21RaynesHehe.
07:24LicenserRaynes: I'll move them in the usual functions
07:25Raynes?
07:31esjis there a specific method of disconnecting emacs slime from swank such that one can reconnect later ?
07:31esji keep getting beachballed on attempting to reconnect
07:33ChousukeBorkdude: nothing
07:33ChousukeBorkdude: as _ato seems to have responded :)
07:33Licenserah you did that already now I stop bing confused
07:34BorkdudeChousuke, I didn't do an async call to you, so I was waiting all the time..
07:34LicenserI was looing what Ib roke for liek 15 mintes
07:35BorkdudeBut what keeps a reference to the head of aseq in my example?
07:37ChousukeBorkdude: the fact that you use it in the call to last
07:38ChousukeBorkdude: last needs to walk the seq to get to the last item
07:39RaynesLicenser: Haha, yeah.
07:39Borkdudehmm, so lazy-seq is actually always a lazy-list?
07:39RaynesOwie. Brain freeze.
07:40ChousukeBorkdude: the other way around. lists are sequences
07:40Borkdudebut not all sequences are lists...
07:40Borkdudeso there is maybe a more clever way to do it?
07:41Chousukewell you could make a function that reduces a function over the seq and then also returns the last item
07:42Chousukebut I think that's the only way to do it if you want to avoid walking it twice and thus having to hold the whole seq in memory
07:42Borkdude,(doc lazy-seq)
07:42clojurebot"([& 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."
07:43licoresse/.
07:43Chousukeand just to clarify, seqs and lists are practically functionally identical. the word "list" is usually used to mean PersistentList instances
07:43esjChousuke: so while the seq is walked by (last ...) say, the GC cannot clear elements that have already been passed by ?
07:43Chousukeas opposed to lazy seqs or seqs over a vector
07:44Chousukeesj: it can at that point, but the seq will still be in memory *before* the call to last, because reduce will have walked it once alreadt
07:45esjChousuke: understand (I think), thanks.
07:45Borkdudedoesn't lazy-seq look at the underlying kind of seq what is the most efficient way of accessing?
07:45ChousukeBorkdude: no.
07:45a_strange_guyit cant
07:45ChousukeBorkdude: seqs are never indexed
07:46Licenserpushed new version
07:46ChousukeBorkdude: if you make a seq over a vector, it basically degrades into a list
07:46Borkdudeso seqs are always walked in the list style?
07:46Chousukeyes.
07:47a_strange_guythey only supprort first rest and next
07:48Raynesa_strange_guy: You're strange. :)
07:49a_strange_guyIve hoped that no one would notice ^^
07:50LicenserRaynes: pushed :)
07:50RaynesLicenser: Yay! :>
07:51Licenserthanks for the great work mate, you're doing a incredible job
07:51RaynesThank you. It was hard work, typing those function names. ;)
07:52Borkdudeok got it, tnx
07:52BorkdudeI gtg now
07:52Licenseryea that is hard
08:05Raynes,(with-out-str (println "Hai"))
08:05clojurebot"Hai\n"
08:15esjis there an assoc equivalent for deftypes ?
08:15chouserdoesn't assoc work on deftypes?
08:16chouseroh, only for IPersistentMap ones ("records")
08:16RaynesI thought you had to implement IPersistentMap.
08:16RaynesAh, yes.
08:16chouserYou don't have to implement it yourself though
08:16esjthe doc says it implements it
08:17chouser(deftype F [a b] clojure.lang.IPersistentMap) (assoc (F 1 2) :b 10)
08:17esjperfect !
08:17chouserplanned: (defrecord F [a b]) (assoc (F 1 2) :b 10)
08:18esjthanks, I misread the doc
08:18esjso IPersistentMap would join ILookup and IObj :)
08:19esjthanks gents. deftype/protocol are awesome, I'm annoyed I didn't pick up on them earlier.
08:38raeknice summary, fogus!
08:43wlangstrothmorning all. Hail Clojure.
08:44RaynesIs there a way to get all of the defmethods defined in a namespace?
08:44esjwotcha wlangstroth
08:45RaynesSomething like methods, but that is namespace specific.
08:47wlangstrothRaynes: doesn't the backtick do something magical like that?
08:49chouser,(filter #(= clojure.lang.MultiFn (:tag (meta %))) (vals (ns-interns 'clojure.core)))
08:49clojurebot(#'clojure.core/print-dup #'clojure.core/print-method)
08:53Rayneschouser: That gets the multimethods, but not the methods.
08:53chouseroh sorry, what did you want?
08:54chouserall methods for a particular defmulti, but then filtered on where they're defined?
08:54RaynesIndeed.
08:54RaynesLike methods.
08:54RaynesJust namespace specific.
08:54chouserI don't think that information is preserved currently
08:54RaynesThat sucks. :\
09:06fogusraek: Thanks!
09:07esjmore deftypes: is there a way to access constr using named fields something like - (deftype F [a b]) (F :b 2 :b 1) ?
09:26esjbah - stupid question, sorry.
10:03defni have a dream
10:04wlangstrothdefn: does it involve ice cream?
10:05defnwlangstroth: funny you should ask
10:05defnwlangstroth: of course it includes ice cream
10:06wlangstrothdefn: then I'm all ears
10:06defnbut seriously folks, anyone have any suggestions on building intelligent auto-indentation
10:07defnpprint does not get me very far (i dont think)
10:07carkhthat problem is *hard*
10:07carkhpprint is configurable i think
10:07Licenseryea the question is what is inteligent
10:07defnyeah i figured carkh :
10:07defn:\
10:08Licenseremacs goes with: next line is idented two more spcaes then the last opening (
10:08carkhwhat is wrong with pprint ?
10:08defnWell I think I can define "intelligent" with a set of a dozen rules or so
10:08carkhdefn : that's what you think
10:08carkhyou need to pprint code as opposed to data ?
10:08defncarkh: perhaps im missing some functionality of pprint
10:09defnbut pprint '(blah blah blah), does not yield desirable results for nested functions
10:09defnit seems to only wrap
10:09carkhbut what are you trying to pprint ?
10:09carkhcode or data ?
10:09defncode
10:09carkhi seem to remember there was an experimental flag for that in pprint
10:10Licenser(doc pprint)
10:10clojurebotExcuse me?
10:10Licenser,(doc pprint)
10:10clojurebotExcuse me?
10:10Licenser,(doc clojure.contrib.pprint)
10:10clojurebotjava.lang.ClassNotFoundException: clojure.contrib.pprint
10:10Licenser,(doc clojure.contrib.pprint/pprint)
10:10clojurebot"([object] [object writer]); Pretty print object to the optional output writer. If the writer is not provided, print the object to the currently bound value of *out*."
10:10defn*code-dispatch*?
10:11carkhThe pretty printer supports two modes: _code_ which has special
10:11carkhformatting for special forms and core macros and _simple_ (the
10:12carkh*code-dispatch* looks like this is the dispatch function for code
10:12carkh(with-pprint-dispatch *code-dispatch* (pprint code))
10:12carkhthere you go
10:13Licenserdefn: btw Raynes was so nice to go through the rest of the core API so 0.2.12 is out
10:13defnLicenser: great
10:13carkhdefn : you can find more docs about pprint there : richhickey-clojure-contrib-d1e831b\doc\pprint\
10:14carkhit just sounds silly to redo that work as it's already pretty good
10:14defn,(use 'clojure.contrib.pprint)
10:14clojurebotjava.lang.IllegalStateException: write already refers to: #'clojure.contrib.monads/write in namespace: sandbox
10:15defn,(use '[clojure.contrib.pprint :exclude (write)])
10:15clojurebotnil
10:15defn(with-pprint-dispatch (pprint '(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))))
10:15defn,(with-pprint-dispatch (pprint '(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))))
10:15clojurebot(reduce + (map (fn* [p1__8899] (+ 1 p1__8899 4)) [1 2 3 4 5 6 7 8 9]))
10:16defnclose but no cigar
10:16LicenserI think clojure does not actually wite things like \n
10:17carkhdefn: that's not a pprint problem you have here, that's the reader transforming #() to (fn [] ..)
10:17Licenserhmm is there a way to map over a nested list without destroying it's structure?
10:17defn,(with-pprint-dispatch *code-dispatch* (pprint '(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))))
10:17clojurebot(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))
10:18carkhohh
10:18carkhthere is some magic going on there
10:19Chousukeit probably looks at the parameter list
10:19Chousukep1__nnnn is not a very common parameter name :)
10:19carkhthi spprint thing is awesome, too bad it's a tad slow
10:20Licenser,(with-pprint-dispatch *code-dispatch* (pprint '(reduce + (map (fn [p1__8899] (+ 1 p1__8899 4)) [1 2 3 4 5 6 7 8 9]))))
10:20clojurebot(reduce + (map (fn [p1__8899] (+ 1 p1__8899 4)) [1 2 3 4 5 6 7 8 9]))
10:20Licenser,(with-pprint-dispatch *code-dispatch* (pprint '(reduce + (map (fn* [p1__8899] (+ 1 p1__8899 4)) [1 2 3 4 5 6 7 8 9]))))
10:20clojurebot(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))
10:20Licenser,(with-pprint-dispatch *code-dispatch* (pprint '(reduce + (map (fn* [x] (+ 1 x 4)) [1 2 3 4 5 6 7 8 9]))))
10:20clojurebot(reduce + (map #(+ 1 % 4) [1 2 3 4 5 6 7 8 9]))
10:20Licenserah fn* is the sneaky thing
10:21Chousukemakes sense.
10:21Chousukeno-one's going to use fn* directly in their code
10:21defnoh someone will :)
10:21LicenserI might .P
10:21Licenser(doc fn*)
10:21clojurebotNo entiendo
10:21Chousukewell those are a statistically insignifcant minority :P
10:21carkhdefn : so does that solve your problem at all ?
10:22Chousukefn* is not even an official part of the API
10:22Chousukeit might go away
10:22defncarkh: heh unfortunately i don't think so
10:22carkhso what's the missing part ?
10:23defncarkh: i dont see where it does any reformatting, when i use *code-dispatch* it just gives me *out* which looks like the code i put into it
10:23defni used with-out-str on it to see what happened and received the same thing
10:23carkhthat's because you're passing one-liners
10:23defnyes, all of the input will be one-liners
10:24defnit must be reformatted with indentation and newlines
10:24carkhallright so you need to make your own pprint-dispatch function
10:24carkhyou have examples in the pprint source
10:24defn*nod*
10:24defnthanks carkh
10:27jfieldsI'm trying to slurp a file that might not exist, is there a file-exists? or another better way to handle this?
10:28S11001001jfields: catch FileNotFoundException
10:28Licenser(.exists (File. f))?
10:28S11001001.exists would have a race condition anyway
10:29jfieldsthanks.
10:44AWizzArdHow can I make emacs replace tabs with spaces without resulting in visable differences in my Clojure code?
10:47noidiAWizzArd, afaik M-x untabify
10:47noidiI'm not sure though, since I don't have Emacs at hand at the moment
10:53slyphon?3
10:56esjAWizzArd: yup, noidi is right, and it affects the selection, not the buffer.
11:01AWizzArdyes okay, untabify works
11:01AWizzArdI will have to see how I can automatically use this when saving a buffer and/or doing C-c C-k
11:01AWizzArdthanks for the tip
11:03drewrAWizzArd: you shouldn't be getting tab chars in your code to begin with (with clojure-mode at least)
11:04AWizzArddrewr: is that also true for the clojure mode from October 2009?
11:04hoeckAWizzArd: (setq-default indent-tabs-mode nil)
11:04AWizzArdhoeck: k, will try that, thx
11:14drewrAWizzArd: not sure; I have indent-tabs-mode set to nil like hoeck mentioned, so maybe that's been taking care of me
11:22BorkdudeI got some problems setting up emacs with swank on ubuntu
11:23BorkdudeFile error: Cannot open load file, swank-clojure-autoload
11:23tomojelpa?
11:23clojurebotelpa is a package manager for Emacs: http://tromey.com/elpa
11:29Borkdudemy ubuntu vm is freaking out while installing a flash plugin that was needed to display some github site
11:30Borkdudeso I couldn't follow anything you said after I asked about the swank error, except tomoj saying: elpa
11:31ChousukeBorkdude: hm, github still requires flash for something?
11:31Borkdudein my freshly installed ubuntu with firefox it asked for it yes
11:32tomojBorkdude: that's all I said
11:32tomojare you using elpa, or not?
11:32Chousukethey replaced some flash stuff with HTML5 and canvas a while ago
11:33Borkdudetomoj I'll see if I can get that started
11:35tomojelpa -> install clojure-mode and swank-clojure -> install leiningen -> add leiningen/lein-swank to dev-deps -> lein-swank -> slime-connect
11:35tomojthat's what I do
11:35Borkdudehmm tomoj I already setup clojure.jar and clojure-contrib, etc through git
11:35tomojno need
11:36tomojunless you want to :)
11:36Borkdudetomoj what will happen if I want to be up to date with new clojure versions, if I go the elpa way
11:38tomojif you're using something like leiningen or maven, it doesn't matter
11:39tomoje.g. with lein-swank, you can put whatever version of clojure in your project.clj deps
11:39tomoj(though, the clojure-contrib snapshot apparently hasn't been updated in a while..)
11:39stuartsierrayes it has
11:40tomojoh, yes, it's just named differently from clojure snapshot?
11:40stuartsierraIt's named clojure-contrib-SNAPSHOT
11:40stuartsierraI mean "clojure-contrib" with version "1.2.0-SNAPSHOT"
11:40tomojwhereas clojure is 1.2.0-master-SNAPSHOT, strange
11:40stuartsierrayeah, my mistake, but I'm hesitant to change it again
11:41chouseror my mistake going ahead with "-master". Hard to say.
11:41stuartsierraIt was useful while "-new" was around, less so now.
11:41tomojI noticed semver doesn't even want a - after 1.2.0
11:42tomojoh, guess that doesn't matter for snapshots, though?
11:43stuartsierrasemantic versioning doesn't really allow for development snapshots.
11:44tomojwhich is ok since they won't be tagged anyway, I guess
11:45stuartsierraThe problem with Clojure is that we're all too darned impatient to wait for numbered releases.
11:46stuartsierraAnd people writing Clojure libraries think numbered releases aren't worth bothering with.
11:49hamzahey guys, I have one namespace that holds os specific classes that i only want to load it if I am on say windows, in java I would do this using reflection what would be the lisp way of achiving this? if i try to load this namespace say in linux it would crash because classes aren't present
11:50stuartsierra(if (= "windoze" (System/getProperty "os.name")) (require 'windoze-stuff))
11:52cgrandrequire or load?
11:53stuartsierraload if you want two different files that define the same namespace for different OS's
12:00hamzastuart: load does work when running from clj files but when i jar the application it fails?
12:01stuartsierrahamza: 'load' take a path without an extension, like "foo/bar/baz" for the file foo/bar/baz.clj or foo/bar/baz.class
12:03hamza(load "win_stuff") load it like this, and from repl it works fine but it cant find the class inside jar
12:03stuartsierraCheck that the jar contains win_stuff.clj or win_stuff.class
12:06hamzait contains both win_stiff.clj and win_stuff__init.class
12:10stuartsierrathen it should work, I think
12:10stuartsierramaybe you need an extra directory layer, i.e. "foo/win_stuff.clj"
12:11hamzajust noticed something, it searches clojure folder inside the jar not my applications namespace, clojure/app/win_stuff.clj not found but file is in app/win_stuff.clj
12:12stuartsierrathat's weird
12:12stuartsierra(doc load)
12:12clojurebot"([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."
12:12stuartsierraAha!
12:13stuartsierraYou need (load "/app/win_stuff")
12:14hamzathanks, now got it..
12:15stuartsierragood
12:28hamzaone more question, i have two files win_stuff and uni_stuff, they both provide same api. i load uni_stuff throug use in ns decleration and load win_stuff via load but functions in win_stuff does not override the calls in uni_stuff.
12:32stuartsierraIf think you should only load one or the other, not both.
12:33hamzabut if I load one, lein can not compile the file because functions does not exist, second file is just a dummy file to get lein to compile the jar
12:34stuartsierramaybe define an file that just 'declare's all the functions in your API, then 'load's the appropriate implementation.
12:57SirNickHello, so I have been playing around with clojure a bit but ran into a problem while trying to make a map of the words to their counts given a list. It seems I only get the first 8 counts. Perhaps I am using transients incorrectly? Does anyone have any insight on why this might not be working: http://paste.pocoo.org/show/BtKBoDa0rGsBDXxfFYvN/
12:59technomancySirNick: yeah, that's not how transients work: http://technomancy.us/132
12:59SirNicktechnomancy: alright thanks
13:02tomojSirNick: is clojure your first functional language?
13:02SirNicktomoj: no I've written a fair amount of Erlang and a bit of Haskell
13:03tomojok, so maybe try to think how you'd solve the problem in haskell
13:03tomojclojure wants you to do it more like that than like, say, ruby (which is what your paste reminded me of)
13:03SirNicktomoj: alright thanks, yea I think the problem I am having is just thinking that transients are something they're not. I think I see the error of my ways now though, hah
13:07tomojwhat's prettier than #(assoc %1 %2 (inc (get %1 %2 0))) ?
13:08hiredmantomoj: update-in
13:11tomojwhat, (fn [m k] (update-in m [k] #(inc (or % 0)))) ?
13:12SirNickDoing this the right way turned out much more elegant, but that's no surprise :)
13:12tomojSirNick: how'd you do it?
13:13tomojI was trying to think of the most elegant way I could
13:13tomoj(didn't work very well, as you can see)
13:13SirNicktomoj: Not to say this is the most elegant way possible, but: http://paste.pocoo.org/
13:15SirNicktomoj: I like your idea with inc and or though... Might have to try that
13:15tomojmy best is (reduce (fn [m k] (update-in m [k] #(inc (or % 0)))) {} words)
13:15tomojyour paste didn't come through
13:15SirNickah, oops: http://paste.pocoo.org/show/fpaZK7c6mrZzQt1I58UT/
13:15tomojhmm
13:16tomojhow about: (def count-words frequencies)
13:16tomoj:)
13:16tomojclojure.contrib.seq-utils/frequences
13:16SirNickhah, wow... I'll see how that works, thanks
13:17tomojit uses (assoc counts x (inc (get counts x 0)))
13:17tomoj:(
13:17SirNickhah well I'm sure they thought about it for a while
13:17hiredman(update-in counts [x] nil-safe-inc)
13:17tomojman, I've written that function so many times
13:17hiredmanright
13:18tomojwhere's nil-safe-inc from?
13:18hiredmanno where
13:18hiredman:(
13:20SirNicktomoj: frequencies worked beautifully, thanks
14:00thiosis there a handy clojure way to execute a system command, or does one need to use java.lang.Runtime directly?
14:00hugodclojure.contrib.shell-out
14:01The-Kennyhugod: http://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/shell.clj#L83
14:01The-Kennywhoops. sorry
14:02hugod:)
14:03thiosthanks
14:07rlbhugod: though that won't work if you're dealing with a *lot* of output.
14:08rlbhugod: I started a version that's intended to support lazy process output, i.e. "lazy line seq" from a sub-process, but I haven't finished it.
14:10rlb(Hmm, I should go find that code...)
14:10rlbBut not today.
14:15slyphonso, what's the cool thing that the kiddies are playing with these days to deal with large tree-like data structures in clojure
14:15slyphon?
14:20carkhslyphon: what do you mean ? that's pretty a open-ended question
14:20slyphon"clojure.zip" i think is what i was looking for
14:23Raynesslyphon: Zippers.
14:23Raynesslyphon: Oh, didn't see your last message.
14:23Raynes:p
14:23slyphonheh
14:27slyphonare zippers good for editing nested hashes?
14:27carkhi like to (update-in [:customers customer-id] update-pricelist pricelist-id update-pl-item item-id inc rate-increase)
14:28carkhslyphon: yes they are
14:28tomojreally? I thought I remembered a discussion here that they weren't
14:28slyphonso if i have {:foo {:bar {:blah "thing"} } }
14:28carkhhuh
14:29slyphonhow do i get to blah?
14:29chouserI don't know that anyone has written a genearic map-zipper. There's a vector-zipper.
14:29chouserand xml of course
14:29carkh(assoc-in {:foo {:bar {:blah "thing"} } } [:foo :bar :blah] "other-thing")
14:29carkh,(assoc-in {:foo {:bar {:blah "thing"} } } [:foo :bar :blah] "other-thing")
14:29clojurebot{:foo {:bar {:blah "other-thing"}}}
14:29slyphonahh
14:29slyphonok, that's good
14:30carkh,(update-in {:foo {:bar {:blah "thing"} } } [:foo :bar :blah] str 2)
14:30clojurebot{:foo {:bar {:blah "thing2"}}}
14:45BorkdudeI am now in emacs and got elpa installed
14:45Borkdudenow which package should I begin with?
14:46Borkdudeswank-clojure ?
14:47hugodrlb: yes, I need to implement that for clj-ssh too
15:00S11001001is the bit where clojure.core/compile recursively compiles loaded files considered a bug or a feature?
15:04BorkdudeI tried to install all the needed packages through elpa now
15:05Borkdudebut.. it's not working
15:05Borkdudejava.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
15:05The-KennyBorkdude: You have to load the java-part too (swank-clojure.jar)
15:06The-Kennyslime consists of two parts: One for the emacs-side and one for the lisp/clojure side.
15:10BorkdudeThe-Kenny, I realize that
15:10Borkdudebut I can't really find out how to start from a clean emacs to a working clojure setup. how do I start best from a clean emacs?
15:11The-KennyBorkdude: Oh, and elpa is just for emacs-lisp files. It won't pull swank-clojure.jar. I'd recommend leiningen for this.
15:11The-KennyBorkdude: For a clean setup, I would use leiningen to set up a clojure project, pull dependencies etc. and use elpa to install slime and swank-clojure.el (the emacs stuff)
15:12The-KennyIn fact, that's what I'm using now
15:14mrSpecHello! I'm trying to use Clojure mode in emacs. But does the name completion work with Java Libraries? Or I have to use Eclipse/NetBeans? eg. .addAc[TAB] => addActionListener
15:15The-KennymrSpec: I think it won't work with java-libs in it's current state. But I think it's on someones todo-list
15:16mrSpecThe-Kenny: but does it work in other IDE?
15:16licoressemrSpec: M-/ will complete the symbol if it already exists
15:17The-KennymrSpec: I don't know. I'm only familiar with slime
15:17mrSpeclicoresse: thanks, but it doesnt solve the problem :(
15:17mrSpecThe-Kenny: ok, thx
15:18The-KennymrSpec: If you're familiar with emacs-lisp, you could try implememting it :)
15:18The-Kenny(I'm not even sure if you have to know elisp for that)
15:18mrSpecThe-Kenny: I'm not familiar enough ;)
15:18carkhwouldn't that be coming from the swank part ?
15:18The-KennyMaybe the whole completion stuff is in clojure
15:19The-Kennycarkh: Yeah, sorry for that. I realized that a few seconds after I pressed enter :)
15:19carkhwell i don't know, just guessing =)
15:20mrSpecso, do you write under Emacs? And do you use all java libraries without name completion? :/
15:20licoressemrSpec: I do
15:20carkhmost of the time you'll hide the java stuff and do the call only once
15:20licoressethere was life before name completion
15:21The-KennymrSpec: I think most people write a thin wrapper around the java stuff.
15:21The-KennyIn fact, it's rather easy to use a foreign library as you mostly have the reference opened already
15:22mrSpecthin wrapper? could you say something more?
15:22The-KennymrSpec: Just some clojure functions to call the java stuff. Nothing more
15:22mrSpecah o
15:22mrSpecs/o/ok
15:22carkhmrSpec: your example with addactionlistener is a good one ... when i need this, i'll just use my own function (add-action-listener (fn [action] ????))
15:23The-KennyI think there's something for action-listeners in contrib too
15:23The-KennyIn swing-utils
15:23carkhahwell i guess i should have looked in there first =P
15:23mrSpechehe
15:24The-Kennyhttp://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/swing_utils.clj#L23 heh
15:24carkhanyways, the thing is that i don't have to do the whole "implementing an interface" thing
15:24mrSpecbut most I will use JUNG, Action listener was only an example ;)
15:25carkhjust build a library of functions that will help you with that, then you need to use each of these completable verbs only once
15:25carkh(when writing the library)
15:25mrSpeccarkh: ok, I will think about it
15:26mrSpecin few days I have to decide Clojure or Java
15:26carkhwhat kind of application are you aiming for ?
15:27mrSpecIt will be aplication to show the relationships between ppl in some blogosphere.
15:28carkhyou'll find that clojure lets you write it with less lilnes of code, but you have to think harder to produce each one
15:28mrSpecI think so, moreover I love lisp and hate java ;)
15:28mrSpecso clojure sounds good for me
15:29carkhhaha well then looks like you made a decision already =)
15:29mrSpec:)
15:30carkhi see (defn potential-dot "Returns a list of potential dot method name completions...." ..) in swank-clojure
15:31carkhso it should be working =/
15:31The-Kennycarkh: Huh? Where?
15:31The-KennyAh, found it
15:34BorkdudeThe-Kenny: it turned out I had a .clojure directory
15:34Borkdudethat eliminated swank-clojure asking if I wanted to install
15:35Borkdudebut now that's fixed :)
15:40The-KennyI think one problem is, that slime-fuzzy (that's what I'm using, fuzzy-completion is great) seems to not-use this function
15:42carkhi'm using it too and yes not working
15:49The-KennyUnderstanding swank_fuzzy.el is so *damn* hard :/
15:49The-Kennys/.el/.clj/
15:55carkhhum yes this isn't easy stuff
15:56carkhcould take fuzzy-find-matching-vars as a base
15:57The-KennyI'm doing this just now :)
15:57carkhand somehow insert the result in fuzzy-generate-matchings
15:57carkhnice =)
15:59The-KennyBut I have to admit: I already tried that some time ago, and I gave up
16:13The-KennyEvery time I try this I start thinking "This isn't worth the effort"
16:14carkhthat's a one time effort for a lifetime of bliss
16:14carkh...so to speak
16:28BorkdudeCool, I finally have a working emacs + leiningen
16:37qbombThe-Kenny: What is it that motivates you to try again?
16:37The-Kennyqbomb: I would like to see this completion. It would be a good improvement
16:45slyphonso, in a gen-class impl function, 'this' is explicit
16:45slyphon?
16:45slyphonbut in proxy it's not?
16:46StartsWithKslyphon, yes
16:46slyphonok
16:46slyphonjust making sure
16:46slyphonmakes sense
16:46StartsWithKin gen-class it has to be as methods are separate functions
17:02slyphonso, -init is always called with whatever the constructor arguments are? so if you have multiple constructors, you should make init variadic?
17:04StartsWithKslyphon, yes, same goes for methods too
17:05slyphonok
17:05StartsWithKand do your own type checking for arg types if you need that
17:05slyphonthanks
17:09slyphonStartsWithK: could you take a look at something for me?
17:09slyphonhttp://gist.github.com/361587
17:09StartsWithKsure
17:09slyphonoh, hm
17:10StartsWithKand what is the problem?
17:10slyphoni could probably do this by only having a default constructor and then using a setter
17:10slyphonwell
17:11StartsWithKthat could be a easy way out :)
17:11slyphonelsewhere i call (XmlRpcRequestWrapper. req new-stream)
17:11slyphonand the compiler throws: error: java.lang.IllegalArgumentException: No matching ctor found for class mbox.harpo.xmlrpc.XmlRpcRequestWrapper (xmlrpc.clj:224)
17:11slyphonyeah, i think i'll just do that
17:11StartsWithKbut you can also do
17:11StartsWithK(defn init ([req] do1) ([req x] do2))
17:11BorkdudeAny ideas when I get "All :namespaces already compiled. " in a leiningen project but no classes are generated?
17:11slyphonoh!
17:12slyphonBorkdude: your namespaces aren't correctly specified? just a guess
17:12slyphoni've had trouble with that too
17:12Borkdudeslyphon, I have this:
17:13Borkdude(defproject swingprj "0.1" :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"] [org.clojure/clojure-contrib "1.0-SNAPSHOT"]] :main swingprj)
17:13Borkdudein my project.clj
17:13slyphonyeah, you need to specify :namespaces explicitly
17:13slyphonStartsWithK: thanks!
17:13Borkdudesince when?
17:13Borkdudea lot of examples on the web don't have it
17:15slyphoni think it's recent
17:15slyphontechnomancy would know
17:15slyphonStartsWithK: so, it's expected that what i have would produce that error?
17:15Borkdudedo you know how I must specify it? :namespaces [swingprj] ?
17:15slyphoni think it's actually each class name
17:15slyphoni *think*
17:16Borkdudeah if I put :namespaces [[swingprj]]
17:16StartsWithKslyphon, yes
17:16Borkdudeit generates some promising errors ;)
17:16slyphonStartsWithK: so it's the signatures on -init that it's unhappy with
17:17slyphon"There's no -init that takes 2 args, dummy!"
17:17StartsWithKi don't think so, as you would get a error saying function has a wrong type hints
17:17StartsWithKthis looks like something from ctor defs in gen-class
17:18slyphonah
17:18slyphonhrm
17:18Borkdudehmm I think this is wrong
17:18StartsWithKbut then again.. with gen-class you never know for sure :)
17:18slyphonStartsWithK: ah, yeah, it all seems a little...hit-or-miss
17:19StartsWithKtry constructiong a stub in java, its what i do
17:19slyphonyeah?
17:19slyphonhrm
17:19slyphonyeah, i guess i could do that
17:20StartsWithKpublic class MyStub { public Map<String, IFn> ifns = new HashMap<String, IFn>(); void someMethod(String arg) { ifns.get("someMethod").invoke(arg); }
17:21StartsWithKlength is almost the same, same compile problem.. no problems with differen clojure versions.. and i know how what to write
17:21slyphonclever
17:22slyphonso
17:23slyphonyou assoc "methName" (fn [] (println "i am methName")) with MyStub/ifns ?
17:23slyphons/with/in/
17:23slyphonor .add rather, i guess
17:24slyphoni'm just a little confused as to what the ifns thing is doing
17:24slyphonthat lets you poke clojure into the java class?
17:24StartsWithK(.put MyStub/ifns "lalala" (fn []))
17:24StartsWithKjust make ifns static
17:24slyphonah, gotcha
17:24StartsWithKit holds fn's from clojure side, this is more-or-less what gen-class will do too
17:24slyphonyeah, totally
17:25slyphonok, yeah, this makes sense
17:25Borkdudeslyphon, what is the format in which to specify the namespaces
17:25BorkdudeI get all kinds of weird error msgs
17:25slyphonum
17:25slyphoni think it's :namespaces [my.full.namespace.ClassName]
17:25slyphonagain, i haven't had much luck with it
17:27slyphonBorkdude: technomancy is the author, he'll most likely be able to give you more authoritative answers
17:27Borkdudetechnomancy ... can you answer this?
17:30technomancy:namespaces [my.full.namespace] should do it
17:30technomancyit's not about the gen-class so much as it is the namespace that contains it
17:30technomancybut I've never done AOT in any of my projects before, so take it with a grain of salt. =)
17:31slyphontechnomancy: is there a leiningen plugin that handles building java classes?
17:33technomancysure, lein-javac
17:33Borkdudetechnomancy, so I don't even need to compile in order to create an (uber)jar or what?
17:33technomancyhaven't used that either
17:33slyphontechnomancy: ah, cool
17:34technomancyBorkdude: in general: you never need to compile unless you want java interop or a main class for an executable jar
17:34BorkdudeI have some java interop in the code
17:34technomancy(that may not be 100% accurate with new 1.2 features)
17:34BorkdudeI am just trying something simple to see if I can get a project compiled to an uberjar
17:35Borkdudebut I don't know what I'm doing wrong her
17:35Borkdudee
17:37Borkdudeborkdude@Ubuntu-VM:~/temp/swingprj$ java -jar swingprj-standalone.jar Exception in thread "main" java.lang.NoClassDefFoundError: swingprj
17:38slyphoni hate you java
17:39BorkdudeI have this structure: swingprj/project.clj
17:39Borkdudeswingprj/src/swingprj.clj
17:41zaphar_psBorkdude: does swingprj.clj have a gen-class in it's namespace declaration?
17:41The-Kennyuhm.. isn't the use of single-element namespaces discouraged?
17:42zaphar_psThe-Kenny: why. If it's not library code there is little need to have a deep namespace
17:43The-Kennyzaphar_ps: I know. But I saw some people here talk about problems with single-element-namespaces. Maybe that's the problem here.
17:43zaphar_pshrmmm I've never had an issue it was usually because I didn't have the gen-class directive that this particular error would crop up
17:44Borkdudezaphar_ps, I have this in swingprj.clj
17:44zaphar_psBorkdude: use a pastebin please
17:45Borkdudezaphar_ps: nevermind, I think I got it now
17:45zaphar_ps:-)
17:47BorkdudeI used a dash in the namespace
17:47Borkdudeprobably that caused it
17:48The-Kennytechnomancy: huh, why? The fuzzy-completion-stuff?
17:48technomancyno, I mean the single-segment namespace problem
17:48zaphar_pstechnomancy: what issues are arising with single element namespaces?
17:48Borkdudeand it looks like the :namespacs is not really mandatory, can you confirm this technomancy?
17:48Borkdude:namespaces
17:48technomancyBorkdude: if you have :main set and your main requires your nses that need AOT then that might be enough
17:49technomancyzaphar_ps: I'm fuzzy on the details; just have heard a proclamation to the effect of "don't do it"
17:49technomancysomething to do with Java packages
17:49zaphar_pshrmmm interesting
17:50zaphar_psis that only when doing AOT or is it for all clojure namespaces
17:50technomancyI think it's AOT-specific
17:51jholloway7Hi. How do you invoke constructor of static inner class? I tried: (Outer/Inner. args) throws IllegalArgumentException saying there is no matching method
17:55slyphonswank is failing me
17:56Borkdudejhollaway7, try this? http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Cookbook#Accessing_inner_classes
17:57Borkdudeso with the dollar sign
17:57Borkdudenever tried it myself though
17:58bsteubercool, polyglot maven with leiningen-support - http://groups.google.com/group/clojure/browse_thread/thread/2949d054ca166da9
17:58bsteuberin case this wasn't posted already a hundret times :)
18:00bsteubers/t/d/
18:02Borkdudecool, my stand alone app works in ubuntu, xp and win7
18:12jholloway7Borkdude, thanks will give it a shot
18:53sattvikHmm... My CA has been received, and I am listed on the contributors page. However, I have not been approved for the clojure-dev mailing list. Also, should I be a 'team member' for Clojure on Assembla now? I can't seem to comment on tickets I have not opened.
18:53TakeVHow do you install/use leiningen addons?
18:56technomancyTakeV: add them as dev-dependencies and do lein deps
18:56TakeVtechnomancy: Hmm, that didn't seem to work for autodoc.
18:58TakeVtechnomancy: To the project.clj, right?
18:58technomancythat's the idea
19:14defnTakeV: did you run lein deps after you added it?
19:15ndimidukTakeV: lein clean will delete the content of lib and thus uninstall your dev-dependencies
19:15TakeVdefn: Yes. When I then try to run "lein autodoc", it tells me that autodoc is not a task.
19:16defnwhat does your lein version tell you
19:16TakeVLeiningen 1.1.0 on Java 1.6.0_0 OpenJDK Client VM
19:19defnTakeV: hm, weird
19:20ndimidukTakeV: is the plugin compatible with 1.1.0?
19:20defnTakeV: what version of autodoc? 0.7.0?
19:20ndimiduki don't know if the revbump broke internal APIs
19:20TakeVYes, 0.7.0.
19:21ndimidukTakeV: try just running `lein` after a `lein deps`- it should list the available tasks
19:22TakeVOdd, it randomly started working...
19:24TakeVErr, thanks for the help, though. 0_o
19:24slyphonso, is there a convention to wrap the pattern (if (pred? thing) (xform thing) thing)
19:25slyphonlike (xxx pred obj & body)
19:33lancepantzis there a way i can define a string with a different delimiter than "?
19:33lancepantzlike %{foo} in ruby
19:34lancepantzdo then %{a"b} returns "a\"b"
19:34lancepantz*so
19:35slyphoni don't think so
19:35slyphonthat'd be a reader macro
19:36slyphonyou could probably do something sneaky like define a macro s
19:36slyphonand just concat all the stuff inside
19:37lancepantzyeah, thats probably my best bet
20:40defnyou could make a map and {:a my-delim :b inner :b inner :b inner :c my-delim}
20:40defnand then build from there?
20:40rlbDo I recall correctly that nested defs are not appropriate in clojure?
20:41defnrlb: better to use a let
20:43rlbthx
20:45hiredmandef is not lexically scoped like schemes define
20:45rlbhiredman: ahh, that's what I (almost) remembered -- thx.
21:06slyphonis there an easy way to get clojure.xml/parse to parse a string as input?
21:08slyphonor do you just have to wrap it in a ByteArrayInputStream
21:08hiredmanbytearray is the easy way
21:08slyphonk
21:09slyphonseems kinda...lame?
21:10slyphoni mean, i very well could be missing something
21:17defn2 quick questions on namespace stuff...
21:17slyphon"yes", and "only on thursdays"
21:17slyphonwas i right?
21:17defn1. When I use defn- in a namespace, does that mean that I can have public defns which use those private defn-s?
21:17slyphonthat works for me
21:17carkhyes
21:17slyphonjust watch out for macros
21:18slyphonthat expand and call private dfns
21:18defn2. Should I use in-ns to split up a large file into more logical pieces, or is this bad?
21:18slyphonoooh
21:18defnslyphon: ah yeah didnt think of that
21:18slyphondefn: yeah, it's tripped me up a couple of times
21:18slyphonit's pretty obvious when it happens though
21:18carkhi keep one file per ns
21:18slyphoni've found moving the private stuff into an "internal" namespace is good
21:19carkhif you need 2 files, then you can make sub-namespaces
21:19defncore.clj and utils.clj seem like they could reside in the same namespace
21:19defncarkh: good point
21:19slyphoncarkh: i don't understand
21:19slyphonif you have two files, *then* you can make sub-namespaces, or it's just better to structure things that way with one-file-per-namespace
21:20defni had absolute namespace hell -- still sort of do -- i let them get away from me
21:20carkhsometimes a single namespace grows a lot
21:20technomancydefinitely don't use in-ns anywhere except the repl
21:20slyphondefn: circular references drove me insane for a good hour or two last week
21:20defntechnomancy: reason! logic! i need none of this!
21:20carkhso when it's getting too big, i do a bit of refactoring
21:20technomancyif you break the one-ns-per-file, one-file-per-ns rules your code just gets a lot harder to follow
21:21defntechnomancy: good point
21:21technomancycontrib sets a bad example here
21:21slyphontechnomancy: what do you mean "rules your code"
21:21slyphon?
21:21technomancyshould be a comma after "rules"
21:21slyphonah
21:21defnif you break the .... rules, your code...
21:21slyphonok
21:22technomancygotta jet; see you cats later
21:22slyphonkk
21:22slyphonwhat do you guys put in 'user.clj'
21:22slyphon?
21:22carkhnothing
21:22carkhwell
21:22carkhnothing for the final application
21:23slyphonrepl stuff?
21:23carkhi use it to play while developing
21:23defncould user.clj be useful for configuration vars?
21:23carkhyes i have a doc searching macro
21:23defnseems like a decent place for them
21:23slyphondefn: might as well make that stuff namespaced as well
21:23slyphonno?
21:23carkhuser is for interactive use
21:24defnslyphon: maybe... i guess i dont see why it couldnt go either way
21:24carkh(to me at least)
21:24defncarkh: even still, some users may use some code i wrote interactively
21:24defnit might be nice to include some helper stuff
21:24carkhlike you make a program that your user interacts with via the repl, you boot himm in there
21:25carkhthen you can import the top level commands of your program
21:25carkhbut that's very 1970 as user interfaces go
21:26slyphonwhat goes in 'core'?
21:27carkhyou mean clojure.core ?
21:27slyphonno, like, my.ns.core
21:27slyphonleiningen creates one by default
21:27carkhi don't use that convention
21:27slyphonah, ok
21:27defni like the core convention
21:28defnquestion on namespaces again... when do you use com.blah net.blah, etc.?
21:28defnit seems sort of loose
21:28carkhthat's java convention, they do it like their real url
21:29carkhi just go cara.my-app-or-library
21:29slyphoni strip off the 'com'
21:29slyphonso like, motionbox.prj-name.thing
21:30carkhthe url thing makes sense as it's quite unique
21:30carkhthere are no 2 com.google.blahblah
22:04defnI have a structure which looks like: (["some string", "another string"] ["some string 2", "another string 2"])
22:04defnhow can I remove duplicates based on the first of each []
22:05slyphonhrm
22:05defni was thinking about a sorted-set maybe, but after i map first across, i lose the context
22:06underdevdefn, what's the url of that clojure examples app you made?
22:06defnhttp://getclojure.org:8080/examples/concat
22:06defnreplace concat with whatever
22:06slyphonwell, if i were gonna do this with ruby or something
22:06defnsome examples don't work still underdev, but it's a WIP
22:06slyphoni'd make a collector that's a hash
22:06underdevrt on
22:06underdevall good
22:07slyphonand just check each item, see if the key is already in the hash, if not add it
22:07slyphoni guess you lose ordering that way though
22:07underdevoooh, syntax highlighting, very nice
22:07chouserslyphon: you want to keep the first or the second?
22:07underdevhow did you do that?
22:07chouserslyphon: and you want to keep order or not?
22:07slyphonchouser: defn's the one
22:07chouseroh, sorry
22:07slyphonchouser: i'm just trying to think it out :)
22:07slyphonnp
22:08chouserdefn: same questions. :-)
22:08tomojdefn: did you get the include-js stuff working, then?
22:08defnchouser: i want to keep both the first and second, i just want uniques for the list of [] [] []
22:08defntomoj: i did yes :)
22:08slyphonit's funny, i was gonna say before "these are the kind of questions usually answered by chouser or hiredman"
22:08tomojcool
22:09chouserdefn: I still don't understand ([:a 1] [:a 2] [:b 3]} becomes what? ([:a 1] [:b 3])?
22:09slyphonso, after i have an xml-tree created by clojure.xml/parse, er, how do i emit that as xml?
22:09defn(["x", "y"] ["x", "y"] ["x1", "y2"]) => (["x", "y"], ["x1", "y2"])
22:10slyphoni see the reading but not the writing
22:10defnactually nevermind -- i can just called sorted-set on that structure, huh?
22:11defn,(sorted-set '(["x", "y"] ["x", "y"] ["x1", "y2"]))
22:11clojurebot#{(["x" "y"] ["x" "y"] ["x1" "y2"])}
22:11slyphonhmm
22:11slyphonfail
22:11defner maybe not
22:12defn,(apply sorted-set '(["x", "y"] ["x", "y"] ["x1", "y2"]))
22:12clojurebot#{["x" "y"] ["x1" "y2"]}
22:12defnthere we go
22:12slyphonah, there you go
22:13lancepantz,(->> '(["x", "y"] ["x", "y"] ["x1", "y2"]) (into {}) (into ()))
22:13clojurebot(["x1" "y2"] ["x" "y"])
22:13defnah, nice
22:15slyphonwell, the zip example is pretty spiffy, i just mutated xml without really grokking what's going on
22:15slyphonwhich i guess is both good and bad
22:15carkh,(distinct [["x", "y"] ["x", "y"] ["x1", "y2"]])
22:15clojurebot(["x" "y"] ["x1" "y2"])
22:16slyphonif you call zip/root at any point in the walk of a tree, do you get the whole (possibly mutated) tree?
22:16defn(doc distinct)
22:16clojurebot"([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"
22:16defnoo, cool
22:16carkh~def distinct
22:17lancepantzi dont think thats what you want
22:17lancepantz,(distinct [["x", "y"] ["x", "y1"] ["x1", "y2"]])
22:17clojurebot(["x" "y"] ["x" "y1"] ["x1" "y2"])
22:18carkhyou can addapt the source to look inside the vectors
22:18carkhit's O(n) and preserves order
22:19carkhthere should be a "key" parameter
22:19carkhi mean to the standard function
22:20carkhso you could (distinct first col)
22:20carkhcould be added easy with no breaking change
22:20lancepantz,(->> '(["x", "y1"] ["x", "y"] ["x1", "y2"]) reverse (into {}) (into []) reverse)
22:20clojurebot(["x" "y1"] ["x1" "y2"])
22:37defncarkh: very grateful for that tip
22:37defnthanks
22:38carkh=)
23:41quotemstrHow well does Clojure work on Android these days?
23:42hiredmannot very, androids gc isn't very good, and it's jit is experimental and turned off by default
23:46TakeVAndroid doesn't use the JVM, right?
23:48quotemstrRight; it has its own JVM.
23:48quotemstrNIH.