#clojure logs

2010-02-11

01:51Rayneshttp://jobs.arstechnica.com/list/543/?utm_source=Indeed&utm_medium=organic&utm_campaign=Indeed "are pragmatic enough to understand that clojure is not a cure for cancer..."
01:51RaynesHeh heh. It's a job offer.
02:00herdrick
02:01herdrick,indexed
02:01clojurebot#<seq_utils$indexed__697 clojure.contrib.seq_utils$indexed__697@19cc8fd>
02:07DeusExPikachuRaynes, it doesn't cure cancer "yet"...
02:07DeusExPikachu:)
02:34LauJensenGood morning all
03:41ordnungswidrigre
04:53neotyk~def for
05:04LauJensen~source for
05:07Licenser_I wonder, is there a way to get a better help during problems then: java.lang.NullPointerException (NO_SOURCE_FILE:1)?
05:15AWizzArdLicenser_: well, you could step through your code with a debugger.
05:16AWizzArdAlthough I must admit that I always had heavy problem with using debuggers for Clojure code.
05:18ordnungswidrigerror reporting must definitively improve
05:20AWizzArdI agree.
05:20AWizzArdIt would be great if JSwat would simply work.
05:21AWizzArdIt was working better in older versions. Maybe this really is the mistake of JSwat and not Clojure.
05:23AWizzArdIf JSwat would work I would constantly have it opened during development.
05:27fulletsWhat's an idiomatic way to go from [:a :b :c :d] -> [:a :c] (i.e., transform a sequence to a sequence containing every other item of the input)
05:29AWizzArdfullets: you can do (vec (take-nth 2 [:a :b :c :d])) ==> [:a :c]
05:29fulletsAWizzArd: Excellent, thanks!
06:14Licenser_AWizzArd: thank you for the hint
06:16zabhi im having trouble using vimclojure
06:16zabim opening a file called 'hello_world.clj' and it gives me: Couldn't execute Nail! java.io.FileNotFoundException: Could not locate hello_world__init.class or hello_world.clj on classpath:
06:17zab'hello_world.clj' has a namespace declaration at the top of the file. if i open another .clj file without a namespace, it loads fine
06:18zabanyone know what's up?
06:19cypher23zab, the ng server needs the correct class path, so it can find your files
06:20cypher23e.g. if your file is located under src/my/namespace/hello_world.clj, you need to make sure that 'src' is on the Classpath for the nailgun server
06:20cypher23The way I do it is start the ng server inside the src dir, and have "." on the classpath
06:22zabhmm okay. i've added the directory to the classpath. i've just added it to the environment variable in my ~/.profile (mac os box). i now get a slightly different message
06:22zabCouldn't execute Nail! java.io.FileNotFoundException: Could not locate compojure__init.class or compojure.clj on classpath:
06:22cypher23well, now it can't find compojure :)
06:22zabyeah i put the path to compojure in my classpath as well though :(
06:23cypher23do you have compojure in source form, or as a jar?
06:23zabjar
06:23triyoWhat would be the equivalent in Clojure of the CL's atom symbol?
06:23cypher23did you add the dir the jar is in, or the path to the jar?
06:24Licenser_any advice about debugging with emacs and clojure?
06:24zabthe dir the jar is in but with a wildcard
06:24zabi.e. ~/vim/vendor/vimclojure/compojure/*
06:25cypher23zab, yeah, that never works for me, at least on os x. you have to add each jar individually
06:25zabcypher23: yikes even the dependancies?
06:25cypher23zab, http://gist.github.com/301431
06:25cypher23that's how I do it (I have all my jars symlinked into ~/classes/)
06:26zabokay that's certainly nicer than what was rushing through my head
06:26cypher23zab, no idea. I'm not a Java person, so all this CLASSPATH dealings are somewhat arcane to me :)
06:27tomojtriyo: I don't think there is one, really
06:27zabcypher23: obviously i am in the same boat. not a Java person either. :)
06:27tomojzab, cypher23: I haven't scrolled up to see what you're really talking about, but have you looked at lein?
06:28tomojI haven't worried about CLASSPATH in quite a while
06:28zabtomoj: i've seen mention of lein in several places but never really explored it.
06:28tomojI see a mention of nailgun though, dunno how/if lein could work with that
06:28cypher23tomoj, no, not yet. Still basically doing my first steps in Clojure
06:28tomojah, ok
06:28cypher23tomoj, yeah, nailgun can be a bit tricky to get it up and running
06:29tomojhmm
06:29tomojactually it appears there is a lein-nailgun plugin :D
06:30esjcypher23: indeed, getting everything in place the first time is very trying, but be strong: its worth it.
06:30tomojsupposedly you can just add it to your dev-dependencies and then do 'lein nailgun' to start a nailgun server
06:31esjyeah, its supposed to do the same for emacs with lein swank, but I had some classpath issues I was too stupid to resolve :(
06:31tomojhmm
06:32tomojI had some classpath issues once, but after a recent upgrade they disappeared
06:32tomoj(I use lein-swank)
06:33cypher23esj, it's mostly the Java stuff that trips me up. Clojure itself has been quite nice so far.
06:33esjyou and me both, but the bump doesn't take too long to get over
06:34cypher23I hope :)
06:38AWizzArdMaybe you two can rewrite the JVM in Clojure :)
06:40tomojhmm
06:40tomojI had never considered clojure hosting itself
06:40tomojit's possible, right?
06:41tomojwould just require distributing an already compiled version, I think?
06:43AWizzArdIt is possible, and in fact this is a work in progress.
06:43ambientwell you need some backend, if not jvm then win32/elf machine code at least
06:43tomojright
06:43AWizzArdIt already has begun. Yesterday Master Hickey implemented lots of stuff of Vectors in pure Clojure.
06:44tomojI had always just thought of cinc as a way to get clojure on other virtual machines
06:44tomojnot as possibly taking us closer to clojure compiling itself
06:44ambientit is, but it can do so much more.. :)
06:44ambientat least how i understand it
06:45ambientimplementing a scheme compiler in scheme opened my eyes a bit of the possibilities
06:45tomojbit shifts are inlined, hurrah
06:46zabhmm, i'm fairly sure my classpath is all sorted now thanks to cypher23, but now i get:Couldn't execute Nail! java.lang.ExceptionInInitializerError (hello_world.clj:0) at clojure.lang.Compiler.eval(Compiler.java:4543)
06:48tomojwhat is this implicit arg stuff? http://github.com/richhickey/clojure/commit/277f0235c1387ddd6247a72857597814a3e10bc3
06:50tomojoh, http://www.assembla.com/spaces/clojure/tickets/242
06:51LauJensenWonder why the ticket doesnt explain the pitfalls
06:52tomojpitfalls?
06:53AWizzArdMoin cemerick.
06:54cypher23zab, how does your hello_world.clj look like?
06:55LauJensentomoj: I think if your macro generates an fn which it internally depend on, then it will break with this change
06:55LauJensenclarify: depends on it having a particular signature
06:58tomojhmm, I figured that was for code internal to clojure
07:01zabcypher23: it's the first 'hello.clj' example here: http://en.wikibooks.org/wiki/Compojure/Getting_Started
07:02LauJensenzab, long story short, head to my blog, read "installing slime", "beating the arc challenge", "reddit clone 1", "reddit clone 2", and you'll be a webguru in no time: http://www.bestinclass.dk/index.php/blog
07:05zabLauJensen: i'm just starting out in clojure. your blog has some good content. will definitely check it out. once i get vimclojure working. :(
07:06LauJensenzab: great, but the reason I mentioned "installing slime" as the first stop, was not so that you could continue in Vim :)
07:07zabLauJensen: hah! yes well it will take more than a few hardships getting vimclojure set up, to get me to move away from vim.
07:08LauJensenOk - Its also worth saying, that VimClojure is pretty great actually
07:09ohpauleezfwiw, I love vimclojure. I don't use the repl stuff, but I do use the completion and doc lookup
07:09zabLauJensen: yeah I've been playing with the REPL and I'm able to send my current buffer to it, no problems. I really like what I've seen so far.
07:09underdev10 year vimmer here- emacs is impressing the heck out of me. Esp since i'm lisping, i've learned some stuff just setting up emacs.
07:09cypher23zab, as a workaround, you could just have a REPL running in a shell next to Vim, and just keep calling (require 'hello-world :reload) to reload your file
07:10underdevbut vim is excellent, and i had to start editing my .emacs file with it
07:10underdevand most other situations i find i'm still opening text with vim
07:10LauJensencypher23: May I henceforth address you as Mr. Fred Flintstone ?
07:11cypher23I don't have a pet dinosaur :)
07:11underdevin other situations (like tcl) i used screen to have a top window of vim and a bottom one of the repl
07:12LauJensencypher23: well... technically you do :D
07:12zabcypher23, LauJensen heh. yeah not ideal. i'm still going to pursue this VimClojure setup. but good to know.
07:12LauJensenzab: Most evenings CET kotarak hangs out in here, he built it
07:13cypher23zab, you could wait for kotarak, he can probably help you out (he helped me a lot)
07:13zabLauJensen, cypher23: cool. I'm so close to it, I can taste it.
07:14cypher23LauJensen, I do?
07:14LauJensencypher23: You use Vim right ?
07:15cypher23LauJensen, sometimes
07:17LauJensenAnyway, enough Vim bashing, lets drop the subject and pick it back up again in 20 minz or so :)
07:19cypher23hehe, k
07:20LauJensenA wee bit OT, but does anybody know if ZyXEL NSA-210 supports SSH ?
07:22somniumhttp://gist.github.com/301463 << spontaneous attempt at coaxing more error info out of exceptions. is there a better way to terminate execution?
07:32zabhooray i have VimClojure working with Compojure.
07:33zabturns out I didn't have the same clojure.jar and clojure-contrib.jar files that I compiled compojure against, in the classpath
07:34zabi'm able to load files which require compojure fine now, except upon loading it, vim gives me: E15: Invalid expression: 2010-02-11 23:27:50.193::INFO: Logging to STDERR via org.mortbay.log.StdErrLog^@clojure.proxy.javax.servlet.http.HttpServlet
07:34zabanyone seen this before?
07:39AWizzArdrhickey: Hi. I think I just discovered a bug in Clojures compiler. When I try to compile my namespace it tells me (Windows XP) that the file name is wrong. I found out that this happens when I try to compile a deftype which contains a slot which contains a questionmark in its name.
07:40AWizzArdWhile for example vars are translated into foo$somefn_QMARK__2457.class this seems to not happen with slots inside deftypes.
07:41zabgg, thanks for your help everybody.
07:43AWizzArdCan any windows user please try to confirm this issue? Put this into a file yourcp/bar/foos.clj (ns bar.foos) (deftype Foo [a b c?])
07:43AWizzArdWhen you then do (binding [*compile-path* "yourcp/build/"] (compile 'bar.foos)) you should see an error message.
07:44AWizzArdmaybe under Linux this is a problem too, don't know how questionsmarks are handled.
07:51triyoAny Clojurians here read the OnLisp book and attempted to implemented the solutions in Clojure?
07:57lpetittriyo: sure. For example: http://blog.thinkrelevance.com/tags/on%20lisp
07:59triyolpetit: thanks. Thats great. I'm working on chapter 19 - Query compiler part. Hope I didn't bite of more then I can chew.
07:59triyoso far so good
08:06Licenser_hjmm can anyone give me an advice here? when adding a emacs swank option I get let: Wrong type argument: listp, "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888"?
08:07Licenser_ah found it had to add '( arund it
08:10Licenser_oh my got jswat is not doing what I expect
08:12AWizzArdYeah, because you can not set break points and such.
08:19krumholtif i have only one ref in my program i want an atom instead right?
08:19AWizzArdkrumholt: not necessarily
08:20AWizzArdI will tell you in .de ;-)
08:31ordnungswidrigme is building a validation library. The name of some validation functions clash or nearly clash with existing functions, what would you suggest to be a good solution? Using a prefix, like v-odd or !odd ?
08:32ordnungswidrigMaybe I should use some macro to build a validation dsl?
08:33AWizzArdordnungswidrig: don't know if possible, but perhaps the validation fns can have the same name, and your Data Structures can extend a Protocol?
08:33cemerickordnungswidrig: that's what namespaces are for
08:34ordnungswidrigcemerick: sure. hm, I see. you mean put the validation functions in foo.validation and import the ns a "v" so that I can use v/all v/odd v/or ?
08:35AWizzArdIf you can use protocols, if they make sense, then they can free you from that naming problem. Otherwise you are only shifting it to some other level.
08:35cemerickordnungswidrig: Yup. There's sometimes a bit of an art to naming the alias ("v" in your example), but it's the way to go.
08:35AWizzArdNamespaces or slightly differently named fns don't resolve polymorphically.
08:36cemerickAWizzArd: having name clashes is *not* a reason to use protocols.
08:36cemerickPlenty of good reasons to do so, but none of them have anything to do with namespace issues.
08:36ordnungswidrigcemerick: so I end up with ((v/all (v/in :name (v/applied count (v/less-than 5))) (v/in :age (v/greater-than 20))) { :name "John" :age 16})
08:37ordnungswidrigcemerick: using a clever macro I could eventually reduce this to (validate (all (in :name (applied count (less-than 5))) (in :age (greter-than 20))) ...)
08:38cemerickordnungswidrig: sure. Alternatively, if you're using that namespace constantly, you could use the whole thing, and exclude or rename the same-named fns from other namespaces.
08:39cemerickordnungswidrig: Totally not worth it, IMO. namespaces are there to solve these issues, and make it obvious to those who come after you what's going on. A macro is just source-level obfuscation in this case.
08:39ordnungswidrigwhen I want to have an open set to validators which can be used as "keys" in the above dsl then I need to use some kind of registry, right? a map like { :all v/all :prime my.custom/prime }
08:39AWizzArdcemerick: for name clashes you are right. I just saw the indicator that ordnungswidrig likes to have many fns that should in principle have an identical name.
08:40AWizzArdAnd this is a potentially a signal that Protocols may help.
08:40ordnungswidrigor I can omit a macro and use keywords: (validate :all [:in :name :applied :count :less-than 5] [:in :age :greater-than 20] ...)
08:40cemerickAWizzArd: Maybe, maybe. Without knowing more, I wouldn't recommend them, though.
08:41cemerickordnungswidrig: well, in that case, a macro makes a lot of sense, insofar as it would "compile" that DSL so that you don't have to do so at runtime.
08:41AWizzArdYes, too early for a recommendation.
08:42ordnungswidrigAWizzArd: the validation shall be independent from the data type. you can validate a string against it's content or it's lenght. I don't see how protocols fall in place there.
08:43AWizzArdordnungswidrig: and multimethods also can't help?
08:43ordnungswidrigcemerick: is there some support for DSLs like that in a lib? In my case it'd be rather simplistic
08:44cemerickordnungswidrig: not sure I grok your question -- are you looking for an example of macro usage like that?
08:44somniumordnungswidrig: you would be parsing :less-than-5 into #(< % 5) ?
08:44AWizzArdordnungswidrig: it would be very much work to make it work with Protocols and strings. But you could invent funny Types, such as StringWithLessThan100Chars or StringThatContainsNoFs :)
08:44ordnungswidrigcemerick: I have a basic understanding of macros. I think I can go with it.
08:45ordnungswidrigsomnium: the predicates like #(< % 5) are lifted to be a validator which returns a map, e.g { :level :error :validator :less-than :info 5 }
08:46cemerickordnungswidrig: OK. FWIW, enlive has a pretty extensive DSL for defining CSS selectors, which it compiles to finite state machines for walking HTML/XML nodes. That's not a simple example, but you can look at its API for an idea of how usage might look like your case?
08:46ordnungswidrigsomnium: I need this to validate nested structures and consolidate on the error level
08:46ordnungswidrigcemerick: that is a good idea!
08:47unomiHi, anyone around?
08:47ordnungswidrigunomi: hmm, no :)
08:47unomithats a shame :(
08:47unomiordnungswidrig: are you a contributor?
08:47cemerickheh, this channel is hardly ever quiet anymore :-)
08:48ordnungswidrigunomi: contributor? no, I don't think so.
08:48unomiI am wondering if I could ask you guys some questions about your code repo
08:48ordnungswidrigpastie
08:48cemericklisppaste8: url?
08:48ordnungswidrigwhere's clojurebot?
08:48unomiyou are on assembla right?
08:48cemerickordnungswidrig: OK, the bot's down, again :-/
08:48AWizzArdbot is sleeping
08:48ordnungswidrigbot is depressed
08:48cemerickunomi: that's where the issue tracker and dev wiki is.
08:49unomiwould you recommend it?
08:49cemerickI'm not a huge fan, but it's worked for Rich's requirements.
08:49ordnungswidrigshall I gist or shall I pase...
08:50ordnungswidrigs/e/t&/
08:51ordnungswidrigFor whom is interested: this is what I have for now: http://gist.github.com/301521
08:51ordnungswidrigAnd the validator definition is a little verbose for my eyes.
08:52jcromartiesomnium: is support for dbref planned in congomongo
08:53AWizzArdOh, what is dbref?
08:53AWizzArdSounds like one of my data structures.
08:53somniumjcromartie: not currently. storing object-ids is just as effective with less ceremony
08:54the-kennyAWizzArd: a data type which refers to another entry in the database.
08:54AWizzArdgood
08:54jcromartiedbref isn's a datatype
08:54jcromartieit's just a convention
08:54the-kennyoh ok, sorry
08:54AWizzArdAnd what is congomongo?
08:54jcromartie{$ref: "column_name", $id: "the object id"}
08:55somniumjcromartie: is there a use case where holding object-ids isnt sufficient?
08:55the-kennyAWizzArd: a client for mongodb in clojure
08:55jcromartiecongomongo is a clojure wrapper around the Java mongodb driver
08:55jcromartiesomnium: no but dbref is the convention in mongo
08:55AWizzArdAnd MongoDB is not relational but document oriented?
08:55jcromartieright
08:56jcromartiedbref optionally supports cross-database references
08:56jcromartieand it includes the collection name
08:56jcromartieit would enable automatic dereferencing language-side
08:57somniumjcromartie: well, theyre supported in the java-driver, so patches welcome
08:57jcromartieah, cool
08:57jcromartieok
08:57jcromartieI am a total n00b when it comes to these drivers :)
08:58somniumI just havent seen anyone use them :) its a map with :db, :object-id, :collection right? why not just use a map
08:58somniumbut maybe Im not understanding
08:59jcromartieit is just a map
08:59jcromartiejust a convention
08:59jcromartiehttp://www.mongodb.org/display/DOCS/DB+Ref
08:59jcromartie(or an object in JSON terms)
09:01somniumah, they use it like an embedded query
09:01somniumwell, patches welcome :)
09:13esji'm using congomongo
09:13esjadmittedly, only for a couple of days now...
09:14krumholtcan something bad happen if i throw an exception inside a transaction?
09:14jcromartiekrumholt: that's what transactions are for
09:14jcromartiethey don't commit if an exception is thrown
09:15krumholtso i can throw my own exceptions inside transactions?
09:15jcromartieyeah, but they don't bubble up
09:15jcromartieerr, sorry, that's for agents
09:15jcromartieyeah you can throw your own
09:16krumholtok thanks
09:17AWizzArdYou can get Exceptions out of an agent, but it is a little bit hackish.
09:57_fogus_,(cond nil 1 nil 2 :lollipop "POP")
09:58_fogus_Clojure-bot must be shoveling also
10:06pdkthat gives "POP" in the console
10:08chouserpdk: clojurebot? Is that you?
10:09pdkin the form of an s expression please
10:09chouserpdk: (= you clojurebot)
10:09AWizzArd~max people
10:09clojurebotmax people is 246
10:09esjhe's in disguise
10:09pdknow gotta define 'you'
10:09esjtired of being asked silly questions all day long
10:09pdkand where's the comma :|
10:19powr-tocDoes anyone know why leiningen is setting my projects root directory to src/myproject, rather than the root directory where my project.clj file is???
10:19powr-toclein swank - specifically
10:23esjnever figured that out - using swank-clojure-project directly instead
10:23powr-tocesj: so I'm not the only one then? :-)
10:23esjwell, you're in poor company, but not alone.
10:24powr-toclol
10:24JomyootDoes clojure.contrib.sql support talking to 2 db simultaneously
10:26powr-tocesj: swank-clojure-project does it too :-(
10:26esjoh, now you've lost even your poor company
10:26esjmine asks me what the root directory is
10:27powr-tocesj: so does mine... but (import java.io.File) (. (File. ".") getAbsolutePath) tells me the JVM is running without that as its root dir
10:27fdaoudhi all
10:28JomyootI need to use 2 databases simultaneously. how do I do that with with-connection* ?
10:28fdaoudwhat's the easiest way to convert {:a 1 :b 2} to {"a" 1 "b" 2} ?
10:30tomojhmm
10:30tomoj,(into {} (map (fn [[k v]] [(name k) v]) {:a 1 :b 2}))
10:30clojurebot{"a" 1, "b" 2}
10:30powr-tocJomyoot: Don't know specifically, but with-foo's usually setup bindings, i.e. vars... so you should be able to nest them
10:30tomojawfully ugly
10:30fdaoudI had
10:31esjpowr-toc: you're correct - I dunno, i was referring to the root in the classpath, sorry.
10:31tomoj,(letfn [(map-keys [f m] (into {} (map (fn [[k v]] [(f k) v]) m)))] (map-keys name {:a 1 :b 2}))
10:31clojurebot{"a" 1, "b" 2}
10:32fdaoudtomoj: i had something like that (but yours is better), but i thought there was a less convoluted way
10:32powr-tocesj: it seems like a bug to me
10:32fdaoud,(let [m {:a 1 :b 2}] (apply array-map (map (fn [k v] [(name k) v]) (keys m) (vals m))))
10:32clojurebot{["a" 1] ["b" 2]}
10:32tomojI can't think of one if you want a map back
10:32JomyootI don't see binding option
10:32fdaoudthx tomoj
10:33fdaoudthat will only do the top-level, right, not any nested maps?
10:33tomojindeed
10:33powr-tocJomyoot: can you pastie your code?
10:33AWizzArdJomyoot: you can not have an overlapping transaction anyway, so could you not just first query db1, retrieve all results you need, and then query db2 with the information from the first run?
10:33tomojalso note that's not lazy
10:34JomyootBecause I don't want to open/close connections all the time.
10:34JomyootI want to keep 2 DB connections open simultaneously
10:34fdaoudthat's fine, i just need to pass the whole map to a Java method..
10:34tomojah
10:34Jomyoot(with-connection db -- opens up connection
10:34fdaoudbut converting keywords to strings
10:34tomojfor nested maps it gets uglier :(
10:35JomyootTHen I have (with-query-results rs -- to do the querying
10:35AWizzArdyes
10:35Jomyoot(with-query-results) does not allow me to specify which connection.
10:35JomyootAWizzArd: do you know how to help me?
10:35fdaoudindeed....but I thought for sure someone else needed that and there was a built-in or contrib function
10:35tomoj(letfn [(map-keys [f m] (into {} (map (fn [[k v]] [(f k) (if (associative? v) (map-keys f v) v)]) m)))] (map-keys name {:a {:foo 3 :bar {:baz 4}} :b 2}))
10:36tomojI've often felt that way too
10:36tomojmapping over maps sucks
10:36powr-tocJomyoot: which library are these functions part of?
10:36tomojwhen you want a map back, anyway
10:36AWizzArdJomyoot: I don't see how it is possible what you want to do without going to some manual use of Java functions.
10:36Jomyootclojure.contrib.sql
10:36AWizzArdOtherwise I would suggest you to first do one query, close the conn, then open the second and run that query.
10:37Jomyootis there a different/better library for sql?
10:38hiredmanJomyoot: they all use dynamic binding unfortunately
10:38AWizzArdI think nearly all of them concentrate on using one db at a time.
10:38tomojhmm
10:38AWizzArdYou can however open two connections manually.
10:38JomyootHow would one deal with sharding/replication then?
10:38tomojcan't you get around it by messing with *db* yourself?
10:38hiredmanAWizzArd: concenctrate is the wrong word
10:38AWizzArd:)
10:40tomojor using the clojure.contrib.sql.internal functions?
10:44tomoj(with-connection _ (let [db1 *db*] (with-connection _ (let [db2 *db*] _ (binding [*db* db1] _) (binding [*db* db2] _)))))
10:44tomoj:(
10:44tomojof course you could wrap that up in a couple macros
10:44hiredman:|
10:45tomojI guess you'd be better off rewriting clojure.contrib.sql
10:45tomojor wrapping it I mean
10:45chouserwow. that's what's wrong with having any args only passable via Var
10:45hiredmanright
10:45tomojclojureql doesn't do that, does it?
10:45AWizzArdchouser: what do you mean specifically?
10:46chouserAWizzArd: if looking at tomoj's code doesn't cause you pain, there's not much I can do for you.
10:46chouserer, that example in particular. not tomoj's code in general. :-)
10:46tomojhehe
10:46AWizzArd^^
10:46AWizzArdWell, one could split it over several lines and nest it a little :-)
10:47AWizzArdBut really, maybe Jomyoot can simply call some .java methods and have two DBs open at the same time.
10:47tomojit's still just fundamentally evil
10:47tomojwell, there's get-connection in the internal ns
10:48tomojbut the problem is, the functions for doing db ops don't care
10:48tomojyou still have to bind *db*
10:48tomojhuh, I guess clojureql does the same thing?
10:48cemerickI was wondering about this the other day -- so every fn should always have at least two arities, one that takes an explicit env (*db* in this case), and another that just delegates to the former using the current value of the bound env?
10:48hiredmanyes
10:49tomojwhyyy
10:49chouserright, you should always be able to pass in everything you need via regular args. Clojure's print fns suffer from the same issue.
10:49tomojI'm pretty sure I remember reading a discussion about this for clojureql quite a while ago
10:49tomojhow did the var people win
10:49cemerickit makes the common case a lot cleaner, short of doing what I just suggested.
10:49chousercemerick: I think so. It's ok to have separate fns if different arities are enough
10:50tomojcan we write a macro that makes it easy to do both?
10:50chouseraren't
10:50cemericktomoj: that's just what I was thinking about
10:50hiredmanall my database functions in clojurebot start with (binding [*db* db] ...)
10:50chouser(prn-to my-out foo bar)
10:50tomojyou need to specify what the implicit arg is and where it is in the args... would always first arg be good?
10:50cemericktrying to generally allow describe the various vars that might be in play is likely intractable tho
10:51tomojin most cases, though, I think it's the first arg
10:51chouserhm. I bet if clojure's print fns did that it would help set the culter and expectations for other libs.
10:51cemerickarg position isn't the issue, its when there's multiple bindable vars
10:51tomojthough, a lot of these functions take &args I guess
10:51chouserrhickey: would you hate having prn-to, print-to, println-to, etc?
10:51tomojcemerick: huh?
10:51hiredmancemerick: how often does that happen?
10:52tomojit's usually just *db*, *server-hostname*, *out*, stuff like that, that I've seen
10:52tomojmaybe the macro can ask for a suffix to tack on to the function names so arity isn't an issue
10:52rhickeychouser: no, prn-to or prn-on?
10:52tomoje.g. for query you could have query-db
10:52cemerickhiredman: more than you'd suspect
10:53cemerickonce you're past trivial stuff, the usefulness of vars is hard to resist
10:53chouserrhickey: "to" seems more natural to me. or maybe "into"
10:53fdaoudtomoj: thanks for your help
10:53hiredmancemerick: I would argue the reverse
10:54hiredmanonce you are past the trival stuff, rebinding vars makes a ball of string of your functions
10:54tomojin any case the pattern of having a var to pick out a resource and then functions which interact with the resource is common
10:55rhickeychouser: not into, streams are not containers/collections
10:55cemerickin many cases, the choices are (a) have a pile of vars, (b) thread lots of args, or (c) ball up the environment into an uber-map
10:55hiredman:(
10:56hiredmancemerick: (c)
10:56cemerickugh. That's way messier than vars, IMO.
10:57hiredmancemerick: until you have to deal with two environments
10:57cemericksure
10:58cemerickI generally try to ensure everything I do is thread-bound anyway (e.g. not using pmap, etc) -- even I'm not using vars at the moment, one of the libs I'm using might, etc.
10:58cemerickeven if*
10:58chouserI'd be find with print-on, though that's not how I usually think of output streams.
10:59hiredmancemerick: :(
10:59rhickeygeneric vectors move forward: http://gist.github.com/301644
10:59hiredmanso the fact that a library you use may be using vars means you are restricted to operating in a single thread?
11:00hiredmanand you are still pro-var?
11:00rhickeyall that's left is a little macrology, but I've factored out the commonality so that only the little bits at the end need to be macros
11:01cemerickhiredman: I think for the vast majority of code, single-thread operation is just fine, and vars are often clearer and easier to work with compared to options (b) or (c). When I find a hotspot, then I cull that bit out, and ensure that I'm using options (b) or (c), and then pmap away or whatever.
11:02cemerickagain, I'm talking here about nontrivial situations where the "environment" is not just a single value, etc.
11:03hiredmancemerick: single threaded and single environment, no matter how many values are in the environment, is trivial
11:04cemerickcompojure is a perfect example of this -- James is very much against vars, but being super-explicit about what data is going where when there's dozens of sources balled up in each request is extraordinarily tiresome. So, we've got some middleware that sets up ~ a dozen vars -- for params, url params, session state, current user, current account, blah blah.
11:05cemerickhiredman: well, I don't like passing around large and opaque grab-bags of values.
11:05hiredmanopaque?
11:05hiredmanhow is a map opaque?
11:06hiredmanif anything a map is less opaque than vars, you can dump a map in a single call to prn, how do you do that for a bunch of vars?
11:07chouserrhickey: why definterface instead of defprotocol?
11:07rhickeychouser: int args :(
11:07AWizzArdI currently have a similar "dilemma". For my Clojure DB I will have transaction, and in those one states the DB. Now I am thinking: should I make insert/update/delete aware of this?
11:07cemerickhiredman: Because the available slots in a map can be changed at any time, and the only indication of that is the source code that does the modification. fn args are explicit about what's available, as are vars.
11:07AWizzArd(insert some-db obj) vs. (insert obj)
11:08chouserrhickey: oh, of course.
11:08rhickeyI did prototype with a protocol, fwiw
11:08chousereasy to switch later. :-)
11:08rhickeyextremely
11:08chouserI need to do something like that for finger trees
11:08hiredmancemerick: bound vars are even more susceptible to change via set!
11:08AWizzArdrhickey: did you notice the problem that I reported 3,5 hours ago?
11:09AWizzArdWith compiling deftypes that have slots which contain questionmarks? This fails under Windows XP.
11:09rhickeydon't use question marks
11:09AWizzArdWhy did you allow them in function names and vars?
11:09chouserright now my measure/reduce objects are little maps with functions in them. I need to allow use of primitives there.
11:09AWizzArd(def *is-null?* false) is fine.
11:10cemerickhiredman: I don't mean changing the values (though set! is a very rare operation), I mean changing the slots that are defined.
11:10AWizzArdalso (defn even? ...) is allowed
11:10AWizzArdwhy not (deftype Foo [a b is-null?])?
11:10hiredmancemerick: so?
11:10AWizzArdThose get automatically renamed to QMARK
11:10cemerickAWizzArd: deftype doesn't mangle field names to the same degree as vars, etc.
11:10rhickeychouser: I really need to bite the bullet and dig into the long/double arg/return support
11:11rhickeyat least definterface is dynamic now
11:11AWizzArdcemerick: yes, but is there a principle reason why it shouldn't?
11:11hiredmanAWizzArd: deftype fields are java fields, and java fields cannot have ? in the name
11:11chouserrhickey: what's blocking ccinc? design improvement questions?
11:11cemerickAWizzArd: no, but I believe it's a low-priority item
11:12rhickeychouser: not much. I really want to find a nice way to work on it, together in a group
11:12chouserrhickey: is it not worth doing something closer to a straight port just to provide a better basis on which to do design improvements like you have on the wiki page as well as things like primitive arg/return?
11:12AWizzArdhiredman: the ? is no problem for Java at all. Only when I *compile* my code the problem shows up. Because the compiler tries to save the field name with a ? inside.
11:12AWizzArdAnd Windows XP does not allow that.
11:12AWizzArdIf XP allowed questionmarks in files then all would be fine now.
11:13rhickeychouser: I'm not going to port the mutable bits, too hard to keep straight. But I think there is a simple mapping to protocols for the same abstractions
11:13hiredmanAWizzArd:
11:13hiredmanfoo.java:2: ';' expected int foo? = 0;
11:13chouserAWizzArd: I don't know that that would be true for all JVMs
11:13AWizzArdhiredman: I can type into my repl: (deftype Bar [a b c?])
11:13chouserrhickey: yes! ok.
11:13hiredmanAWizzArd: it is not a filename issue
11:13AWizzArdThis code gets compiled when I type enter.
11:13cemerickAWizzArd: and you won't be able to access the c? field from a Bar.
11:13AWizzArdAnd I can do (println (:c? (Bar 1 2 3)))
11:14hiredmanAWizzArd: deftype's are different when AOT'ed
11:14chouserrhickey: protocols on plain maps?
11:14rhickeychouser: I'm very frustrated with the online design and collab tools
11:14AWizzArdcemerick: in my Clojure it works perfectly well.
11:14rhickeychouser: no, deftypes
11:14fdaoud,(associative? ["a" "b"])
11:14clojurebottrue
11:14rhickeyprotocol on plain map just begs how to dispatch
11:14chouserok
11:14fdaoudyikes
11:15cemerickAWizzArd: Then your build has slightly better runtime mangling than mine, but apparently AOT'ing non-java field names isn't yet there. *shrug*
11:15fdaoudwhat is true for a map but false for a vector or list?
11:15hiredmanfdaoud: vectors associate indexs to values
11:15AWizzArdI just found it to be a bit inconsistent to allow questionmarks in principle everywhere else, but not as slots for deftypes.
11:15hiredmanfdaoud: map?
11:15chouser,(map? [])
11:15clojurebotfalse
11:15chouserfdaoud: like that?
11:15esjfdaod: map?
11:15fdaoudchouser: yes, but that's so simple that I feel foolish now
11:15cemerickAWizzArd: AFAIK it's not a design decision, merely an implementation limit right now.
11:16AWizzArdOkay.
11:16esjrats.... that'll teach me to paste before seeing if somebody beat me to it....
11:16AWizzArdSo, for now I will rename those guys then.
11:16AWizzArdis-null-p comes to mind ;)
11:17sparievHi, I'm getting reflection warning on (java.io.File. path) - call to java.io.File ctor can't be resolved
11:17hiredmanwhy are you naming a field as a predicate anyway?
11:17fdaoudtomoj: so I changed associative? to map? since I want vectors and lists to stay intact
11:17sparievwhere should I put type hint ?
11:17fdaoudfor example, {:a 1 :b ["a" "b"] :c {:d 5 :e 6}}
11:17chouserspariev: (java.io.File. #^String path) ... or on wherever path is defined in the first place.
11:18AWizzArdhiredman: rhickey did that himself too in some .java files, without the questionmark of course. It is nice for slots that will always be true or false.
11:18sparievchouser: many thanks
11:18fdaoud,(letfn [(map-keys [f m] (into {} (map (fn [[k v]] [(f k) (if (associative? v) (map-keys f v) v)]) m)))] (map-keys name {:a 1 :b ["a" "b"] :c {:d 5 :e 6}}))
11:18clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.Named
11:18fdaoud,(letfn [(map-keys [f m] (into {} (map (fn [[k v]] [(f k) (if (map? v) (map-keys f v) v)]) m)))] (map-keys name {:a 1 :b ["a" "b"] :c {:d 5 :e 6}}))
11:18clojurebot{"a" 1, "b" ["a" "b"], "c" {"d" 5, "e" 6}}
11:18chouserspariev: np!
11:19BrandonWtrying to come to terms with writing programs functionally: i have 2 vectors of the same number of elements. how do i transform the first vec so that it returns a new vec where each element is added to the element with the same index of the 2nd vector? is a list comprehension the only concise way to do that?
11:19chouser,(map + [1 2 3] [10 20 30])
11:19clojurebot(11 22 33)
11:19hiredman,(vec (map + [1 2] [3 4]))
11:19clojurebot[4 6]
11:19BrandonWerrr
11:19BrandonWi even looked at map
11:19BrandonWbut it didn't click for some reason
11:20BrandonWoh, i know. i was forgetting the optional multiple collections, heh
11:20chouserBrandonW: 'for' is for when you want to do something like a nested loop or a cross product, that is every item in seq1 with every item in seq2
11:20chouserBrandonW: 'map' is great when you want to walk two seqs in step.
11:21BrandonWgotcha
11:22BrandonWyeah functional programming is going to take a while to wrap my head around :) certainly brings the fun back in programming though
11:22unfo-literally ;)
11:22fdaoudlol
11:23fdaoud"Clojure puts the fun in functional"
11:23unfo-or rather, as i saw in a tshirt once, only functional programmers know real fun --- where the last 'fun' was in fixed width font ;)
11:24tomojfdaoud: oh, yeah
11:24tomojforgot they were associative as well
11:24fdaoudI wouldn't have thought of that, but I guess it makes sense that it's index -> value
11:27fdaoudanyone here ever watched Night Court? there's a scene where a crazy lady is holding a gun (she thinks she's in a movie) and they're all trying to act a character from movies to try and convince her to give them the gun
11:27fdaoudthey're going through so much trouble and then Bull just walks in and takes the gun from her.
11:28fdaoudthis is how Clojure makes me feel vs. all the Java EE world..
11:29fdaoudall that ceremony and frameworks and layers and set up and dependency injection and AOP and....meanwhile with Clojure you just get things done.
11:31Apage43but then there's the other side, when you spend so much time writing this amazing thing, you finish, you're proud of it.. then you feel.. odd
11:31Apage43because it's only.. 40 lines of code..
11:32chouserApage43: heh. yeah.
11:32chouseror 10
11:32Apage43yeah that's worse.
11:33phirschHi all! I have a problem with file-str on Windows. Whenever a path contains "/" or "\", file-str throws an exception: "java.lang.StringIndexOutOfBoundsException: String index out of range: 1".
11:33phirschLooks like a bug in c.c.duck-streams/file-str to me, as it tries to replace "/" by "\" using java.util.regex.Matcher/replaceAll,
11:33phirschwhich in turn tries to interpret the "\" as the start of a numbered back reference.
11:33phirschUnfortunately, I do not have a CA yet, so I cannot post this on the google group.
11:33phirschAny ideas how to proceed with this?
11:33AWizzArdI single "\" should not be used.
11:33AWizzArdA single one you can get by "C:\\mein\\pfad\\datei.txt"
11:34fdaoud,(doc letfn)
11:34clojurebot"([fnspecs & body]); Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body. fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
11:34phirschAWizzArd: sure, I used the string literal "\\", resulting in a single "\"
11:34AWizzArdphirsch: do you have a small text file directly in C:\?
11:34AWizzArdIf yes, please try: (slurp "/some.txt")
11:34phirschAWizzArd: I'll try...
11:34fdaoudApage43: you can add some documentation to make you feel better :)
11:34stuartsierraphirsch: please file a ticket
11:35AWizzArdokay, so it is a bug and I should not upgrade :)
11:35chouserphirsch: file-str in clojure.contrib.io on the master branch seems to work here. you must be using an older version?
11:38stuartsierrafile-str should work fine on windows, it uses java.io.File/separator
11:40phirschOk, it works with slurp, but not with file-str:
11:40phirschuser=> (file-str "c:/")
11:40phirsch#<CompilerException java.lang.StringIndexOutOfBoundsException: String index out of range: 1 (NO_SOURCE_FILE:4)>
11:40phirschuser=> (file-str "c:\\")
11:40phirsch#<CompilerException java.lang.StringIndexOutOfBoundsException: String index out of range: 1 (NO_SOURCE_FILE:5)>
11:40phirschuser=> (count (slurp "c:\\menu.lst"))
11:40phirsch3057
11:40phirschuser=> (count (slurp "c:/menu.lst"))
11:40phirsch3057
11:41chouserphirsch: what version of contrib are you using?
11:42hiredman,"c:\\"
11:42clojurebot"c:\\"
11:42hiredman,"c:\"
11:42clojurebotEOF while reading string
11:42phirschchouser: Should be 1.1.0 final, but I have checked the latest source on github, and there was no change to file-str.
11:42hiredman,(doc file-str)
11:42clojurebot"clojure.contrib.duck-streams/file-str;[[& args]]; Concatenates args as strings and returns a java.io.File. Replaces all / and \\ with File/separatorChar. Replaces ~ at the start of the path with the user.home system property."
11:42DeusExPikachuis there an idiomatic way to get common lisp defvar behavior (conditional binding) with def?
11:43hiredman,(use '[clojure.contrib.duck-streams :only file-str])
11:43clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
11:43hiredman,(use '[clojure.contrib.duck-streams :only (file-str)])
11:43clojurebotnil
11:43tomojDeusExPikachu: not really idiomatic, but defonce
11:43hiredman,(meta #'file-str)
11:43clojurebot{:ns #<Namespace clojure.contrib.duck-streams>, :name file-str, :file "clojure/contrib/duck_streams.clj", :line 86, :arglists ([& args]), :doc "Concatenates args as strings and returns a java.io.File. Replaces\n all / and \\ with File/separatorChar. Replaces ~ at the start of\n the path with the user.home system property.", :tag java.io.File}
11:44tomoj(I say not idiomatic because that's just the macro for it, doesn't seem like an idiom)
11:44hiredman,(file-str "/")
11:44clojurebot#<File />
11:44hiredman~def file-str
11:45DeusExPikachutomoj, ok, you ever use like that before?
11:45tomojI just realized that "defonce" is at least 10x better as a name than "defvar"
11:45DeusExPikachutrue
11:45tomojthat's the right way to do it, I was just being pedantic
11:46phirschchouser: The problem is file-str's use of java.util.regex.Matcher/replaceAll - which tries to interpret the replacement string (on Windows, that is a single '\') as a back-reference that should be followed by a number, but there is no number following it. On Unix, the replacement is a "/", which has no special meaning to replaceAll, and is therefore fine to use.
11:46the-kennyOh, I didn't know about :strs and :syms while destructuring a map.
11:46the-kennyAwesome :) Thanks, Joy of Clojure :D
11:46chouserphirsch: ah, got it.
11:46hiredmanphirsch: I don't believe java's regexs don't use \1 for back references
11:46hiredmaner
11:47hiredmanremove one of those don'ts
11:47DeusExPikachuah, so defonce is the defvar of CL, cool
11:47chouserboth are supported
11:47phirschhiredman: You can choose to use "$x" and "\x" notations
11:47hiredmanoh, I see
11:48phirschCould someone file a bug for this?
11:48stuartsierraphirsch: ok, I see
11:48fdaoudtomoj: where does letfn come from?
11:48chouserfdaoud: it's a special form
11:48stuartsierraphirsch: I'll fix it
11:48phirschstuartsierra: ;_)
11:48tomojfdaoud: huh?
11:49hiredman~def c.l.Compiler
11:49fdaoud(doc letfn) in my REPL gives java.lang.Exception: Unable to resolve var: letfn in this context (NO_SOURCE_FILE:1)
11:49clojurebot"([fnspecs & body]); Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body. fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
11:49chouser,(.replaceAll (re-matcher #"/" "~/foo/bar/baz") "\\")
11:49clojurebotjava.lang.StringIndexOutOfBoundsException: String index out of range: 1
11:50tomojstrange, I see it as a macro
11:50hiredmanhttp://github.com/richhickey/clojure/blob/b63af1ad6ce38b50552be3c424ea166cb063ee7c/src/jvm/clojure/lang/Compiler.java?r=b63af1ad6ce38b50552be3c424ea166cb063ee7c#L4597
11:50chouserfdaoud: are using clojure 1.0 perhaps?
11:50tomojI get that error for (doc letfn*) though
11:50tomojdespite:
11:50tomoj,(letfn* [])
11:50clojurebotnil
11:50chouserbecause it's a special form
11:51hiredmanmost of the "special forms" are macros which emit a call to the real special form fn => fn* letfn => letfn*, etc
11:51hiredmanspecials forms have no vars to hang a docstring on
11:51chouser,(.replaceAll (re-matcher #"/" "~/foo/bar/baz") (java.util.regex.Pattern/quote "\\"))
11:51clojurebot"~Q\\EfooQ\\EbarQ\\Ebaz"
11:51chouserhehe
11:51fdaoudchouser: ah, my app is clojure 1.1.0 but the repl is 1.0.0 for some reason :/
11:52hiredmanfdaoud: using lein?
11:52hiredmanwhat do you mean by "my app is clojure 1.1.0"
11:52fdaoudhiredman: maven
11:53hiredmanfdaoud: that is a word
11:54fdaoudhiredman: ?
11:54hiredmanfdaoud: you are going to have to give me more than a single word
11:55fdaoudhiredman: that's what I'm using: Maven (http://maven.apache.org)
11:55hiredmanfdaoud: ok, and what does that have to do with "my app is clojure 1.1.0"
11:56fdaoudhiredman: my maven app is set up to use 1.1.0, but my plain command-line repl is on 1.0.0. now I figured out that I should use mvn clojure:repl to get a repl with the same environment as my app.
11:57fdaoudhiredman: sorry if I'm not making much sense.
11:59hiredman*shrug*
11:59fdaoudhiredman: lein is a build system?
12:01stuartsierrayes
12:01hiredmanit uses some maven stuff internally
12:04fdaoudthanks, I'll have to check it out, everyone seems to be on it
12:04stuartsierraphirsch: pushed file-str fix to master
12:04stuartsierrafdaoud: Not everyone :)
12:05phirschstuartsierra: Thanks! :-)
12:05fdaoudstuartsierra: well, maven is just easiest for me right now, mvn jetty:run and it's a go
12:05phirschstuartsierra: Looks good to me!
12:06phirschstuartsierra: Now try that with commercial software...
12:07phirschstuartsierra: ... I mean getting a fix within 5 minutes.
12:07stuartsierrayep
12:07stuartsierraWe aim to please.
12:08phirschstuartsierra: Sounds like a motto for clojure ;-)
12:10phirschIs there an idiomatic way to use with-open (or any other resource-managing form for that matter) with lazy seqs? I have been tripped up by the stream already having been closed when I realize the seq later on. I suspect I should use some kind of closure?
12:11hiredmannot for with-open
12:11stuartsierraphirsch: this is a common problem. A technical solution is in the works.
12:11ChousukeI think the most common thing to do is to use doall
12:11stuartsierraYep, that's the simplest for now
12:11hiredmanor move the code that uses the resource within the with-open
12:12phirschChousuke: The prohibitive size of the file was the reason to use the lazy seq in the first place...
12:12cemerickphirsch: There are cases where I don't particularly care whether something gets closed...there, I simply put the close in the terminating condition of the fn producing the lazy seq. *shrug*
12:12cemerickThat can bite in different ways, of course.
12:12hiredmanphirsch: you can move the processing code inside the with-open
12:13phirschcemerick: I see, that's what I was referring to as using a closure.
12:14cemerickphirsch: well, it's not even that complicated -- more like (if (whatever) (lazy-seq (this-fn other-args)) (.close data-source))
12:14phirschhiredman: That's what I have done. But it still feels like a workaround. I wanted to turn a seq of filenames into a seq of java.io.File's and that in turn into a seq of lines - and all that lazily, if possible...
12:14hiredman,(doc file-seq)
12:14clojurebot"([dir]); A tree seq on java.io.Files"
12:14Chousukephirsch: there's already line-seq if you're fine with just reading the file line by line
12:14Chousukephirsch: but you must consume the entire seq
12:15Chousukehmm
12:15phirschYes, I was using file-seq and line-seq, but realizing the line-seq (outside of the function turning the seq of filenames into files) was where the closed stream bit me.
12:16Chousuke(mapcat line-seq (map #(File. &) filenames))
12:16hiredman,(doc line-seq)
12:16clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
12:16hiredman^- doesn't take a File
12:16Chousukeah, damn.
12:17phirschChousuke: Will look at that - and see if it plays nicely with adding additional layers of using ZipInputStream and decryption on top...
12:18Chousukeanyway, the point is that you don't need to use with-open with line-seq
12:18Chousukethe stream is closed when all of it has been read.
12:18BrandonWi'm stumped again: how do i use the max function if i have a seq?
12:18ChousukeBrandonW: apply it :)
12:18chouser,(apply max [1 2 3 4])
12:18clojurebot4
12:18BrandonWah yes, i remember now :)
12:19cemerickChousuke: and even if it wasn't, the underlying inputstream would get closed upon GC.
12:19BrandonWit's weird when you read it in a book and you understand it completely, but then when you start writing code it seems to elude me :)
12:19phirschChousuke: That's another problem: The "File"s I am talking about are parts of a ZipInputStream, and when no more lines are available, I should not close the stream, but call .getNextEntry instead...
12:20hiredmanphirsch: you have two resources open there
12:20Chousukeah.
12:20phirschhiredman: ?
12:20hiredmanor you don't actually have a File
12:21hiredmanactually, you must not have a File
12:22phirschYes, as written above, there are three sequences: involved: Filenames (of zip files), ZipInputStreams, and lines.
12:23phirschhiredman: You can do (java.util.ZipInputStream. anyotherinputstream)
12:23hiredmanphirsch: you might want to look at ZipFile instead of ZipInputStream
12:23phirschhiredman: java.util?
12:23hiredmanhttp://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/ZipFile.html
12:24hiredmanit has an entries() method so you can just get a collection of entries
12:25hiredman,(doc enumeration-seq)
12:25clojurebot"([e]); Returns a seq on a java.util.Enumeration"
12:25phirschhiredman: Thanks for the hint, I somehow missed that. Have to find out how to use it with decryption (which Java itself does not support.)
12:27hiredmanugh
12:27hiredmanzipentries might not actually allow you to get the data
12:28hiredmanhow horrible
12:28hiredmanoh, you have to pass the entry back through ZipFile
12:28hiredmaninteresting choice there
12:35phirschhiredman: Yes, that is exactly what I thought when I looked at this API.
12:43avarushi!
12:44stuartsierrahi
12:46cemerickthis "clojure has a runtime" stuff is irritating.
12:47chousercemerick: namespaces and such?
12:48cemerickchouser: just the standard library constitutes a runtime, apparently: http://twitter.com/njbartlett/
12:52stuartsierraClojure has a runtime, it's just a singleton.
12:54chouserwell ... it has a few static fields of mutable object. I suppose those together consititue a runtime, don't they?
12:54cemerickthat's pretty weak
12:54cemerickfor a language, to me, runtime == interpreter
12:54clojurebotI will hold the money!
12:55cemerickanyway, he's an osgi guy, so I'm hoping to find out what the beef is there.
12:57chouserI know essentially nothing of OSGi, but I did think that static fields of mutable things like that might be an issue, since you probably can't separate copies of them for independant scripts without also copying all of the clojure classes.
12:57chouseror something.
12:58chouserthat sentence alone surely proves how much I don't understand. *sigh*
12:59cemerickthere's apparently a distinct issue with using clojure across osgi bundles (e.g. http://twitter.com/njbartlett/status/8968196187), but there's no problem with the corollary in netbeans apps, so there's something particular to osgi going on there.
12:59rhickey(vector-int) or (gvector :int) ?
12:59chouser"gvector"?
13:00rhickeygeneric vector
13:00chouserthere will only ever be long, double, or Object?
13:00rhickeyno, all primitive types
13:01rhickeybyte,short,char,int,long,float,double,boolean
13:01rhickeyerm. maybe not boolean
13:02chouserI think that tips the scales for me to making it an arg. Not sure I like "gvector" though.
13:02rhickeynow's a good time to suggest names :)
13:02chouseryes. thinking...
13:02cemerickpvector is probably linked to parallel, eh?
13:02cgrand(vector-of :int)
13:02chouserooh!
13:02cemericknixw
13:02cemericknice
13:03cemerickrhickey: what's special about booleans?
13:03rhickeythere are only 2 canonic values, so don't have the storage overhead of the other boxed primitives
13:05chousera reference to a boolean is bigger than a byte, isn't it? of course you could also just use (vector-of :byte) then.
13:05hiredman,(identical? true true)
13:05clojurebottrue
13:06hiredmanideally it's all the same object
13:06chouser,(if (Boolean. "false") "oops")
13:06clojurebot"oops"
13:06hiredman"2 canonic values" etc
13:06chouserhehe
13:07hiredmanthat is a Boolean anyway
13:07chouserright, but an array of Boolean length n probably takes about n*8 bytes on a 64-bit machine, doesn't it?
13:08rhickeychouser: true, I'll include it
13:08hiredman,(identical? false (boolean (Boolean. "false")))
13:08clojurebottrue
13:09Drakesonhow would you store and update a simple map on disk?
13:09hiredman,(doc prn)
13:09clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
13:10hiredman,(doc pr)
13:10clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
13:12Drakesonhiredman: thanks, maybe I should have explained in more details.
13:13DrakesonI am looking for a [possibly] simple form of persistence
13:13hiredman,(let [x {:a 1}] (read-string (pr-str x)))
13:13clojurebot{:a 1}
13:15Drakesonthe problem is with the "update". I am looking for a way that is more efficient than reading the whole map for every update
13:15Drakesondo you know of a simple persistence library in contrib or otherwise in clojars ?
13:15chousercan you keep it in memory as well, so you only need to read it on startup?
13:16hiredmanDrakeson: clojure maps are immutable
13:17Drakesonchouser: I am doing that, but I was hoping for a more efficient way (in terms of memory)
13:17stuartsierrasomeone wrote a persistent lib that does logging, don't remember what it was called
13:18stuartsierraBut at that point, you're implementing a database, so doing it correctly requires a vast amount of work.
13:19chouserI don't know of anything that (a) doesn't keep the whole db in memory and (b) isn't a full on DB with its own query language (SQL or otherwise), etc.
13:20cemerickwasn't there a tokyo cabinet wrapper floating around?
13:20cemerickobviously a variety of (b), but a good options
13:22noidihow can I get stdout to be redirected to swank's REPL?
13:22noidior some other readable buffer
13:24rhickeyvectors of primitives: http://gist.github.com/301644
13:25rhickeystill needs some finish work, equality symmetry with vectors, j.u.Collection support, IFn etc
13:26cemerickwhew, having the interfaces inline is rough in this kind of setting
13:26rhickey?
13:26cemerickrhickey: when asking one's self, "what interfaces does this deftype implement"
13:27rhickeyah, yeah, I'd like some better highlighting support for deftype definitely
13:27rhickeyalthough it's stil la difficult question to answer in Java as well, will all the inheritance. I need IntelliJ's hierarchy browser for that
13:28rhickeywith all
13:28hoecknoidi: slime-redirect-inferior-output may work
13:28cemerickI guess that's what supers is for in general.
13:31chouserthe type parameterization macro is amazingly small.
13:31chouserI must be doing something wrong...
13:32hiredmanrhickey: collections support would mean boxing?
13:34noidihoeck, it doesn't seem to work with a swank server (to which I connect with slime-connect), but thanks
13:34rhickeyhiredman: there is dynamic boxing, even now for the Clojure collections interfaces which are object-based.
13:35hiredmanI mean for the j.u.Collection interface
13:35rhickeythe j.u.Collections would be the same. But under the hood the storage is primitives in both cases. It's strictly a matter of implementing all the j.u.collection interfaces
13:35rhickeywhat's nice is Vec ended up being one type, not N types
13:35hiredmanright
13:36rhickeyN array managers
13:38DrakesonI thought clojure.contrib.duck-stream was renamed to clojure.contrib.io ; clojure-contrib-1.2.0-SNAPSHOT.jar still contains duck_stream$*
13:38cemerickrhickey: this is all pointing towards an endstate that will be quite remarkable. :-)
13:38rhickeywhat's fun is that these are faster than vector for most things
13:39rhickeyI think it's kind of a shame to have to use interfaces for primitive args, but it's all in Clojure at least
13:40rhickeyso, one thing that's not present is that the coercion ops truncate rather than balk on out-of-range
13:41rhickeyI can either 'fix' int/long/short coercions or make checking versions
13:44chouserthis is something that's generally not available in Java container types outside of specialized math/vector libs, right?
13:44chousersorry, I mean math/matrix
13:46rhickeychouser: apache has/had specialized containers per primitive type
13:46rhickeythe reason this hasn't been done is the on-the-fly boxing involved, probably prohibitive in the past
13:47rhickeyand so far, I haven't seen escape analysis doing to much across fn calls
13:47rhickeyso the big benefit here might be memory footprint
13:47eyerisI'm trying to setup NetBeans with the Enclojure plugin. When I load source code into the repl, I get FileNotFound exceptions for libraries that I've added to the NetBeans project's Libraries menu. Is there something more I have to do to make sure those libraries are added to the CP of the repl?
13:47rhickeyuntil we get some ops that can reach into the representation
13:48hiredmanIReduce, etc?
13:49rhickeyhiredman: yeah that, but still as long a the reducing fn takes/returns objects, you'll need escape analysis to optimize away the ephemeral box
13:49rhickeynow, fns taking/returning long/doubles otoh...
13:49hiredman:D
13:49cemerickeyeris: classpath changes do not apply to running repls, you'll have to restart it
13:50eyeriscemerick: Do I have to restart NB to do that? I don't see a UI element to do so.
13:51cemerickeyeris: right-click in the repl window to restart it, or close the repl window and start a new one from the project node.
13:52hiredman"project node"
13:55eyeriscemerick: When I right-click on the repl window, I see a Reset option, but that doesn't do anything (visually).
13:55cemerickeyeris: you should get a new prompt
13:55cemerickhiredman: you're just that 133t :-P
13:56cemerickeyeris: the enclojure devs hang out in #enclojure, BTW :-)
13:56eyerisWell I can't seem to kill that one, but I started a new one, which seems to work
13:56cemerickor some of them, anyway
13:56eyerisThanks for your help.
13:56cemericknp
13:57hiredman"project node" "factory factory" how do you say these without at least a smirk
13:57cemerickwell, I don't use any factory factories :-)
13:57cemerick"project node" I have no problem with
13:58hiredmandescribe a project node for me
13:58cemerickit's the top-level representation of a single project, off of which a variety of operations hang.
13:59cemericksurely not a new concept?
13:59hiredmanisn't that just a project?
14:00cemerickyes, but in NetBeans, each icon in the project panel are called nodes
14:00avarusahhh catch Exception reveals the BUG! :_)
14:00avarusodd, the same statement worked before
14:04cemerickOT: this seems properly inline with typical MS nuttiness: http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx
14:10chousercemerick: it sure does
14:11avarusI don't get it...regarding contrib.sql: INSERT INTO todos (user_id,title,body,created_on,created_by,finish_on) VALUES ('1','foo','bar','11-02-2010','1','12-02-2010') <--this works perfectly in pgadmin but if I execute this statement via contrib.sql I get the error that the date is not a timestamp but a var char...:>
14:26rhickeywhy do unexpected test exceptions always report tes_clojure.clj?
14:26rhickeyERROR in (test-pos?-zero?-neg?) (test_clojure.clj:77)
14:36stuartsierrarhickey: I need to look into that
14:37stuartsierraI think it's because the exception gets caught at the top level.
14:40stuartsierraI've been thinking that I should rewrite clojure.test with less macro magic and more functional-ness.
14:40Drakesonis clojure.contrib.prxml broken? it does not init
14:40stuartsierraDrakeson: ?
14:41Drakeson(require 'clojure.contrib.prxml)
14:41Drakesonjava.lang.IllegalAccessError: escape-xml is not public (NO_SOURCE_FILE:0)
14:41stuartsierraThat's a bug, something changed.
14:42stuartsierralazy-xml changed; I can fix that
14:42fdaoudis there something simpler than (or (list? a) (vector? a) (seq? a))
14:43chouseroh, I probably broke it. sorry.
14:43cemerick(or (sequable? a) (seq? a)) ?
14:44stuartsierrachouser: no problem, easy fix
14:45fdaoudcemerick: where does sequable? come from? contrib?
14:45cemerickno, it's in the stdlib; maybe starting with 1.1 though?
14:45fdaoudI'm on 1.1.0
14:46cemerickhrm. Well, I'm using a build from the 'new' branch from november :-/
14:46stuartsierrafdaoud: try (instance? clojure.lang.Sequential ...)
14:47Drakesonstuartsierra: thanks
14:47tomojsequential?
14:48tomoj,(map sequential? [[] () (seq [1 2 3])])
14:48clojurebot(true true true)
14:48fdaoudexcellent, thanks all
14:49fdaoudtomoj: this is for {:a [{:b 2} {:c 3}]}
14:49fdaoudour solution wasn't looking at maps inside e.g. vectors
14:49cemerickheh, I had forgotten about sequential?
14:49cemerickI hardly ever use predicates like that.
14:50fdaoudcemerick: i'm just trying to convert a map (and all nested maps) from {:a ...} to {"a" ...} so that Java can use it.
14:50stuartsierrafdaoud: clojure.walk/stringify-keys will do that for you
14:50tomojhehe
14:51fdaoudstuartsierra: omgwtfbbq
14:51fdaoudwhere were you this morning? :D
14:52cemerickbbq? :-)
14:53fdaoudhttp://www.thinkgeek.com/homeoffice/kitchen/aa6a/
14:53cemerickheh
14:54fdaoudstuartsierra: well thanks, i knew there had to be something already done for this. this was still a useful learning exercise.
14:56eyerisI have a ns macro on line 0. Later in my file (ns-resolve 'the.ns.named (symbol "function-name")) resolves the function, but (resolve (symbol "function-name")) returns nil, so somewhere I am changing the ns but I don't call in-ns anywhere. How else might I be changing the ns?
14:57eyeris(ns-resolve *ns* (symbol "function-name")) also returns nil
14:58Drakesondebug it with (println *ns*) ?
14:58eyerisYeah, it's set to clojure.core
14:58stuartsierraDrakeson: just pushed a fix
14:59DrakesonI mean, find the expression that changes the ns
14:59stuartsierraThis is what happens when you don't have unit tests. :D
14:59hiredmaneyeris: how are you loading the file?
14:59eyerishiredman: it is from a jar packaged by netbeans
15:00hiredmaneyeris: so it's AOT'ed?
15:00eyerisYes
15:02hiredmancome to think of it, it may not even be an AOT issue
15:02cemerickI've actually seen this once before, but just worked around it.
15:03cemerickand it wasn't in AOT'd code
15:03hiredmanresolve is runtime
15:04hiredmanlisppaste8: url
15:04hiredmanguh
15:04Drakesoneyeris: what happens if you place (resolve (symbol "function-name")) right after the (ns) ?
15:04Drakesonstuartsierra: thanks
15:04hiredmanhttp://gist.github.com/301896
15:05hiredmanthe function that calls resolve runs in the namespace that calls it
15:05hiredmanso resolve runs in that namespace
15:05Rayneshiredman: What namespace do you run in? :D
15:05hiredmanin this case your -main is being called by clojure.core
15:06hiredmanwell, something in clojure.core
15:06eyerisOh! that makes sense, since the main change I made was sticking the mainline code into a -main
15:07eyerisAlthough, wait. -main doesn't call (resolve)
15:07eyerisresolve is called down the stack a ways
15:08eyerisDoes that matter?
15:08hiredmanyes
15:08hiredmanwell no
15:08hiredmanI mean no
15:09hiredman*ns* is 'clojure.core unless something in the stack says otherwise
15:09eyerisDrakeson: nothing happens if I put (println *ns*) right after the (ns ...) call.
15:10hiredmanth ns form has nothing to do with it
15:10hiredmanthe
15:11hiredmanbetween clojure.core and the call to your.namespace/-main nothing changes the value of *ns*
15:14hiredman*ns* has a runtime value and a compile time value, resolve is the runtime value
15:14eyerisOkay. In my.ns/-main I call my.ns/run-report as (run-report). I've confirmed that *ns* is clojure.core in -main. Why does the call to (run-report) not result in a resolution error?
15:14eyerisI guess that answers it.
15:14hiredmaneyeris: because at compile time the value of *ns* is my.ns
15:15hiredman(defmacro capture-ns [] @#'*ns*) (def this-ns (capture-ns))
15:15eyerisSo I can call (in-ns my.ns) in -main
15:16hiredmaneyeris: better to just pass the namespace as an arg to ns-resolve if you go that route
15:16hiredman,(doc create-ns)
15:16clojurebot"([sym]); Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing namespace of the same name."
15:17Chousukehiredman: isn't @#'*ns* exactly equivalent to *ns*? :/
15:18hiredmanno
15:18hiredmanwell
15:19hiredmanmaybe close enough
15:19hiredmanI just wanted to be sure to capture the value at macro expansion time and not at runtime
15:19hiredmanwhich I guess just *ns* would do
15:19Chousukeyeah
15:20eyerishiredman: Does ns-resolve work with aliased namespaces?
15:20hiredmaneyeris: define "work"
15:20hiredmanif *ns* were private @#'*ns* would get you the value anyway :P
15:20eyerise.g. (ns my.ns (:require [my.ns.level.two as :alias]))
15:21eyerisCan I then call (ns-resolve 'alias ...)?
15:23eyerisThe reason is that this function looks up named ranges in Excel spreadsheets, then tries to resolve a function corresponding to the name, then interpolates the results of the function into the spreadsheet.
15:24eyerisSpecifying the namespace would require that I change it from project to project
15:25tcrayfordhow do I define a function that only takes a seq of args?
15:25tcrayfordI'm thinking something like (defn foo [& args] blah)
15:25tcrayfordbut this doesn't seem to work
15:25Chousukethat would take any number of args
15:25Chousukeyou want just (defn foo [aseq] ...)
15:26tcrayfordnah I want the any number of args actually
15:26tcrayforddescribed the problem wrong
15:26tcrayfordI have the following function definition:
15:26tcrayford(defn td
15:26tcrayford [& args] (map #(vector :td) args))
15:26tcrayfordand passing any arguments to it results in an illegal number of arguments exception
15:27tcrayfordoh
15:27tcrayfordyeah fixed
15:27tcrayforddidn't call % in the anon function
15:27Chousukeheh.
15:27tcrayfordthough that shouldn't be an illegal number of args thing
15:28tcrayford,(vector 1
15:28clojurebotEOF while reading
15:28tcrayford,(vector 1)
15:28clojurebot[1]
15:28tcrayfordseeing as that works
15:28Chousukeit is. the anonymous function takes no args
15:28tcrayfordahhh
15:28Chousukeand map requires a function that takes one in this case.
15:28tcrayfordyeah makes sense
15:28tcrayford#() forms are confusing sometimes here
15:30hiredman(partial vector :td)
15:30hiredman:D
15:30tcrayfordyeah that's nicer
15:31tcrayfordand tests still pass
15:31tcrayfordchairs
15:31hiredman,::D
15:31clojurebot:sandbox/D
15:35tcrayfordon other notes, http://katas.softwarecraftsmanship.org/?p=154
15:36tcrayfordfeedback from you guys would be very much appreciated
15:37avarusok, it seems I have to convert my data with (.setTimeStamp foobar)
15:37avarusbut apparently contrib.sql doesn't touch pgsql anymore :)
15:38eyerisWhat is the correct syntax for (create-ns)?
15:38hiredman,(doc create-ns)
15:38clojurebot"([sym]); Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing namespace of the same name."
15:38hiredman,(create-ns 'foo)
15:38clojurebot#<Namespace foo>
15:38hiredman,(create-ns 'sandbox)
15:38clojurebot#<Namespace sandbox>
15:38eyeris(create-ns my.ns) and (create-ns 'my.ns) both throw java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol
15:38hiredman,(identical? (create-ns 'sandbox) *sn*)
15:38clojurebotjava.lang.Exception: Unable to resolve symbol: *sn* in this context
15:38hiredman,(identical? (create-ns 'sandbox) *ns*)
15:38clojurebottrue
15:39hiredmaneyeris: then you are doing it wrong
15:41eyerisAlright, I fixed that. (I had it out-side my do) But now it says Can't change/establish root binding of: *ns* with set
15:42hiredmaneyeris: stopping using set!
15:42eyerisI'm not. I'm using (in-ns)
15:42hiredman~def in-ns
15:42clojurebotNo entiendo
15:42hiredmanbah
15:42hiredmanwhat do you think in-ns does?
15:42hiredman12:19 hiredman : eyeris: better to just pass the namespace as an arg to ns-resolve if you go that route
15:43eyerisYeah, it sets *ns*
15:43eyerishiredman I exaplained why that's not a good option.
15:43eyerisI don'
15:44hiredman12:18 hiredman : (defmacro capture-ns [] @#'*ns*) (def this-ns (capture-ns))
15:44unfo-btw. how does clojurebot's execute work? does it work with REPL or something else?
15:44eyerisI don't want to use in-ns. I want to be able to use (ns-resolve) with a compile-time evaluation of *ns*
15:44eyerisThat didn't work.
15:45eyerisMaybe I used it wrong?
15:45hiredmaneyeris: what does "doesn't work" mean?
15:46eyerisIt still used clojure.core
15:47hiredmaneyeris: what do you mean by "It"
15:47eyerisYour capture-ns macro
15:47hiredmaneyeris: how did you use it?
15:47eyerisI tried both (ns-resolve (capture-ns) sym) and (ns-resolve (this-ns) sym)
15:47eyerisTo be honest, I don't understand how it is supposed to work.
15:49hiredmanif you ran (ns-resolve (this-ns) sym) you should have gotten an exception
15:49hiredmandid you?
15:49eyerisNo
15:50hiredmaneyeris: then you didn't run it
15:52hiredmanthat macro and the def may not actually even compile
15:52hiredman(AOT compile, they will of course work at the repl)
15:53eyerisThey compiled.
15:53eyerisSo I just looked really hard at it.
15:53avarushow can I define some data to be http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Timestamp.html :)?
15:53eyerisAnd it looks like I should call (capture-ns) at the top of my fn
15:53eyeristhen use this-ns instead of *ns*
15:53eyerisIs that right?
15:53hiredmaneyeris: no, you don't call capture ns in your fn
15:54hiredmanyou need to call it outside your fn, in the def I suggested
15:54eyerisI must have missed that in my scroll-buffer.
15:54hiredmanavarus: you use the constructors to make one
15:55hiredman12:18 hiredman : (defmacro capture-ns [] @#'*ns*) (def this-ns (capture-ns))
15:55eyerisOmg! PARENS!
15:55eyerisI mis-read that totally
15:56eyerisThat makes a lot more sense now.
15:56hiredmanas Chousuke pointed out, you should be fine leaving off the swearing "@#'"
15:57eyerisThat works. Thank you for being patient with me.
15:57hiredman:)
15:59stuartsierraavarus: Just make an instance: (Timestamp. 1234567890)
16:04BrandonWif i want to join two vectors together, is this the correct way to do it: (into second-part (reverse first-part)) ?
16:04tcrayfordtry concat
16:04BrandonWah
16:04tcrayford,(concat [1 2 3] [1 2 3])
16:04clojurebot(1 2 3 1 2 3)
16:04hiredmanBrandonW: why are you reversing the second part?
16:04hiredmanfirst part
16:04hiredmanwhichever, the second vector
16:04fdaoud,(into [1 2 3] [1 2 3])
16:04clojurebot[1 2 3 1 2 3]
16:04BrandonWwell because if i didn't, then the elements would be in the wrong order
16:04BrandonWhmm
16:04hiredmanare you sure?
16:04BrandonWno
16:04BrandonW:)
16:05BrandonWlet me take closer look
16:05stuartsierraonly if they're lists
16:05BrandonWwell i perform some operations on them
16:05BrandonWthey get returned as sequences, but that doesn't change them from being vectors, right?
16:05hiredmanBrandonW: of course it does
16:05BrandonWoh
16:05hiredmana sequence is not a vector
16:05avarusstuartsierra: yessir, it didn't throw an error but there wasn't any changes in the db: http://pastie.org/820783 <-- that's how I did it
16:06stuartsierraavarus: I dunno, that may be something to do with how c.c.sql talks to the database
16:06avarusya :P
16:07BrandonW,(class (rest [1 2 3]))
16:07clojurebotclojure.lang.PersistentVector$ChunkedSeq
16:07BrandonWthat looks like a vector
16:07chouserno, it looks like a seq
16:07chouser,(vector? (rest [1 2 3]))
16:07clojurebotfalse
16:08chouser,(seq? (rest [1 2 3]))
16:08clojurebottrue
16:08stuartsierraHey contrib authors: wanna help me factor out c.c.java (formerly java-utils?)
16:08BrandonWso it isn't a vector or a list
16:08BrandonWit is a seq
16:08triyo$ChunkedSeq is a inner class
16:08chouserit's a kind of seq that happens to be defined inside the PersistentVector class, but it's a seq
16:08danlarkinstuartsierra: factor out how?
16:08BrandonWokay, so you know the output was derived from persistent vector, but it isn't of that type any more
16:09BrandonWok
16:09chousereven that detail doesn't make if very far down a chain of seq ops
16:09chouser,(class (filter odd? [1 2 3]))
16:09clojurebotclojure.lang.LazySeq
16:09hiredman,(class (map inc [1 2]))
16:09clojurebotclojure.lang.LazySeq
16:10stuartsierradanlarkin: Fix all the libs that use c.c.java to use the other namespacse
16:10hiredman,(class (cons 2 (map inc [1 2])))
16:10clojurebotclojure.lang.Cons
16:10stuartsierraI mentioned I was going to do this on the dev list
16:10hiredman,(class (filter even? (cons 2 (map inc [1 2]))))
16:10clojurebotclojure.lang.LazySeq
16:10stuartsierrahttp://groups.google.com/group/clojure-dev/browse_thread/thread/b4acea9c95a9cfe9#
16:10stuartsierraPushed a new branch to github, "drop-java"
16:10stuartsierraJust need some help finding all the usages and fixing them.
16:11danlarkinwall-hack-* getting a name change is probably a good idea :)
16:11stuartsierrayes
16:11stuartsierraIt's now c.c.reflect
16:11stuartsierraPer Halloway's suggestion
16:12hiredman:(
16:12danlarkinalthough whoever came up with that name originally is a genius
16:12hiredman<--
16:12stuartsierraI never understood what it meant.
16:12hiredmanclojurebot: hiredman
16:12clojurebothiredman is an evil genius.
16:12danlarkinwell then you had a sad childhood!
16:12danlarkin:-p
16:12stuartsierraclojurebot: stuartsierra
16:12clojurebotstuartsierra is volunteering
16:12stuartsierraHa!
16:12fdaoudclojurebot: danlarkin
16:12clojurebotGabh mo leithscéal?
16:13hiredmanhttp://en.wikipedia.org/wiki/Cheating_in_online_games#Wallhacking
16:13fdaoudclojurebot: fdaoud
16:13clojurebotGabh mo leithscéal?
16:13fdaoudclojurebot: rhickey
16:13clojurebotGabh mo leithscéal?
16:13triyoclojurebot: clojurebot
16:13clojurebotclojurebot is like life: you make trade-offs
16:14fdaoudclojurebot: chouser
16:14clojurebotWho??
16:14danlarkinookay that's enough
16:14triyohaha
16:14fdaoudyou started it
16:14stuartsierraSeriously, though, can people with commit access pitch in to fix this?
16:14boojumhello world
16:16eyerisIs there a good example of how to use clojure.set.join?
16:16hiredman/
16:16hiredmanit is clojure.set/join
16:17eyerisRight.
16:17hiredman,(doc clojure.set/join)
16:17clojurebot"([xrel yrel] [xrel yrel km]); When passed 2 rels, returns the rel corresponding to the natural join. When passed an additional keymap, joins on the corresponding keys."
16:17tcrayfordgithub.com/relevance/functional-koans, see the clojure branch on sets
16:17tcrayford(and run through the whole thing, its useful)
16:17hiredman,(clojure.set/join #{:a :b} #{:c :d})
16:17clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
16:18eyerisThanks tcrayford
16:19stuartsierraArgh, anyone remember how to push a new update on a remote branch?
16:20tcrayfordgit push origin branch-with-the-same-name-as-remote-branch
16:20chouserstuartsierra: I see only json, http.connection, pprint, and test-java
16:20tcrayfordat least that's all I've ever done
16:20cemerickor git push origin local-name:remote-name
16:20chouserstuartsierra: does that seem right?
16:20stuartsierratcrayford: yeah, not working, says eveyrthing is up to date
16:20tcrayfordgit status?
16:21stuartsierrachouser: yes, I thought it was more than that actually
16:21tcrayford:P
16:21stuartsierra"On branch drop-java \n nothing to commit"
16:21tcrayfordweiird
16:21hiredmanstuartsierra: what does git remote say?
16:22chouserstuartsierra: Should I do pprint?
16:22stuartsierrachouser: yes, thanks
16:22hiredmanis origin the right repo?
16:22stuartsierrahiredman: yes, git@github.com:richhickey/clojure-contrib.git
16:22chouseroh, jmx is there too
16:22hiredman*shrug*
16:22stuartsierra" Tracked remote branches
16:22stuartsierra 1.0.x 1.1.x clojure-1.0-compatible drop-java gh-pages master maven new"
16:22arohnerare pre & post conditions supported on multimethods yet?
16:23the-kennyhow can I convert \r\n to the native newline of the os?
16:24stuartsierraOh, maybe it's just Github not showing the commit yet...
16:24tcrayfordgithub can be kinda slow sometimes
16:24chouserstuartsierra: what broke with lazy-xml earlier? it wasn't escape-xml was it?
16:26stuartsierrachouser: yes, it was escape-xml
16:26LauJensenGuys - What is the simplest class(es) which allow me to load an image from a while, and then poke at the pixels, like (getColor 15 15) ==> RGB(1,2,3) ?
16:29hiredmanImageIO
16:29hiredman~jdoc javax.imageio.ImageIO
16:32LauJensenSank ju!
16:35LauJensenAh yes now I remember - This was the class which borked with OpenJDK
16:35LauJensenAlways use it with Oracle JDK instead
16:35chouserstuartsierra: only jmx is left, I think. Are you on it?
16:37stuartsierrachouser: yes
16:37stuartsierrachouser: thanks
16:37chouserhardly anything, but you're welcome. thanks for leading up such efforts.
16:37hiredmanLauJensen: really? I've never had it not work
16:38hiredmanpossibly it supports a different set of image formats on the openjdk
16:38LauJensenhiredman: For outputting jpegs with certain color models, it would just emit black images. I struggled with it for hours until I flushed OpenJDK, then it worked
16:39hiredmaninteresting
16:41stuartsierraI'd be done now, if only scgilardi weren't so clever about abbreviating his lib names...
16:42stuartsierra(:use (clojure.contrib [java :only ...])) hmph
16:42chouserooh, my grep didn't catch those.
16:42stuartsierramine either
16:43chouserwant me to do sql or miglayout?
16:43stuartsierraI've started sql,
16:43avarusholy moly
16:43stuartsierrago for miglayout
16:43avarusI'm missing out columbo for that shit timestamp issue :P
16:46NikelandjeloIs there any function to merge 2 or more sequences? I can't find :(
16:47stuartsierraok, pushed c.c.sql fixes
16:48chouserpushed miglayout
16:48chouser3 times before I quit comflicting with you. :-)
16:48stuartsierraoops
16:48stuartsierraok, testing now
16:48boojumNikelandjelo, interleave?
16:48chouserI assumed that was possible with git, but never actually ran into it before.
16:49hiredmanhttp://www.thelastcitadel.com/lab/contrib.svg
16:49stuartsierrachouser: I guess that's why we're supposed to work on separate branches and merge. Oh well.
16:49stuartsierraTests pass, preparing to merge on master.
16:50stuartsierraPushed to master.
16:50stuartsierraDeleting 'drop-java' branch
16:50chouserwe'll have to do something like this again for libs that go from clojure.contrib.foo -> clojure.foo, right?
16:51stuartsierrayep
16:51stuartsierraI've been doing this kind of thing for a couple of weeks.
16:51chouserand once that's done, I'll have to go through and fix the book...
16:51stuartsierrayep
16:51stuartsierraRenaming's a bitch.
16:52hiredmanhttp://www.thelastcitadel.com/lab/contrib.svg <-- updated
16:52chouserdo they have any refactoring tools for markdown? :-P
16:52chouserhiredman: good! so much clearer now!
16:52hiredman:P
16:53hiredmanI completely forgot about clojure-dependency-grapher
16:53avarusstuartsierra: what have you changed?
16:55stuartsierraavarus: just posted to the main list
16:56avarusok
16:57stuartsierraWait, dammit, did I just delete one of the commits?
16:58stuartsierrayes, miglayout
16:58stuartsierrafixed, pushed
16:59avarusbtw. I changed my database field type to text now instead of timestamp :(...there doesn't seem to be a way to insert timestamp values for now
16:59stuartsierratest-java is still there
17:00avarusomg.-..now I have the same error just with integer :(
17:01stuartsierraOk, NOW the tests pass.
17:07rhickeyok, vector-of is up. help welcome in bringing it over the goal line
17:07rhickeyalso feedback on use/perf
17:11ulfsterhi there, anybody knows if it is possible to add headers to a response in compojure, when using the defroutes macro?
17:12hiredmanbleh, the .io nic is $100 a year
17:12arohnerulfster: yes, it's possible
17:13arohnerthe response is just a map, and headers is a key
17:13ulfsteri got a route like (GET "/url" (myFunction))
17:14ulfsterinside the route i return (html someStuff)
17:14ulfsterhow do i add the headers in this case?
17:15chouserrhickey: awesome!
17:15arohnerreturn {:status 200 :body (myFunction) :headers { "HeaderName" value}}
17:15arohnerulfster: which header do you want to return? there are helper functions for several common ones, like mime type and cache control
17:15arohnerif it's a one off, you can do what I wrote above
17:16arohneror you can write a middleware, which is a wrapper function that modifies the response
17:16ulfsteri want to set a cookie, but that happens conditionally inside myFunction
17:16rhickeychouser: if nothing else, it proves the deftype stuff and relatively ordinary clojure code is as fast as the Java implementation
17:16arohnerin that case, you want to call session-assoc
17:17arohnerit should be part of the return value
17:17rhickeyhrm, I guess it is kind of primitive code :)
17:17rhickeywell, let's say it proves you can write the bottom layer in Clojure
17:18arohner[ (session-assoc cookie-map) (myFunction)]
17:18arohnerulfster: FYI, there's also a #compojure, but it's pretty quite
17:18arohner*quiet
17:18ulfsterok, thanks, i will try it from here
17:22ulfsterarohner: awesome, it worked! thanks a lot!
17:22arohnerulfster: great
17:24BrandonWdo clojure newbies tend to get bitten by lots of vector/list/seq issues?
17:47ska2342Hi. Currently I'm trying to get rid of a particularly Perlish way of thinking and to find a functional way of parsing file-formats which were created with line by line parsing and state-keeping in mind. E.g. the popular ini-file format. Can you give me any pointers?
17:48avarushow can I call java.sql.Timestamp.valueOf("some value") from inside clojure?
17:48hiredmanska2342: is there a reason you can't use java.util.Properties?
17:49hiredmanavarus: http://clojure.org/java_interop
17:49avarusI'm there for 30mins now :P
17:49ska2342escaping to Java is one possibility for just solving the problem, sure. However, I'd like to adjust my rather Perl-influenced thinking ;-)
17:50hiredmanska2342: why is it escaping?
17:50hiredmana library exists to do what want you want
17:50hiredmanuse it
17:50hiredmanavarus: so what is the problem?
17:51hiredmanit's very clear
17:51ska2342hiredman: because it's not functional. I know how well it is integrated and that it is perfectly acceptable, even encouraged, to do so.
17:51avarustoo few examples, too many possibilities :)
17:51avarusno, for me it's not
17:51avarusthat's why I am asking
17:51avarusI came up with something like this: (java.sql.Timestamp. (.valueOf (str "2005-04-06 09:01:10"))))
17:51avarusbut I get "no matching field" :>
17:52hiredmanavarus: why would you expect that to work?
17:52avarusit compiles and doesn't look too strange :)
17:52hiredmanthe interop page says ClassName. is the same was (new ClassName)
17:53avarusya, I know
17:53avarusso?
17:53hiredmanso you are constructing a new Timestamp argument and pass the result of (.valueOf (str "2005-04-06 09:01:10"))) to the constructor
17:53avarusah oh
17:54hiredmanwhat is the signature of the method you are trying to call?
17:54ska2342avarus: if I understand it correctly, the answer to your question is right on the top of the page, hiredman suggested.
17:54avarusya, it was!
17:55avarusbut the example wasn't clear enough :)
17:55avarus(java.sql.Timestamp/valueOf (str "2005-04-06 09:01:10")) <-- I didn't know you could write it like this
17:55avarusI'm struggling with this shit for over an hour now
17:56hiredmanwhat is not clear about it?
17:56avarusbut that works perfectly now
17:56ska2342avarus: do you need the str at all?
17:56hiredman(Classname/staticMethod args*) ; exactly the same was what you just wrote
17:56avarusI don't know what. I can only tell that it confused me and I wrote the stuff in all kinds of variants
17:57avarusska2342: no :)
17:57avarusworks without
17:57hiredmanwhy did you have the call to str in the first place?
17:57avarusska2342: oh, apparently it's needed
17:58hiredmanavarus: why do you say that?
17:58avarushiredman: please relax; I'm not a pro like you and if you don't feel like helping me, don't do it; i'm not taking it personal
17:58avaruswhy? because it fails without :P
17:58hiredmanwhat makes you think I am not relaxed?
17:58ska2342It fails with what message?
17:59avarusjava.lang.String cannot be cast to clojure.lang.IFn
17:59hiredmanavarus: why would it be trying to treat the string as a fn?
17:59ska2342Maybe you omitted the str but kept the parens?
17:59hiredmanska2342: shhh
17:59avarusska2342: yep, the parens were still there :) thx
17:59ska2342hiredman: uhm, sorry, to fast and beyond the lesson ;-)
18:00avarusthe lesson not to help :>?
18:00avaruscome on guys
18:00hiredmanto ask questions until we find one you know the answer to, and work from there
18:00ska2342avarus: hiredman is asking the important questions and therby helping a lot if you solve them.
18:01avarusheh, the problem is I don't understand
18:01ska2342.. just in my case he didn't get the intent of the question ;-)
18:01avarusmy question was very simple :)
18:02hiredmanthat is a problem, but you are not a tabula rasa, you have some guess
18:02hiredmanguesses
18:02avarusfor him it would take a second to answer
18:02avarusand I would understand
18:02avarusbut this way we only wasted so many lines here
18:02avarusfor nothing :)
18:02hiredmanI'm trying to teach you to fish
18:03ska2342avarus: I happen to disagree; it's just not giving the quick solution but paving the way.
18:03hiredmanbut feel free to /ignore
18:03avarusska2342: if you followed the chat I was having this problem with interop almost two hours ago :)
18:03avarusand since then I experimented a lot
18:04ska2342anyway, need some sleep. Cheers :-)
18:04avarusread that page about interop, looked at some examples at github etc...
18:04avarusthere is some time where a "pro" just knows the answer
18:05avarushiredman: I never ignored anyone :)
18:09arohnerI have a text file living in the source directory of my app. Is there a way to get the path to the file, without hardcoding the location?
18:12arohnerlike using getResource(), or something like that?
18:13hiredmanare you using lein?
18:13arohnerno
18:13hiredmanso it's in the source directory?
18:13hiredmanand that is on the classpath?
18:13arohneryes, and yes
18:14avarus(System/getProperty "user.dir") works for me
18:15hiredmanarohner: http://github.com/hiredman/clojurebot/blob/master/src/hiredman/clojurebot.clj#L22
18:15hiredmanclojurebot.properties is a file at the root of a directory on the classpath
18:16hiredmanthe (fn []) is kind of an interesting wrinkle, and I kind of forget why I did that
18:16hiredmanpreviously it was (-> clojure.lang.RT (.getRe...
18:16arohnerthanks
18:17arohnermaybe it has something to do with clojure classloaders getting GC'd
18:17arohner?
18:17hiredmanI don't think so
18:17hiredmanI think it was when I started using lein for clojurebot, which was when I start aot compiling it
18:31avarusthanks for the clarification on the interop problem I had, hiredman ...
18:31avarus... and good night :)
19:03abrenkIf I want to implement the following pseudo code "repeat (64): ctext = encrypt-ecb(state, ctext)" (so the value of 'ctext' is the result of a previous call) which form should I take a look at?
19:03abrenkCan I use 'recur' in an anonymous function?
19:04abrenkOr do I need to defn a seperate function?
19:04rhickeyabrenk: yes, you can use recur
19:04abrenkAnd introduce the counter as a seperate parameter and stop recursion when it hits 64?
19:05abrenkrhickey: thanks.
19:06hiredmanabrenk: have you seen iterate
19:06hiredman,(doc iterate)
19:06clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
19:06abrenkhiredman: Ah! You always know the right form. :-)
19:09abrenkhiredman: But I don't need all the values - just the last one. So I'll try an anonymous function with recur first. That should do it.
19:10hiredmanthat will most likely be faster
19:10hiredmanI got tweeted
19:11hiredmanhttp://twitter.com/schipplock/statuses/8982760061
19:11abrenkhiredman: but you're a nice guy as far as I can tell!
19:11danlarkinhow rude
19:12hiredmanI'm sure they are verying opinions
19:12hiredmanthere
19:36hiredmantechnomancy: is there any kind of agenda for this evening?
19:40technomancyhiredman: it's freeform... just getting to know folks and possibly pulling out projects if we run out of things to talk about. =)
19:40technomancymeetings that involve presentations every time are great, but they're a lot more work to organize. plus then you're bottlenecked by finding speakers.
19:41technomancySonian's Seattle branch is a 140 sq-ft office in my back yard; not exactly lots of hosting options like you have in SF
19:42hiredmansure
20:06BrandonWdo clojure newbies typically have problems with vec vs list vs seq?
20:06BrandonWare you supposed to use quoted lists by default, unless you need the vec data structure specifically for performance?
20:07technomancyoften even small vectors are more convenient
20:08technomancyespecially for literals
20:08technomancyuse a list if you're going to be processing it in a first/rest fashion
20:09BrandonWi just kind of defaulted to vectors by default, but it seems kind of awkward to choose to use vectors, and then any time you execute a seq operation on the vec, you have to convert it back to a vec if you want the same conj (and any other function that operates differently depending on the data structure used)
20:09BrandonWbehaviour
20:11technomancyyeah, if you need vector performance you should avoid seq-ifying operations
20:11BrandonWaren't the majority of data structure functions seq-ifying, though?
20:12BrandonWmaybe it is just a coincidence that most of the operations i use in my first project happen to be seq-ifying
20:14technomancyyes, many core functions are sequifying. if you _really_ need performance you will need to either avoid them or learn to frame your problem in terms of seqs. (the latter is probably the right approach)
20:15BrandonWthat's what i was thinking. I just have to start training myself to think in terms of seqs.
20:15technomancyseqs are pretty central to clojure
20:16technomancyit's common to build up a vector in one step, then start using a seq that's based on the vector once you're ready to consume it.
20:16technomancyusing a seq based on a vector is cheap; it's going the other direction that's expensive
20:17BrandonWi think once i get this puzzle solver working i'm going to convert it to be seq-based
20:17BrandonWright now it is kind of seq/vec hybrid (had a few bugs involving that, too)
20:30abrenkStrange, if I use #(... (recur (inc %1) x)) it works, but (fn [i x] ...) I get "Can only recur from tail position".
20:31abrenkHow come? Named parameters would be nice. And (let [i %1 x %2] ...) seems unnecessary.
20:31abrenkhttp://paste.lisp.org/+215N
20:33abrenkIt is a tail position...!?
20:35chousernope, it's not
20:35chouserthere are other differences between your #() and (fn ...) examples
20:35chouserYou have (fn [i state] (if ...) 0 state)
20:35chouserso the 'if' is not in the tail position of the fn
20:39abrenkchouser: am I missing a paren then or how did I screw up there? Seems I've got the syntax to call a (fn [] ...) form wrong.
20:40chouserIf you meant to call the fn right there like you do with the #(), then you need ((fn [] ...) 0 state)
20:40abrenkRight!!!
20:41abrenkchouser: Thanks again for taking a look! Now I've got it.
20:41chousernp
21:17lancepantzanyone have any experience implementing a connection pool with the sql api in clojure-contrib?
21:18_mstlancepantz: I haven't tried it with the c.c sql, but I've had good success using http://proxool.sourceforge.net/. I *think* it'd work for c.c sql too
21:23lancepantzcool, thanks man
21:23lancepantzlooks like it does
21:53qedmonads are scary
21:54qedi dont know why im reading about monads in clojure...
22:06offby1clojurebot: hey ho
22:06clojurebotI don't understand.
22:28Luytqed: Don't worry, I don't understand monads either. Not yet.
23:26BrandonWwhoo finally!
23:27BrandonWcompletely un-optimized, but i now have a snake puzzle solver
23:27BrandonWtook around 10 minutes to brute-force, heh