#clojure logs

2011-08-12

02:19leo2007why starting swank takes such a long time?
02:19leo2007Or is the load time high in all clojure apps?
02:49luccaleo2007: jvm startup
02:50leo2007ok, but abcl loads much faster.
02:54amalloyleo2007: abcl is not on the jvm. there are a lot of upsides to being on it; slow startup is a downside
02:55leo2007sorry I am unfamiliar with the jvm. How to define 'on the jvm'?
02:59amalloy$google java virtual machine
02:59lazybot[Download Free Java Software] http://www.java.com/en/download/
02:59amalloyyou get to plug into java libraries, run anywhere that java runs with no extra installation overhead or cross-compilation
03:48leo2007How to convert any object to string? (format "%s" ...)
04:00amalloy&(doc str)
04:00lazybot⇒ "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."
04:02depywork,(str #{1 2 3})
04:02clojurebot"#{1 2 3}"
04:02depyworknice :)
04:05pyrwhen you end up pulling in most classes from a package, is there an equivalent to import some.package.* ?
04:07zoldarpyr: if you are talking about clojure namespace then it's (use 'some.namespace)
04:08pyrnope, about java packages
04:09pyrwhen working with java libs
04:09pyryou often end up with
04:09pyr(:import [some.java.package Class1 SomeOtherClass YetAnotherClass ...])
04:10zoldarafaik there's no such possibility - from what I've seen, it's a design decision\
04:11pyrok
04:11leo2007depywork: thanks
04:11leo2007,(format "%s" #{1 2 3})
04:11clojurebot"#{1 2 3}"
04:20leo2007Any offline docs?
04:21pyr,(= {} (read-string (str {})))
04:21clojurebottrue
04:21pyrleo2007: str and read-string are very useful everywhere in clojure :)
04:24pyrleo2007: you can pull the api docs or rebuild them if you want to (with autodoc) or get a good book
04:29amalloypyr: yikes, don't combine str and read-string
04:29amalloy&(= "test" (read-string (str "test")))
04:29lazybot⇒ false
04:38amalloy(for those following along at home, the safe way would have been ##(= "test" (read-string (pr-str "test"))))
04:38lazybot⇒ true
04:43pyramalloy: thanks!
04:47depyworkwhat's the difference between pr-str and str?
04:48depywork&(doc pr-str)
04:48lazybot⇒ "([& xs]); pr to a string, returning it"
04:59amalloy&((juxt str pr-str) "str" "pr-str")
04:59lazybot⇒ ["strpr-str" "\"str\" \"pr-str\""]
05:10raekdepywork: pr-str serializes a clojure data structure to a string. str concatenates its arguments after calling .toString on them. a string foo"bar becomes foo"bar with str, but "foo\"bar" with pr-str.
05:38pyrsometimes paredit makes me crazy
06:10depyworkraek: tnx.. all clear now :)
06:14fliebel_Has anyone managed to get clojure-protobuf working on Mac?
06:16fliebel_https://github.com/flatland/clojure-protobuf/issues/8
06:27triyoI'm trying remember how to do this... I want to create a multimethod that dispatches on first argument of type keyword. Second argument is a string to be passed in to the defmethod. So I want to be able to do something like this... (convert :int "123") or (convert :date "2011-08-12")
06:42clgvhello, are protocoll methods related to multimethods? or even implemented via multimethods?
06:43fliebel_clgv: I don't think so. A protocol is just a map of functions, afaik.
06:44clgvfliebel_: did you write parallel programs in clojure yet?
06:44the-kennyI think multimethods are too slow for implementing protocol methods.
06:44fliebel_clgv: What do you mean?
06:46clgvfliebel_: I noticed that multimethods seem to have some locking since I got problems with the functions from clojure.contrib.math that are implemented via multimethods when using them really frequently in code that was run on 10 cores in parallel
06:46triyoProtocols are definitely not multi-methods
06:46clgvok. might the protocol method implementation do some locking?
06:47triyoAs far as I recall they are based on java interfaces, but are ore flexible.
06:47triyo*ore=more
06:47clgvyeah they generate a java interface
06:48clgvbut if you are using the methods like: (method1 obj ...) then this is not a direct call to the interface. but what is it exactly?
06:48triyowhat kind of locking are you referring to?
06:48triyoI think its more like a reflective dispatch, hence slower
06:48clgvthe one that ruins scaling on multiple cores although there is the same algorithm running completely independent but in the same vm
06:50clgvwhen dividing parallel average run times by serial average run times I get a quotient of about 2.4
06:52clgvah when running on 24 threads
06:54clgvI'll do a measurement with fewer threads just to be sure it's not the virtual HT Threads slowing down
08:10lnostdaldoes something like in-transaction? exist?
08:14lnostdalhm, i actually bind some other dynamic global at the same time i wrap my top-level functions in a sync so i can use that to check
08:19clgvlnostdal: what code does have to know whether it is executed within a transaction?
08:20lnostdalcode which might "come from" the repl
08:20lnostdal..stuff evaled from the repl doesn't run in a sync because it doesn't need to .. in addition it doesn't change any globals based on this
08:21clgvwhy is it not within a transaction when it comes from the repl although it needs a transaction?
08:21lnostdalit doesn't
08:21clgvwhy does it need a transaction when it was NOT launched from the repl?
08:22clgvI mean if you are using clojures STM, i.e. you do use refs, then you always do need a dosync-transaction
08:24lnostdali'm not using refs, anyway, when testing this in the repl
08:24lnostdal..i.e. it doesn't talk with session related stuff
08:25lnostdali guess i could modify the slime repl loop or something, just in case .. it might want to touch some refs later for all i know
08:25lnostdal(add a sync wrapper to the repl)
08:25lnostdal..but dunno yet
08:47solussdis there a 'for side-effects' version of pmap (e.g. like doseq is to for)?
08:47depywork:Q
08:52depyworksry, typo
09:03tufflaxHm I'm using proxy to create an instance of an interface. But I'm trying to define some more methods that are not part of the interface, and it doesn't seem to work all that well. Is that not possible?
09:03clgvlnostdal: sounds a bit strange
09:03stuartsierratufflax: nope
09:04tufflaxhm, so what if I want to :(
09:04joegallostop wanting that :)
09:04MasseRtufflax: AFAIK you can't have any extra methods with a proxy. You need to use :gen-class
09:04clgvwaits for cemerick's chart to be posted ;)
09:04stuartsierraTufflax: define a protocol with the methods you want and use `reify`
09:04joegalloclgv: just pulling that up now!
09:05tufflaxIt's a java interface I'm trying to proxy, can I like extend that interface with a protocol?
09:06joegallocan you tell us which interface it is and which extra methods you're looking to add? or it is something internal?
09:07stuartsierratufflax: `reify` and `deftype`/`defrecord` can define interface methods the same way they define protocol methods.
09:08stuartsierragotta go
09:10tufflaxIt's this GUI library, and it uses a "Controller" (Listener type thing) java interface to do stuff with the GUI, but the interface declares only very basic methods, and the idea is that you give your controller instance more methods as you need them, and you call them via the GUI (xml) e.g. onClick="doSomething()"
09:12joegalloah, okay -- yeah, maybe deftype is what you're looking for then, if not gen-class. (in my highly limited knowledge of this particular thing)
09:40dnolenmatch now has guards https://github.com/swannodette/match/blob/master/test/match/test/core.clj#L126
09:41fliebel_dnolen: Sweet!
09:42fliebel_dnolen: Hey, I thought you had to declare your predicates? Or am I confusing stuff?
09:43dnolenfliebel_: that's later when we get around to integrating core.logic
09:43dnolenfliebel_: and we probably won't get to that soon, we need a plan for open matching, tricky business that.
09:47thorwillovely how concise and easy to read that is
09:47dnolenadding guards was like 40 lines of code :)
09:51thorwildnolen: what happens if there are multiple matches? does it stop on first match, return the last match, can you get a collection out of it?
09:52dnolenthorwil: it always stops on the first match
09:52dnolenthorwil: the testing is ordered, top down
09:53dnolenas far as getting a collection out, we're going to add :as next.
09:53thorwilgood, that would have been my assumption
09:54dnolen(match [x] [[({_ :a} :as foo) _ _]] …)
09:55wunkican someone help a beginner with this exception: https://gist.github.com/3b3f6536a6f71435b0ac
09:55wunkicaused by this code:https://gist.github.com/ad829a9b36b821ea8648
09:58tufflaxIn Java, interfaces can extend/inherit from other interfaces, for example DataInput is a superinterface of ObjectInput. Can I create a subinterface of a Java interface in Clojure without AOT compilation or other nasty stuff? :p
09:59lnostdalhow does deliver/promise work when combined with dosync or STM? .. will a call to deliver be rolled back?
09:59dnolenlnostdal: no, separate system entirely.
09:59lnostdalok, thanks, dnolen
10:01joegallowunki: i think your ns declaration is wrong
10:01joegallono need to quote stuff
10:01joegalloand put redirect in a vector, not a list
10:01wunkijoegallo: I copied it from here
10:01wunkihttps://github.com/mattrepl/clj-oauth
10:02joegallo(require) and (:require) use different syntax
10:02joegalloyou are using the latter, they are using the former
10:02wunkijoegallo: ah, thank you...
10:03joegallonp, eventually it all seems perfectly natural, but yeah, it's a little odd
10:03thorwili did run inti that early on, too
10:04thorwilthere's a hint in the error, as it complains about line 1 (otherwise it's terribly unhelpful, of course)
10:05lnostdali suppose i could use an agent; and call send / send-off with a call to deliver there .. since agents run after a completed transaction, dnolen .. .. or something
10:05lnostdalfeels sort of hackish tho
10:05lnostdalthere's no "after transaction" hooks?
10:07dnolenlnostdal: send / send-off is the after transaction hook as far as I know.
10:18coopernursebasic design question for y'all
10:19coopernurselet's say I'm writing a web service that stores data somewhere
10:19coopernurseand I want to have two different persistence implementations
10:19coopernurseone that stores data in a sql db, the other in, say, mongodb
10:19coopernursethe persistence call semantics are the same for both
10:20coopernursewhat's the idiomatic way to switch between implementations at runtime?
10:20coopernurseone idea that came to mind would be to have a separate .clj file for each impl with the same functions, and to require the impl dynamically at runtime
10:21coopernursewould that work? or is there a better way to do this?
10:21coopernursenormally in Java I'd just have an interface, and then some way of dispensing the correct impl
10:21joseHi all
10:27manuttercoopernurse: are you talking about a one-time startup choice of implementations, or a continual on-the-fly switching back and forth between the two?
10:27coopernursemanutter: at this point, a one time startup choice
10:28coopernurseperhaps driven by a properties file
10:28manutterfor a one-time startup, I'd think having separate .clj files would be reasonable
10:29coopernurseok, thanks. or is this the problem protocols are designed to solve?
10:29raekcoopernurse: protocols can be used also
10:29manutterI'm pretty sure you can (if (global-is-mongo?) (require 'mongo-version) (require 'sql-version')) onr whatever
10:30raekthe dispatch happens at runtime, but is quite fast
10:30manutterI did a test once where I used multi-methods and defined a macro called with-driver that you could pass a keyword to
10:30manutterThat was pre-protocol days, but I'd think protocols could work the same
10:31coopernurseok, I'll read more about protocols -- seems like that's the solution most similar to using a Java interface
10:31manutterThe nice thing about protocols is you could conceivably have both implementations available at runtime, and easily switch between the two.
10:32raekcoopernurse: yes, protocols are very similar to interfaces
10:32manutterthey're cool, I should play more with them :)
10:32raekthey also add a way to document the abstraction
10:41coopernursegreat, I'm reading the section about them in Joy of Clojure.. seems to be what I'm after
10:45pyra question for paredit users (on emacs)
10:45stuartsierrapyr: ?
10:45pyri often go back to code wanting to nest an expression in a new one
10:45pyras in
10:46pyr(let [a :a] (thing)) -> (let [a :a] (.foo (thing)))
10:47pyrparedit does this annoying thing where if you open up a ( before (thing) it will write out () (thing)
10:47TimMcC-right
10:47pyris that on the cheat sheet ? can't figure out why i never found it
10:47TimMcaka "slurp", IIRC
10:47pyrthank you <3
10:48stuartsierrapyr: You've got two approaches: M-S-( before the expression to wrap it in another expression, or TimMc's suggestion.
10:48pyr\o/
10:48pyrdark hours for my vim setup
10:48joegallofor bonus points, you could M-( and it will start off the way you'd like it to be
10:49pyri've been pastin' ) all day!
10:49joegallooh, just saw stuartsierra's response -- oops
10:49pyr:)
10:49stuartsierranp
10:49TimMcWhile we're on the topic, how do I kill whitespace after the point?
10:49pyr^K ?
10:49TimMce.g. (foo | bar)
10:49pyrah
11:59clgvwhat is the easiest way to realize a "press any key" via *in*? (.read *in*) waits for an enter.
12:00manutterclgv: there's a related question on stack overflow: http://goo.gl/AJ3qd
12:01clgvmanutter: humm it says thats not possible...
12:01clgvonly "return" works
12:03manutterThat's consistent with what I've heard :/
12:04manuttershort of using some kind of native lib
12:04clgvok. then its limited like this...
12:05clgvI only need it to get my profiler attached to the jar before starting the computation ;)
12:05manutterprobably the simplest way would be to put up a Swing panel to wait for the keypress
12:05manutter("simple" being a relative term)
12:06clgvlol. a swing panel doesnt work that well over ssh in general ;)
12:06joegallochange the prompt from "press any key" to "press enter" :)
12:06manutter:)
12:06clgvjoegallo: I did in fact a minute ago^^
12:07joegalloa bug? nope, we just changes the specs. now it's a feature. presto!
12:08manutterI withdraw my earlier comment about the "simplest" solution.
12:08clgvI still wonder if someone has enough to investigate the behavior of defmultis in parallel execution
12:08clgvs/enough/enough time/
12:08lazybot<clgv> I still wonder if someone has enough time to investigate the behavior of defmultis in parallel execution
12:25technomancyTimMc: M-SPC
12:25aaelonyhi - I have what must be a common Leiningen question regarding local jar files (apologies in advance). I am able to copy local jar files into the lib directory, but is there a way to specify a local directory containing jar files in the project.clj ?
12:26technomancyaaelony: I think there's something for that in "lein help sample" but you should really get them in a proper repository.
12:26aaelonythanks!
12:27aaelonyi was googling but was looking for exactly this. thx again.
12:27TimMctechnomancy: Fantastic, thanks.
12:30wastreltechnomancy turns out to be surprisingly helpful
12:35ejacksonIs there a way to do something like, given (defrecord My-rec [a b]), create an instance with (My-rec. {:a 1 :b 2}) ?
12:37cemerickejackson: in that case, defrecord defines ->My-rec and map->My-rec; you want the latter
12:38ejacksonthanks gents.
12:47dnolentechnomancy: better watch out, if you start using match w/ Java objects - you might become a protocol expert yourself :)
12:49ejacksonwould that make him C3PO ?
12:49technomancyinterop schminterop.
12:49ejacksoni'm not interoping, I'm polymorphing :)
12:50technomancy(not really)
12:51Bronsa is there a way to trasform a keyword to a symbol?
12:51Bronsaeg :a -> a
12:51dnolen,(-> :a name symbol)
12:51clojurebota
12:52Bronsathanks
12:57JackAllanhow can I sort a long text ( "adb dba cba acb abcd" following a defined sequence? I want to order in sequence "cdba" and NOT with traditional "abcd"
13:01mdrogalisJackAllan, elaborate a bit on how you want it sorted?
13:02ScriptorJackAllan: do you mean how you can provide your own comparision function for sorting?
13:02JackAllani want order adb dba cba acb abcd .... to.... cba dba acb adb abcd (Because "c" is the first letter)
13:03JackAllanyes, my own comparision, but i guess it is possible using regex or something
13:06dnolen,(sort-by #((zipmap (seq "cdba") (range)) %) (seq "adb"))
13:06clojurebot(\d \b \a)
13:07dnolen,(require '[clojure.string :as string])
13:07clojurebotnil
13:10JackAllan,help zipmap
13:10clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0)>
13:10dnolen,(map (partial apply str) (map (fn [s] (sort-by #((zipmap (seq "cdba") (range)) %) s)) (map seq (string/split "adb dba cba acb abcd" #" "))))
13:10clojurebot("dba" "dba" "cba" "cba" "cdba")
13:10dnolenJackAllan: ^
13:14JackAllanoh my god, it is work :)
13:14JackAllanlet me try with my project
13:16JackAllancool... thanks
13:22JackAllanI will ask how to order by letter too, but this code already order by word and by letter.
13:32alandipertdoes anyone know off-hand if any of the ide plugins are using nrepl?
13:38dakronealandipert: the eclipse clojure plugin does I believe
13:40alandipertdakrone: thanks!
13:47cemerickalandipert: That's where Enclojure is going as well AFAIK, at least if/when Eric has bandwidth for working on it.
13:47alandipertcemerick: cool
13:48cemerickAnd I *think* vimclojure uses it now……?
13:48alandipertreason i ask is, we're looking into a clojurescript nrepl server
13:48wastrelwhat's nrepl
13:48alandipertin the early design stage at least, about to fire out a confluence page
13:49cemericknrepl?
13:49cemerickhrm
13:49cemerickclojurebot: nrepl is a network REPL implementation: http://github.com/clojure/tools.nrepl
13:49clojurebot'Sea, mhuise.
13:50cemerickwastrel: ^^
13:51cemerickalandipert: I thought a clojurescript REPL was out of scope?
13:53alandipertcemerick: the eval form is out of scope, but an extensible E in REPL is not. ie untie cljs repl from rhino, and add ability to have v8, multi-browser evaluation backends
13:53alandiperta-la brepl
13:53alandipertthen for the front, support multiple presentations, of which an important one seems to be nrepl
13:55alandipert(also opens up possibility of simultaneous evaluation in multiple browsers for compatibility testing!)
13:57triyoAnyone know of any nice projects out in the wild that widely utilize the "enlive" library?
13:58technomancytriyo: http://seajure.github.com
13:58technomancykind of a trivial usage, but it may be a good starting point
13:58technomancyor rather: https://github.com/Seajure/seajure
14:00triyotechnomancy: thanks, I've reached that point where it would be good to see how others utilize enlive. It is a bit of tricky library to get used to
14:00triyowell maybe just in the beginning of course
14:01technomancyyeah, true. don't ask me how it works though; I've forgotten everything about it since writing that code.
14:01technomancymarick has a nice tutorial now though
14:01triyoOh really? Do you have the link to the tutorial by any chance?
14:02technomancyclojurebot: google marick enlive tutorial
14:02technomancycome on brah
14:02technomancytriyo: not off the top of my head
14:03algernonhttps://github.com/swannodette/enlive-tutorial ?
14:03triyoOh I've read that one
14:03technomancyalgernon: I'm thinking of a different one that was more focused on output than scraping
14:03seancorfieldi wish enlive was more of a function library and didn't use macros so much
14:04algernontechnomancy: hm.. I need to find that one too, then.
14:04seancorfieldi was trying to incorporate it into a port of my FW/1 mvc framework but i need a lot of its functionality as functions not macros since all the templates are dynamically located and processed...
14:05algernonthis seems to be the other one: https://github.com/cgrand/enlive/wiki/Table-and-Layout-Tutorial,-Part-1:-The-Goal
14:05seancorfieldenlive is certainly very cool tho'
14:05triyoOh yes that one is pretty cool
14:05triyothe 5 part tutorial
14:06triyoenlive is cool, however, even though I've been programming for over a decade, facing enlive I still look like a noob
14:07triyoFor example, I've written a nice little binding+validation library for my web app and now I need to display the errors via enlive....
14:07triyoEasy right? ;)
14:09triyoI have a snippet that already loads the html template and does quite a bit of foot work already. Remove non-admin viewable fields, set "value" attribute of input fields and now add errors if any...
14:10triyoLogically, I would like to split these parts out. But seems that its easier said than done.
14:11triyoHence its good time to see how others deal with these common patterns.
14:14triyohttps://github.com/marick/enlive-tutorial
14:15technomancyclojurebot: ping?
14:15clojurebotPONG!
14:16triyoNeed to catch a flight. Later friends!
14:19symbolednolen: About your talk at NYC Clojure next week, is there any introductory infromation one could look at before the talk so as to not get lost?
14:21dnolensymbole: the talk will not assume you know anything about pattern matching.
14:21dnolensymbole: but if you want a head start, look at pattern matching in Erlang, Haskell, SML, Racket to get the general idea.
14:23symbolednolen: Great.
14:28gtrak`when you write key/value pairs, is it more proper to line up values or let them get jagged base on key length?
14:29arohnergtrak: I line up the keys, but that's just me. I don't think there's a standard
14:31cemerickKeeping values lined up seems like a lot of ongoing maintenance.
14:31gtrak`but it looks pretty
14:32gtrak`M-x pretty-mode
14:33duck1123you could use org mode and then regex to remove the lines
14:34duck1123Has anyone received the "can't recur here" error trying to use noir-cljs
14:37ibdknoxduck1123: are you using pinot as well?
14:37duck1123well, it's on the classpath
14:38duck1123havn't gotten there yet
14:38ibdknoxduck1123: try removing it
14:39technomancyhiredman: M-x align-regex; I've seen it around but am not a fan personally
14:39duck1123so noir-cljs expects my files to be in src/
14:39ibdknoxduck1123: yeah I saw your pull request
14:39duck1123but that's where they would normally go, right?
14:40ibdknoxmhm
14:40duck1123I had them in src/main/clojurescript/ before today
14:40hiredmantechnomancy: interesting
14:41technomancyactually I saw it more in ruby
14:41ibdknoxduck1123: that would be fine, they can go anywhere inside of source
14:41ibdknoxerr src
14:42duck1123ibdknox: NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf
14:43ibdknoxduck1123: what caused that error?
14:44owl__hi, i just wrote a gen_fsm like fsm for clojure, tell me what you think of it: https://github.com/rixmann/gen_fsm
14:44duck1123hold on, if it happens again, I'll gist it
14:45duck1123does it matter that I'm not using noir
14:45duck1123I pulled it in, but I'm using my own framework
14:46hiredman~single segment namespaces
14:46clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
14:47duck1123https://gist.github.com/1142689
14:47duck1123I'm not sure if the line numbers will match up, I added 2 printlns to see what the params were
14:47Hodappugh, jesus christ, I just got banned from #java again.
14:48ibdknoxduck1123: never seen that one before, that's something to do with the compiler itself. do you have code actually in your project?
14:49duck1123https://github.com/duck1123/jiksnu/blob/master/src/main/clojurescript/jiksnu/core.cljs
14:50ibdknoxchange the extension of that to not be cljs and see what happens
14:50ibdknoxyou may have something in there that the compiler chokes on
14:51ibdknoxI also just pushed new versions of everything up
14:51ibdknoxthere were a few changes in the cljs compiler stuff
14:51ibdknoxmaybe it will fix it
14:51duck1123actually, it looks like I had everything commented out except the greet and the require
14:52duck1123I doubt this would be an issue, but I'm also using Aleph
14:52hiredman~underscores
14:52clojurebotidiomatic clojure uses dashes to separate words
14:52hiredman~filenames
14:52clojurebotyou filename should match your namespace declaration, but with - channged to _ e.g. (ns foo.bar-baz) => foo/bar_baz.clj
14:52ibdknoxduck1123: Aleph has 1.3 compat now?
14:52ibdknoxI couldn't use it for brepl
14:53duck1123I've been maintaining the 1.3 branch
14:54duck1123Okay, even with that file renamed, it's still choking
14:54owl__plz have a look at my gen_fsm, it's not a lot of code and i use a behaviour like in erlang and i'm not sure about the performance issues of resolve: https://github.com/rixmann/gen_fsm
14:56ibdknoxduck1123: hm
14:56ibdknoxduck1123: so this jiksnu project is the one you're running?
14:57duck1123yes
14:58duck1123It started as an implementation of OneSocialWeb, but now it also does OStatus
14:58arohner,(clojure.string/replace "foo?bar" #"\?" "\\?")
14:58clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>
14:58arohnerhrm.
14:59arohner&(clojure.string/replace "foo?bar" #"\?" "\\?")
14:59lazybot⇒ "foo?bar"
14:59duck1123ibdknox: How are you packaging up clojurescript for clojars?
14:59arohnerwhat is going on there?
14:59arohner&(clojure.string/replace "foo?bar" #"\?" "\\\\")
14:59lazybot⇒ "foo\\bar"
14:59mdeboard``arohner: regex string replacement
14:59ibdknoxduck1123: hah which part of it? cljs projects? the compiler? the goog libs?
14:59duck1123ooh, I see a pom now
14:59mdeboard``arohner: What are you confused by
14:59arohnerthe fact that the first version doesn't contain a \
15:00arohnerI expect to see "foo\?bar"
15:00duck1123I was asking about the compiler. I'm building fresh to see if I can figure out where this is going wrong
15:00ibdknoxduck1123: mm
15:02mdeboard``&(clojure.string/replace "foo?bar" #"\?" "\\\?")
15:02lazybotjava.lang.Exception: Unsupported escape character: \?
15:02mdeboard``Yeah
15:02mdeboard``&(clojure.string/replace "foo?bar" #"\?" "\\\\?")
15:02lazybot⇒ "foo\\?bar"
15:03mdeboard``Huh.
15:03mdeboard``Iunno :)
15:05mdeboard``&(clojure.string/replace "foo?bar" #"\?" '("\\?"))
15:05lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
15:05ibdknoxduck1123: any luck?
15:05mdeboard``&(clojure.string/replace "foo?bar" #"\?" '"\\\?")
15:05lazybotjava.lang.Exception: Unsupported escape character: \?
15:05mdeboard``&(clojure.string/replace "foo?bar" #"\?" '"\\?")
15:05lazybot⇒ "foo?bar"
15:06mdeboard``arohner: If you figure it out, let me know.
15:08ibdknoxduck1123: how do I run this?
15:08thorwilibdknox: what's the reasoning behind noir's defpartial? couldn't you justuse hiccup's defhtml?
15:08duck1123lol, come over and use my computer
15:09duck1123you could try the ./checkout-dependencies to build everything it needs
15:09ibdknoxthorwil: yeah, I don't remember it being there back when I originally wrote noir.
15:09duck1123I think that'll get you everything
15:09duck1123then mvn clojure:run
15:09ibdknoxthorwil: or I just missed it
15:10duck1123in ciste, I have defsection which allows dispatching on the class, the format, and the srialization
15:12thorwilibdknox: does noir include any kind of support for composing views? (just curious, looking for code to learn from)
15:12ibdknoxthorwil: composing views?
15:13ibdknoxthorwil: since you end up with partial functions, composing views is just a matter of calling those functions in other partials
15:13stuartsierraarohner: It's because of Matcher.replaceAll interpreting the replacement string.
15:14ibdknoxassuming you keep using hiccup
15:14ibdknoxif you don't
15:14thorwilibdknox: ah, then i have to look at those partials
15:14arohner&(.replace "foo?bar" "?" (str (char 92) "?"))
15:14lazybot⇒ "foo\\?bar"
15:14ibdknoxthorwil: the blog app provides a decent example
15:15arohnerdoes that \\? mean two characters? is it printing the ? as escaped?
15:15duck1123I love Hiccup, I fear I'm really going to miss it now that I've replaced all the templates in my code with soy templates
15:15arohner&(count (.replace "foo?bar" "?" (str (char 92) "?")))
15:15lazybot⇒ 8
15:15stuartsierraYes, "\\?" is two characters, an escaped backslash and a question mark.
15:15arohnerstuartsierra: thanks
15:16stuartsierraSee http://download.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer, java.lang.String)
15:16ibdknoxduck1123: nooooooooo
15:16duck1123ibdknox: I excluded your clojurescript compiler, and replaced it with one I just checked out, and it works
15:16ibdknoxduck1123: don't do that
15:16ibdknoxduck1123: weird
15:16duck1123I might go back if I can get your hiccup for cljs working
15:17ibdknoxcan you remove my jars from ~/.m2/repository
15:17ibdknoxand get the deps again
15:17duck1123I just don't want to have to duplicate my templates in both places
15:17ibdknoxI pushed up the latest compiler
15:17ibdknoxit should be exactly what you downloaded
15:17ibdknoxback shortly
15:20duck1123ibdknox: same error
15:23ibdknoxduck1123: hah, I wonder if it's because we're telling it to build but there are no files to build
15:23ibdknoxthat path is relative
15:24wunkisomeone willing to help me out on this error: https://gist.github.com/395ce4c072e2ed2ba041
15:25wunkitook me a day to get here, now I'm stuck :)
15:29thorwilwunki: looks to me like you are handing a string to fetch-and-modify where it expects an object
15:30thorwilwunki: is there perhaps a a username-as-string->mongo-db-object kind of function you should be using?
15:35wunkithorwil: I really don't know. I will check the types that i'm passing on
15:43TimMc:-(
15:47TimMcI got an ზ
16:01amalloywunki: i don't know how fetch-and-modify works, but you don't need it here
16:02amalloyjust do a regular update, like (update! :users {:username username} {:$set {:access-token access-token}})
16:24fliebelRaynes or ninjudd around? I need to figure out timezones, because my day is ending already.
16:25Raynesfliebel: I just woke up, but that isn't exactly a normal thing where I live.
16:25RaynesIt's 3:28PM.
16:25fliebelRaynes: At which time do the other five inhabitants of your vilage wake up?
16:25fliebeloh
16:26Raynesfliebel: Early morning. And there are 6, not five.
16:27fliebelRaynes: Okay, so I assume you'd rather have some more sleep and coffee, or are you ready for some Jiraph troubles?
16:27Hodapphah
16:28Raynesfliebel: I'd love more sleep, but I don't really drink coffee. I'm good to go.
16:28Raynesfliebel: There is a #jiraph channel if you'd rather talk about it there.
16:28fliebeloh, sure
16:29HodappNow I'm curious WTF Jiraph is.
16:30ibdknoxHodapp: it's a graph database
16:30HodappWhat sort of things does one use a graph DB for?
16:31RaynesHodapp: Graphs.
16:31Hodapp9_9
16:31Hodapp"Graph" is quite a vague term, at least when I'm around people who describe their pie charts as being graphs.
16:32ibdknoxlol
16:32ibdknoxGraph in the datastructure sense ;)
16:32RaynesHodapp: Graph databases are just specialized databases. A graph DB can typically be used as a general database but excells in places where things are connected to each other. Like, for example, products to the users who own them. Graph databases make it easy to make and find those connections.
16:33fliebelOr discussions, like on Twitter and in email. :D
16:33HodappRaynes: So, something you could do in SQL, but you wouldn't unless you were clinically insane?
16:33RaynesHodapp: Essentially.
16:33fliebelHodapp: Basically, but Twitter implemented a graph database on top of MySQL.
16:33HodappThis does seem a natural fit for Clojure.
16:35RaynesHodapp: http://jim.webber.name/2011/04/21/e2f48ace-7dba-4709-8600-f29da3491cb4.aspx Good read.
16:37HodappRaynes: Thanks, I will read this
16:50HodappRaynes: interesting article. Good explanation.
16:56duck1123Anyone ever see this error from closurescript? No method in multimethod 'javascript-name' for dispatch value: class cljs.closure.JavaScriptFile
17:01ibdknoxduck1123: different problem now?
17:02duck1123yeah, it's odd. With the middleware in, it fails. but I can remove it, compile, run, add the middleware and eval, and it works
17:06ibdknoxthat *is* weird
17:06duck1123I just keep going further down the rabbit hole with this one
17:06ibdknoxso you have both my thing and clojurescript on your class path
17:06ibdknox?
17:06duck1123glad I took today off work
17:07ibdknoxThat could cause problems
17:07ibdknoxI tried doing a completely fresh install of everything on mine and it worked
17:07ibdknoxI'm using Noir but that shouldn't make a difference overall
17:08duck1123I've excluded your version of the clojurescript library, and I have a pom I created to compile clojurescript
17:08ibdknoxI couldn't get your project to run
17:08duck1123I think I may have something messed up now
17:08ibdknox*sigh* such is the way of these things :(
17:08duck1123yeah, it's a bit of a mess dependency-wise
17:09duck1123I keep running into the issue that Tigase looks for it's plugins by loading EVERY class on the classpath
17:09duck1123so I have to keep patching that file to exclude all but the one class that actually has a plugin
17:21arohnerdid c.c.duck-streams/to-byte-array make it into core?
17:22hiredmannope
17:22hiredmanit is in some silly incubator namespace
17:23hiredmanhttp://dev.clojure.org/display/design/Contrib+Library+Names
17:23hiredman(See comments)
17:23arohnerI'm starting to get really annoyed by all the contrib ns shuffling
17:23hiredmanstarting?
17:24ibdknoxlol
17:24arohnerthe only thing mutable in clojure seems to be namespaces
18:09TimMchaha
18:19duck1123sigh. I've now got just about everything working except the fact that it can't resolve anything in cljs.core
18:28TimMcI'm reading that as "kludges dot core"
18:35dnolenok it's official, map pattern supports Java classes, https://github.com/swannodette/match/commit/ba6ef717d1445c3d32ec35ad7c36328aea040b7e#L0R7
18:37hiredmandnolen: do you have to explicitly extend the protocol to each java class you want to match against?
18:38dnolenhiredman: yup, do you have a better idea?
18:39hiredmanI dunno
18:40hiredmanextend it to objet and have object generate something for all .get* methods the first time it encounters a given class?
18:40hiredmanobject
18:42dnolenhiredman: how could tho get method be made fast?
18:42dnolens/method/methods
18:42lazybot<dnolen> hiredman: how could tho get methods be made fast?
18:43hiredmanwell you would generate the specific protocol extension for that type and subsequent usage would use that
18:44dnolenhiredman: what I mean is how could I make get access for unknown types fast at runtime?
18:44dnolenit seems to be best I could do is provide a macro to automatically IMatchLookup-ize a Java type.
18:44hiredmanit would require eval for runtime code generation
18:44hiredmanmaybe the macro would be best
18:45dnolenhiredman: yeah I'd prefer not tread into eval waters. I'd be will to accept a patch that provides said macro.
18:46hiredman:)
19:15neotykGood morning everyone
19:16pdkrefresh me
19:16pdkdoes clojure auto upscale numbers to bignums transparently
19:18hiredmanpdk: not in 1.3
19:18hiredmanunless you use special overflowing fns +' and friends
19:19pdkoh is 1.3 up to a production release yet
19:19hiredmanno
19:19hiredmanbeta1
19:19pdkdang
19:19pdkgotta get hustlin!
19:20hiredman*shrug* given clojure/core's sense of drama I think 1.3 will be released at the conj
19:20ibdknoxhaha
19:20ibdknoxprobably
20:17seancorfieldpdk: at world singles we're in production with clojure 1.3 and we've had no problems
20:17seancorfieldi heard that we'll get beta2 "real soon now"
20:19seancorfieldwe were developing against the nightlies for a while... that was a bit fraught at times... then we settled on one of the alpha builds for development and first took clojure code into production with alpha7 (i think), then updated to each milestone as it appeared...
20:19ibdknoxis there an official "what's new" for 1.3 somehwere?
20:20ibdknoxsomewhere*
20:26raekibdknox: there is a file called changes.txt or something similar in the repo
20:28ibdknoxraek: thanks
20:38seancorfieldhttps://github.com/clojure/clojure/blob/master/changes.txt
20:39seancorfielddoesn't show changes from alph8 to beta1
20:39seancorfields/alph/alpha/
20:39lazybot<seancorfield> doesn't show changes from alpha8 to beta1
20:40seancorfieldbut there were only two bug fixes in that delta: 801 and 769
20:41seancorfieldand just a few bug fixes since beta1
20:41seancorfieldsome without jira tickets... tsk, tsk!
21:28pdkactually
21:28pdkthere's a clojure jobs blog right
21:28duck1123The biggest issue with using 1.3 is fixing the dependencies
21:29seancorfieldYou can use the new contrib libs from 1.2 so folks can already switch.
21:29seancorfieldThat then makes it easier for them to move to 1.3 later.
21:30seancorfieldit also means they can take advantage of the bug fixes and enhancements in the new contrib libs.
21:30duck1123I switched to 1.3 very early on and had to patch just about every lib I was using
21:30duck1123it's getting better though
21:33amacis there a widely-accepted clojure style guide published anywhere?
21:37duck1123I know there is a Lisp style guide that people were using for a while
21:37duck1123most of the rules were pretty much the same
21:39duck1123http://mumble.net/~campbell/scheme/style.txt Some of the rules don't apply to Clojure
21:40amacah, thanks; this'll help
21:40duck1123when in doubt, look at a well-written library
21:42amactrue, though there can still be plenty of variation; and the clojuredocs guide didn't seem very comprehensive
21:43duck1123The rule I follow is: put it wherever emacs wants it
21:58amalloyyeah, emacs is always right
22:13leo2007does clj have continuation?
23:08carlo_auis there some special notation for accessing a subtype of a class?
23:09tomojhow is it you want to access the subtype
23:09carlo_auI'm trying to make a new ArrayDouble.D2 for dealing with NetCDF files: https://gist.github.com/1143434
23:09tomojah
23:09tomojthe class name is ArrayDouble$D2
23:09tomojyou must import it separately
23:09carlo_auI can use a 'factory' method in a superclass to make one of these things, and Clojure thinks that it is of type ucar.ma2.ArrayDouble$D2
23:10tomojyeah
23:10carlo_automoj: how do I import it separately?
23:10tomojwell, you're doing it right
23:10tomojjust don't do three separate imports
23:11tomoj(:import (ucar.ma2 Array ArrayDouble ArrayDouble$D2)) should work
23:11tomojto create an ArrayDouble$D2, call:
23:12tomoj(ArrayDouble$D2. 1 2)
23:12tomojif the constructor is public
23:12tomojlooks like it is
23:13carlo_au$ clj x.clj
23:13carlo_au#<D2 0.0 0.0 >
23:13carlo_auhuzzah!
23:13carlo_automoj: many thanks :)
23:16carlo_auactually for my example this line does the job: (ns testing-netcdf (:import (ucar.ma2 ArrayDouble$D2)))
23:19carlo_automoj: is there a place with more detail about :import?
23:20carlo_auhttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/import is pretty brief
23:20tomojthink that's it
23:20tomojhttp://clojuredocs.org/clojure_core/clojure.core/import
23:20amalloycarlo_au: your issue is nothing to do with import really
23:21amalloythe class is named ArrayDouble$D2, so you import ArrayDouble$D2. there's no magic there, you just need to know the classname
23:21tomoj"Note that nested classes are named EnclosingClass$NestedClass, per the JVM spec."
23:21tomojhttp://clojure.org/java_interop
23:21carlo_auah, I can also do (ucar.ma2.ArrayDouble$D2. 1 2) with my earlier import
23:22amalloycarlo_au: you can do that without any imports at all
23:22carlo_auamalloy: ah, of course
23:23carlo_automoj: thanks for the link
23:26dnolenas patterns have landed, match-0.1.0 pushed to Clojars - I'm sure there are crazy bugs - feedback appreciated.
23:35jliI'm working on a little clojurescript thing. how can I read in clojure data structures in clojurescript?
23:36jlie.g., some page has the text "[1 2 3]". how can I convert that into a vector in clojurescript?
23:41amalloy&(doc read-string)
23:41lazybot⇒ "([s]); Reads one object from the string s"
23:42jlihm
23:43jliWARNING: Use of undeclared Var hops.main/read-string
23:43jliam I doing something wrong?
23:48jliah, found cljs.reader
23:55sridwhat is the algorithmic complexity of peek and conj on clojure.lang.PersistentQueue?
23:56amalloyO(1)
23:57amalloywell. O(log32(N)), like vectors
23:57sridbtw, I meant pop, not peek.
23:57pdkthey're implemented as trees with 32 children per node
23:57sridwhen the front list is exhausted, the rear vector is wrapped in a seq -- wouldn't that cause subsequent pops to be O(n)?
23:57amalloyno
23:58sridso the vector items are never garbage collected until they too are exhausted?
23:58amalloyfirst and rest on a seq is O(1)
23:58sriddoes `seq` return a copy of the underlying data structure, or only a 'view' on it?
23:59amalloya view
23:59amalloyit could copy in order to create the view if it wanted; that's not specified
23:59sridok, so a pop on seq == deleting the first item of a vector … which is O(1)?