#clojure logs

2012-10-22

02:32Sgeo,(let [+ 5] (resolve '+))
02:32clojurebot#'clojure.core/+
02:32CubicHi! If I want to do something with side effects that depends on multiple refs, how do I get the values of the refs without risking inconsistency?
02:32SgeoNot sure why I'd expect anything else to happen
02:38CubicNevermind, I just saw that dosync returns the last evaluated form
03:41cmdrdatsHey guys, I started putting together an app for refactoring clojure project and would appreciate some feedback: https://github.com/CmdrDats/ns-refactor
03:42cmdrdatsbasically just a readme for now, just want to get the goals fleshed out first
04:01scottjcmdrdats: not sure if this is out of your scope, clojure-refactoring's unthread, thread-first, thread-last, and extract-fn refactorings are pretty nice. I didn't seem them on your list.
04:01ro_stcmdrdats :-)
04:03cmdrdatsscottj: i'll check it out
04:03ro_stanyone know how to use clojure.core/*assert* to conditionally compile code with clojurescript? i'm guessing some sort of macro?
04:03cmdrdatsro_st: o/
04:05cmdrdatsscottj: ye, probably out of scope - I'm planning ns-refactor to be more of a large-scale refactoring tool, so not really an individual expression thing
04:18Raynescallen: I figured out the connection issue re: refheap.el. It was my setenv call in my init.el. Don't even ask how long it took me to track that down.
04:36kralnamaste
04:42antares_Elastisch 1.0.2 is released: http://blog.clojurewerkz.org/blog/2012/10/22/elastisch-1-dot-0-2-is-released/
04:45doomlordanyone here program in both haskell and clojure ?
04:45Cubic,(doc dosync)
04:45clojurebot"([& exprs]); Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a transaction if none is already running on this thread. Any uncaught exception will abort the transaction and flow out of dosync. The exprs may be run more than once, but any effects on Refs will be atomic."
04:46Cubic,(doc sync)
04:46clojurebot"([flags-ignored-for-now & body]); transaction-flags => TBD, pass nil for now Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a transaction if none is already running on this thread. Any uncaught exception will abort the transaction and flow out of sync. The exprs may be run more than once, but any effects on Refs will be atomic."
04:47CubicHm, neither says anything about returning a particular value. So my earlier observation of it returning the value of the last form isn't defined behavior? Or just an undocumented feature?
05:21leoncameldoomlord: I use both clojure and haskell in my toy projects. :)
05:22doomlordi keep oscillating between something else to learn..
05:22doomlordi like loads of the ideas in haskell but get put off by the record system;
05:23shachafYou should learn about lenses!
05:23doomlordi'm finding clojure much easier to get into; but i would much prefer something with the type inference of haskel
05:23shachafLenses = the future (maybe).
05:23doomlordclojures' ability to just throw datastructures together ad-hoc is very appealing to me
05:24doomlordlenses require 'template haskel' to implement?
05:25doomlordi'm lukewarm on the JVM aswell
05:25lucianjvm is a definite downside for me
05:25doomlordWill haskell's record system stay broken and just be patched over with 'lenses' ?
05:26doomlordhow much is involved in using lenses
05:27doomlordthe thing with clojure is... decent datatsructures appear to work and its very simple to use
05:29doomlordnote that by "put off by record system" i dont mean any limitations of immutability, just the simple inability to define 2 datastructures with the same element name :)
06:16shachafdoomlord: Having unique accessor names *does* help type inference, you know. :-)
06:16shachaff(x) = x.foo // what's the type of f?
06:17doomlordi'm not convinced its essential; it seems like an oversight and thats an excuse invented
06:17shachafYes, there are various ways it can be worked around.
06:17shachafWhat's your proposal? :-)
06:21doomlorda waste of time me proposing fixes for haskell; peeps who work on the compiler will drive it
06:23doomlordin the above example, there is simply a constraint that f is a function of something that must support .foo
06:25shachafYes, that's one way of doing it.
06:25shachafE.g. http://blog.ezyang.com/2012/04/how-urweb-records-work-and-what-it-might-mean-for-haskell/
06:25doomlordof course when i say 'simply', i've not personally implemented a type inferer :)
06:29doomlordi've been assuming that under the hood clojures literal maps can be turned into simple structs... perhaps i'm hoping too much
06:31clgvdoomlord: depends on what you mean with "under the hood"
06:35doomlordif you make a {:foo ?:bar ? :baz ?} .. and other routines use :foo :bar :baz acessors - so long as they can be traced to always come from construction in the same form, does it boil down to "struct FooBarBaz {...} " and loads from offsets from the base of that...
06:36doomlordof course routines could get the same names from different structures.. perhaps it requires whole-program analysis to seperate out the cases where it can be infered simply
06:36cemerickdoomlord: those are records
06:36clgvdoomlord: defrecord can optimize access to its defined fields
06:36cemerickThere is no automatic optimization where records are substituted for regular maps.
06:37clgvs/can optimize/optimizes/
06:37luciandoomlord: a regular map will be just a hashmap
06:38doomlordfair enough.
06:39doomlorddo you have to declare references to the record types when they come into a function as arguments, or can it at least trace those ok
06:39doomlord(so long as the origin is always the record constructor)
06:40clgvdoomlord: you can use it like a regular map when you want to access its values
06:40mklappstuhlhey... I'm looking for examples of clojure in the field (companies/products/...)
06:41cemerickdoomlord: slot access is always mediated through the Associative and/or ILookup interfaces; "declarations" (called type hints in Clojure) are only ever useful to avoid interop reflection.
06:41clgvdoomlord: e.g. (defrecord Foo [a b]) (let [f (Foo. 1 2)] (println (:a f) (:b f)))
06:44doomlordis there any difference between (:a f) and (f :a)
06:46cemerickYes; :a is the function in the former, f is the function in the latter.
06:46cemerick:a always looks itself up in an arg passed to it; (f :a) will do whatever f is defined to do
06:50mklappstuhlanyone here who could point me to a list oif commercial clojure companies/projects?
06:57wingyhow do one check what country an ip is bound to?
06:57wingyso i know what language to show
06:58andrewmcveigh|wwingy: which language do you show for bilingual countries?
06:58wingyandrewmcveigh|w: yeah no idea
06:58wingysuggestions how to handle locales?
06:59andrewmcveigh|wwingy: Accept-Language headers?
06:59wingyprobably a good idea
07:00wingyandrewmcveigh|w: that one is coupled with the language the browser is using right?
07:01andrewmcveigh|wwingy: yeah, I think so. Of course the browser must be set in the preffered language. Not sure if the OS does that.
07:01wingyseems like a smarter choice than checking on ip
07:03andrewmcveigh|wwingy: let me tell you, it pisses me off no end that infer that I speak Dutch because I live in Brussels/Belgium.
07:03wingyyeah .. i let you chooce language .. but need to know what to display at first
07:03wingyAccept-Language
07:04andrewmcveigh|wpersonally I'd go with that. Google do IP based lookup FWIW.
07:05wingybut as you said IP cant be mapped to a lang
07:07andrewmcveigh|wno, it can't for non-natives, travellers, multi-lingual places. I guess many sites don't think that's a big enough group to matter.
07:08wingyi want it to be perfect .. so whatever their browser is showing i am using :)
07:08wingythat cannot be bad right :)
07:08wingymakes sense
07:08andrewmcveigh|wThat's my opinion.
07:09wingyi just hope that a browser using Vietnamese would send the correct Accept-Language header
07:09andrewmcveigh|wIf my browser shows I'm using US English, I want US English.
07:09andrewmcveigh|wI think it's a standard... could be wrong. Not really looked into it in great detail.
07:09wingyI'll install Windows and use different languages for the whole OS and see what it sends out
07:10wingyor I can just do the same on my Mac :)
07:12bordatoue`>>
07:12bordatoue`hello could anyone tell me how to manage local .jar files in lein 2
07:14bordatoue`I am using lein 2 can't see ./lib directory ,
07:14andrewmcveigh|wbordatoue`: I think the recommended way is to install to a maven repo, or if not possible install to your machines' local maven repo.
07:14andrewmcveigh|wbordatoue`: lein 2 doesn't use ./lib - it uses the local maven repo
07:15bordatoue`andrewmcveigh : i don't have a local maven repo, why can't I just use lein as I had used lein version 1
07:16andrewmcveigh|wbordatoue`: you can install jars locally using -> https://github.com/kumarshantanu/lein-localrepo
07:17andrewmcveigh|wbordatoue`: I'm not sure of the motivations for the change, so I can't advise you on that.
07:17bordatoue`thanks, do you think lein 2 is easier than lein 1, it keeps getting complicated for me
07:19andrewmcveigh|wpersonally, I prefer lein2 - it has enough functionality built-in so I don't have to use maven for some things.
07:20andrewmcveigh|wnot sure if it's easier though.
07:26clgvthe motiviation seems to be to not have a copy of the deps in every project but only once in the maven repo
07:28wingyi am using a rest param in a function [foo & options] .. what is the idiomatic way to check if :details is specified in options
07:33bordatoueis there an equivalen of lein update in lein version 2
07:34wingythis was a long one
07:34wingy((fn [& options]
07:34wingy (= (filter #{:flag} options) '(:flag))) :flag)
07:35wingy,((fn [& options] (= (filter #{:flag} options) '(:flag))) :flag)
07:35clojurebottrue
07:35wingy,((fn [& options] (= (filter #{:flag} options) '(:flag))) :no-flag)
07:35clojurebotfalse
07:35wingyi combined = and filter and #{} .. if there is a more idiomatic way let me know
07:36andrewmcveigh|wwingy: you could use destructuring in the fn declaration (fn [& {:keys [flag]}] ...)
07:36wingyoh!
07:37andrewmcveigh|w,((fn [& {:keys [f]}] f) :f 8)
07:37clojurebot8
07:38AtKaaZthat's pretty epic, I was just reading about that few minutes ago here: http://clojure-doc.org/articles/language/functions.html
07:38AtKaaZwith :syms and :strs too
07:39bordatouecould anyone tell me what is the command in lein version 2 to update dependencies
07:39wingyandrewmcveigh|w: i cant get it to work .. isn't the rest params a sequence?
07:39hyPiRion,((fn [& {:keys [f] :or {f 5}}] f) :non-existing :f)
07:39clojurebot5
07:39wingyyou are using :keys
07:40wingy,((fn [& {:keys [flag]}] flag) :flag)
07:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :flag>
07:40hyPiRionYeah, rest of the args must be k-v pairs.
07:40andrewmcveigh|w,((fn [& {:keys [flag]}] flag) :flag true)
07:40clojurebottrue
07:40AtKaaZ,((fn [& {:keys [flag] :or {flag nil}}] flag) :flag)
07:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :flag>
07:41AtKaaZit's like an incomplete map that way
07:42AtKaaZ,((fn [& {:keys [flag] :or {flag nil}}] flag) )
07:42clojurebotnil
07:42AtKaaZ,((fn [& {:keys [flag] :or {flag nil}}] flag) :a 1 :b 2 )
07:42clojurebotnil
07:42AtKaaZ,((fn [& {:keys [flag] :or {flag nil}}] flag) :a 1 :b 2 :flag 3)
07:42clojurebot3
07:42wingy there is no way to destructure a sequence since the rest params is a sequence
07:42AtKaaZ,((fn [& {:keys [flag] :or {flag nil}}] flag) :a 1 :b 2 :flag 3 :c)
07:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :c>
07:43andrewmcveigh|wyou can destructure a sequence, but only by position/index (i think)
07:43AtKaaZI mean, the number of params must be even
07:43wingyandrewmcveigh|w: yeah just tried that
07:44wingyi should look at (require)
07:44wingysince it allows :reload :reload-all etc
07:44andrewmcveigh|w,((fn [& [[flag]]] flag) [:flag 2 3])
07:44clojurebot:flag
07:46hyPiRionhm
07:49hyPiRionWell, now I learned something.
07:49hyPiRion,((fn [& [a b :as {:keys [f] :or {f 5}}]] [a b :f f]) :a 3)
07:49clojurebot[:a 3 :f 5]
07:50hyPiRiondoesn't work the opposite way though.
07:51wingyso this one is my best shot?
07:51wingy,((fn [& options] (= (filter #{:flag} options) '(:flag))) :flag)
07:51clojurebottrue
07:51wingyi believe you clojurebot
07:53hyPiRionwingy: it really depends on how the flags and so forth are set up.
07:54hyPiRionIf you're only testing for existence of one element, then just doing (some #{:flag} opts) should be sufficient.
07:55hyPiRionOtherwise (empty? (reduce disj #{:set :of :flags} opts)) would be good, as it then wouldn't be order dependent.
07:57wingyhyPiRion: some was pretty good and concise
07:57wingyno need to use =
08:00AtKaaZ,(some #{:flag} {:flag 1 :a 1 :b 2})
08:00clojurebotnil
08:01AtKaaZwhat am I missing here?
08:02AtKaaZ,(some #{:fred} '(:fred 1 2 3))
08:02clojurebot:fred
08:02AtKaaZ,(some #{:fred} {:fred 1 2 3})
08:02clojurebotnil
08:02AtKaaZok got it i guess:)
08:02andrewmcveigh|wAtKaaZ: when you seq a map, it's not the same as a sequence
08:03andrewmcveigh|w,(seq {:flag 1 :a2 3 4})
08:03clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Map literal must contain an even number of forms>
08:03andrewmcveigh|w,(seq {:flag 1 :a 2 3 4})
08:03clojurebot([3 4] [:a 2] [:flag 1])
08:05AtKaaZI just didn't know that opts was a seq instead of a map
08:05andrewmcveigh|wI think it's a bit of a special case.
08:06AtKaaZjust trying to understand what hyPiRion said
08:06AtKaaZ,((fn [& options] (some #{:flag} options))) :flag)
08:06clojurebotnil
08:07AtKaaZ ,((fn [& options] (some #{:flag} options)) :flag)
08:07clojurebot:flag
08:07AtKaaZlol how did that not err?
08:08AtKaaZ,((fn [& options] (some #{:flag} options))) :flag
08:08clojurebotnil
08:08mklappstuhlanyone here who could point me to a list oif commercial clojure companies/projects?
08:08AtKaaZoh i see, clojurebot does only first form
08:08hyPiRionOh, right.
08:09hyPiRionAtKaaZ: I consider opts as a sequence, not a map. With a map, you'd prolly do (keys) or something.
08:09AtKaaZ,,((fn [& options] (boolean (some #{:flag} options))) :flag)
08:09clojurebottrue
08:20frawrHello, looking for some help on twitter-api http://github.com/adamwynne/twitter-api
08:23wingyhow do i add a key/value pair to a Ring request so that the other middleware can use what i have added
08:23wingyi know how to add a key/value pair to the request map but then it just creates a new one, and the old request map is still used in the subsequent middlewares
08:24wingyoh of course i get it now
08:25wingyhttps://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/middleware/session.clj
08:56wingyis there a way to simplify this: https://www.refheap.com/paste/6026
08:56wingyinstead of fetch acount in a second line
08:58edbondwingy, I think you can't. It simple enough.
08:59noidi,(let [{{bar :bar} :foo} {:foo {:bar 123}}] bar)
09:00clojurebot123
09:00noidi,(let [{foo :foo} {:foo {:bar 123}}] foo)
09:00clojurebot{:bar 123}
09:01noidiso you can replace the variable name with another destructuring form
09:02jcromartieDoes anybody know if there's a name or way to refer to the idea of separating your personal beliefs from understanding opposing views? E.g. understanding any point of view on different sides of an argument, no matter what your view is?
09:02jcromartieAnd conversely: when someone confuses explanation or understanding with justification or support?
09:03noidiwingy, I think this might work: (GET "/" {:keys [lang color], {account :account} session})
09:03jcromartietotally off-topic but I figure if any of the programming channels I frequent was home to an armchair philosopher, this would be it
09:03noidior at least something like that
09:04noidioopes, that should be {account :account} :session
09:04noidi-e
09:05mpenetjcromartie: being objective? as the opposite of subjective, maybe
09:05AtKaaZjcromartie, maybe being objective? can't be it , too simple right?
09:06jcromartieI think it's "confusing explanation with excuse/justification"
09:06jcromartieyeah
09:06AtKaaZmisunderstanding?
09:06noidiwingy, and my last attempt after checking Compojure's destructuring docs :) (GET "/" [:as {:keys [lang color], {account :account} :session}] ...)
09:07noidi(not tested)
09:07AtKaaZjcromartie, possible good read? http://plato.stanford.edu/entries/reasons-just-vs-expl/
09:08wingynoidi: doesn't make sense to me
09:09wingynoidi: but it worked :)
09:09ro_stwingy: clojuring instead of noding, i trust?
09:10wingyro_st: huh?
09:10wingynoidi: thx
09:10ro_stusing clojure instead of node.js, i trust?
09:10ro_stlast time we spoke you were dithering
09:10wingyro_st: yeah
09:10wingyro_st: im back!
09:13wingyfound clojure more logically correct, good data manipulation, fp, has datomic and light table, less hacky
09:15AtKaaZjcromartie, unbiased? naah it would be too easy
09:17wingynoidi: (GET "/" [:as {:keys [lang color], {:keys [account]} :session}] ...)
09:17wingyeven better :)
09:19AtKaaZjcromartie: anyway I figure that is the job of an arbiter
09:19CheironHi, I have a ref type that holds many maps and I would like to employ something like self expiring maps
09:19Cheirontime to live maps
09:23andrewmcveigh|wwingy: I think you can do this (GET "/" {:keys [lang color] {:keys [account]} :session} ...) - if I'm reading it right. Is :session on the request map?
09:23AtKaaZjcromartie, unbigoted ? impartial? ok I give up:)
09:23wingyandrewmcveigh|w: yeah that is what i ended up doing
09:24wingyclj is so nice .. handling every detail
09:35jcromartieAtKaaZ: thanks anyway :) but I think you are on the right track
09:35AtKaaZjcromartie: is it maybe the Scientific method?; or 'rationalizing' for what you said: "when someone confuses explanation or understanding with justification or support"
09:35AtKaaZok now I give up :D
09:36jcromartiefor example: explaining the actions of terrorists is not justifying the actions of terrorists
09:36zoldarCheiron: I don't know if it would suit your use case but maybe you could build something based on this: https://github.com/clojure/core.cache/wiki/TTL
09:36AtKaaZrationalizing the actions of terrorists?
09:37AtKaaZoh wait, nvm:)
09:37AtKaaZthat's when you're justifying
09:38AtKaaZtoo complex for my little brain to compute
09:39Cheironzoldar: is it safe to use one of those types inside a ref type?
09:43zoldarCheiron: from the looks of it, I don't see anything that would cause problems: https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L241
09:58CubicIs sync/dosync guaranteed to return the value of the last evaluated form (it does that in 1.4 and probably in the earlier versions too, but is that guaranteed behavior)?
10:00clgvCubic: yes, it is. an implicit do is mentioned in the docstring
10:01AtKaaZ,(dosync ((throw nil) 2))
10:01clojurebot#<NullPointerException java.lang.NullPointerException>
10:01AtKaaZ,(dosync ((throw (Exception. "a")) 2))
10:01clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: a>
10:01AtKaaZdidn't return 2 =)
10:02clgvlol. because an exception happened. that is the same with clojure functions
10:02AtKaaZ,(dosync (map #(throw (Exception. "a")) '(1)) 2)
10:02clojurebot2
10:02AtKaaZ:)
10:02CubicAtKaaZ: fair point, but I was more talking about something like (dosync [@a @b @c])
10:02AtKaaZclgv, you have a point:)
10:03clgvCubic: dosync in your example returns that vector
10:03Cubic,(doc dosync)
10:03clojurebot"([& exprs]); Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a transaction if none is already running on this thread. Any uncaught exception will abort the transaction and flow out of dosync. The exprs may be run more than once, but any effects on Refs will be atomic."
10:03CubicIt says it does an implicit do, but it doesn't say that the value of the do is returned.
10:04CubicI mean I know it DOES that
10:04clgvCubic: it wraps the expressions in an implicit do
10:04AtKaaZ,(do 1 2)
10:04clojurebot2
10:04clgvCubic: and do is for side effects and returns the value of its last expression
10:04AtKaaZI guess the fact that it acts like a do is implicit :D
10:05Cubicclgv: Maybe my lack of english skills is in the way here, but for me, wrapping in do could technically also mean ((do ,@stuff) nil)
10:05clgvAtKaaZ: thats through dosync -> sync -> fn -> do
10:06clgv;)
10:06clgvCubic: thats only valid clojure if a function is returned from the do
10:06Cubic,(doc when)
10:06clojurebot"([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."
10:07clgvCubic: like in a lot of macros finally your expressions are put into `fn` or `fn*`
10:07AtKaaZ_kwhat's with irc failing :)
10:08CubicI mean like that. Ok bad example because the do is bound to a condition, but for me the implicit do part only says that it does all the stuff you listed in that order, not that there's necessarily nothing else that happens afterwards.
10:10clgvCubic: well read th `do` docstring
10:10AtKaaZ,(dosync)
10:10clojurebotnil
10:10AtKaaZ,(declare ghost)
10:10clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:11CubicI know what do does, I just don't read "implicit do" as "there is an implicit do, and the value which it evaluates to will be returned". Maybe that's just me being silly though
10:13AtKaaZimplicits are evil
10:13clgvCubic: well you cant repeat the do semntics on every function that uses it. saying that the given expressions are wrapped in a do, should suffice as a pointer
10:13AtKaaZ,(#(do &% nil) 1 2 3)
10:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: & in this context, compiling:(NO_SOURCE_PATH:0)>
10:14AtKaaZ,(#(do %& nil) 1 2 3)
10:14clojurebotnil
10:15AtKaaZ,(#(do %&) 1 2 3)
10:15clojurebot(1 2 3)
10:17clgvAtKaaZ: lol what's your point with those?
10:17AtKaaZfailing to emulate do :)
10:18AdmiralBumbleBeeemulating do using do?
10:18AntelopeSaladis this the #1 resource for clojure-related podcasts? http://stackoverflow.com/questions/2758783/podcasts-for-clojurians
10:18AtKaaZwell on the second one, but the first one was meant to not return 3 lol
10:18S11001001AtKaaZ: not possible
10:19AtKaaZS11001001, to emulate the special form do?
10:19clgvAtKaaZ: `do` is a special form, so it's very unlikely that you can do that... at least not exact
10:19AtKaaZok, trying...
10:20AtKaaZdoes it unlazy the lazy seqs?
10:20clgvAtKaaZ: no.
10:21AtKaaZcan we destruct [& all] into "all except last" and "last" ?
10:21clgv(do (create-my-lazy-seq) 42) would create a lazy-seq and throw it away
10:22AtKaaZwithout let?
10:24AdmiralBumbleBeedroplast and last?
10:24S11001001AtKaaZ: no
10:24AdmiralBumbleBeeyou can't destructure without let
10:24AtKaaZ,((fn [& all] (let [xall (reverse (rest (reverse all))) last (first (reverse all))] (map #(eval %) xall) last)) (println 1) 2 3)
10:24clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:24AtKaaZah eval:)
10:24AtKaaZthing is, println would get evaluated unless i make it a macro
10:24AtKaaZevaluated before being passed
10:25AdmiralBumbleBeewhat are you trying to do?
10:25AtKaaZemulate do :)
10:25S11001001AtKaaZ: that's the #1 reason you can't
10:25AtKaaZS11001001 but then I make it a macro, I can?
10:25S11001001AtKaaZ: and if you were to have that, you would have...
10:25AtKaaZthat=as macro?
10:26S11001001AtKaaZ: do
10:26AtKaaZI didn't understand
10:26S11001001AtKaaZ: try to implement do as a macro, without using core do *or* anything that provides implicit do (e.g. let)
10:27AtKaaZeval?
10:27clojureboteval is DENIED
10:27AtKaaZlol
10:27AtKaaZok let me try
10:27clgveval would work.
10:27clgvbut why would you even try?
10:27S11001001clgv: no, you lose enclosing scope
10:27AtKaaZlike for xp
10:28S11001001AtKaaZ: I take it back, there's a function you can write that simulates do, with exactly the same semantics as do.
10:28clgvS11001001: ah right. for his trivial use cases it would work ;)
10:28AtKaaZfunction?
10:28clojurebotfunction is <Chouser> there is one class per fn, one instance of it per closure
10:28AtKaaZS11001001, what function is it?
10:28AtKaaZS11001001, without evaluating my params beforehand?
10:29clgvAtKaaZ: there are more useful tasks for xp ;)
10:29KototamaI have a nasty bug with jayq.utils.clj->js, when I add a simple key to a map, the function doesn't work anymore http://paste2.org/p/2366957 Any ideas?
10:29S11001001it does eval your params beforehand, but that's not a phenomenon you can observe with a direct call, so you can implement do with it
10:29AtKaaZwait, does do also eval the params beforehand? i wonder
10:29Kototamaor it's a bug in clojurescript merge :-p
10:29S11001001(def lastarg [& args] (last args))
10:29AtKaaZS11001001 oh thanks for that
10:30S11001001(defmacro do' [& forms] `(lastarg ~@forms))
10:31AtKaaZ,(butlast '(1 2 3))
10:31clojurebot(1 2)
10:32AtKaaZ,((fn [& all] (let [xall (butlast all) last (last all)] (map #(%) xall) last)) (println 1) 2 3)
10:32clojurebot1
10:32clojurebot3
10:32S11001001AtKaaZ: no
10:32AtKaaZyep i fail:) lazy
10:32AtKaaZno doall? ::D
10:33S11001001AtKaaZ: try it
10:34AtKaaZ,(class #())
10:34clojurebotsandbox$eval27$fn__28
10:34AtKaaZI need something to can call either func or number :) not eval
10:35AtKaaZmaybe some if
10:35S11001001AtKaaZ: I don't know why you're doing any of it; lastarg is sufficient
10:35frawrAnyone here with some experience using twitter-api for their streaming api?
10:35AtKaaZfor this:
10:35AtKaaZ,((fn [& all] (let [xall (butlast all) last (last all)] (doall (map #(%) xall)) last)) #(println 1) 2 3)
10:35clojurebot1
10:35clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
10:35AtKaaZ,(#(2))
10:35clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
10:36Cubicclojure?
10:36clojurebot"[Clojure ...] feels like a general-purpose language beamed back from the near future."
10:36S11001001,(#(last %&) (println 1) 2 3)
10:36clojurebot1
10:36clojurebot3
10:37AtKaaZ,(#(last %&) #(println 1) 2 3)
10:37clojurebot3
10:37jweissi've heard it's better to use "for" rather than map and fn. But what about when you want to have a fn of multiple args and consume multiple lists? seems like map is easier. or is there a simple way also with 'for'?
10:38AdmiralBumbleBeewho says it's better to use for than map?!
10:38S11001001jweiss: "It's better to use map and fn than for; for is terrible." There, now you've heard it both ways
10:38AdmiralBumbleBeeI've never heard that before
10:38AdmiralBumbleBeethough I've heard the exact opposite many many times
10:39jweissAdmiralBumbleBee: so there's no general consensus that (for [i mylist] ...) is preferred to (map (fn [x] ...) mylist) ?
10:40jweissi know map is very straightforward when the function already exists, eg (map inc [1 2 3])
10:40clgvjweiss: they are both in clojure.core since they "shine" in different use cases
10:40jweissso what i'm hearing is that map is the way to go when i have multiple lists?
10:40AdmiralBumbleBeejweiss: most clojure code I've seen uses map. the 4 clojure books I've read also highly prefer map
10:41jweissAdmiralBumbleBee: map+fn?
10:41AdmiralBumbleBeejweiss: yes
10:41AdmiralBumbleBeein fact, it often seems that people try to figure out how to use map even when it doesn't make much sense
10:41AdmiralBumbleBee(incuding myself :))
10:41jweissinteresting, i don't know what "for" is for then :)
10:41nDuff*shrug*. There are places where for is the obvious thing.
10:41AtKaaZ,(#(let [a (last %&)] a) #(println 1))
10:41clojurebot#<sandbox$eval177$fn__180 sandbox$eval177$fn__180@72f1f2f3>
10:41jweissi suppose if you want to use :while or :when in there
10:41nDufffor lets you do :let [] within it.
10:42AdmiralBumbleBeefor is useful certainly
10:42AtKaaZ,(#(let [a (last %&)] (a)) #(println 1))
10:42clojurebot1
10:42AdmiralBumbleBeebut preferring `for` over `map` in general I would think is very very silly
10:42clgvjweiss: `for` is awesome if you have hierachic data to traverse ad/or constraints when to traverse a child collection
10:42nDuff*nod*; nesting is another case where for shines.
10:43clgvjweiss: e.g. (for [bs as :when (even? bs) b bs] (do-something-with b))
10:43jweissi would guess for also doesn't add to the zillions of little classfiles i get when i make an uberjar
10:43hyPiRion,(for [a (range 4), b (range 4) :when (not= a b)] [a b]) ; also practical
10:44clojurebot([0 1] [0 2] [0 3] [1 0] [1 2] ...)
10:44AtKaaZ,(fn? #())
10:44clojurebottrue
10:44AtKaaZ,(fn? 1)
10:44clojurebotfalse
10:44clgvjweiss: map shouldnt as well. only an (fn ...) inside it would.
10:45jweissclgv: that is the case i'm referring to - when the function doesn't already exist
10:45clgvAtKaaZ: (ifn? #{})
10:45clgv(ifn? #{})&
10:45AtKaaZthanks i'll try that after
10:45AtKaaZ,((fn [& all] (let [xall (butlast all) last2 (last all)] (doall (map #(let [a %] (if (fn? a) (a) a)) xall)) (last2))) #(println 1) #(do 2) #(do 3) 4 #(do 5))
10:45clojurebot1
10:45clojurebot5
10:45clgvjweiss: but thats not map's fault ;)
10:47AtKaaZgetting too ugly for a 1 liner
10:47AtKaaZ,,((fn [& all] (let [xall (butlast all) last2 (last all)] (doall (map #(let [a %] (if (ifn? a) (a) a)) xall)) (let [b last2] (if (ifn? b) (b) b)))) #(println 1) #(do 2) #(do 3) 4 5)
10:47clojurebot1
10:47clojurebot5
10:49AtKaaZnow without doall? lol
10:49AtKaaZlet's test is do is macro like
10:50AtKaaZ,(do #(println 1) (println 2) 3)
10:50clojurebot2
10:50clojurebot3
10:50AtKaaZ,(do (doall #(println 1)) (println 2) 3)
10:50clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval133$fn__134>
10:50AtKaaZ,(do (doall (#(println 1))) (println 2) 3)
10:50clojurebot1
10:50clojurebot2
10:50AdmiralBumbleBeeyour one-liner is spanning 2 lines on my screen
10:50clojurebot3
10:50AdmiralBumbleBeeand you also should have your own repl to try things in...
10:50AtKaaZlol
10:51AtKaaZAdmiralBumbleBee, I have that too
10:51wingyhate having to use (declare) because of the compiler is not smart enough
10:51AtKaaZI'm doing most there, so imagine the fails
10:51AdmiralBumbleBeethen there's no reason to be posting things that fail here I would think
10:52AtKaaZ,,((resolve (symbol "declare")) 'ghost)
10:52clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$declare>
10:52AtKaaZAdmiralBumbleBee, except this time, I didn't know they would fail
10:52antoineBhello, i use proxy to implement some method of java object, but how to create new method for those object?
10:53AdmiralBumbleBeeyou would if you used your local repl :|
10:53AtKaaZAdmiralBumbleBee, I'm using it but not 100% of the time, but I get your point, less spam
10:55lucian i'm pretty sure the bots support privmsg
10:59solussdany monger users have any advice on how to switch to a 'test database' when running tests?
11:01AtKaaZS11001001: ok this is it, emulated do: ##((fn i_do [& all] (let [xall (butlast all) last2 (last all)] (doall (map (fn [one] one) xall)) last2)) #(println 1) #(do 2) (println 3) 4 #(do 5))
11:01lazybot⇒ 3 #<sandbox7657$eval318244$fn__318253 sandbox7657$eval318244$fn__318253@225c31>
11:02jlewisis there a way to serialize a bunch of PersistentHashMaps that preserves their structural sharing?
11:02AtKaaZS11001001, wait... lol your version is the one
11:02AtKaaZS11001001, this one: #(last %&)
11:03AtKaaZgood thing I finally realized it
11:03AtKaaZthanks and sorry for the spam, I'll be more considerate in the future
11:03clgvantoineB: thats only possible if you define an interface or protocol that contains the new methods
11:04simonadameithi
11:04clgvantoineB: if you do not want that you have to use :gen-class instead of proxy
11:05antoineBok thanks
11:08clgv jlewis: javas serialization should do that but adds additional overhead
11:08KototamaI have written a code that reproduce the error http://paste2.org/p/2367082 it's either an error in clojurescript merge or in jayq clj->js any ideas???
11:08lazybotKototama: Oh, absolutely.
11:09Kototamahum here: http://paste2.org/p/2367089 the first line was missing
11:21jlewisclgv: that makes sense, because it's just a tree of objects... what if i want to serialize a PHM that shares with a pre-serialized set of PHMs?
11:22jlewisi suppose i'd have to deserialize the first set and link them somehow
11:24clgvjlewis: you can serialize the first PHM to string and for each derived PHM you only serialize the change operation to string (assoc, dissoc)
11:24bordatouehello if I have a method say (str (.getVersionNo Instance)) , when i set warn on reflection is does say it cannot resolve the field of .getVersionNo, if .getVersionNo returns a int how do i specify this hint
11:24clgvjlewis: but you could also just serialize them all to string and compress that string.
11:25jlewisyes. what i'd really like to do, though, is something like the following...
11:25clgvjlewis: the last suggestion only reduces size. the read PHMs will not share anything
11:25jlewistake a PHM called a, and serialize it first
11:25jlewissome time in the future, take some new PHM based off of a called b, and serialize just the differences between a and b
11:25jlewisjust like b is stored in memory as just the differences (more or less) from a
11:26jlewisi'm guessing this isn't straightforward
11:28wingyi just dragged another guy into clj :)
11:28wingyfrom node.js
11:29bordatoueis it possible to provide a hint without a binding
11:30TimMcbordatoue: WRT reflection hints, I believe so, yes.
11:30TimMcI'm not sure if primitive hints can be on arbitrary forms.
11:30bordatoueso if i have (str (.getVersionNo someInstance)) where do i add the hint
11:30clgvjlewis: you can use clojure.data/diff to find the differences (clojure 1.4.0+)
11:31bordatoueTimMc: say getVersionNo returns an int
11:31mpenetyou need to hint your instance probably
11:32mpenetbordatoue: (str (.getVersionNo ^Something someInstance))
11:32clgvbordatoue: your reflection warning is due to "Instance" being of unknown type
11:32bordatouempenet: I have done something like this (str (.getVersionNo #^Integer myInstance)) but i still get the reflection warning
11:33TimMcFYI, #^ is old syntax.
11:33clgvbordatoue: you have to type hin the class that has the property/method "getVersionNo"
11:33mpenetbordatoue: you need to hint the type of your instance, not the return type of the method
11:35bordatoueTimMc: #^ obsolete
11:35TimMcbordatoue: Right, so use ^Foo instead of #^Foo
11:35TimMcnot that it will make a difference here
11:36bordatoueclgv: it says in the warning message field can not be resolved not instance
11:36clgvbordatoue: yeah, the filed can only be resolved if the class of the instance is known
11:36TimMcbordatoue: import
11:36clgv*field
11:37bordatouesay if i define this instance globally using def , then every time i use this instance within a function do i need to provide hint
11:38wingywhat do you think about this one: https://github.com/schani/clojurec
11:38wingydoes it have a chance to get popular?
11:39TimMcbordatoue: CHeck for yourself. You can turn on reflection warnings.
11:39TimMcI believe you can hint it in the def.
11:40clgvbordatoue: yes, I noticed that some time ago. thats because the def can be redefined
11:44clgvbordatoue: but checking by enabling reflection warnings will show you
11:47wingyhas anyone used light table in project mode?
11:47wingyi cant get it to display all my project's namespaces
11:48nDuffbordatoue: ...well, you can put a hint on the var
11:48nDuffbordatoue: that way you don't need to attach it to the uses.
11:49bordatouethanks nDuff clgv
11:50bordatoueis there any good way to debug clojure application
11:50bordatouemost of the time i don't even get a line no corresponding to the error
11:50jaleyI think the SoftCache has? implementation in core.cache may not be thread-safe? I'm getting an NPE from here: https://github.com/clojure/core.cache/blob/core.cache-0.6.2/src/main/clojure/clojure/core/cache.clj#L510
11:51nDuffbordatoue: If you haven't redefined the code since it was last AOT-compiled, you certainly should have a line number in the stack trace.
11:53bordatouenDuff: is there any tool to step through the execution of each function
11:53clgvnDuff: oh right. you can add the typehint, but e.g. automatic detection from the java function does not work
11:54nDuffbordatoue: Maybe? Haven't needed one, haven't looked.
11:54nDuffbordatoue: I try to write my code in small enough pieces that it can be tested and iterated on at the REPL.
11:54clgvbordatoue: do you use emacs?
11:55clgvbordatoue: swank has a `break` macro that starts a repl in the context of it position
11:56bordatoueis there any swank equivalent in eclipse also
12:02mpenetyes, counterclockwise has that I heard
12:02hyPiRionI think CCW and nrepl works fine now.
12:04clgvbordatoue: no break macro though. there is a debug-repl macro but that wont work with nrepl
12:08michaelr525bordatoue: https://github.com/clojure/tools.trace <-- i found this very usefull in a case where i desperately missed a stepping debugger :)
12:14actsasgeekI have a Java object that I created through Clojure interop that holds a reference to a proxy I created. When I serialize then deserialize the object, I get a "StreamCorruptedException invalid type code: 00" error. Is there a reason inherent in Clojure interop that explains why this would happen?
12:16clgvactsasgeek: serializing via Java's serialization?
12:17actsasgeekclgv: yes
12:17clgvactsasgeek: could be a classloader issue if the proxy is not compiled as a class file
12:20actsasgeekclgv: so when I'm doing it from the REPL, it can't figure out the class the pickled object is talking about; it should theoretically be fixed by AOT compilation?
12:20clgvactsasgeek: if that's the problem, yes
12:21actsasgeekclgv: thanks.
12:22clgvactsasgeek: but you might run in other problems regarding serialization id or such
12:24actsasgeekclgv: good point.
12:28CheironHi, I want to use TTLCache that needs to be wrapped with a ref type . is it allowed?
12:28Cheironhttp://clojure.github.com/core.cache/#clojure.core.cache/TTLCache
12:29clgvCheiron: depending on it's implementation retries might ruin the cache behavior
12:30CheironI need a map that is guarded by ref, it is will be used by multiple resources
12:30Cheironand and I need the behavior of TTL to perform a self house cleaning
12:31clgvCheiron: you could use locking (pessimistic) on the cache isntead of transactions (optimistic)
12:31Cheironthat is my case : data structure will be used and updated by multiple resources and a TTL policy to prevent "zombie" data
12:32Cheironwhat do you mean by that?
12:35clgvCheiron: I am not sure if core.cache is a pure immutable implementation.
12:35clgvCheiron: check that and you know whether you can use it in refs without a problem
12:35Cheironit implements : Interfaces: clojure.lang.Associative, clojure.lang.Counted, clojure.lang.ILookup, clojure.lang.IPersistentCollection, clojure.lang.IPersistentMap, clojure.lang.Seqable
12:36Cheironthose wont guarantee the "immutability" ?
12:38AntelopeSaladquestion: the source for the fn 'last' says it calculates it in linear time
12:39AntelopeSaladis that going to be worse than running count?
12:40nDuffAntelopeSalad: Depends on the implementation of Counted provided.
12:40nDuffAntelopeSalad: ...worst-case, count is linear time, but it sometimes can be better.
12:41AntelopeSaladare implementation of length in other languages in linear time too?
12:41AntelopeSalad*implementations
12:41nDuffAntelopeSalad: Completely depends on the data structure.
12:41AntelopeSaladlet's assume vectors for now
12:41nDuffAntelopeSalad: ...Clojure is very explicit about its data structures' efficiency boundaries, to allow choosing the right one for the job
12:44DerpherpHi I have a noobie question regarding gen-class
12:45DerpherpI would like to have a class created with gen-class then in the same file have a method that creates an instance of the class then call some methods on it
12:45Derpherphowever I am getting class not found, which is likely due to AOT compilation?
12:45Derpherp(or lack there of)
12:46nDuffDerpherp: Getting class-not-found at what time? You need to do AOT to get a gen-class class to be created, yes.
12:46nDuffDerpherp: ...if you can use one of the alternatives to gen-class, you may not need that.
12:46nDuffAntelopeSalad: In the case of vectors, count is constant-time.
12:47technomancyyeah, gen-class is annoying. why do you need it?
12:47DerpherpI would not like to use an alternative because those classes would be one off (correct?)
12:47Derpherp(correct ? )*
12:47nDuffDerpherp: Do you mean compiled every time they're used? If so, no, they're not.
12:47Derpherpand that would possibly be bad/inefficent for a clojure web service
12:47nDuffDerpherp: ...indeed, the alternatives are generally faster/more efficient at runtime.
12:48Derpherpagain want to note that i am new ;)
12:48technomancygen-class is an advanced topic
12:48AntelopeSaladnDuff: ok thanks
12:48technomancythere are a few legitimate cases where it's needed, but it's a bad place to start if you're new
12:48Derpherpok i will try proxy then?
12:48nDuffDerpherp: gen-class is slowest but works for the most situations, then proxy, and reify is fastest (but most restrictive).
12:48AntelopeSaladso in a vector's sake, using last would be a lot worse than count right?
12:49nDuffDerpherp: ...so -- always use reify if you can, proxy if you can't reify, gen-class if you can't proxy.
12:49Derpherpok thanks
12:49nDuffAntelopeSalad: Actually -- getting the last element isn't linear for a vector.
12:49nDuffAntelopeSalad: ...that'd be quite fast.
12:50CheironHi, all. would you please have a look at http://stackoverflow.com/questions/13015906/is-it-safe-to-use-a-clojure-core-cache-guarded-by-ref-type feel free to answer here or on SE
12:50nDuffAntelopeSalad: Perhaps you're thinking of a list?
12:50AntelopeSaladi wasn't thinking of any data structure in specific, i just happened to see the docstring for count
12:51nDuffAntelopeSalad: ...well, that's the thing -- the specific data structure matters.
12:51AntelopeSaladi threw out vector because getting nth index is usually popular
12:51nDuffAntelopeSalad: ...the docstrings give you the guarantee that performance won't be worse than ${given_thing}
12:51DerpherpCan i do a reify if i want to extend a java class?
12:52nDuffDerpherp: No; you need proxy for that; reify will extend Java interfaces, but not classes.
12:52Derpherpok thanks
12:53AntelopeSaladi don't really know clojure too well and am not an algorithm wizard either
12:53AntelopeSaladbut their implementation seemed really crazy to me
12:54AntelopeSalad(for last)
12:56joegalloAntelopeSalad: is there a better way to walk through a linked list until you reach the last item?
12:57lnostdalhi guys .. get returns the value of a mapentry in a map based on the key .. is there a getter that returns the mapentry itself? the association?
12:58AntelopeSaladjoegallo: i have no idea, but it didn't occur to me that other languages might be doing it the same way (i figured they wouldn't)
13:01AntelopeSaladjoegallo: i guess it stemmed from trying to understand things i'm just learning now but don't fully understand
13:02AntelopeSaladfor example, why can't it do a bisection search instead instead of going through every element?
13:02nDuffAntelopeSalad: Pardon? Which "it"? In what context?
13:03AntelopeSaladit = the last function in clojure
13:03nDuffAntelopeSalad: You can't seek efficiently within a linked list, period -- the structure doesn't allow it
13:04nDuffAntelopeSalad: ...so how would you do that search?
13:04AntelopeSaladthe code for last to me looked like maybe it was calling next on itself until next no longer existed
13:04nDuffAntelopeSalad: ...and again, last is implemented efficiently on structures that do allow it.
13:04nDuffAntelopeSalad: Yes, and for linked lists, that's the only way it _can_ be done.
13:04AntelopeSaladbisection could be implemented by doing nth x right?
13:04nDuffAntelopeSalad: How do you think nth is implemented on a linked list?
13:04nDuffAntelopeSalad: Hint: It's horribly, horribly inefficient.
13:05Wild_Catagain, bisection can't be done efficiently in a linked list
13:05AntelopeSaladgood to know, thanks
13:05DerpherpOk so I am stil trying to wrap my head around proxies. From what i gather they can dynamically create classes that can extend other classes. However, is it possible to: name the proxy class AND extend another class, and allow for multiple instances of the proxy to be created and methods called on it?
13:05Wild_Catit is, in fact, worse than linear search.
13:05jcromartieproxy creates an *object* not a class
13:06AntelopeSaladWild_Cat: only in the case of linked lists tho, no?
13:06DerpherpAll i want is a class and a main static method to be in a file. Where the main creates an instance of the class and calls a public method
13:06Derpherpjcormartie: ya i got that feeling....
13:06jcromartieyou want deftype and reify if you want to implement multiple instances of a Java class defined in Clojure
13:06Derpherpunlike gen-class
13:06technomancyDerpherp: what is it you're actually trying to do?
13:06Wild_CatAntelopeSalad: yup. In array lists/vectors, bisection is fast because they allow O(1) element access.
13:07technomancyunless this is a homework assignment "a class and a main static method in a file" is not a goal in and of itself =)
13:07nDuff(...well, amortized O(1) if we're being pedantic)
13:07Derpherptchnomancy: as above, have a class defined in a file, have a main static method which creates an instance of the class and calls a public method
13:07AntelopeSaladthat's what i was thinking too Wild_Cat
13:07AntelopeSaladi used vector as my example
13:07technomancyDerpherp: that's not what I asked
13:07Wild_CatnDuff: why amortized? I'm talking about read access
13:07AntelopeSaladisn't a vector an array?
13:07technomancypresumably you have an actual problem that you're trying to write code to solve?
13:08nDuffWild_Cat: Clojure's vectors require up to 7 lookups depending on their size, IIRC.
13:08joegalloAntelopeSalad: nope.
13:08Derpherptechnomacy: apoligies, i am basically trying to use a java library in clojure
13:08Wild_CatnDuff: oh? I thought they mapped directly to arrays.
13:08nDuffWild_Cat: Definitely not.
13:08Wild_Cat(what with not being resizable and all)
13:08Wild_Catinteresting.
13:08nDuffWild_Cat: ...keep in mind that arrays don't support structural sharing.
13:09jcromartieDerpherp: can you point to the library or API docs?
13:09nDuffWild_Cat: ...and that vectors _do_ support conj
13:09Derpherpwhich requires that i extend a class to create a new one, and have a static method that can create an instance of the class and get it to do its stuff
13:09Wild_CatnDuff: hrmm. Good point. I still have a lot to learn about Clojure's internals.
13:09AntelopeSaladthen half my conversation needs to be re-evaluated then
13:09DerpherpI want to do this in clojure: http://dynamicjasper.com/docs/current/xref-test/ar/com/fdvs/dj/test/FastReportTest.html
13:09AntelopeSaladi thought vectors were arrays heh :/
13:09AntelopeSaladthey seem to work like them going by the little i read on them
13:10joegallocorrect, they work a lot like them
13:10joegalloand vectors are implemented in terms of arrays (and arrays of arrays), if i recall correctly
13:10nDuffAntelopeSalad: ...very, very large vectors are actually faster than arrays, for obscure reasons involving cache lines in modern processors. :)
13:10Derpherp(FastReportTest) http://dynamicjasper.com/documentation-examples/getting-started/
13:11AntelopeSaladi guess all this stems down to count vs last
13:11jcromartieDerpherp: so you just want to make a runnable class with a "main"
13:11AntelopeSaladis there any case when i shouldn't use last?
13:11Derpherpyes
13:11AntelopeSalad(assume in general with any data structure)
13:11nDuffAntelopeSalad: Use the one that fits the goal you're trying to achieve.
13:11jcromartieDerpherp: then gen-class is for you
13:11Derpherpbut most examples lack an instantiation or self refercing (this.)
13:12Derpherpjcromartie i thought so initally but was advised against it
13:12jcromartieDerpherp: why is the instance or self-reference necessary?
13:12AntelopeSaladwould last be the more commonly used way in clojure land?
13:12jcromartieyou want to make a Clojure program not a Java program
13:12nDuffDerpherp: ...well, you're claiming that you have some fairly unusual requirements here.
13:12nDuffDerpherp: You haven't shown any of us the Java API you're working from, so we can't really evaluate that.
13:12Derpherphowever, if you try to directly convert that code ("new FastReportTest()") has an issue
13:12nDuffOh, wait, you have.
13:12nDuff*looks*
13:12Derpherpbecause the class is not recognized because it need AOT
13:13Derpherp:)
13:13jcromartieDerpherp: does something actually require you to instantiate a custom class here?
13:13technomancyDerpherp: ok, it sounds like you need :aot [whatever.ns] in project.clj then
13:13jcromartieDerpherp: like, you specify the class, and it instantiates it?
13:13nDuffDerpherp: You could still use proxy if you were providing a factory for generating instances.
13:13nDuffDerpherp: If you need to provide a class name, not a factory, then yes, you need gen-class.
13:14jcromartieDerpherp: like, there is some interface that will call a certain static method on your class, and your method will return an instance of that class?
13:14jcromartieDerpherp: and unless you can do *exactly that*, then you can't do what you want to do?
13:14jcromartieor do you just want to write a class with a "main" in Clojure
13:15jcromartiebecause the example you linked is "public static void main(String[] args)" which means it really does not matter what you do inside of it
13:18Derpherp*takes a deep breath* i just want the code I posted to work in clojure... soo I know im probably not going about it the best way just following tutorials and my BASIC knowledge of clojure. Would you advise going the proxy or gen-class route? And if i go with gen-class how would i do the AOT? I tried using the :aot flag but i do not think i am doing it right. Also if i go the proxy route then how do i call methods that were defined in the proxy?
13:19DerpherpAlso if i go the gen-class route then CAN I have a similar style as in the java class that has a main create an instance of the class?
13:19Derpherpor do i have to have the main in a separate file / name space
13:19Derpherpif so (which i have tried) there is a few other issues i ran into
13:20technomancyDerpherp: it sounds like the API you're trying to call might force you down the gen-class route. you can do it all in the same file though.
13:20jcromartieOK sorry all the gen-class and proxy stuff can be overwhelming :)
13:20nDuffDerpherp: If you can, go the proxy route. I don't know that you've answered the questions that need to be answered before we can tell whether "if you can" is true.
13:20ynnivlein is using clojure 1.3, even with :dependencies [[org.clojure/clojure "1.4.0"]]. am I insane?
13:20technomancyynniv: one of your dependencies is insane
13:20technomancyhttp://nelsonmorris.net/2012/07/31/do-not-use-version-ranges-in-project-clj.html
13:20jcromartieDerpherp: I did a basic example here v
13:20jcromartiehttps://www.refheap.com/paste/6028
13:21technomancyynniv: see also: https://github.com/xeqi/lein-pedantic
13:22ynnivtechnomancy: wow, that is most excellent. The community is definitely the best part of clojure.
13:23technomancyynniv: np. once you figure out which dependency is pulling in the wrong version you should see if you can open a bug report on it if it's still a problem in the latest version.
13:23mpenetibdknox: ping
13:24Derpherpthanks jcromartie, i am trying to use it now (going through import and class not found errors atm)
13:24Derpherpbrb
13:24jcromartieDerpherp: so are you trying to write a DynamicJasper test in Clojure?
13:24Derpherpyes
13:25Derpherpjcromartie: why do you have a gen-class and proxy use in the file?
13:27tvachonhey folks - is there any way to specify pre/post conditions on
13:27tvachonmethods implemented in a defrecord?
13:27tvachonit seems to work in extend-* calls, but the hash is ignored in defrecord
13:27dnolentvachon: not really
13:28tvachonk, thanks
13:28dnolentvachon: though if you follow the CLJS pattern you could avoid calling protocol implementations directly and go through a fn instead.
13:28dnolentvachon: in CLJS you have -first, but everyone actually uses first
13:29ynnivdefrecord still seems half baked
13:29tvachonI have different prereqs for different types tho, so I'd need to
13:29tvachonhave a function per type right?
13:30Derpherpjcromartie: ya i cant seem to get around BaseDjReportTest :/
13:31jcromartielike, you can't import it?
13:31Derpherpi have everything imported as stated on http://dynamicjasper.com/docs/current/xref-test/ar /com/fdvs/dj/test/FastReportTest.html
13:32technomancyDerpherp: if you're trying to learn clojure it might be more productive to find a project that doesn't involve crazy java APIs =)
13:32technomancyI mean if that is an option.
13:32dnolenynniv: not IME
13:33technomancyynniv: people use it way more than they should
13:33Derpherptachnomany haha ya
13:33dnolentvachon: it seems a bit strange to me to have different pre/post for the same protocol regardless of the types involved - but hard to say w/o knowing more about what you're trying to do.
13:33DerpherpThis is my current code https://www.refheap.com/paste/6029
13:33ynnivdnolen: perhaps I should qualify that by saying "for general use"
13:33dnolenynniv: general use for what?
13:34Derpherpya there are a few obvious issues in there (like Date)
13:34ynnivstoring data and polymorphic functions
13:35Derpherpmy (current) issue is with line 47
13:36technomancyynniv: people with OO backgrounds jump to polymorphism way sooner than necessary
13:36dnolenynniv: having used deftype / defrecord extensively they seem pretty well suited for exactly that.
13:37ynnivdefrecord comes with unexpected tradeoffs. the records are java classes and require a specific kind of import. constructors are strictly positional. fields can only be specified as forms and not a value
13:38ynnivyou can't extend records, only protocols
13:38dnolenynniv: so make your own ctor fn if the ones that doesn't come defrecord don't suit. using :import on deftype/record is an anti-pattern.
13:39jcromartieDerpherp: I think there's a simple solution waiting here
13:39antares_ynniv: Clojure compiler generates MyRecord->map and map->MyRecord conversion functions, you can use that instead of constructors
13:39ynnivi agree that polymorphism is overused, but when it's presented as part of the lang it seems like a good idea at first
13:40ynnivyes, defrecord creates some functions, and it's good to make more. at some point it isn't clear why one would bother with defrecord
13:40Derpherpok here is a simplification: https://www.refheap.com/paste/6030
13:40ynnivI've switched to validation functions, named field accessors, and plain old maps
13:40Derpherpwhat is the issue with line 12? How should i do AOT?
13:41dnolenynniv: sounds like you didn't need defrecord then.
13:41ynnivdnolen: i agree, but that wasn't obvious when I started
13:41jcromartieDerpherp: well first the preferred way to do member access is (.foo bar) rather than (. bar foo)
13:41ynnivand when I describe what I need (weakly typed data records), it sounds like defrecord is what I want
13:42Derpherpjcromartie ok, just going from tutorials
13:42dnolenynniv: yes it's hard to know when you need it, technomancy's advice is precisely what people say here all the itme.
13:42jcromartieDerpherp: what is going to be calling your code? that's the important part of interop
13:42jcromartieDerpherp: and in a local scope, you want let, not def
13:42jcromartiedef defines top-level bindings
13:42jcromartiei.e. it creates a var in the namespace
13:42Derpherpi thought it might, just was using them temporarily (but thanks!)
13:43jcromartieso the AOT stuff
13:43Derpherpjcromartie another method within the file will be calling my code
13:43Derpherpits a kinda gross 1 file .clj file
13:44jcromartieDerpherp: if the ONLY thing instantiating your class is the "main" method, which is void, then it's not necessary to create a class to instantiate at all!
13:44ynnivdnolen: when do you reach for defrecord?
13:44dnolenynniv: performance
13:44technomancyynniv: where do you feel like defrecord is being presented as something you should use in lieu of maps?
13:44ynnivthat's what I figured. it might be useful to mention that in defrecord's docstring
13:44dnolenynniv: or some serious DSL / infrastructure like clojure.core or core.logic
13:45ynnivdnolen: what about defrecord helps with that?
13:45jcromartieDerpherp: it looks like this comes down to creating a JUnit test case in Clojure
13:45Derpherpjcromartie eventually i will have multiple methods using an instantion of a the class OR just have a static method within the class that will create the report BUT because of the way reports are created i need to create an instance
13:45dnolenynniv: performance, high performance extensibility
13:46Derpherpjcromartie: JUinit test cas in Clojure?
13:46dnolenynniv: you wouldn't want first to implemented over types via multimethods
13:46Derpherpcase*
13:47jcromartieDerpherp: you're trying to replicate a subclass of BaseDjReportTest, which is a JUnit TestCase
13:47jcromartieso this makes more sense now
13:47Derpherpah ok
13:47jcromartieas someone else said: it's probably better to learn Clojure with something that doesn't involve existing Java APIs :)
13:47SgeoI wonder what people who hate typical OO systems think about Tcl Snit
13:47SgeoIt's OO but not inheritance-based
13:47SgeoMore delegation-based
13:47Derpherpbut to try to work from one issue to the next... how do i go about creating an instance of a class that is defined in the same file! :P
13:48jcromartieDerpherp I don't think you really have to
13:48ynnivtechnomancy: defrecord is featured in Joy of Clojure, but also anyone who has used CLOS will likely end up with defrecord
13:49Derpherpso i should avoid creating classes in clojure and using them in the same file?
13:49technomancyDerpherp: files don't really matter when it comes to gen-class
13:49Derpherp(i apogize for my java mindset :P)
13:50jcromartieDerpherp: the whole point of gen-class interop is to provide a class to be consumed from Java
13:50Derpherpapologize*
13:50jcromartieDerpherp: and in this case you want to do that
13:50Derpherpok
13:50jcromartieDerpherp: but you don't need to go any further than just implementing a certain method
13:50jcromartiethe "main" is actually irrelevant
13:51Derpherpok, i thought so at one point but then i was having issues refercing something similar to a "this" (like in java)
13:51Derpherpif i were not to have a main then how would i do the same task at hand
13:52jcromartiethe key is buildReport
13:52Derpherphmm i have an idea brb
13:52jcromartieso you would just use gen-class and (defn -buildReport [] …)
13:53jcromartiethe "main" in this class just looks like it's for quickly running the test, I don't know though http://dynamicjasper.com/docs/current/xref-test/ar/com/fdvs/dj/test/FastReportTest.html
13:53dnolenynniv: isn't CLOS considered a bit of overkill for many things as well?
13:56ynnivdnolen: it is, but you can use as much or little as you like. I was looking for some features (field accessors for sanity checking, some manner of validation, and some form of method dispatch), which lead me to defrecord. I eventually implemented these things as functions operating on maps instead.
13:57ynnivdefrecord looks like a slightly more structured map, but in reality seems to be a specific kind of performance optimization that leaks some of the runtime through and incidentally provides some structure
13:58dnolenynniv: I think some pretty nice sugar could be built on top of deftype/record ... my hunch is that Clojure is expressive enough that few people bother. Those that do bother prefer flexibility to do things how you like.
13:58technomancyynniv: sounds about right
13:59dnolenynniv: yes and no, there's enough there to some Self style "Programming Without Classes" style programming.
13:59dnolenynniv: if your protocols are small (which they should be), delegation is pretty easy.
14:00ynnivdefrecord doesn't appear to be more useful than defmulti
14:01ynnivexcept for performance
14:01technomancythat's not really the right comparison; it's defprotocol that's less useful than defmulti (modulo performance)
14:01dnolenynniv: both are useful in completely different ways - it's not unusual to combine both.
14:02borkdudeI just got an e-mail about this job, might any of you be interested: https://doo.net/en/jobs.html#clojure (click on clojure on the left)
14:04jcromartiedamn, gen-class and compile are pretty cool… you can genuinely redefine a compiled class on the fly
14:04jcromartielike, redefine the methods of an instance
14:05ynnivdnolen: I think, tho, that one should only use defrecord when performance is a problem
14:05S11001001jcromartie: sure, but you're better off using proxy's secret features for that
14:05borkdudegotta go again, bye
14:05technomancyjcromartie: not really, you just redefine stub vars
14:06jcromartieI understand, technomancy
14:06bendlas`dnolen: are you there?
14:07jcromartiebut the effect is that you can instantiate a "real" Java object and, for all intents and poirposes, swap out its method implementations while it's still alive
14:07jcromartieI understand it's not so direct under the hood
14:07technomancyI guess if you're coming from Java that sounds novel =)
14:08jcromartieit does, in that context
14:08jcromartiebut I've used Smalltalk and Ruby etc.
14:08jcromartieso it's not surprising in that regard
14:08jcromartiejust surprising that it lets me do this with stodgy old Java objects
14:08jcromartielooks like I can't add a method, though
14:08technomancyit's a clever sleight-of-hand
14:08ynnivthe JVM is actually quite permissive. most of the restrictions in Java come from the compiler.
14:09jcromartieynniv: yeah, like "how do I use generics in Clojure" has a rather surprising answer to most people :)
14:11ynnivyes. and method / field visibility
14:11dnolenynniv: more or less. but I'm glad Clojure / ClojureScript isn't written on top of multimethods.
14:11dnolenbendlas`: hey
14:11ynnivdnolen: for performance reasons?
14:12TimMctechnomancy: I hope Java's security mechanisms don't assume that methods on an object can't change over time...
14:12dnolenynniv: yes
14:13ynnivdnolen: I suppose, but perf is always a tradeoff. If I just wanted perf, clojure will never beat sbcl.
14:13technomancyynniv: the original motivation for protocols was for Clojure to be able to achieve self-hosting. people seem to have forgotten that.
14:13dnolenynniv: but also complexity reasons, protocols are simple. multimethods can easily involve :prefer-method and hierarchies which brings it's costs
14:14ynnivhmm, both interesting points
14:15xeqitechnomancy: link? I must be missing what protocols provide over multimethods
14:16ynnivmy philosophy is: first correct, then fast. so I will forego defrecord until performance is an issue
14:16technomancyxeqi: don't have anything off the top of my head. but yeah, it's purely a speed thing.
14:17ynnivtime to go. thanks for the lein-pedantic link technomancy
14:24lynaghktechnomancy: re: intro data vis, do you have a particular angle? Stephen Few's "Show me the numbers" is a very solid intro, though it can be a bit dry at times.
14:24CheironHi, calling (cache/has? c3 :a) ==> false but printing c3 shows {:a 1} , why?
14:25Cheiron(def c3 (cache/ttl-cache-factory {:a 1} :ttl 20000))
14:25technomancylynaghk: nothing really in mind other than a solid intro. I'll check it out; thanks
14:25lynaghktechnomancy: Anything by Tufte (what I like to call "The Gospel according to Tufte") is fun to read and look at but doesn't have a ton of emperical research behind it or nitty-gritty technical details.
14:26technomancyhm; yeah, what I've seen is pretty accessible but I'm not in a position to evaluate it from a technical perspective
14:26lynaghktechnomancy: this is a very good keynote on human perception w.r.t. data visualization: http://vimeo.com/26205288 I.e., when you should use color, shape, length, &c. to encode quantitative values.
14:27technomancycool; thanks
14:29lynaghktechnomancy: no problem, let me know if you have any more specific/technical questions.
14:30technomancylynaghk: this project looks like what I wished incanter had when I did the lein survey
14:30lynaghktechnomancy: c2po?
14:30technomancyyeah
14:31technomancyI would link you, except apparently AWS is currently on fire
14:32lynaghktechnomancy: yeah, I'm pretty stoked about it. I'm not looking to do much in the way of stats (depending on the survey results from folks signing up for the mailing list). As I mentioned to you earlier, I think most people are going to get a ton of value from just visualizing their data in reasonable ways without any advanced stats
14:32lynaghktechnomancy: link me?
14:32TimMctechnomancy: That would explain reddit being down.
14:32cscheidHi folks, I'm a complete clojure idiot. I probably did something dumb when installing clojure and leiningen via homebrew, but i ran across this interesting bit: (clojure-version) returns "1.3.0" in a $ lein repl, but "1.4.0" in a $ clj -r. Is this expected?
14:32technomancylynaghk: when the AWS outage is over you can try http://lein-survey.herokuapp.com
14:33technomancycscheid: yeah, never use clj from the command line
14:33technomancyit's just some bogus script that the homebrew packagers added because they didn't realize that clojure is a library rather than an end-user application.
14:33lynaghktechnomancy: ah, got it. Yeah, I'll keep that use case in mind. I'm trying to collect a variety of use cases now so we can make sure the system handles a good swath.
14:34technomancyhttps://github.com/technomancy/lein-survey if you want to see the horrible horrible code
14:34cscheidI'm guessing I'm ok with 1.3.0, then? clojure.org seems to say it's outdated.
14:35technomancycscheid: whatever you define in project.clj will be used. for experimentation outside the context of a project it really doesn't matter.
14:35hyPiRioncscheid: If you setup a new clojure project and change the version in project.clj, you'll be fine.
14:35technomancycscheid: but it does indicate you're not on the latest leiningen. I don't know much about homebrew beyong a vague suspicion of it, but lein is pretty easy to download manually
14:35oskarthHaving problems testing a macro and understanding why I get different outputs in the repl vs in the test. https://www.refheap.com/paste/6032 How do I get the actual test to return the same thing as in the repl?
14:36cscheidah, I see it. lein init created it, so I hadn't actually looked at that file
14:36cscheidrather, lein new
14:39cscheidsweet, switching to leiningen 2.0.0 did it. Thanks.
14:41cscheidlynaghk: incidentally, good seeing you here. We chatted at visweek a few days ago.
14:46ToBeReplacedanyone know a good way to wrap enlive templates with doctype?
14:49ebaxtToBeReplaced: You need to use all caps DOCTYPE because of TagSoup
14:49ebaxthttps://github.com/cgrand/enlive/issues/15
14:52ToBeReplacedebaxt: thanks; i'm looking for a way to hack or wrap deftemplate to tack it on automatically
14:54ToBeReplacedemit* is buggy if you do multiple things before <html>... likely true whenever you aren't at-most-one-node then a valid xml structure
14:57xeqioskarth: If I'm reading that right its checking ##(type (:name (meta #'+))) vs ##(type +)
14:57lazybot(type (:name (meta (var +)))) ⇒ clojure.lang.Symbol
14:57lazybot(type +) ⇒ clojure.core$_PLUS_
14:58xeqias an equivalent example
14:58xeqiI think you want to use 'nand*
14:59oskarthxeqi: you are absolutely right, I was going about it backwards. Thanks!
14:59oskarthsilly - saw the output and assumed there was something up with ns
15:01frawrHow Can I get the compilation exception Unable to resolve symbol realized? when realized is in clojure.core?
15:02jcromartie,clojure.core/realized
15:02clojurebot#<CompilerException java.lang.RuntimeException: No such var: clojure.core/realized, compiling:(NO_SOURCE_PATH:0)>
15:02jcromartie,clojure.core/realized?
15:02clojurebot#<core$realized_QMARK_ clojure.core$realized_QMARK_@c1ba52c>
15:02jcromartiefrawr: I hope that answers your question :)
15:03S11001001frawr: C-M-i in emacs is your friend
15:04frawrin nrepl?
15:04S11001001uh, maybe; it worked in slime
15:04CheironHi, from http://clojure.github.com/core.cache/index.html hit function Is meant to be called if the cache is determined to contain a value associated with e . what does this mean?
15:04frawrit's realized?, with the questionmark included
15:05jcromartiefrawr: that's the one
15:06frawrhmm, same here though..., when i ask the repl.
15:07frawrThat's odd, it should be in core according to the api on the website.
15:09S11001001frawr: is there a way you can build a reduced code sample that would allow others to observe the problem you are having?
15:10jcromartiehttp://clojuredocs.org/search?x=0&amp;y=0&amp;q=realized
15:11jcromartiehttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/realized?
15:11clojurebothttp://clojure.org is help
15:11jcromartiethere's no "realized" in clojure.core
15:14frawrit's on github somewhere, 1 sec
15:15frawrhttps://github.com/fmsbeekmans/http.async.client/blob/development/src/clj/http/async/client/request.clj
15:15frawrWhen I a project that uses this project as a dependency, compiling tells me clojure.lang.Compiler$CompilerException: java.lang.Exception: Unable to resolve symbol: realized? in this context (request.clj:71)clojure.lang.Compiler$CompilerException: java.lang.Exception: Unable to resolve symbol: realized? in this context (request.clj:71)
15:16TimMcfrawr: You're probably pulling in an old version of Clojure somewhere.
15:16jcromartiefrawr: OK so it is "realized?" in the code
15:16frawrYeah, when did i say it without?
15:17jcromartiehah I thought that was the whole thing
15:17TimMcfrawr: In your initial message, but only in one place.
15:17jcromartiethe supposed error message :)
15:17frawrAah, my bad.
15:17TimMcfrawr: Run this and check for the right Clojure version: lein classpath
15:18frawrit gives me a huge list, let me check
15:18TimMc,(-> realized? var meta :added)
15:18clojurebot"1.3"
15:19TimMcYou might also have `lein deps :tree` available to you if you are using the right version of lein.
15:19frawrnice feature!
15:21frawrlein deps :tree doesn't list clojure itself though
15:21TimMcThat's surprising.
15:21lynaghkIs there a clever way I can have any symbols that start with ? not evaluate. Or, alternatively, force evaluation of a form within a quoted form? (Like syntax quote but without prefixing all symbols with full namespaces.)
15:22TimMclynaghk: Macros!
15:22TimMcYou can strip namespaces off selectively.
15:23lynaghkTimMc: you're thinking something like clojure.walk within a macro?
15:23TimMcYeah.
15:23ChongLiyou can even convert symbols to strings and do all sorts of regex-fu on them
15:23ChongLithough that doesn't sound too robust
15:23lynaghkTimMc: yeah, I was hoping I could avoid that but it's probably the only decent way. The issue with clojure.walk is that it loses record types ocassionally.
15:24mpenetlynaghk: prewalk-replace makes this easy
15:24mpenetoh records :(
15:24lynaghkTimMc: I've already alter-var-root'd clojure.core/empty? to handle records, so maybe I'll be alright.
15:25frawrI seem to only have clojure 1.3 on my classpath though i have 1.4 as a dependency
15:26amalloyfrawr: probably someone is using version ranges
15:27amalloylynaghk: what does "not evaluate" mean?
15:27lynaghkamalloy: I need to replace ?x with '?x
15:27frawramalloy: What's the best way to research if that is the case?
15:28lynaghkI think the walk solution will be fine; I just wanted to check if there was a clever thing in tools.macros or something.
15:28amalloyfrawr: if you're using lein2, you can lein deps :tree
15:28amalloylynaghk: i'd use flatten and symbol-macrolet
15:28frawramalloy: I did, but none of my dependencies list clojure itself
15:28amalloyflatten the input and search for symbols starting with ?, and then symbol-macrolet each of them
15:29amalloythen you don't have to rebuild the input form
15:29lynaghkI checked symbol-macrolet, it will lose record types.
15:29amalloywat. you have record types as your source forms?
15:30lynaghkThe form includes records, yes
15:30dnolenlynaghk: is this related to issue that core.logic uses walk?
15:31lynaghkdnolen: no, but that's the same problem. I am getting around that by alter-var-rooting clojure.core/empty to return "empty" records.
15:31llasramamalloy: Isn't this exactly what clojure.walk/postwalk is for? Or are there unpleasant downsides to it?
15:32lynaghkdnolen: doing these logic matches and rewrites is making me thinking about the different kinds of nothingness quite a bit lately =P
15:32dnolenlynaghk: heh about alter-var-rooting empty :)
15:32amalloyllasram: imo postwalk is a lot better suited to manipulating "data" than "code", insofar as those are actually different
15:33wingyI dont quite get how I can programmatically make sense of {"Accept-Language" en-US,en;q=0.8"}
15:33dnolenlynaghk: I still up for providing an uninitialized record protocol
15:33dnolenso that people can make it work without resorting to such things.
15:33lynaghkdnolen: you mean having a special case that doesn't drop to clojure.walk?
15:34lynaghkdnolen: when, e.g., prepping the lvars in an expression?
15:34wingyin my app I just have en-US, sv-SE etc .. how can I be sure to get the language/country code combo from the {"Accept-Language" en-US,en;q=0.8"}
15:34dnolenlynaghk: yes
15:34amalloyeh? you can still use clojure.walk, just not post/prewalk
15:34amalloyoh no, i take it back. the coll? version uses empty
15:35antares_wingy: by parsing it to "the best preferred language". There are Ruby and Java parsers for content/language negotiation strings out there, it is not that complex.
15:35lynaghkdnolen: yeah, I need to give some more thought to what exactly I need for the stuff I'm doing. We can discuss at strata. I'm getting into NYC Wednesday at 7 a.m.
15:35dnolenlynaghk: it's easy enough to check for records
15:35dnolenlynaghk: k
15:35wingyantares_: could you give me a link to a good Java parser for content negotiation?
15:37antares_wingy: http://stackoverflow.com/questions/6824157/parse-accept-language-header-in-java, although with Jetty you may need a different solution
15:37frawrManaged to get realized? recognized. thank you.
15:38antares_wingy: http://jetty.codehaus.org/jetty/jetty-6/apidocs/org/mortbay/jetty/Request.html suggests there is getLocale, I think you may be able to combine that with Tower
15:39wingyantares_: im new to Jetty .. what is Tower?
15:39antares_wingy: how to access raw Jetty request from Compojure or Noir, I am not sure
15:39wingyokay
15:39wingythx
15:39antares_https://github.com/ptaoussanis/tower
15:40antares_wingy: all you need is access the original Jetty request object and use .getLocale or .getLocales
15:42julson,
15:42clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
15:42TimMcfrawr: Which dep was the culprit?
15:47wingyantares_: Tower looks nice
15:48wingyantares_: atm im creating my own lang middle ware .. perhaps just better to use tower
15:48xeqifrawr: https://github.com/xeqi/lein-pedantic can help figure it out in the future as well; sometimes lein deps :tree doesn't provide enogh info
15:48wingyantares_: if im using Tower I don't have to parse the Accept-Language myself?
15:49wingyit says that the ring middleware does that
15:50TimMcHmm, one consequence of cloud services is that when a big one goes down, a *ton of websites are affected all at the same time.
15:50TimMcWhen one company's non-cloud servers go down, it's just them.
15:51wingyTimMc: are you talking about Heroku? :)
15:51TimMcAnd Reddit.
15:51TimMcand anyone else in that availability zone.
15:54antares_wingy: I am not very familiar with Tower but it should be able to also work with Locale instances. Which is what request.getLocale should return you. Jetty then will do all the hard parsing work.
15:55wingy"The request's Accept-Language HTTP header."
15:55wingyits also allowing language choice based on (get-in request [:session :locale])
15:56wingygreat fit .. lets use it!
15:56wingyi dont get why certain libs have so few users thoug
15:56wingyh
16:03antares_wingy: because their authors do 0 marketing
16:04wingyin node.js we got a TJ
16:04wingywhen he launches one lib it hits 500 users in some weeks
16:04antares_and libraries (even the most awesome ones) need some marketing to grow a community
16:04antares_(good documentation is marketing, by the way)
16:04wingyyeah
16:05devinusanybody work with Titan in Clojure?
16:06antares_devinus: I have a very rough client that is not yet good enough to be published
16:07devinusi think clojure + titan would be wicked sick
16:07antares_Titan is not hard to use directly but also not trivial to wrap in a more idiomatic API
16:07SgeoWhat's Titan?
16:07antares_Sgeo: http://thinkaurelius.github.com/titan/
16:08devinusantares_: here's one wrapper: https://github.com/megakorre/clj-titan/blob/master/src/clj_titan/core.clj
16:08antares_devinus: I may have something useful enough to others in about a week
16:08devinusantares_: what's your GH?
16:09antares_devinus: that looks pretty good. I am michaelklishin but it will be published under github.com/clojurewerkz, like the rest of new clojurewerkz.org projects.
16:09biscarchis titan a solid graph db? I was looking at it a while ago.
16:09devinusantares_: that would be really awesome
16:09antares_devinus: I think you can probably go with clj-titan and not wait. I want Titanium to match the quality of clojurewerkz.org's other DB clients.
16:09devinusantares_: i'm writing a website in clojure that's going to use titan
16:10devinusit's a game changer
16:10antares_biscarch: well, Neo4J is solid, too, but has no HA or *backups* (!!!) in the Community edition
16:10antares_Titan is backed by HBase or Cassandra so it has distribution built-in
16:10antares_with consistency model you want
16:10devinusNeo4j is not distributed at all
16:10biscarchantares_: so I've discovered heh
16:10antares_devinus: Neo4J Server is
16:11biscarchantares_: I like the sound of cassandra/hbase as a backend
16:11antares_devinus: master-slave replication with master election on failures
16:11antares_biscarch: I haven't looked at the storage impl but I guess adding Riak, MongoDB and JDBC backends won't be difficult, too
16:12antares_I agree that Titan is a game changer in the graph db space
16:12antares_but it is also not very mature yet
16:13devinusthere seems to be a lot of Clojure development "groups"
16:13biscarchantares_: any glaringly serious problems?
16:14devinusi like it
16:14antares_devinus: in any case, I will try finishing initial Titanium API and some docs. Now that I see some other folks interested, it will be much easier to motivate myself.
16:14AntelopeSaladdo you guys use datomic for your non-graph db needs?
16:14devinusantares_: yes, i will start using it immediately
16:14devinusAntelopeSalad: i unfortunately can't use anything that's not open source. IIRC datomic isn't open sourced yet?
16:15AntelopeSaladi'm not sure, still new to the clojure scene -- i don't think it's OS though
16:15antares_biscarch: no obvious glaring bugs but it's not well documented, bug free or heavily tested by many people. Being based on the Tinkerpop stack means the API is very much fleshed out, though.
16:15antares_devinus: it never will be open source
16:15devinusantares_: thought so
16:15wingyantares_: tell me whyyayyy
16:16devinusyeah, i can't sell to my boss a completely proprietary db
16:17S11001001devinus: would you accept a proprietary db for which you received source & hacking permissions?
16:17devinusS11001001: yeah
16:17technomancynot if you can't share you hacks
16:17technomancyin which case it's not proprietary
16:17S11001001technomancy: good qualifier
16:17devinuslol right
16:17S11001001technomancy: there's a threshold
16:17devinusat which point you might as well just go open source
16:18pipelinethat's not true devinus
16:18pipelineopen source was a long tradition in e.g. proprietary unix
16:18S11001001diff doesn't say everything
16:18devinuspipeline: oversimplification, i know
16:18pipelinethey expected to pay your dues, but you could share code with other people past the gate
16:18devinusseems weird that datomic doesn't sell itself as "the datomic company" instead, like e.g. basho or datastax
16:18pipelinea perpetual license and open-but-nonfree source doesn't sound too bad
16:19technomancydisagree; sharing is what makes software worth doing
16:24S11001001technomancy: I wouldn't have bothered becoming a programmer without it
16:27ivanI have a new appreciation for text editors after trying to implement shift-home/ctrl-shift-a in nrepl.el
16:31wingyanyone here having experience with tower?
16:40seancorfield~anyone
16:40seancorfieldhmm, isn't that something the bot responds to?
16:40emezeske~anybody
16:41emezeske^ Just a guess :)
16:41seancorfieldwingy: can you be more specific?
16:41danlarkinclojurebot!!!!!!!!!!!11111
16:41wingyseancorfield: about tower?
16:41emezeskeclojurebot's being lazy I guess ;)
16:41wingynvm about tower
16:42hiredmanlooks clojurebot is have ebs issues, like the rest of aws
16:42cscheidhas anyone seen lein uberjar fail with a ClassCastException and then work if you try it again?
16:43pelismoin compojure (or ring) is there a way to block stack traces from leaking out to users when errors occur?
16:43seancorfieldyeah, aws problems hit us for an hour but we're back up now... although it looks like more aws services are suffering than an hour ago...
16:44wingydoes anyone know how i can access the Jetty request in compojure?
16:44technomancypelismo: that's the default behaviour
16:44wingyi mean ring
16:45pelismotechnomancy: i'm using lein-ring to use a local dev server - could that be the reason it exposes it out?
16:45technomancypelismo: I don't know; I never got the point of lein-ring. you just need to find whatever is enabling the stacktrace middleware.
16:45pelismook, thanks
16:45technomancyif you're not turning it on in your own code it could be coming from the plugin
16:45Raynestechnomancy: What do you mean by 'never got the point' of it?
16:46technomancyRaynes: I completely fail to see the appeal?
16:46RaynesDoes not compute.
16:46technomancyunless you are working with a company that has a lot of investment in existing war-based deploys
16:46technomancyI don't understand why people use it during development
16:47RaynesI'm fond it because I don't have to add server starting code to my apps.
16:47technomancyRaynes: you mean a single line invoking run-jetty?
16:48RaynesYes.
16:48devinusRaynes: did you get enough to go to the conf?
16:48Raynestechnomancy: Your forgetting explicitly added dependencies too.
16:48technomancyRaynes: lein-ring is an explicitly added dep too though
16:48RaynesIt makes it easy to deploy and run your code in a variety of ways.
16:48RaynesYeah, and it does other things and doesn't require additional code.
16:49technomancyI would understand that if the variety of ways were somehow better
16:49Raynesdevinus: Yes.
16:49devinusnice
16:49Raynesdevinus: Reconsidering now that technomancy has shown his true colors.
16:49RaynesCan't been seen with him.
16:49technomancyRaynes: repl uber alles bro
16:51antares_More updates to the Concurrency CDS guide today, feedback very welcomed: http://clojure-doc.org/articles/language/concurrency_and_parallelism.html
16:52ToBeReplacedtechnomancy: what is your workflow then... nrepl-jack-in, run jetty, kill it when you need the repl back?
16:52technomancyToBeReplaced: you can do run-jetty with :join? false to start it in the background
16:54technomancyI like the regularity of being able to frame everything in terms of -main entry points
16:55ToBeReplacedseems nice... i like the (.stop server) ability
16:56technomancyyeah typically I do (def s (-main)) so I can come back to it
16:57ToBeReplacedright, sounds good
16:58cscheidok, i figured it out, so here's in case anyone's searching the logs: lein uberjar fails with a less-than-very-helpful error message if you say (defproject ... :main "the.namespace" ...) instead of (defproject ... :main the.namespace ...). complete idiot mistake of mine, but anyway
17:45jcromartieis there a fn like (foo [1 1] inc dec) => (2 0)
17:45eggheadyou want to pass as many fns as the length of the seq?
17:45jcromartielike, "transform each element in the collection by the matching argument fn"
17:45jcromartieyeah
17:45jcromartieI can imagine writing it
17:46emezeske,(map #(%1 %2) [inc dec] [1 1])
17:46jcromartienot bad
17:46jcromartie(defn combobulate [coll & fns] (map #(%1 %2) fns coll))
17:47eggheadlol, there you go
17:47metellus&(map apply [inc dec] [1 1])
17:47lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
17:47eggheadI was told today that clojure is not as good as scala because it doesn't have 'final'
17:47eggheadand because of that it's an imperative language
17:48egghead:3
17:48jcromartiesure, you can def all day long
17:48jcromartiewhy not
17:48eggheadI heard you like to def so I put a def in your def
17:49jcromartie(do (def n 0) (loop [] (def n (inc n)) (println n) (if (< n 10) (recur))))
17:49jcromartie<3
17:49jcromartieprocedural clojure is so natural
17:49amalloyjcromartie: https://github.com/flatland/useful/blob/develop/src/useful/fn.clj#L94
17:49jcromartieamalloy WINS!
17:49jcromartiewith a neat name and everything
17:50amalloyevery cool function you want is already in useful, mate
17:50eggheadflatland
17:50jcromartie:) I'll checkit out
17:50eggheadflatland was a cool book
17:50jcromartienever used it
17:50jcromartieI keep passing it at the bookstore, should I read it?
17:50jcromartieI can get it for free I'm sure
17:51eggheadcertainly wouldn't hurt, it uses a 2d world to explain what a higher dimension might be like
17:51amalloyit also spends a lot of time on victorian satire
17:51amalloyshort enough to read in an evening, as i recall
17:51eggheadI've been reading 'to mock a mockingbird' and GEB
17:52amalloyoh, my brain. mockingbirds are too hard for me
17:52wingydo you think i am ready for joy of clojure? i have been on clojure for 1.5 month now .. knowing the basics
17:52eggheadyes wingy read it
17:53amalloyyou were ready before you touched clojure. i don't understand claims that it's too hard
17:53wingylol
17:54tgoossensI heard a lot of flatland. Read a lot *about it*. But never the actual book
17:54tgoossensFunny idea though. it is almost de standard way that scientist try to explain higher dimensions to non-scientists or students
17:55eggheadI liked sagan's bit on the 4th dimension from the cosmos series
17:55eggheadshowing how 3d objects have 2d shadows
17:55tgoossensyes
17:55tgoossensi saw that one too :)
17:56egghead4th spatial dimension that is
17:56emezeskeI second amalloy and nDuff in saying that JoC is not too hard (if you're willing to put in some effort)
17:58scriptorthere's just a few places where it assumes knowledge of something without really explaining it
18:03emezeskescriptor: Presumably someone learning Clojure has access to the internet, where they can fill in gaps
18:03emezeskescriptor: Anyway, all books assume a tremendous amount of knowledge (e.g. the English language for example)
18:04scriptorI didn't mean that as a criticism, meant that there really are just a few
18:04wingyif they have internet they can you google translate along with it
18:04emezeskescriptor: Oh :)
18:04SgeoIs Joy of Clojure more about why things are done this way and theoretical abstract concepts than Programming Clojure?
18:04SgeoBecause I like theoretical concepts and explanation
18:04Sgeos
18:04nDuffIs there a clean way to create an anonymous dynamic var? I want to create a set! target without polluting my namespace.
18:04scriptorSgeo: it definitely has that
18:04nDuffSgeo: Yes, exactly.
18:05amalloy&(doc with-local-vars)
18:05lazybot⇒ "Macro ([name-vals-vec & body]); varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set"
18:05nDuff...mind you, Programming Clojure at least has _some_ of the why... unlike, say, Clojure in Action (which is almost all "how" and no "why" at all)
18:05nDuffamalloy: nice; thanks!
18:07AntelopeSaladsomeone recommended me SICP once as a general lisp learning tool and to explain functional programming in general
18:08AntelopeSaladif you like theory, it's worth checking out ^ Sgeo
18:09SgeoAntelopeSalad, I started SICP a while ago, I should resume it
18:10AntelopeSaladi actually stopped about a third of the way through due to time management issues i had (+ it's really difficult with the math if you don't have a decent math background)
18:10TimMcHave You Watched Your SICP Today?
18:10AntelopeSaladbut yeah, i plan to revist it again
18:10AntelopeSaladthe first few lectures alone will probably change your entire philosophy on programming
18:12shaungilchristI am still trying to read SICM
18:12eggheadcomputer machines
18:12shaungilchristevery year I pick it up and make it half a chapter further and realize how much more I don't know about physics
18:12shaungilchristI'd actually be bummed out if it were any other way
18:32devth_is there a function to detect if something is a lazy seq?
18:35brehautdevth_: a seq or do you want to specifically know about laziness?
18:35devth_put another way: i have the result of some (eval foo) - it could be anything. i want to get its string representation: (str (eval foo)). this sometimes returns "clojure.lang.LazySeq" which is very unhelpful.
18:35tgoossensi think he wants something like this:
18:35tgoossens(lazy? coll)
18:36texnomancymaybe you want pr-str
18:36devth_ah
18:36devth_texnomancy: perfect. ty
18:37emezesketexnomancy: Are you technomancy's doppelganger? Are you a good doppelganger or a evil one?
18:38texnomancyemezeske: I'm using it to weather awsageddon
18:39emezesketexnomancy: :)
18:39zackzackzackAny ideas about what java.lang.String<> means as a parameter type?
18:40clojurebot(2 0)
18:40zackzackzackI've tried using a string as a input type but it says that there is no matching method for that call
18:44amalloyzackzackzack: doesn't mean anything, so you'll have to provide more context
18:46tgoossenswell good night everyone (for me atleast :) )
18:49seancorfieldI had never realized how counter-intuitive core.cache must seem until I tried to explain it on the list today...
18:52texnomancyI couldn't figure it out when I briefly tried it
18:52texnomancyended up rolling my own memoize that exposed the atom
18:52amalloytexnomancy: hadn't you already done that long before core.cache existed?
18:52texnomancyafter submitting http://dev.clojure.org/jira/browse/CLJ-804
18:53texnomancyamalloy: no, I think that was just complaining about c.c/memoize and not writing anything
18:53seancorfieldIt does seem like it would cause less confusion if core.cache actually wrapped itself in an atom in the first place... unless fogus imagines other uses (which I can too, just not sure they're likely to be common)
18:53texnomancyhaha "recommend Guava for advanced caching"
18:54tomojis there an easy way to get the requires of a namespace?
18:55texnomancytomoj: slamhound does that
18:56tomojcool, so just need a function to get a filename from an ns
18:56tomojthanks
18:58tomojwas hoping to avoid reading, but if slamhound takes care of it, great
19:20zackzackzackamalloy: took an hour of googling, but I found out what's up
19:20zackzackzackamalloy: Canonicalizes class names as Clojure symbols. Types can extend to the TypeReference protocol to indicate that they can be unambiguously resolved as a type name. The canonical format requires one non-Java-ish convention: array brackets are <> instead of [] so they can be part of a Clojure symbol.
19:20zackzackzackhttp://clojure.github.com/clojure/clojure.reflect-api.html
19:24zackzackzackI guess the question is now how to create a typed array (or if I even want to).
19:28acagle /flush
19:57ivanhttp://awelonblue.wordpress.com/2012/10/21/local-state-is-poison/
20:51Kowboyok, got a tricky one...
20:51KowboyI have a map that I got from a JSON request (trough clj-http)
20:52Kowboyit has the following content: {:T.Brady "00-0019596", :J.Tuck "00-0023509", : "0"}
20:52Kowboynotice the last key
20:53Kowboyit's empty
20:53Kowboyif I try to write this out and read it back in, I get a parse error
20:53tomojin cases like that I prefer :as :json-string-keys
20:53Kowboyhmmm, I'll try that
20:54Kowboyin the original JSON, it is actually :0 with no key
20:54Kowboydidn't know that was valid JSON. Maybe it's not
20:54dnolenKowboy: it's not valid
20:55tomojsure it is?
20:55tomojit's inconvenient
20:56emezeskeI just typed {"a" : 1, : 2} into my local JS console, and it threw an error. Seems not valid.
20:56tomojluckily anything (I think?) that doesn't work as a keyword is inconvenient for js programmers, so rare
20:56tomojthe json is {"a": 1, "": 2}
20:57dnolentomoj: yes that's different.
20:57emezeskeKowboy just said it is :0 with no key. "" is a key.
20:57tomojthat's his keywordized version
20:57tomojthe key is (keyword "")
20:57tomojotherwise cheshire would have blown up
20:57emezeskeI quote, "in the original JSON, it is actually :0 with no key"
20:57tomojoh
20:58tomojI don't believe that :)
20:58emezeskeI mean, maybe Kowboy is writing confusing things, but the way I interpret that is that the JSON is malformed
20:58tomojcheshire blows up
20:58dnolen,{(keyword "") 0}
20:58clojurebot{: 0}
20:58tomojmaybe it looks like no key if you print it in js
20:59emezesketomoj: Yeah, maybe that's it.
20:59tomoj(it does in chrome: "Object {: 4, foo: 3}")
21:00tomojfactual-clojure-driver keywordizes everything even if the keys have spaces and other funny characters, and for some reason :json-string-keys blows it up :(
21:01tomojoh, I just realized why
21:02tomojselecting keywordization seems somewhat tricky
21:02Kowboythe JSON looks like {:0, T.Brady:00-0019596, J.Tuck:00-0023509}
21:02tomojJSON.stringify it
21:03tomoj(that isn't JSON)
21:03amalloyyeah, that looks closer to random characters than to json
21:03Kowboycheshire reads it as {: "0" etc..}
21:03Kowboythat doesn't parse when you try to read-string it
21:04Kowboy,(read-string "{: \"0\"}")
21:04clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :>
21:04Kowboythat's the exact error I'm seeing
21:04tomoj..don't pass true to cheshire (i.e. use :as :json-string-keys with clj-http)
21:05Kowboycheshire consumes the JSON just fine, but I can't write it to a file and read-string it later unless I filter it
21:05tomojthat or deal with the empty keyword manually
21:05Kowboyok, thanks
21:10dakronethat is some crappy json
21:14amalloyi don't think we got through to him with the message "That is not JSON. It is random garbage someone decided to tell you is JSON."
21:14muhoohttp://jsonlint.com/
21:16FrozenlockIs there something more recent than clj-units for units dans dimensions stuff? (clojure 1.2!) http://onclojure.com/2010/03/23/computing-with-units-and-dimensions/
21:23xeqiFrozenlock: https://github.com/martintrojer/frinj ?
21:31Frozenlockxeqi: looks very nice! Thanks for the link.
21:53KhaozWrite something like (defn s->k [s] (keyword s)) is just a preference/best pratice, right ?
21:55Khaozlike the use of ? to visually tell that a function return a boolean
21:56amalloygiving a cryptic new name to a function already in the standard library sounds more like a worst practice
21:59Khaozyou think that i'm writing some kind of valid code ? It's just an example. My main point here is the s->k particle.
22:05Khaozanyway, looks like "yes" is the answer to my question :)
22:05Khaozthanks :)
22:09Licenserokay here is the question, what was the way to go now to work with EMACS, slime was not the SOTA thing right?
22:15xeqiLicenser: nrepl
22:15Licenserxeqi thanks!
22:23Kowboyok, so I decided I like keywords better and used clojure.walk to replace the empty keywords
22:23Kowboytwas easier than I thought
22:23Kowboyin general, which walk function is better on performance?
22:24Kowboyprewalk-replace, postwalk-replace, or some other third thing?
22:54Licensergosh uploading to clojars got a lot more complicated :(
22:55seancorfieldLicenser: I still do `lein do pom, jar` and then scp it manually
22:56Licenserhmm that isn't a bad idea
22:57xeqiLicenser: how so?
22:57LicenserI'm reading the read me of the deploy task and there is stuff in there like registering on some website (other the clojars)
22:57Licenserah I should have probably looked at the topic
22:59muhooit's pretty insane last I checked, PGP stuff, etc
22:59muhooi just scp manually too :-) fast and easy
22:59texnomancythe only thing worse than signing jars is pulling in jars that are impossible to verify =\
23:00texnomancyLicenser: registering on some other site?
23:00Licenseryea it was in the maven central section :)
23:01LicenserI didn't see the topic there
23:01texnomancyoh, heh
23:01texnomancyyeah, luckily clojars is much simpler
23:01xeqiI tried to make it as simple as `lein deploy clojars` :p
23:02Licenserxeqi yea that gives me a 401 sadly :(
23:02Licenserthat would be really cool if it wired so :P
23:02Licenser*ponders* if that might be because he's not owner of the group the jar is in
23:03xeqi401 should be failed login if I remember right
23:03amalloyauthentication required
23:04xeqiunfortunatly aether (the library lein uses for dependency management/pushing) doesn't have a way to produce good errors
23:04xeqieven if a real messsage is sent back from clojars :(
23:05Licenseryea but my http credentials are right
23:05xeqigroup permission problems should end up as a 403 if I remember and am scanning code right
23:05texnomancy401 could be http rather than https too
23:06Licenserah there we go, problem solved. For once I used https now then I changed the group to something I own :)
23:07Licenserah I've not worked with clojure far to long - bad me
23:08xeqiLicenser: lein version ?
23:08Licensergot 2.0
23:08Licenserxeqi I really think the problem was that I tried to push to a group that was not mine
23:08LicenserI am fixing a 3rd party library and wanted to put the jar on clojars and did not use my group for that
23:09xeqik, glad to hear its working for your group :)
23:09Licenser:D and me