#clojure logs

2012-11-29

00:00jyfl987like {:jyf1987 {:name "jyf" :age 26 :brothers [{:alien ...} ...]}}
00:00jyfl987wil change :age every year, or add brothers when i have :]
00:01jyfl987dont want to change the whole record, that's the differences between redis and memcached
00:11jyfl987seangrove: yep like firebase, but i dont want to use a 3rd party host webservices, i need local service
00:16seangroveInterestingly, I want something like firebase in local memory
00:16seangroveIs there a way to tell if a variable is an atom? Something like (when (atom? var) ...)
00:20brainproxyseangrove: maybe check whether its class is clojure.lang.Atom
00:20brainproxyiirc...
00:21jyfl987seangrove: just like me
00:21brainproxy(instance? clojure.lang.Atom your-var)
00:21jyfl987seangrove: wow, the same like me !!!
00:21seangrovebrainproxy: That's perfect, thanks!
00:21brainproxy&(instance? clojure.lang.Atom (atom {}))
00:21lazybot⇒ true
00:21jyfl987i'd like to know if a data in a tree struct or in its nested struct
00:29seangroveAh, damn it
00:29seangroveclojure.lang.Atom doesn't work in cljs
00:29seangroveMaybe cljs.core.Atom will work
00:38TimMcholy shit I think I'm actually getting the hang of enlive
00:41muhooscary :-)
00:45TimMcIt seems a bit like point-free programming.
00:45TimMcI'm passing all these transformers around and not actually seeing the node arguments at any point.
00:46solussdanyone know how to compile the current sexp in emacs using 'nrepl' ?
00:46solussdi used c-c c-c when I used clojure-jack-in
00:47ChongLihttps://github.com/kingtim/nrepl.el#keys
00:48ChongLiC-x C-e looks to be what you want
00:48RaynesTimMc: It feels a bit like ,3mvirtwunvgiruetngiuenqfiu programming.
00:48TimMcI didn't know you knew Norwegian.
00:48solussdChongLi: thanks
00:49RaynesTimMc: I didn't know you were dumb, but today's events make me wonder.
00:49Raynes:P
00:52solussdTimMc: Enlive is awesome
00:52jyfl987so is there anyguys using vim here?
00:53TimMcsolussd: I keep running into this impedence problem of node vs nodes. Do you find that to be a problem too?
00:53Sgeo__Enlive + monads + ??? = PROFIT
00:54RaynesTimMc: I'm sure he'll hear that, wherever he is.
00:54TimMc:-(
00:54RaynesSgeo__ >>= monadistic
00:55seangroveA js library of cljs helper functions would be nice
00:55jyfl987Sgeo__: i like enlive's way
00:56Sgeo__I think do-> is just syntax for using some particular monad. I need to look at it again
00:57Sgeo__All these library authors keep reinventing the monad wheel.
01:00seangroveA few shortcuts for inspecting cljs objs as js objects, auto-deref-ing atoms, etc.
01:00TimMcWell, here's my first working enlive code: https://github.com/timmc/pellucida/blob/master/src/org/timmc/pellucida/listing.clj#L23
01:10ynnivok, last time I needed something specific but simple #clojure pointed me to a core function
01:11ynnivso this time I need a foo such that (foo { :x { :a 1 } } { :x { : b 2 }) -> { :x { :a 1 :b 2 } }
01:12ynnivand i already forgot about colloquy's funny smileys. :x is (keyword 'x)
01:12ynnivany takers?
01:13hyPiRion,(merge-with merge {:x {:a 1}} {:x {:b 2}})
01:13clojurebot{:x {:b 2, :a 1}}
01:15hyPiRionYou didn't specify what to do if a keyword appears twice though. This one will only keep the last key-value pair, as in, from the last map you send in
01:15hyPiRion,(merge-with merge {:x {:a 1}} {:x {:b 2}} {:x {:a 2}}) ; e.g.
01:15clojurebot{:x {:b 2, :a 2}}
01:15ynnivthat only works with the first nesting
01:15ynnivbut perhaps a simple modification will nest indefinitely
01:15hyPiRionhm
01:16ynniv,(merge-with merge {:x {:a {:m 1}}} {:x {:a {:n 2}}})
01:16clojurebot{:x {:a {:n 2}}}
01:18hyPiRion,(letfn [(mw [& r] (apply merge-with mw r))] (mw {:x {:a {:m 1}}} {:x {:a {:n 2}}}))
01:18clojurebot{:x {:a {:n 2, :m 1}}}
01:18hyPiRion,(letfn [(mw [& r] (apply merge-with mw r))] (mw {:x {:a 1}} {:x {:b 2}}))
01:18clojurebot{:x {:b 2, :a 1}}
01:19hyPiRionSo (defn foo [& r] (apply merge-with foo r)) is what you want.
01:20muhoowhat's the difference between merge and merge-with?
01:20muhoooic, nm. f.
01:20Sgeo__o.O
01:20Sgeo__For some reason I failed to process how easy that function would be to write
01:21Sgeo__My nested maps are easy to decompose into an unnested one, so was consdering doing that then merge
01:22ynnivhyPiRion: that is most excellent. I'm trying to build something with partial, but self-referencing isn't working there
01:22ynniv(inc #clojure)
01:22lazybot⇒ 1
01:22muhoo(inc inc)
01:22lazybot⇒ 2
01:22ynniv(inc hyPiRion )
01:22lazybot⇒ 3
01:22muhoo(inc dec)
01:22lazybot⇒ 1
01:22muhoo(dec inc)
01:22lazybotYou want me to leave karma the same? Fine, I will.
01:22Sgeo__(dec lazybot0
01:22Sgeo__(dec lazybot)
01:22lazybot⇒ 8
01:23Sgeo__(inc lazybot)
01:23lazybot⇒ 9
01:23muhoo(inc lazybong)
01:23lazybot⇒ 1
01:23muhooo_0
01:23Sgeo__I should just go ahead and keep lazybot dec'd
01:23Sgeo__For its wrong behavior.
01:25hyPiRionynniv: self-referencing is possible there too!
01:25hyPiRion,(let [mw (fn mw [& r] (apply merge-with mw r))] (mw {:a {:b 2}} {:a {:c 3}}))
01:25clojurebot{:a {:c 3, :b 2}}
01:26hyPiRionJust put in the name of the function right after "(fn"
01:28ynniv,?
01:28ynnivI think I killed lazybot
01:28ynnivI asked it for a list of help topics
01:28ynniv,(+ 1 2)
01:28ynnivawesome
01:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ? in this context, compiling:(NO_SOURCE_PATH:0)>
01:28clojurebot3
01:29muhoo&(identity :foo)
01:29lazybot⇒ :foo
01:29muhooit's alive
01:29ynnivhmm, looks like I was just lagging for a couple of minutes
01:29ynnivI just got a burst of backlog
01:30muhoowell it is LAZYbot.
01:30muhoo(realized? lazybot)
01:30ynniv(dec muhoo)
01:30lazybot⇒ 0
01:30ynniv(inc muhoo)
01:30lazybotYou want me to leave karma the same? Fine, I will.
01:30ynnivjust kidding
01:32ynnivis there no way to print current karma?
01:33nightfly_(str muhoo)
01:33ynnivhyPiRion: I meant (def recursive-merge (partial merge-with recursive-merge)). It can't self-reference because partial needs to evaluate before it can def recursive-merge
01:33ynnivi assume
01:34hyPiRionah, right
01:35ynnivwell… your expr macroexpands into (def foo (fn* ([& r] (apply merge-with foo r))))
01:35ynnivnot sure how that's different from partial
01:38ynnivk, asked lazybot for help again, seeing the same lag
01:40Sgeo__partial isn't a body, all its arguments get evaluated
01:40Sgeo__Incidentally, try using the Y combinator or some other fixed-point thing?
01:40ynnivoh, fn is a special form that pre binds the function name to allow self referencing
01:40bluegrayhowdy all
01:41bluegrayI'm trying to get his going: https://github.com/hugoduncan/hornetq-clj
01:41bluegrayis that yours hugod?
01:41ynnivSgeo__: why does partial not being a body matter? wouldn't it only matter if it were part of a special form that wasn't evaluated?
01:42Sgeo__(partial f (+ 1 1))
01:42Sgeo__(+ 1 1) gets evaluated before partial ever sees it
01:42clojurebot2
01:42Sgeo__o.O
01:43Sgeo__(fn [] (+ 1 1)) (+ 1 1) doesn't get evaluated unless the function is called
01:43ynnivyes, but symbols are bound on compilation
01:43ynniv,(fn [] undefined)
01:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: undefined in this context, compiling:(NO_SOURCE_PATH:0)>
01:45Sgeo__Maybe the def form allows use of the name it's defining within it?
01:45ynnivhttp://clojure.org/special_forms says this is because fn does magic to allow it
01:45ynnivand defn expands to (def (fn name
01:46Sgeo__http://ideone.com/BqgXcu
01:46ynniverr, actually it doesn't… hmm
01:46Sgeo__Not getting an error about unresolved name, but about unbound var
01:47Sgeo__Which indicates that when you're in a def's body, you can in fact use what is currently being def'd
01:47Sgeo__Hmm, "use"? Lemme se
01:48Sgeo__http://ideone.com/Yneg8Z
01:48Sgeo__Guess that doesn't strictly speaking prove it, could look like weird fn magic
01:48bluegrayI'm having trouble running the example code - can't figure out how to create the queues
01:49Sgeo__I hope I didn't crash IdeOne
01:50Sgeo__Now, how to use this knowledge for evil instead of good...
01:51ynniv~(+ 1 1)
01:51clojurebot,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) )] (testar 11 25))
01:53Sgeo__o.O what?
01:53Sgeo__~(inc 5)
01:53clojurebotsee Subject Computing, Inc
01:53Sgeo__wat
01:53Sgeo__~(dec 0)
01:53clojurebot(+ 2 10) reply 12
01:53Sgeo__...what?
01:54Sgeo__~()
01:54clojurebot() is awesome
01:54Sgeo__~(do)
01:54clojurebotIt's greek to me.
01:54ynnivdoesn't ~ talk to lazybot?
01:54ynnivand , to clojurebot?
01:54ynniv,1
01:54ynniv~1
01:54clojurebot1 is marg
01:54clojurebot1
01:54Sgeo__~HoNk
01:54clojurebotI don't understand.
01:54Sgeo__~(+ 346 126)
01:54clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25))
01:55Sgeo__~(+ 346 126)
01:55ynnivclojurebot: foo?
01:55clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an")) )] (testar 10 25))
01:55clojurebotFoo is is Short, Self Contained, Correct (Compilable), Example http://sscce.org/
01:55ynnivdunno
01:55ynniv,(+ 1 1)
01:55clojurebot2
01:56ynniv(inc clojurebot)
01:56lazybot⇒ 15
01:56ynnivi guess the bots have changed since the last time I was here
02:33Raynes$mail ynniv Lazybot is triggered with &
02:33lazybotMessage saved.
02:34RaynesSgeo__: http://dl.dropbox.com/u/23745600/Screenshots/32ba.png You should use refheap. At least it can keep text in bounds.
02:35Sgeo__Can refheap evaluate code that I paste in?
02:44Sgeo__As soon as I finish my long overdue math homework I must sleep
02:49abpSgeo__, so, quite a few hours to go? Sleepy brain and math sounds like an unforgiving combination.
02:49Sgeo__I'm actually doing these a lot faster than I thought I would
02:49Sgeo__But I did make a few dumb mistakes
02:50Sgeo__A lot of these questions are requiring minimal thinking though, so that's good
02:53Sgeo__" (If a value does not exist, enter NONE.)"
02:53Sgeo__I vaguely decided that the value did not exist, put DNE down, and was saddened by the wrong mark.
02:53Sgeo__(I get multiple tries)
03:01abpSgeo__ uh I know that feeling.
03:02abpSgeo__ but I've got absilutely no math skills. You would laugh for hours, would you know what I program, considering how absent my maths are.
03:20Sgeo__I am now distracted by a recreation math thought I've had for a while and now feel closer to solving
03:47tomojhmm
04:16clj_newb_234on linux, are there any wms that can be scripted via clojure?
04:16clj_newb_234(wms = window managers)
04:18jyfl987havnt saw anyone , but heard of any other list dialect driven wm
04:19mpenetthere is stumpwm
04:19mpenetbut its common lisp
04:19mpenetyou can script gnome with js I think now, but its not a wm
04:20p_lclj_newb_234: wmii can be scripted through anything that can use file i/o
04:21Sgeo__Liskell/Lisk with xmonad?
04:21Licenserand I thought wms = weapons of mass sausage
04:22p_lLicenser: ... sausagefests?
04:22Licenseryap
04:22Licenserp_l are you stalking me?
04:22p_lLicenser: nope
04:22p_lbut I'
04:22LicenserI start to get the feeling whenever I say something somewhere you pop up :P
04:22p_l*I'm trying to rewrite tests from HP QTP into Selenium
04:23p_land I went with Clojure for driving Selenium
04:23LicenserHP QTP?
04:24algernon/20/16
04:25p_lQuickTest Professional
04:26jyfl987maybe you could worte by yourself
04:26tagrudevlein : The plugin task has been removed.
04:27tagrudevhow do I install plugins via lein now :( ?
04:28ucbtagrudev: lein2?
04:28tagrudevyup
04:28ucbtagrudev: https://github.com/technomancy/leiningen/wiki/Upgrading
04:28the-kennytagrudev: Add them to ~/.lein/profiles.clj
04:28ucbfirst hit on google for "leiningen 2 plugins" ;)
04:28ucb(at least for me)
04:29tagrudevthe-kenny, yeah I've added them to profiles but how do I install them :) ?
04:30the-kennyYou don't need to. The profiles.clj will be merged with the local project.clj of your project and lein will fetch the plugins
04:31the-kenny{:user {:plugins [[foo/bar "0.1-SNAPSHOT"]]}}
04:31tagrudevseem legit
04:31tagrudevlet me try it
04:31the-kennyIf the project depends on the plugin, add it to the project.clj itself
04:33tagrudevif it is not a project and just a file, I am starting with clojure now
04:36tagrudevi am trying to jack-in in emacs but it is searching for a project.
04:36tagrudevclj
04:38the-kennytagrudev: Using nrepl?
04:38the-kennyOr slime?
04:42the-kennynrepl is much easier to setup/use, especially when using leiningen 2 :)
04:42the-kennynrepl is the future!
04:42tagrudevneither I guess
04:42tagrudevtrying to get emacs + slime + swank working
04:43the-kennyOkay, you should really try nrepl :)
04:43the-kennyswank-clojure is more or less deprecated. Many people switch to nrepl nowadays, as it's easier to setup and written from the ground up for Clojure
04:43the-kennyDo you use a recent emacs? (23+)
04:43tagrudev24
04:44the-kennyM-x package-install nrepl RET
04:44tagrudevdone
04:44p_lthe-kenny: most importantly, nrepl isn't for unknowable reasons bound to ancient releases :)
04:44the-kennyThis will install nrepl and clojure-mode. Then you can M-x nrepl-jack-in wherever you want
04:45the-kennytagrudev: OR you can run "lein repl" anywhere and in Emacs run M-x nrepl RET localhost RET <port> RET
04:45the-kennyThe latter will connect to the repl running at <port>, the forer will run lein-repl as a subprocess and connect to it
04:46the-kennyleiningen 2's repl has an integrated nrepl server
04:46tagrudevthat's cool but my idea is is there a way to run it
04:46tagrudevwith the current context
04:46the-kennyWhich context?
04:46maleghastMorning:-)
04:46tagrudevthe-kenny, lets say i have dir/file.clj and it is loaded in buffer in emacs
04:47zoldarby the way, anybody successfully using ritz-nrepl along with current stable nrepl.el? last time I've tried it, on every attempt of evaluating/compiling a form it failed for me
04:47tagrudevthere are some functions in it and I want to run repl with this file loaded so I can test it
04:47the-kennytagrudev: Ah, ok. Just run nrepl anywhere or use nrepl-jack-in. Then do C-c C-l to load the file
04:47the-kennyC-c C-k might work too
04:48tagrudevty that is what I was looking for
04:48tagrudev:)
06:22AnderkentAnyone know where deftype* comes from? I see it used by the defrecord macro, but can't find it anywhere. Is it a special form?
06:28FoxboronAny people using/used TextMate here?
06:31maleghastFoxboron: I use Textmate for lots of things, and have done for Clojure… What can I help you with?
06:31Foxboronmaleghast, does (+ 1N 2N) turn out as valid syntax with TextMate?
06:32FoxboronSublime uses the same Syntax files, and it is considered invalid code. But its totally valid :P
06:34maleghastFoxboron: Yeah it's fine in Textmate
06:36FoxboronYeah, then i'll find TextMates syntax files :) Thanks maleghast
06:36Anderkent(okay it does seem it's a special form, but it's not in the special form list)
06:37maleghastFoxboron: NP :-)
06:37maleghastAnderkent: Is this what you are looking for…? -> http://clojuredocs.org/clojure_core/clojure.core/deftype
06:38Anderkentmaleghast: if you look at the source of that, it expands into `(deftype*
06:38Anderkentand the deftype* is not defined anywhere, so I had to look at the compiler sources to make sure it's a special form
06:39maleghastAnderkent: Ah I see - sorry I did not see the "*" in your original Q.
07:02clgv Anderkent: it is a special form
07:03clgvAnderkent: see here: ##(keys (clojure.lang.Compiler/specials))
07:03lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Compiler is bad!
07:03clgv,(keys (clojure.lang.Compiler/specials))
07:03clojurebot(deftype* new quote & var ...)
07:09Anderkentyeah, i was looking at http://clojure.org/special_forms but it's apparently not complete :)
07:11clgvAnderkent: ah that one documents only specialforms you are supposed to use
07:11clgvAnderkent: you should not use deftype* yourself
07:11AnderkentI'm not, but I'm writing a code walker and need to be aware of what cannot be evaluated
07:11Anderkentanyway, thanks for the Compiler/specials
07:11Anderkentthat will help
07:12clgv&(apropos "special")
07:12lazybot⇒ (special-symbol?)
07:12clgv&(special-symbol? 'deftype*)
07:12lazybot⇒ true
07:12Anderkentcheers
07:13FoxboronWeee, patched the 1N problem in Sublime.
07:13maleghastFoxboron: Nice job! :-)
07:13maleghast(paste please)
07:13Foxboronfind constant.numeric.integer.clojure
07:13Foxboroncorrect regex: (-|\+)?\b[0-9](|N)+\b
07:14Foxboron(Only added (|N) there)
07:14maleghast*nods* nice
07:14FoxboronLimited exp with regex, so was a funny task ^^
07:15FoxboronAlso, was condering making a few Clojure plugins for Sublime. If anyone got any suggestions or what not, please tell me and i'll see what i can do.
07:15FoxboronWas considering a little CLojureDoc search for a start.
07:15maleghastFoxboron: That sounds like it would be very useful.
07:16FoxboronYeah i know. havent decided if its better to add the search result to a view, or just open the browser.
08:27abpRaynes, https://www.destroyallsoftware.com/talks/wat ?
08:57the-kennyWat?
08:59@rhickeyI'm still not loving the names of the new thread macros, considering:
08:59@rhickeylet-> ==> as->
08:59@rhickeytest-> ==> pred->
09:00@rhickeymaybe - when-> ==> is->
09:00@rhickeythe latter then being a nil test
09:00maleghastrhickey: Is this for 1.5..?
09:01@rhickeyyes
09:01@rhickeywould like to get this sorted before release
09:01foodoorhickey: is there a google groups discussion about these? (couldn't find one)
09:01maleghastand your preference is for the versions on the right..? (I'm guessing because they seem more semantically appropriate?)
09:01foodoowhat are they supposed to do?
09:02@rhickeythe ones on the left are already in the beta
09:02maleghastrhickey: I thought so
09:02@rhickeysome people are confused about let->, I don't like test-> conflicting with ideas about testing
09:03maleghastrhickey: fwiw I like the options you set out ^^ better than the current ones
09:03@rhickeywhen-> is ok, and matches when, but nil test more general than truthy
09:03@rhickeybut 'is' is a new notion
09:03ChousukeI'm reading those names as "thread-as" and "thread-pred" and "thread-is". the last one doesn't quite make sense to me.
09:03@rhickeyI have other ideas for it, not for now
09:04maleghastCertainly as-> and pred-> are better (imho) than let-> and test->
09:04clgvrhickey: I like "as->" and "pred->" - improved naming. :) I dont know about "is->"
09:06@rhickeynnil-> another option for when-> or is->
09:06mpenetpred-> does sound better than test->
09:06maleghastrhickey: would you be completely opposed to being totally explicit =: notnil->
09:07@rhickeywould have to be not-nil->
09:07algernonperhaps truish-> ?
09:07@rhickeynot truish, when-> is better for that
09:07maleghastrhickey: I would imagine so
09:07@rhickeynew name to get to not nil semantic
09:08alexnixonrhickey: I was thinking about let-> ( http://dev.clojure.org/jira/browse/CLJ-1110 ) in particular it feels like it should support destructuring
09:08alexnixonrhickey: though if it were renamed that would make less sense
09:08Chousukennil-> is probably not going to be a good idea. it will look like a typo
09:09maleghastChousuke: Hence my suggestion to be more explicit and we got to not-nil->
09:11jballanc_maybe exists->
09:12@rhickeyalexnixon: let-> does destructure, but that's less useful than you might think as it gets repeated and often the threaded result won't destructure similarly
09:14alexnixonalexnixon: I don't think it does - the body of the expr in the 'let' after macro expansion is ~name (which doesn't work if name is {:keys [x y z]})
09:14Chousukefor the not-nil cases you might just use the ? convention and go for -?>
09:14alexnixonrhickey: I don't think it does - the body of the expr in the 'let' after macro expansion is ~name (which doesn't work if name is {:keys [x y z]})
09:15@rhickeyalexnixon: showing firther how that can't be made to work
09:15@rhickeyfurther
09:16HodappHere's a silly question I couldn't figure out last night: Is there a way I can evaluate something as if in the context of some namespace, without using :use for the entirety of the file?
09:16Hodappsay, just one function.
09:16@rhickeyI'm not going to discuss destructuring more, it's too complex for threading, can't cascade
09:17ChousukeHodapp: you can use require and import just that one function
09:18ChousukeHodapp: you can also temporarily change namespaces by calling in-ns but that's kind of ugly.
09:18HodappChousuke: I meant more that I want to define (for instance) just a single function, but in order to reduce some syntactic sugar I'd like to avoid either :use-ing that namespace or prepending it to everything inside it
09:19hugodrhickey: when-> is a little like a maybe monad, so maybe->?
09:20Hodappoh well, in the meantime I can just alias quil.core to 'qc', that's not too ugly I suppose
09:21@rhickeyhugod: we don't have maybe
09:22alexnixonrhickey: fair enough, I'll leave it there. FYI though I've found it useful when making incremental updates to state-like maps (let-> {:foo 1 :bar 2} {:keys [foo bar] :as state} (assoc state :foo (inc bar)) (assoc state :bar (* foo 2))) ==> {:foo 3 :bar 6}
09:23HodappThis might be one of the few languages I use where the language's creator frequents the IRC channel :)
09:23@rhickeyone problem people had with pred-> was thinking that the tests would be predicates called on the threaded val
09:24@rhickeyhugod: without a culture built around a Maybe type, raises the question as to maybe based on what?
09:25maleghastrhickey: I can see how that would be (almost) as confusing as test-> now that you mention it… The naming of "things" is a difficult pursuit when you get down to it, no?
09:28hugodrhickey: when-> and test-> could also take an optional binding (when-> expr [a] ....), and if let-> used (let-> [a] ...), then the three forms would vary only in the logic applied to the clauses. If the binding in let-> were optional, then it becomes just an augmented variant of ->.
09:30@rhickeyhugod: how does binding cascade?
09:30@rhickeyas-> gives the threaded argument that name in every expression
09:31@rhickeyyour now going to bind over and over, so it becomes a one-shot
09:31@rhickeynow very threaded
09:31@rhickeynot
09:31@rhickeyyou're
09:32lpetitrhickey: beware, or Raynes will not talk to you anymore :-p
09:32squidzwill the stack traces in clojure ever improve? I just started programming with clojure and so far have made a simple blog, and a XML manipulation script, and in the beginning I thought there are two negatives about clojure. The first being the parenthesis, the second being the stack traces. Now the parenthesis don't bother me at all though. Will I also get used to the stack traces? Or are they kind of difficult for everybody?
09:32@rhickeysquidz: write a patch
09:33squidzhm never done anything crazy like that before
09:33maleghastsquidz: To be honest I used to find them very intimidating and now I don't - time and exposure do seem to help
09:33@rhickeylpetit: for correcting myself? :)
09:33Chousukemaleghast: also, pretty-printers
09:33foodoomaleghast: agree. It's a matter of practise
09:33lpetitrhickey: Don't know if you've been following on clojure-dev, but I'm working on adding more dynamicity to the 'ns macro
09:34lpetite.g. have (ns a) (ns b (:require a)) work on a repl
09:34lpetitthere were interesting questions along the way, involving how clojure.core is loaded differently when it's from raw source code, or from AOT code. Detailed email coming soon
09:34squidzalso, Ive heard that there is a new Invokedynamic bytecode for the JVM. Could this benefit clojure?
09:36lpetitsquidz: stack traces mostly keep being intimidating, we'll have to work on this, for sure
09:37squidzlpetit: have you heard about invokedynamic in the JVM?
09:37HolyJaksquidz: http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/
09:37squidzthanks HolyJak
09:41pyrrhickey: hugod: any chance of since something resembling thread-expr's for-> and for->> ?
09:44TimMcrhickey: Destructuring in let-> is not meaningful at all, since the binding form is also the tail-position form.
09:44TimMc(let [& 0] (let-> [1 2 3] [f & r] [r & f])) ;; => [(2 3) 0 (0 1)]
09:45TimMcMaybe it should expand to let* instead of let.
09:45lpetitall, I've got a patch for the dynamic ns issue I raised on the ml: https://github.com/laurentpetit/clojure/commit/0fe0c5238c00ef871ff6523d4b50d07a1bd86aa8
09:46lpetitIf anybody can test against his own project / codebase, etc. ?
09:47lpetitrhickey: no, he tweeted earlier in the week about not wanting to talk anymore to people using your you're incorrectly :-)
09:47lpetitrhickey: don't know if you've time for it, but there's a patch ^^ for solving the dynamic ns problem
09:48lpetit3-liner
09:50maleghastrhickey: Totally off topic and trivial, but please can you bring stickers to Clojure exchange next week..?
09:51@rhickeylpetit: link?
09:51lpetithttps://github.com/laurentpetit/clojure/commit/0fe0c5238c00ef871ff6523d4b50d07a1bd86aa8
09:51lpetitrhickey: ^^
09:52@rhickeylpetit: I'm quite concerned about touching ns for this release given the ridiculous complexity and fragility in the ns/require system
09:52lpetitrhickey: I understand. We've put 2 hours of pair-programming with Christophe to be sure that we've got the most ridiculous and innocuous addition to it
09:53@rhickey:)
09:53lpetitrhickey: meaning, we've had the temptation to rewrite the whole thing several times, but got away from it :)
09:55lpetitrhickey: in a nutshell (between a tl;dr and the full explanation): (require 'foo) adds foo to *loaded-libs*, but (ns foo) does not. Meaning that if you first write (ns foo) then (ns bar (:require foo)), then it's only the first (:require foo) that will prevent it from being reloaded again and again from the disk.
09:57hugodrhickey: https://gist.github.com/4169539 was what I had in mind
10:00hcumberdaleHi ;)
10:02maleghasthcumberdale: Hello
10:03hcumberdaleI've uploaded files to a server into a directory 'x'
10:03maleghastok
10:03hcumberdaleNow I build a reference to the files by extension fs/list x
10:03maleghastI see
10:03hcumberdaleHow to send an order of the elements from the frontend for further processing?
10:04hcumberdaleSimply send the file names in an ordered list again?
10:04maleghaster...
10:05hcumberdaleReordering of the processing is possible without changing them
10:05@rhickey@hugod I find that baffling, and with the docstring unchanged, don't know how to use it
10:05@rhickeyhugod: ^^
10:06hcumberdalewow rhickey here, awesome
10:06@rhickeyhugod: sticking to as-> what is the intent?
10:09@rhickeylpetit: is there no ticket w/patch? I can't move on that without it
10:10hcumberdalerhickey: what are the plans for clojure 1.5 ?
10:10lpetitrhickey: oh, I wanted to wait for some kind of approval first, 'cause I don't like when bug trackers are filled with things that may not go anywhere
10:10lpetitrhickey: I'll create it right now, following the procedure
10:10mdeboardhcumberdale: It's almost like he's a real person
10:11hcumberdalemdeboard ;)
10:14@rhickeyhcumberdale: what do you mean?
10:15@rhickeycgrand: yes. please help
10:16@rhickeyas-> pred-> instead of let-> test->
10:17@rhickeywhen-> could stay as-is or get nil-based version name TBD
10:17borkdudewow, even loading packages is lazy in haskell?
10:19cgrandI like Chousuke suggestions of using the ? convention so -?> or ?->
10:19@rhickeyhugod: now as-> is gone from your gist - I'd like to focus on as-> to understand your destructuring proposal
10:20@rhickeycgrand: ? means truthiness elsewhere
10:20hugodrhickey: I see now I was confused about let->, since it doesn't actually thread anything.
10:21cgrandrhickey: true it's importing a conflicting convetion
10:21maleghasthcumberdale: sorry, I had to step away for a few minutes there… I _was_ trying to be helpful… Where did we get to?
10:21@rhickeyhugod: you mean in its implementation?
10:22cgrandtest-> has a cond feeling but cond-> would lead people to think only one expr is threaded
10:22hugodrhickey: it's just a repeated let, nothing is threaded into the forms
10:22@rhickeycgrand: right, cond-> is my favorite
10:23@rhickeyhugod: depends on what you consider threading, it does not become the first arg
10:23hugodcgrand: cond for me implies the threaded value would take part in the test predicates
10:23@rhickeyhugod: I don't see that unless condp->, but most people expected short-circuit
10:26lpetitrhickey: http://dev.clojure.org/jira/browse/CLJ-1116
10:26@rhickeythere are many places where one needs only non-nil conditionals. Imagine nnil->, if-nnil, when-nnil
10:27@rhickeylpetit: ok, how about some tests with that please?
10:28hugodrhickey: I added examples to the gist too. I find the usage confusing in the end. Apologies for the noise.
10:32@rhickeyhugod: the problem with that is that the most important use of as-> is to thread into expressions where you don't want to be forced into first arg
10:32@rhickeyand more generally, of binding as well
10:32@rhickeyyour stuff threads and binds
10:32lpetitrhickey: grmlml, ok :)
10:34lpetitrhickey: do you want a separate patch, so that you can try it against current version of clojure (demonstrating the problem), and then against patched version of clojure ?
10:34@rhickeylpetit: no, I tried it already with current Clojure
10:35lpetitrhickey: ok, so I'll add the tests to the patch and ping there when it's done
10:43TimMcrhickey: I strongly support as->, since (as-> 5 a ...) is way less confusing than (let-> 5 a ...).
10:44TimMc"With 5 starting as 'a, ..." vs. "Let 'a be 5, no wait, let 5... 'a..."
10:44TimMcI keep messing up the order of the first two forms in let->.
10:46TimMcIt's as bad as nth.
10:46alexnixonTimMc: the intended usage (also unclear, I'd argue) is within an existing threading macro
10:47alexnixonTimMc: (-> (+ 1 2) (as-> three (+ 1 three))) => 4
10:47TimMcYeah, I understand the rationale -- but the name should match the order.
10:48TimMc(And I understand that nth, as a seq fn, takes the seq as the final arg.)
10:48hugodwould ->as be a better name, in that it is used within a thread, but doesn't start one?
10:49TimMcI don't see why it *can't* be used on its own.
10:50hugodTimMc: indeed - would a non-threaded version have a body (like let), or just return the bound value?
10:50TimMcNon-threaded version?
10:53TimMcAll I'm saying is that as-> would be nice where -> and ->> are not quite enough.
10:53hugodI thought you meant something like https://gist.github.com/4169930
10:57TimMchugod: How does that differ from as-> (well, let->)?
10:59hugodTimMc: it doesn't have the first expression argument, so the argument order is more what you would expect when using outside of a threaded expression
11:02TimMcOh I see -- I missed that you'd reversed the param.
11:02TimMc*params
11:03TimMcRaynes: Is there a Mongo-related reason why refheap doesn't accept pastes over 64kB?
11:05TimMc(or other technical reasons besides disk space)
11:09@rhickeyhugod: I don't like ->blah for thread stuff, and still, that depends on your notion of threading. This is named threading
11:10@rhickeyas-> seems uncontroversially better than let->. What avour pred-> and nnil-> ?
11:10TimMc->foo also conflicts (visually and possibly code-wise) with record constructors
11:10@rhickeyTimMc: right
11:11TimMcNo one *should* create a record called that, but it's still a problem.
11:14jballancrhickey: could you use cond-> instead of pred-> ?
11:14jballancpred-> reminds me of lisp-ish cond's
11:15@rhickeyjballanc: people presume cond-> will short circuit on first match
11:15jballancah, true
11:15jballancnaming *is* hard
11:15@rhickeythis threads into every expr for which corresponding test is true
11:17mdeboarddowhile :)
11:18jballancsolongas->
11:18jballanckeepgoing->
11:18jballancyeah...I'm out of ideas
11:18clgv+1 for "pred->"
11:19@rhickeyit's not while, nor so long as
11:19mdeboardI see.
11:19jballancit returns at the last pred that evaluated true, right?
11:19@rhickeyeach clause is gated, but it proceeds
11:20@rhickeygate-> was an earlier proposal
11:20jballancoh, ok...I see
11:20jballanchmm...makes me think test-> is almost best
11:20@rhickeythere's just so much test-this and test-that around testing
11:20@rhickeythe word is dead
11:21jballancassert-> ?
11:21jballancbut that's probably as dead as test
11:22TimMcTHe problem here is that we don't have a pattern in Clojure branching on nil alone.
11:22TimMc*for branching
11:22TimMcWe've got nil-punning and that's it.
11:22TimMcit's more like while-has-value->
11:23@rhickeyTimMc: this one (pred->) has nothing to do with nil, do you mean nnil-> ?
11:24TimMcSorry, yes, I'm pondering when->
11:24TimMcoff in my own little world
11:26TimMcvalue->
11:26@rhickeyis->
11:27FoxboronMixing up some ClojureDocs search plugin for Sublime Text 2. Anyone got any whis on functionality :D?
11:27Foxboronwish*
11:27@rhickeysome-> (also currently truthy)
11:28@rhickeyand predicate based
11:28TimMcis-> sounds like a test
11:28TimMcAs for test->... how about guard->?
11:28@rhickeyTimMc: only if your notion of is has been broken by that test framework
11:28@rhickey:)
11:28TimMchaha
11:29TimMc*That's* where I got that.
11:30mdeboardIs test-> currently (test-> pred & args)?
11:30mdeboardCan't really find any docs for 1.5 that cover new stuff.
11:31@rhickeymdeboard: no, (test-> expr test1 thread1 test2 thread2 ...)
11:31mdeboardAh i see.
11:31mdeboardJust found changes-draft-v7.md
11:31@rhickeywhere test1 is an expression, if true, threads through thread1, else skips
11:33@rhickeyTimMc: guards in other langs short circuit like cond
11:34TimMcIs there semantic pollution on the name "guard"?
11:34TimMcs/pollution/baggage/
11:34TimMcguard-each-> would be more explicit
11:35@rhickeynot for Clojure, but as I said, guards are like cond
11:35jballancwhen you put it like that, it seems more like select->
11:35jballancor even filter->
11:35mdeboardif-apply-> or when-apply->
11:36mdeboardjballanc: You're not really filtering or selecting though, you're performing operations selectively (I thought about those two as well)
11:36@rhickeygate->
11:40xumingmingv,(let [String 1] (println String))
11:40clojurebot1
11:41mdeboardrhickey: I'm a newb but I think a noun as a threading macro name is a bad idea.
11:41xumingmingvWhy the above the above output is 1? according to the http://clojure.org/evaluation
11:43xumingmingvaccording to http://clojure.org/evaluation, it should output "String" right?
11:43mdeboardxumingmingv: Because it finds a binding to that var locally so it uses it without checking for other bindings
11:44gfredericksmdeboard: xumingmingv: not a var, just a local
11:45xumingmingvmdeboard: but according to http://clojure.org/evaluation, it should check whether String is a class first, then check whether it is a local binding or not
11:45mdeboardYeah, sorry, I just meant variable.
11:45llasrammdeboard: I think what xumingmingv is saying is that the documentation says that class name lookup happens *before* local binding lookup
11:45xumingmingvllasram: YES
11:46lpetitrhickey: tests added: http://dev.clojure.org/jira/secure/attachment/11725/dynamic-ns-patch2.diff
11:48mdeboardxumingmingv: Yeah, no clue. It doesn't seem like it works like that
11:49llasramxumingmingv: The documented order seems odd to me though -- the observed behavior seems less surprising. You'd need to dig into the implementation to figure out if something has changed or if the documentation is just wrong
11:50xumingmingvmdeboard: llasram, yeah seems the documentation does not match the REAL implementation
11:52xumingmingvrhickey: hi hickey, any hint? does the documentation indeed doesnt match the implementation?
12:26antoineBhello, is there a clojurescript developper here?
12:27dnolen_antoineB: yes :)
12:28dnolen_bbloom: ping, what was your points about errors yesterday?
12:28antoineB(= js/NaN js/NaN) give false
12:29antoineBin js: NaN == NaN also give false
12:29antoineBshould clojurescript "=" fix it?
12:30antoineBas same as (number? js/NaN) => true
12:30S11001001,(= Double/NaN Double/NaN)
12:30clojurebotfalse
12:30S11001001antoineB: guess not
12:30ttimvisherhas there been any progress towards enabling debugger support along the lines of `require 'ruby-debug'; debugger; 1` in ruby or `(swank.core/break)` that actually allows you to access a repl in the frame?
12:31ttimvishercdt seems to work too much with state, and I can barely get it to work anyway. I want to be able to set a breakpoint in my code and then get a repl
12:31llasramttimvisher: ritz? https://github.com/pallet/ritz
12:31technomancyttimvisher: I worked on getting swank.core/break working in nrepl: https://github.com/technomancy/limit-break
12:32antoineBS11001001: why such behavior?
12:32technomancyI haven't tried it on recent versions but it might work
12:32technomancyerr--debug-repl specifically, not the swank version exactly
12:32ttimvishertechnomancy: hah! love the name
12:33S11001001antoineB: because functions following behavior laws like transitivity and reflexivity is for ivory tower academic types, not those working down in the trenches on real world applications
12:34S11001001antoineB: see also: http://dev.clojure.org/jira/browse/CLJ-893?focusedCommentId=27605&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27605
12:34seangroveS11001001: That's a bit of an obtuse answer ;)
12:35antoineBS11001001: why Double/NaN and Double/NaN differ?
12:35S11001001seangrove: guess I'm more annoyed about the resolution of clj-893 than I thought I was.
12:35ttimvisherthanks for the pointer
12:35S11001001antoineB: the same justification as in clj-893 can be applied to your scenario: it's faster this way, just document that it doesn't work with nan
12:36llasramIt's an an aspect of IEEE floating point. NaN != NaN in any compliant language
12:37S11001001llasram: that's irrelevant if your contract for = includes reflexivity
12:37technomancyyou could argue that floats are a lost cause; if you're using them you need to understand you're prioritizing speed over correctness
12:38FoxboronSo, i am making some plugin to search the clojuredocs.org. I notice that, when you search. The Search result displays wrong number of examples.
12:38FoxboronAnybody know if this is a known bug or?
12:39llasramS11001001: Fair enough, but adds some flavor to your to your argument :-)
12:40dnolen_antoineB: I don't see what there is to fix. If you want to check for NaN, use js/isNaN
12:41technomancyI guess that's not a helpful distinction if your runtime offers nothing but floats
12:41technomancysomething to keep in mind when picking a runtime I guess
12:41antoineBi use NaN from string to int conversin
12:41antoineB*conversion
12:42technomancyantoineB: there are no ints in JS
12:43antoineBgood points
12:44antoineBso i convert string in an integer form to floats :)
12:45antoineBdnolen_: just notice also that i can use map/filter/etc... with (.children dom-element) if i don't extend HTMLCollection
12:46antoineBdnolen_: do you plan to do it?
12:46dnolen_antoineB: I'm not sure what you mean. plan to do what?
12:48antoineBdnolen_: am i the only who wants to do map/filter on dom tree?
12:49dnolen_antoineB: no need for us to add it. extend HTMLCollection to ISeq or ISeqable
12:50antoineBi do it, but i take me some type to figure it out
12:50antoineB*he take
12:50antoineB*it takes
12:55dnolen_antoineB: yes more examples on how to do this would be nice, DOM array-like collections are easily made into seqs via `prim-seq`
12:56dnolen_(extend-type HTMLCollection ISeqable (-seq [this] (prim-seq this))
12:58antoineBdnolen_: i use the same as (extend-type array ...)
12:58antoineBso i use array-seq
12:58dnolen_antoineB: sure, but array-seq just calls prim-seq :)
12:58antoineBi just noticed it :)
12:59antoineBwhat "prim" stands for?
13:02dnolen_antoineB: primitive
13:12DaReaper5Anyone here know korma
13:19DaReaper5Anyone here know korma
13:20mdeboardDaReaper5: Always better to just ask your question
13:22DaReaper5how do i do a "with" when a relationship is not defined
13:22DaReaper5i can do a join but it does not grab all the fields like a "with" would
13:22DaReaper5... and i am having trouble with subselect
13:40Sonderbladewhat's the way to sum a list of sum a list of ints in clojure?
13:40antoineB(sum (flatten nested-list)) ??
13:40lazybotantoineB: What are you, crazy? Of course not!
13:40technomancySonderblade: reduce + apply concat
13:41technomancyinsert parentheses as appropriate
13:41nDuffSonderblade: was the "sum a list of" being repeated intended?
13:41technomancycomp partial reduce + partial apply concat
13:42Sonderbladeyes but reduce + isn't very good for a huge list
13:42Sonderbladeor for summing floats due to rounding errors
13:42technomancySonderblade: ...?
13:43technomancythere's no way to work with floats without rounding errors
13:43technomancyyou can use apply + instead of reduce, but it works out to the same thing
13:44Sonderbladewell the naive way of using reduce + produces bigger rounding errors than a smarter algorithm does
13:46dnolen_Sonderblade: not sure why you think reduce is bad for large lists. And rounding errors don't apply to your original question - ints. reduce is the way to go unless you need something more specific.
13:47dnolen_Sonderblade: and you can probably get a pretty decent performance boost by using the same code shape but switching to reducers for the case of list of list of ints.
13:50Sonderbladednolen_: what if i have a list of floats then?
13:50dnolen_Sonderblade: it sounds like you want to do something different in that case. So implement whatever you think is best.
13:54tanzoniteblackSonderblade: if you're really worried about round errors for some reason, and don't care about performance or memory, you can use reduce +'
13:55Sonderbladetanzoniteblack: i care about performance too
13:56technomancyperformance, speed, convenience: pick any two
13:56gfredericksI can't imagine that + vs +' has anything to do with rounding
13:56technomancyerr--s/performance/correctness/
13:57Hodapptechnomancy: I usually see it as "fast, cheap, good"
13:57technomancyyep =)
13:57gfredericksor as devops_borat recently said
13:57Sonderbladee.g. this (println (reduce + (range 99999999))) is much slower than i thought
13:57gfredericks"enterprise, cloud, strategy"
13:57tanzoniteblackgfredericks: +' supports arbitrary precision, so if the number of bytes needed to correctly encode the number exceeds the current number type (int, float, double, etc.) it ups the number to a larger type (eventually to BigNum)
13:57Hodappor sometimes "fast, cheap, good, Windows - pick 2 (Windows counts as 2)"
13:57technomancyHodapp: I'll have to remember that one
13:57clgvSonderblade: it performs boxing and unboxing ;)
13:58gfrederickstanzoniteblack: I really doubt the difference applies to floats
13:58Sonderbladeclgv: now you understand why i asked for a sum function
13:58tanzoniteblackgfredericks: why wouldn't it?
13:59gfredericks,[(* 3e250 7e250) (*' 3e250 7e250)]
13:59clojurebot[Infinity Infinity]
13:59gfrederickstanzoniteblack: because there's no easy way to do what you want with floats
13:59kevin4567why doesn't "lein test" run the tests specified by with-test?
14:00gfrederickstanzoniteblack: what should (+' 1e300 1e-100) do?
14:00gfrederickstanzoniteblack: should it change to BigDecimal because of rounding issues?
14:01technomancykevin4567: that style is just very uncommon; lein test simply searches for namespaces in your test directory
14:01tanzoniteblackgfredericks: would there be a rounding error there?
14:01gfrederickstanzoniteblack: yep
14:01gfredericks,[(= 1e300 (+' 1e300 1e-100)) (= 1e300 (+ 1e300 1e-100))]
14:01clojurebot[true true]
14:02technomancykevin4567: running all src namespaces through run-tests would be unreasonable for most projects
14:02gfredericksapparently I didn't need such drastic exponents to demonstrate that
14:03kevin4567technomancy: thanks for the info
14:03technomancykevin4567: you can specify test namespaces on the command line. maybe being able to read them out of project.clj would be a good feature?
14:03gfredericks,(= 1e20 (+ 1e20 1))
14:03clojurebottrue
14:03kevin4567technomancy: how do you specify the namespaces on the command line?
14:04tanzoniteblackgfredericks: apparently that doesn't work as I thought then
14:04gfrederickstanzoniteblack: with integers the situation is much simpler; but the issue isn't rounding, it's overflow
14:04technomancykevin4567: you just ... specify them on the command line?
14:04technomancynot sure what you're asking
14:07kevin4567technomancy: I think adding the dir to my project's :test-paths seems like the best solution... thanks again
14:07technomancyoh yeah, if all your src/ namespaces are likely to have tests that's probably best
14:08kevin4567technomancy: that is the case for me, yeah
14:10dnolen_Sonderblade: you haven't been clear as to what kind of performance you are looking for. Do you want to work on large primitive Java arrays? for that you have areduce. your expression takes ~6000ms on my machine. using areduce takes <100ms
14:14m0smithhi all
14:15solussdis it possible to make protocol implementations namespace private?
14:15m0smithis there some trick to getting add-watch to work in clojurescript on an atom? It seems to work but is never called
14:17gfredericksm0smith: I've used it a good bit without issues
14:18m0smithjust calling swap! correct?
14:18gfredericksyep
14:19m0smithok, thanks
14:20gfredericksonce you're desperate enough you can try the JS debugger
14:20m0smithgfredericks: I was trying but it locked up firefox on the a deref of the atom
14:29seangrovem0smith: I'm using shoreleave's pubsub which is built on atoms and add-watch I believe, working well
14:30m0smithseangrove: ok, thanks it must be something I am doing wrong
14:30dnolen_m0smith: sounds like you might be accidentally doing some kind of recursive deref?
14:32m0smithdnolen_: maybe but the code works in that the atom is updated as expected, just the watchers don't get called
14:32m0smithin clojure is works as expected, just clojurescript is not working
15:02degHi all... So, I decided today to abandon my misguided ways and switch to Emacs, rather Eclipse. (Only using Eclipse because I couldn't get nrepl to work when I first started with clojure a few weeks ago). Anyway, all attempts now are still failing, but I'm now familiar enough with the clojure env that I figure I need just a bit of help to get things working...
15:02eggheaddeg: with emacs did you try using technomancy's emacs-starter-kit ?
15:03degAnyway, first attempt was in Windows 7, and I ran into problems with both clojure-jack-in and nrepl-jack-in, that they could not start the server. (no error, just hang)
15:03degSo, I figured I'd try in a Ubuntu VM. Things came much closer this time.... Nrepl works, but I seem to be having a problem with the classpath.
15:03eggheadooo, windows... don't think I'll be much help there, though it might be a environment variables issue :/
15:04deglein run works fine from the command line. But, I try a c-c c-k from an emacs buffer, and it fails to find the *__init.class of the first namespace in my ns
15:05deg(for now, let's ignore the windows problems. If I get this working in Ubuntu, I'm happy for today).
15:05technomancydeg: did you do jack-in from a buffer inside the project?
15:05degNo.
15:05degLet me try that.
15:05technomancyok, so in that case it will start a stand-alone repl that only has access to leiningen itself
15:06degSound like that's my problem. Let me just test. gonna be a moment or two. Thanks!
15:07spiral68if you have installed nrepl in emacs, you could connect to a running "lein repl" and type M-x nrepl...
15:07bbloomdnolen: i updated that ticket last night about the errors
15:07dnolenbbloom: yeah I checked it out earlier & left a comment as well.
15:08bbloomdnolen: did you take a peek at the second patch?
15:09degMuch closer now, but I don't seem to be in the right namespace.
15:10dnolenbbloom: I did, but I agree that it doesn't make sense. It's not communicating the correct environment.
15:11degegghead: yeah, it works if I type the namespace explicitly, but I can't yet see how to put the repl into my namespace.
15:11bbloomdnolen: yeah, that's what i realized. but what i think we could do is to make a new exception class like CompilerError or something and then add a catch block for it and allow that one to pass through… that would be the right environment then, right?
15:12technomancydeg: C-c C-n should do it
15:12technomancyC-c M-n rather
15:12dnolenbbloom: like I said in my comment - I don't see how that would be any different from the first patch, everywhere an error might occur you must pass along the environment in the exception. so it ends up looking like your first patch.
15:12degAha. https://github.com/kingtim/nrepl.el says C-c M-n but that seems to have no effect.
15:13bbloomdnolen: well every form goes through a call to parse, which does have the correct environment
15:14degHmm, and C-c C-n seems to do something -- shows a nil result. But, I'm still not in the right namespace.
15:14degI'm going to restart emacs. Maybe traces of the old repl are still running and getting in the way.
15:15dnolenbbloom: ok, so I guess we'd still have to change from assert to something that throws this new exception. Did you actually try to see if this works?
15:15bbloomdnolen: no, you don't need that change, you just only wrap it once. i started to do the change but realized it needed a custom exception type and i don't know anyhing about gen-class :-P
15:18bbloomdnolen: the issue with that approach is gen-class needs AOT compilation and stuff, right?
15:18dnolenbbloom: hmm do we need to do that - we have ex-info
15:18dnolenbbloom: in Clojure 1.4 I think for this exact purpose.
15:18bbloomdnolen: I don't know about ex-info
15:19dnolenbbloom: look for ex-info (and ex-data) http://github.com/clojure/clojure/blob/master/changes.md
15:19bbloomdnolen: ah ok, that'll probably do the trick
15:19bbloomi'll give it a try
15:19dnolenbbloom: cool
15:20degtechnomancy: Whoops, missed your comment above... but found the same answer. The M-x command works for me and is, indeed, bound to C-c M-n. But, looks like that keystroke is not going through Windows+VMWare+Ubuntu to Emacs. So, not a problem with clojure; something else in my env eating chars, I guess.
15:21technomancydeg: you can use ESC n if something is interfering with alt as meta
15:22brainproxydeg: if you're just getting started w/ emacs, I can recommend bbatsov's emacs "prelude":
15:22brainproxyhttps://github.com/bbatsov/prelude
15:22brainproxygives you a nice base setup
15:22degtechnomancy: Right. Forgot about that... too many years of emacs working right sinc ethe last time I had to use ESC.
15:22degActually, I'm and old time Emacs user, going way back to Teco in 1978 or so.
15:23technomancywhoa nice
15:23brainproxydeg: ah, i see
15:23degBut, for the past many years, my "emacs" was the DOS/Windows Epsilon clone.
15:23technomancyI'd recommend reading through things like the prelude or starter kit for stuff to steal but not using them outright
15:23Raynestechnomancy: Is someone else working on fixing partial selectors so they don't go into unnecessary namespaces? I can't follow that thread very well.
15:23technomancyRaynes: selectors in general, not partial selectors as such
15:23degSo, I'm not real up-to-speed on where Gnu emacs is different from Epsilon, ZMacs, or (gasp) Twenex Emacs.
15:24Raynestechnomancy: Partial selectors, selectors, whatevs.
15:24degAnyway, thanks for the help. I think I'm good now, until the next question.
15:24technomancyRaynes: 1.x does this, but I suspect only because it was added after 2.x branched
15:28brainproxytechnomancy: there's enough wiring in the prelude that cherry-picking isn't really possible if you're a noob (in this case, deg isn't exactly a noob), however...
15:28brainproxywhat's nice is you can stick whatever .el stuff you want in personal/
15:29brainproxyand it just works
15:29technomancythat's a shame
15:29technomancyI specifically rewrote the starter kit to move most of the functionality out into independent packages for composability reasons
15:29brainproxywell for the most part anyway, so what a lot of people are doing is forking prelude, and then pushing their clones w/ their stuff in personal/
15:30technomancybut most of the people working on alternate starter-kits are moving in the opposite direction
15:30technomancymaybe 3 years in they will turn around and start to consider composability =)
15:30brainproxytechnomancy: I understand your reasoning, and it's probably the better approach all considered
15:30_zachIs there a reasonable way to extend a protocol to a java array type? (e.g. Byte[])
15:30brainproxyhowever, for getting started, it's hard to beat the prelude
15:31technomancyyou could say the same thing of rails
15:31p_lI love starter-kit-24, but for god's sake, I think I need to bleach out the clojure parts
15:31technomancyeasy to get started until you want to do something the authors didn't have in mind
15:31bbloomdnolen: yeah this works
15:31bbloomdnolen: new patch incoming
15:31dnolen_zach: (extend-type (class (make-array Byte/TYPE 0)) ...)
15:32brainproxytechnomancy: i get you; however, after spending almost a year w/ it, I've been able to do whatever I needed by just sticking some custom .el scripts in personal/
15:32p_ltechnomancy: does prelude also include the "brain dead opinionated decisions that cause horrible crap but are hidden from first time user" part of Rails?
15:32_zachdnolen: Awesome, thanks
15:32dnolenbbloom: sweet
15:32brainproxyp_l: probably the easiest thing is to just take a look :D
15:32bbloomdnolen: ticket updated
15:33p_lbrainproxy: nah, Emacs is too important part of the OS to risk ;P
15:33technomancyp_l: I mostly just know of it from people with questions in #emacs
15:33p_lnot when I needit everyday
15:33p_lthough I was quite pissed today when launching slime while having nrepl open bollocked both
15:33p_l(and no, I didn't do anything by myself to setup association between slime and clojure)
15:34brainproxyp_l: trying it out isn't too risky; just copy your ~/.emacs.d to somewhere else, then start fresh with an empty .emacs.d and clone bbatsov/prelude into it
15:34bbloomdnolen: similar approach could be taken in compiler.clj with emit -> emit-form
15:34bbloomdnolen: but most errors come from analysis at this point
15:34p_lbrainproxy: that's when laziness comes in ;)
15:35brainproxy:D
15:39dnolenbbloom: what's the motivation for parse -> parse-form? seems like unnecessarily breaking code for anyone that might be using the analyzer right?
15:39dnolenbbloom: seems better to add something like parse* which doesn't the exception wrapping and leave parse unchanged.
15:40dnolenwhich does
15:40bbloomdnolen: it's only a breaking change if people are using defmethod on parse
15:40bbloomdnolen: there still is a parse function
15:40dnolenbbloom: yes but why do we need a breaking change at all. just make a new entry point - none of those parse lines need to change right?
15:41bbloomdnolen: you need the breaking change because calling analyze pass through the try/catch
15:41bbloomdnolen: er calling parse
15:41bbloomparse is recursive
15:41bbloomthe alternative breaking change would be worse: every call to parse would need to be rewritten to parse*
15:41tgoossensIn a game. I represent a robot as a map. Also there is a board. i'm trying to convince myself that i don't need identity for having a robot on the board. But i'm not sure. Because how i'm going to "move robot X forward on that board" "is robot x on this board?"
15:42dnolenbbloom: there is only one call to parse tho right? line 902
15:42dnolenin analyzer.clj
15:42tgoossensAny advice in what direction i can look to help myself out here
15:43S11001001tgoossens: how many robots can be on the board
15:43bbloomdnolen: hmmm, i might have been thinking of analyze
15:43tgoossenssince they cannot share position with another robot. As much as there are cells on the board
15:43dnolenbbloom: yes different
15:43bbloomdnolen: there are many calls to analyze :-P
15:43dnolenbbloom: yep
15:43tgoossens(so finite)
15:43bbloomdnolen: k, let me look
15:45bbloomdnolen: hmm seems like i probably want the try/catch wrapper around analyze too
15:46tgoossenss11001001: i've been thinking about that it doesn't matter. "moving robot x forward" means "move the robot at position x,y that has certain properties, forward" but i think its getting tricky then
15:48S11001001tgoossens: you don't have to think about the rest
15:48S11001001tgoossens: of the properties
15:48S11001001(assoc robot :x new-x :y new-y)
15:49tgoossenswhy don't i have to think about the rest?
15:49iosicaanyone writing unittest for macro?
15:49S11001001look at that assoc call, tgoossens
15:49tgoossensyes
15:49S11001001does it mention anything about the other properties of robot?
15:49iosicahow do you compare with expected results when macros are using gensym ?
15:49tgoossensno. but what if suddenly i allow two robots to be at the same place
15:49dnolenbbloom: I don't see why we need it there. Why do you think we need it?
15:49tgoossensthen the system is broken
15:50S11001001tgoossens: the call I just wrote allows two robots to be in the same place
15:50bbloomdnolen: if an exception occurs outside of a special form, the line reported will be the enclosing special form
15:50cvkem_I get some weird errors in clojure when processing larger volumes of data: "java.lang.ClassFormatError: Unknown constant tag 34". I seems like my data is transformed to a classfile ???
15:50lazybotcvkem_: How could that be wrong?
15:51tgoossensmaybe i'm just not getting what you are trying to do :p
15:51tgoossensi know what assoc means
15:51tgoossensand i know what it does
15:51tgoossensbut i don't see how it solves my problem
15:51S11001001(assoc robot :x 8 :y 43) puts a robot at 8,43
15:52S11001001(assoc robot2 :x 8 :y 43) puts another robot there
15:52tgoossensso instead of keeping on the board on what position what pieces are
15:53tgoossensyou give a piece a coordinate
15:53S11001001sure
15:53tgoossensok
15:53tgoossensi was trying to make a "piece" independent of the "board"
15:53tgoossensbut then again
15:53tgoossensmaybe i'm forgetting that is doesn't matter here
15:54tgoossensbecause i can freely add en remove news key-vals to the map
15:54tgoossenswithout anyone caring
15:54S11001001indeed
15:54tgoossenshmmm yes
15:54tgoossensand
15:54tgoossensif there are two boards
15:54tgoossensand they both expect a piece which has an x coordinate
15:54tgoossensbut x means y in the other boards axis
15:55tgoossenswhere in the program would you convert that
15:55dnolenbbloom: ah right, there are some asserts that are not w/in parse - but are at the analyze level.
15:55tgoossensmeaning:
15:55bbloomdnolen: yup, v4 of path uploaded. much nicer :-)
15:55S11001001tgoossens: all your pieces are {..., :x ?, :y ?}. Means a function.
15:55bbloomdnolen: w00t code reviews.
15:55tgoossensok cool
15:56tgoossensi think i get it
15:56bbloomdnolen: although if we want to do the same thing for compiler.clj, we'll probably need to rename emit to emit-form or something like that
15:56bbloomdnolen: for the reasons prior discussed about better to break defmulti than to break emit callers
15:56bbloomer defmethod
15:56bbloom15 -> 6 -> 6 -> 2kb
15:56tgoossensi just came from java. So maybe that's where my thinking came from. Because of the interface of a piece that cannot be adapted
15:56tgoossensbut in clojure you just at some key :p
15:56bbloomthat's the way patch version sizes should look :-)
15:57S11001001tgoossens: there are more complicated ways you can separate coordinates, piece types, per-board data, and coordinate systems, in a functional setting, but they're easier to get right in Haskell. No need to overcomplicate things for yourself when something simple works.
15:57tgoossenscool
15:58tgoossensthanks a lot :)
15:59tgoossensstill wondering whether at some point in the little game i'm making i'll need some references
15:59tgoossens*(ref *)
15:59bbloomdnolen: oops, small issue
15:59S11001001tgoossens: if your ad-hoc structures start to need separation, you can namespace your :keys
15:59bbloomdnolen: want that one wrapping-errors to also include the parse-invoke
16:00bbloomdnolen: v5 coming i guess, heh
16:00dnolenbbloom: did you have chance to confirm that the patch actually catches the kinds of errors that were tripping you up on your own code base?
16:00tgoossenscorrect
16:00bbloomdnolen: yes
16:00dnolenbbloom: cool, I'll take it for a spin myself as well
16:00S11001001tgoossens: per se, you never *need* refs, and I think our large, ~1000-file clojure application at my previous job used, like, 7 of them, but that was just for hackishness
16:01tgoossensmm
16:01tgoossensinteresting
16:02tgoossensfor example robots must be able to exchange energy (tag :energy in the map)
16:02tgoossensmy first way of thought was
16:02tgoossensrefs and transactions
16:02tgoossensbut i could just as well just return a vector (or map) of the two new robots
16:02tgoossensright?
16:02clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
16:02bbloomdnolen: v5 there too
16:02S11001001tgoossens: indeed, and that's the first (and likely last) thing I'd do too.
16:02tgoossensok cool
16:03jondavidjohnSo I've got this guy -> (take card_count (reduce into (mapcat (fn [c] (-> (inc (rand-int _rand_ceiling)) (take cards) (cons _new_cards))) cards)))
16:03tgoossensits hard to start thinking like that if two months ago all i knew was OO in java :p
16:03jondavidjohnand it almost does what I want it to do
16:04S11001001tgoossens: welcome to magic land
16:04tgoossensyeah the past two months have been the most interesting of all time for me (a humble student computer science in the third grade )
16:05bbloomdnolen: devn was asking me for help with an error he was encountering. i sent him patch v1 and it made it so he could track down the issue instantly :-)
16:05jondavidjohnbut it keeps repeatedly taking the first N elements off the front of `cards` with take, I really want it to progress through `cards` as it removes elements from the front
16:05tgoossensa lot of the magic i found in destructuring. its fantastic
16:06tgoossensnevertheless thanks for the support ;-)
16:06S11001001np
16:07TimMccvkem_: That's pretty bizarre. Is it repeatable?
16:07dnolenbbloom: no this is a great patch - errors at analysis time are so painful.
16:08dnolenbbloom: I think this should catch ns errors too w/ file & line numbers etc :)
16:08cvkem_TimMc: it is very repeatible.
16:08Raynesdnolen: I got my first patch vetted by The Rich. :D
16:08bbloomdnolen: yeah, that's the benefit of the exception handling approach rather than throwing a special new type of error in select cases
16:08dnolenRaynes: sweet :)
16:08bbloombrb
16:08RaynesNot that you should care. Just wanted to tell somebody with cool hair and you're the closest.
16:08dnolenhaha
16:09ucbI'm using aleph's tcp-client to implement a protocol, however the handshake of the protocol has different frames depending on the stage of the handshake. Is it possible to re-set the encoder/decoder of an already open tcp-client in aleph?
16:09ucbadditionally, is there an aleph-specific channel?
16:09TimMccvkem_: I'd love to see a reduced test case.
16:10cvkem_That is slightly more complex, as it runs as an integrated part of a web-framework.
16:10cvkem_Any suggestions when data is stored as class-files?
16:12TimMcCan you determine what your code is doing to provoke this?
16:12cvkem_The class-file is: 34 in class file vinzi/cdp/ns/pcCvrm$eval359 (where the $eval359 suggests that it is generated on the fly)
16:13tgoossenss11001001: just realized how fucked up the OO design was. a Piece was an object that could be either on a board or not on a board and had to have "class invariants" and that bullcrap
16:13tgoossenshere it is as simple as
16:13tgoossensremoving the :x :y keys
16:13S11001001tgoossens: you got it
16:13tgoossensalso
16:13tgoossensa robot has an inventory of items
16:14tgoossenseg [battery1 battery1 battery2]
16:14tgoossensit doesn't matter "which one"
16:14tgoossensas long as they have the same values
16:14tgoossensit has "that" item
16:14tgoossensstill wondering though because not all keys might match
16:14tgoossensprobably a bad idea
16:15gfredericksdoes anybody using paredit-vim know the keybinding for splicing?
16:16gfredericksor where the docs for that are?
16:16S11001001tgoossens: Smalltalk has a structure called a "Bag". It is an unordered list, in that if you add the string 'hi' to it twice, you have a bag with two 'hi's in it. It's typically implemented as a map of unique items to an int indicating the count, because all 'hi's are created equal, so it only bothers to remember one of the actual values.
16:17gfredericksnm we got it
16:17bbloomgfredericks: https://github.com/vim-scripts/paredit.vim/blob/master/plugin/paredit.vim#L162
16:17tgoossensinteresting
16:17tgoossensthats probably more useful
16:19S11001001since all batteries are created equal, if you have a list [battery battery battery], you can remove the first, you can remove the last, you can replace it with a list of two new batteries, and it's all the same
16:19cvkem_TimMc; the names-space vinzi/cdp/ns/pcCvrm is a namespace that is generated by code and that is filled dynamically with code via (clojure.core/load-string)
16:20tgoossensand if a certain battery has different properties then it is just "Another" type of piece in the inventory
16:20S11001001right
16:22cvkem_TimMc: the execution of the function is trigged by an (eval myFunc) or (eval myFunc params). Now I think of it, this eval is killing me as the parameter params is probably translated to an anonymous class
16:23gfredericksany guesses why my type Foo cannot be cast to Foo?
16:23gfredericks(given I've run `lein clean` since code changes)
16:23brehautgfredericks: different class loaders?
16:23tgoossenscool i'm really getting the hang of this. And to avoid that robots can be in the inventory of another robot i could use taxonomies (isa? ::item) or a key that e
16:23gfredericksbrehaut: wat? this is a really vanilla project
16:23tgoossensclojure is just so mindboggenly flexible i just can't believe it
16:23brehautgfredericks: an AOT'd lib?
16:24S11001001tgoossens: yeah
16:24cvkem_TimMc: at least I think the eval is the issue. Earlier I also ran into problems as eval uses the undocumented print-dup function to pass parameters around.
16:25gfredericksbrehaut: well I am doing gen-class on the ns
16:30brehautgfredericks: the clojure runtime does use its own class loader for the compiler i think
16:31gfrederickssure
16:31gfredericksI just don't understand why this would happen if I'm not doing anything weird
16:32mpenetIs this expected with extend-type on cljs? https://gist.github.com/4172023
16:32mpenetlooks like a bug
16:34mpenetdnolen: still around?
16:34dnolenmpenet: extend-type on js/Object doesn't make sense
16:35dnolenmpenet: you probably want extend-type default
16:35dnolenmpenet: as far as the syntax- that quirk matches Clojure as far as I know.
16:35mpenetwell its just an example, I had a similar issue with js/jQuery
16:35mpenetand IFn
16:36dnolenmpenet: yes ^
16:36mpenetk
16:37tgoossenss11001001: ow cool I just realized what 'complecting' is about (in my robot example)
16:37dnolenmpenet: I could be wrong about that - if Clojure allows a more relaxed style for multiple arities of a protocol then it should be fixed.
16:37dnolenmpenet: if you're allowed to do that in Clojure feel free to open a ticket in JIRA
16:38mpenetok I ll check
16:38tgoossensi was thinking "when i create my robot how can be sure that it is on a correct position"
16:38tgoossensthe thing is
16:38tgoossensyou don't
16:38tgoossensat least not at that level
16:38tgoossensof the program
16:38S11001001yeah, "don't do that" is an important part of clojure philosophy
16:38dnolenmpenet: what I really meant was that - that limitation in CLJS predates my involvement
16:38tgoossensthat would be complecting multiple stuff
16:38tgoossensand would be a pain
16:38tgoossensif you want to change the rules
16:39S11001001same applies to ensuring robots don't fit in inventories, incidentally :)
16:40tgoossenshmmm
16:40tgoossensyes :D
16:43tgoossenss11001001: ok i'm almost there! Last thing: Do you have something to say on this issue of mine: http://tinyurl.com/dyx7q95
16:44tgoossensits about collision detection and to check whether a certain piece can be on another
16:47S11001001tgoossens: marick's approach is good, and you can deal with the reverse problem by calling your collision function both ways
16:47tgoossensyes
16:50oskarthhow can I find out that @foo is a dereffed atom rather than just the value that is stored in the atom? something like (type @foo) or (meta @foo)
16:51jondavidjohncan anyone help a clojure n00b with this? -> http://stackoverflow.com/q/13634761/555384
16:51llasramoskarth: mu. That depends on `foo`, not the value returned by `(deref foo)` (which is what `@foo` means)
16:53oskarthllasram: what do you mean? I'm traversing a form and want to define a predicate to find all @forms
16:53tgoossenscool.
16:53tgoossensa robot cannot share position with another robot
16:53tgoossensbut can share position with itself
16:53tgoossensso thats a problem there :D
16:54llasramjondavidjohn: Just on your formatting q, the ->> macro can help a lot to avoid nesting and improve readability. (->> cards (mapcat ...) (reduce into ...) (take ...))
16:54jondavidjohnthanks
16:55llasramoskarth: Oh, ok. `@foo` is a reader macro which expands at read-time to `(deref foo)`. So if I understand correctly, you could look for all calls to `deref` and sort out the type of their argument
16:56oskarthI can do this: (= "clojure.core/deref" (str (first (macroexpand (quote @foo))))) but that's kind of...ugly
16:56jondavidjohnllasram: it's you again. :) yeah, I can my mind starting to work a little differently, not thinking as much in terms of mutability and looping, pretty interesting.
16:57jondavidjohn*...can feel my mind...*
16:57oskarthllasram: what do you mean by 'look at all calls to `deref`'? how would we do that?
16:57mpenetdnolen: jvm clojure seems to allow both: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L802 unless I am missing something obvious
16:58llasramjondavidjohn: It is me! Heh. But yeah, it was quite a mind-trip at first. I've been programming in Clojure every day for about a year now, so instead my code in other languages ends up looking weird and inverted to other people :-)
16:58llasramoskarth: There are several ways, depending on your larger goal. Taking a step back, may I ask what that goal is?
16:58jondavidjohnllasram: right right... I love languages that stretch me to think about problems differently
16:59jondavidjohnllasram: it is hard to compartmentalize though
16:59dnolenmpenet: there's not enough information there to confirm that. make a multi-arity protocol and actually try it.
17:00dnolenmpenet: sorry I mean multi arity protocol fn.
17:01oskarthllasram: trying to traverse a hiccup-like form which represents the DOM, and inside it there are dereffed atoms. Writing a macro that maps these forms to 'events'
17:02llasramjondavidjohn: So just program in Clojure full time. Seems like the easiest solution.
17:02muhooall you need is to find someone to pay you to do that.
17:03mpenetdnolen: you are right, it doesn't work, maybe the docstring could be updated on deftype though
17:04mpenetdnolen: I guess the intention was to show how it could be done for single arity, then show multiple, but it can be interpreted differently imho
17:04jondavidjohnllasram: If only it could pay the bills...
17:04llasramoskarth: Check out http://clojuredocs.org/clojure_core/clojure.walk/postwalk That's probably your best bet
17:05mpenetdnolen: on extend-type I mean
17:05oskarthllasram: thanks! will do
17:06dnolen mpenet: I've been burned by in the past as well - I see 2 paths - rally to making extend-type more flexible (a lot of work) - or use the static information that we have about the protocol to give a descriptive error of the syntax violation (a patch)
17:07mpenetdnolen: the later seems good enough, yes
17:07dnolenmpenet: I honestly the last option is better than improving an already verbose doc string.
17:07dnolenhonestly think.
17:07mpenetbetter to have 1 way to do it also
17:08dnolenmpenet: the CLJS compiler has all the information it needs for good error warning here - feel free to open a ticket.
17:08mpenetdnolen: I think I ll open tickets for this on both clj and cljs, they both allow it
17:08dnolenmpenet: sure
17:09mpenetdnolen: cljs is a bit odd, it depends on what you extend, sometimes it works, sometimes not
17:09dnolenmpenet: what do you mean?
17:10mpenetdnolen: https://github.com/ibdknox/jayq/blob/master/src/jayq/core.cljs#L25
17:10mpenetdnolen: there is a mix of the 2 styles on this file, see nth and lookup
17:11mpenetdnolen: again, I might be missing something
17:11dnolenmpenet: yeah it's not clear to me how that every worked in jayq
17:11dnolenever
17:12mpenetdnolen: I am trying to clean this up, I stumbled on this while trying to kill the jQuery.prototype.call extension
17:16mpenet actually only cljs allows this, I am getting confused :p
17:25degtechnomancy, brainproxy: Thanks for those final bits (two hours ago). I had to run off for a bit, so missed them then.
17:26wei_what's a good way to send a clojurescript data structure along with the initial page load? I can ping the server after the page loads (I'm using noir and fetch), but I'd like to save an xhr.
17:34dnolenwei_: you could probably emit a script tag and populate with a call to CLJS compiler infrastructure directly - (cljs.compiler/emit (cljs.analyzer/analyze {:ns {:name 'cljs.user}} '{:foo 1}))
17:34dnolenthat will give you a string, "cljs.core.ObjMap.fromObject(["\uFDD0'foo"],{"\uFDD0'foo":1});"
17:40bbloomfor the first time in 6+ months of writing clojure, i'm really wishing for some static type checks….
17:40bbloomtrying to write a dense little algorithm. keeping track of the various maps and sets and their values is hurting my brain
17:40wei_good idea. I would have to include the cljs compiler into my project then right? how would I do that since I'm getting "could not find cljs/compiler.clj on classpath"
17:41dnolenbbloom: so playing around with the patch - I note that you dump the env or is that because we use ex-info?
17:41bbloomdnolen: what do you mean "dump the env" ?
17:41mpenetwei_: dnolen: couldn't you just use cljs.reader/read-string instead? (on something like a script tag with type=text/edn)
17:42dnolenmpenet: nice idea
17:43dnolenbbloom: at the repl if I type (let [x 1] (let [y])) I get a giant dump of the analysis environment this doesn't seem desirable
17:43mpenetdnolen: sounds like something I could add to jayq as well
17:43wei_bbloom: would clj-schema help for validating the maps?
17:43bbloomdnolen: oh, didn't try it in the repl. was working with lein cljsbuild auto
17:44bbloomwei_: had no idea there was a clj-schema, was just thinking about the need for that the other day
17:45bbloomdnolen: could use a different ex-info map entry rather than :env
17:45wei_there's also typed clojure but I haven't looked at it yet
17:45dnolenbbloom: are you saying because we use :env is why it gets dumped?
17:46bbloomdnolen: apparently: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ExceptionInfo.java#L40
17:47bbloomdnolen: seems like lein cljsbuild is calling .getMessage, but nrepl is calling .toString
17:47bbloomdnolen: how about I just put :line, :col, and :file into ex-data ?
17:47bbloomdnolen: or something like that
17:48dnolenbbloom: :line, :column, :file and perhaps :tag - and we should use :tag as the filter when catching the exception?
17:49bbloomdnolen: what would :tag be? :cljs/CompilerError ?
17:49dnolenbbloom: AnalysisError no?
17:49dnolen:cljs/analysis-error ?
17:49bbloomdnolen: well we could do this same thing for emit at some point
17:50bbloomanalysis plus code generation == compiler. compiler.clj is a misnomer right now :-)
17:50dnolenbbloom: really? someone might use the analyzer w/o the compiler
17:51bbloomdnolen: so if we add wrapping-errors to compiler.clj, should that have a different :tag ?
17:51dnolenyes
17:53bbloomdnolen: i'm not convinced about that, but we can always deal with that when the issue arises
17:53bbloomdnolen: I'll tweak the patch to include those keys
17:53wei_mpenet: works great, thanks. what does text/edn mean?
17:54mpenetwei_: possible mimetype for edn, just like text/js with js on script tags
17:54mpenetwei_: and I guess to prevent some (old) browsers to interpret it as js
17:54dnolenbbloom: I see no reason to not deal w/ it now. projects like cljs-lua have already shown the analyzer can be used by itself.
17:55bbloomdnolen: i meant deal with the differing name when we get to better error reporting in compiler.clj
17:55wei_oh, this edn (https://github.com/edn-format/edn). gotcha
17:57dnolenbbloom: it's not an error generated by the compiler - so I see no reason to claim that it's a compiler error. :cljs-lua/compiler-error :cljs/compiler-error :cljs-scheme/compiler-error etc seems about right to me.
17:57bbloomdnolen: ok
17:57dnolenbbloom: we actually have a nice parse-ns fn now in analyzer - the kind of thing you'd want to use w/ datomic - :compiler-error makes no sense.
17:58dnolener codeq
17:58bbloomdnolen: i was mainly concerned with a common source code error, so there is an easy way to test for an error without having to know all the potential sources
17:59bbloomdnolen: you're right, the name compiler-error doesn't make sense, but call it :foo-error and it would be easier to tell "has this error already been wrapped up with environment info?"
18:06dnolenbbloom: I don't know what you mean. how is that different from :cljs/analysis-error ?
18:07bbloomdnolen: this patch currently only improves error reporting in the analyzer. if we also improve error reporting in the code generator, then we'd still only want to wrap ex-info onto the error once, not multiple times. if they use different tags, then the should-i-wrap-this? predicate needs to test for both tags
18:09mpenetwei_: I just added this functionality to jayq (also fyi fetch has a nasty bug with persistent datastructures, I would be careful)
18:10mpenetibdknox: If you are around, any chance of merging the PR that fixes that (fetch #14)?
18:10bbloomdnolen: anyway, v6 is up http://dev.clojure.org/jira/browse/CLJS-432
18:10dnolenbbloom: so you're afraid a second level of wrapping - perhaps I don't really understand ex-info, but I don't see how that would happen. analysis throws an analysis error, compiler catches doesn't know what to do w/ it and just throws it right?
18:11bbloomdnolen: what if an exception is thrown in the compiler?
18:11bbloomdnolen: outside of analysis
18:12dnolenbbloom: it throws it's own ex-info error, right? what's the problem?
18:12wei_cool, I am using jayq. re: fetch, are you talking about this issue that you fixed recently? https://github.com/ibdknox/fetch/pull/14
18:12mpenetwei_: yes
18:13bbloomdnolen: well yeah, but then you wind up with duplication in error handling mechanisms. as the number of AST passes increase, we want to have 1 error handling mechanism, not N == number of passes :-)
18:13bbloomdnolen: i'm just happy to have analysis errors reported clearly. we can deal with expanding the error handling strategy later
18:15wei_mpenet: nice. what's the easiest way to apply the fix? are you on clojars?
18:15mpenetnope I am not but I can push a version with the fix
18:16mpenetunder my ns
18:19mpenetwei_: https://clojars.org/cc.qbits/fetch
18:19wei_mpenet: tyvm
18:21bbloomdnolen: does that new patch look good?
18:29bbloomi'm wondering how other people handle this reoccurring functional programming issue that I encounter….
18:29bbloomlet's say you have a nested data structure that you plan to manipulate across several iterations of an algorithm
18:30bbloomand you're "mutating" the various odds and ends in that data structure
18:30bbloomit seems useful to separate identity and value, so sometimes i'll "flatten" the structure and replace the value with a gensym that represents the identity
18:31bbloomlike, if you had a graph with nodes and edges represented by {:a #{:b :c} :b #{} :c #{}}
18:32bbloomand you wanted to "name" the edges, you could replace the :b and :c with 'edge__123 and 'edge__124
18:32bbloomdoes this make sense at all?
18:36jondavidjohnI'm using partition-by to split up a collection into chunks, and I want to randomly size the chunks up to a given max so I can say that each chunk can't exceed that max number of items.
18:40bbloomjondavidjohn: can you give an example to clarify?
18:49jondavidjohn,(partition-by (fn [i] (= 0 (rand-int 5))) [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20])
18:49clojurebot((1 2 3 4 5) (6 7 8 9 10 ...) (15 16 17 18) (19 20))
18:50jondavidjohn,(partition-by (fn [i] (= 0 (rand-int 2))) [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20])
18:50clojurebot((1) (2 3 4 5) (6 7 8) (9 10) (11 12 13) ...)
18:51jondavidjohnso see how it's producing chunks bigger than 2? I understand why, but I'd like the chunks to have max # of items, but randomly chunked up to (and including) that max.
18:51jondavidjohnbbloom: ^
18:51AimHereWhy not repeatedly invoke (partition (rand-int n) ...) on your sequence?
18:52metellus,(doc partition-by)
18:52clojurebot"([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions."
18:52AimHereOr perhaps the increment of (rand-int n)
18:52bbloomjondavidjohn: ah, i see
18:52metellusjondavidjohn: that means that the length of a partition is really the amount of times in a row (rand-int 2) gives the same number
18:53jondavidjohnmetellus: right, but I'd like to do it without having to track that
18:53bbloom&(take 5 (repeatedly #(rand-int 5)))
18:53lazybot⇒ (2 1 2 0 2)
18:53bbloom&(take 5 (repeatedly #(rand-int 5)))
18:53lazybot⇒ (2 1 3 2 4)
18:54bbloomseems like a more reliable strategy, then use that with take/drop pairs
18:54jondavidjohnmy non-functional mind thinks I need to track how many times it gives the same number and force it the next time around.
18:55bbloomjondavidjohn: you're better off with a split-at in a lazy-seq loop
18:55AimHereI'd concoct a function that 'take's a random number less than your maximum, and lazily spits out the subsequences
18:55arohnerRaynes: with conch, is there a way to use (cd)?
18:55AimHere,(doc split-at)
18:55clojurebot"([n coll]); Returns a vector of [(take n coll) (drop n coll)]"
18:55AimHereOr that
18:55hughfdjacksonwhy does (repeat 3) crash my repl?
18:56hughfdjackson:D it seems an odd thing to do so; i expected it'd just be an infinite seq of `3`s
18:56bbloomhughfdjackson: you're repl is likely trying to print an infinite sequence
18:56hughfdjacksond'oh
18:56hughfdjacksonthat would explain it
18:56bbloomhughfdjackson: try binding *print-length*
18:57Raynesarohner: To change the current directory? No, but you can pass a :dir option as per the readme.
18:58arohnerRaynes: ah, thanks
18:58arohnerI did "read" the readme, but I was looking at :env vars instead :-)
18:58hughfdjacksonbbloom: apparently the lein repl doesn't declare itself rebindable
18:58hughfdjacksonbah!
18:58hughfdjacksonthanks for the answer none the less :)
18:59Raynesarohner: Actually, the readme doesn't seem to show any :dir examples, but it should work. If not, open an issue and I'll fix it tonight.
18:59arohner:dir works
18:59RaynesGreat
18:59arohnerThe readme only contains (print (sh/stream-to-string (sh/proc "ls" "-l" :dir "lib/") :out)), which is a little subtle
19:00RaynesYeah, I need to add an example for conch.sh too
19:00arohnergreat lib
19:00Raynes<3
19:01arohnerI might extend it to support SSH
19:03bbloomjondavidjohn: did you come up with a solution?
19:04bbloomjondavidjohn: here's what i got: https://www.refheap.com/paste/7164 somebody can probably do a shorter/better version too :-)
19:10AimHerebbloom, mine looks very similar
19:11AimHereTHe only real difference is the check-for-emptiness at the start
19:11AimHereAlso, I think you have a bug
19:12AimHererand-int can sometimes return 0, which is maybe not a good thing to have here
19:57nsxthas anyone worked through let over lambda?
20:21lynaghkI'm using Compojure to fetch data a 3rd party API, munge it, and then serve it up over http. The data isn't personalized in any way. Would it make sense to write a caching layer in Clojure (to limit duplicate API calls) or should I put a cache directly in front of the Compojure instance?
20:25brehautlynaghk: if its truly doing nothing at all, use a caching front end server
20:25brehautno need to reimplement it in clojure
20:25bbloomlynaghk: yeah, no sense reinventing the wheel. just a few lines of varnish config should do the trick
20:25brehautor even just nginx proxy pass caching
20:26bbloomeither way
20:26brehautnginx isnt as impressive as varnish, but it'll still do the job just fine for a lot of basic caching needs
20:26bbloomagreed
20:26lynaghkbrehaut: yeah, that's what I was thinking. The only tricky part is that sometimes the requests are coalesed. E.g., a single http request fetches data for IDs 1, 178, 387, and 43.
20:27lynaghkbrehaut: I could split apart the requests in the client, but having 5--10 simultanious HTTP requests from a mobile app sounds like trouble.
20:27brehautim not sure i understand; if you have frontend server → clojure app → api
20:27bbloomlynaghk: how are the batch requests formulated? as query params? json data? what?
20:27lynaghkbbloom: it's flexable. Right now it's query params
20:28brehautlynaghk: also, if you are implenting a cache in clojure, its worth looking at core.cache first
20:28lynaghkbrehaut: yep.
20:28lynaghkbrehaut: oh, yeah, that's what I was looking at. Just thought I'd poll #clojure about the relative merits of thaht vs. something out of process.
20:28brehauti'd go out of process myself
20:29brehautHTTP cache is a solved problem
20:29brehauteven if you set up varnish between your app and the API
20:29bbloomlynaghk: are the individual looks ups expensive? or is it the network round trip? or what's the slow part?
20:29bbloomlynaghk: how likely is the same batch request going to happen multiple times?
20:30bbloomlynaghk: ie. is it worth it to cache batches? or do you really need to cache individual items
20:30lynaghkbbloom: the batching is just so the moblie app can ask for new data all at once; no batching going on between the backend server and 3rd party API
20:31bbloomlynaghk: ok, is the 3rd party api the slow part?
20:31lynaghkbbloom: yeah, slowest right now. I haven't done a ton of benchmarking to see when Compojure falls over
20:32bbloomlynaghk: could you put the nginx or varnish cache in front of the 3rd party api?
20:32lynaghkbbloom: so it sounds like I could do a varnish cache between Compojure and the 3rd party API
20:32bbloomlynaghk: bingo :-)
20:33lynaghkbbloom: of course, if I unbatch the requests I can save Compojure from having to do a ton of repeat work. I'll look into HTTP request overhead and see if it makes sense
20:33lynaghkbbloom, brehaut: thanks for the tips. I wouldn't have thought to put Varnish between my server and the 3rd party API, which sounds rad.
20:33bbloomlynaghk: yeah, request overhead is bad unless you've got Keep-Alive enabled
20:34bbloomlynaghk: but in general, HTTP is a terribly broken protocol when it comes to concurrency
20:34bbloomlynaghk: keep alive will only save you the connection overhead… but there still isn't any pipelining really
20:34LuytWhat to think of http://programming-motherfucker.com/
20:34bbloomi mean the HTTP spec has pipelining, but so many servers are broken, that most browsers don't do pipelining
20:35lynaghkbbloom: hmm. I think I'll tackle it one bit at a time. Once jetty becomes the bottleneck that'll mean our app is very successful =D
20:35bbloomlynaghk: luckily, most browsers will have a keep-alive connection pool of 4 or 6 or so connections per domain. so you'll get some concurrency there and just keep-alive should be good enough
20:36bbloomlynaghk: all i'm saying is that you should make sure your HTTP response headers include "Connection: Keep-Alive" when measuring request overhead :-)
20:37lynaghkbbloom: thanks for the pro tip; I'll check that in right now.
20:38muhoohow would you even do pipelining in ring/jetty anyway?
20:38Guest14063Hello, On behalf of 3 bachelor thesis project.
20:38bbloomlynaghk: often keep-alive is off by default because it introduces some subtle state into an otherwise stateless protocol. can cause odd confusing bugs if you're proxying to various backends
20:39lynaghkbbloom: you mean if the HTTP connection from the client goes through a few proxies before it hits my server?
20:39dybadoes anyone know of a Clojure library that automatically runs your tests in the background?
20:39dybaIf you're familiar with Ruby, I'm looking for the Guard equivalent for Clojure
20:40bbloomlynaghk: we ran into an issue where we had some app mounted at /foo and another mounted at /bar … when we set keep alive, and you navigated in your browser from /foo/xyz to /bar/abc, then you got an error from the server that was serving /foo … b/c the browser pools connections by domain, not by path
20:41lynaghkbbloom: ah. Subdomains would aleviate that potential issue, no?
20:42bbloomlynaghk: yes, but they introduce a new issue: Cross Domain Origin Policy :-/
20:42bbloomer Single Origin Policy? whatever it's called
20:42brehautderp-hard :/
20:42lynaghkbbloom: any apps would be totally independent
20:43bbloomlynaghk: then that would be fine :-) our case was like /app and /api
20:43lynaghkbbloom: the client is iOS, so cross-domain stuff isn't an issue
20:43lynaghkbbloom: ahh. yeah. trouble.
20:43bbloomlynaghk: even better :-)
20:43lynaghkbbloom: c2po client is getting polished up with some docs, and it has the livereload server built in as you suggested
20:44lynaghkbbloom: you want to schedule a time to skype and kick the tires on it?
20:44bbloomlynaghk: could do that. what's the skype about? you want to observe me try to use it? or you want feedback after i try it?
20:44lynaghkbbloom: yeah, behind the preverbial mirror
20:46bbloombbloom: um ok, not sure what i'd graph with it tho :-) i'd need a goal
20:46bbloomer lynaghk: not bbloom:
20:47lynaghkbbloom: yeah, I'm writing up some basic docs. I'll ping you early next week with the details and maybe a use-case or two if you don't have any data of your own you want to dig into
20:47bbloomlynaghk: yeah, email me when you're ready
20:51dybahaven't found a Clojure tool that automates test runs after saving files. Does anyone know of such a tool?
20:51muhoodyba: midje
20:52dybamuhoo: oh yeah? I'll take a look right now
20:52brehautlein-autotest/lazytest?
20:55dybabrehaut: that's it! lazytest is what i've been looking for. Thanks!
21:13arohnerdid clojure.contrib.except/throwf get migrated anywhere?
21:14bbloomarohner: not familiar with it, but is it just a non-special form of throw? would #(throw %) suffice?
21:15arohner(throwf "an exception message") => (throw (Exception. "an exception message"))
21:15arohnerit also does (throwf "a %s message" "exceptional"), but I can live without that part
21:16bbloom#(throw (Exception. %))
21:16bbloom:-P
21:16wei_when writing leiningen plugins, how does one test locally?
21:16arohnerthank you :-)
21:16bbloombut yeah, i wish that the special form was throw* and that throw was a function
21:20gfredericks#(throw (ex-info % {:wat :happened}))
21:22seangrovewei_: What kind of plugin are you writing?
21:23wei_deploying clojurescript assets to s3
21:24seangroveAh, nice
21:24seangroveNo idea on testing, sadly, as I'm sure you've seen on the ml
21:29Sgeo__Wait, throw is a macro?
21:29Sgeo__Why?
21:29clojurebotWhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
21:29wei_seangrove: it's pretty easy to deploy to clojars, so that'll work
21:29seangroveIs there a macro like thrush that takes the a form and then pass it as-is to each subsequent sexp?
21:30seangrove,(let [x 10] (- x 4) (- x 6))
21:30clojurebot4
21:30seangroveI suppose let is essentially that, with a bit of extra typing
21:31Sgeo__doto?
21:31Sgeo__,(macroexpand '(doto (a b c) (d e) (f g)))
21:31clojurebot(let* [G__56 (a b c)] (d G__56 e) (f G__56 g) G__56)
21:31Sgeo__Oh, guess not
21:32gfrederickswell nearly
21:32gfredericksif all he wanted was side effects that's basically equivalent
21:32Sgeo__Well, if the things are macros...
21:33Sgeo__Then you don't want to use let like that
21:33Sgeo__possibly
21:34seangroveNo problem, I just see this pattern a lot using the closure library
21:34seangroveIt's not horrible, but it could really use a nice cljs library to wrap it and make sense of it
21:42devnAnyone see https://github.com/micha/hlisp-starter/blob/master/PROJECT.md?
22:54Sgeo__If I'm tempted to do metaprogramming with run-time shenanigans rather than macroexpand-time shenanigans, does that mean Ruby is likely to be a better fit for me than Clojure?
22:56arohnerSgeo__: not really. Clojure can do more than enough run-time shenanigans
22:56arohnerthough they're still very different
23:34zeirisHI! I've never used clojure, but am familiar with Java/Haskell/a Lisp. I want to hack together a data visualization app: I want a really responsive and clean-looking UI (most likely custom) with (probably) detailed raster graphics involved.
23:35zeirisCould anyone point me towards good UI library starting points? I remember some of the worrydream.com based UI experiments used clojure - possibly through a web service, but still a starting point.
23:35devnzeiris: seesaw is worth a look
23:35zeiris(The reason I want to use clojure, is I strongly suspect I'll want to spend a bunch of time tweaking a data transformation DSL. None of the other languages in my toolbag really suit that.)
23:37devnzeiris: i might be misunderstanding your needs, but seesaw is basically java's swing, but not as big of a bummer to use
23:37devnand it supports theming
23:38devnis that what you mean by UI?
23:38devnzeiris: quil would probably be another good place to look (processing in clojure)
23:40devnSgeo__: re: you're previous question about ruby. it depends on how much you enjoy the ability to shoot yourself in the foot.
23:40Sgeo__It's fine as long as all doing so is deliberate.
23:40devnright, until it isn't ;)
23:41devnor until another developer needs to add a feature
23:41Sgeo__And as long as it is not idiomatic to make shooting oneself in the foot more likely.
23:42zeirisdevn: awesome, thanks - that should be a decent starting point for clojure-y abstractions, if not the final library choice :)
23:44devnzeiris: godspped!
23:45devnSgeo__: i don't know specifically what you're trying to do, but my experience is that some of the iffy metaprogramming that i used to do in ruby feels much more elegant in clojure
23:46devnjust as in ruby you're allowed to make mistakes, but i think it's a bit more obvious when you're walking down that path in clojure
23:48devnSgeo__: anyway, it seems like you're asking a question that can be answered without trying it. do some of this metaprogramming stuff in clojure and then weigh it against your ruby impl.
23:48devns/can/can't
23:48Sgeo__I haven't touched Ruby in a while
23:49Sgeo__It's just a language that comes to mind when I think of run-time metaprogramming
23:49Sgeo__A
23:49Sgeo__Although now that I think of it, surprised Smalltalk didn't come to mind first
23:49devnso why the question about ruby vs clojure? try it in clojure. that will ultimately be your answer
23:50devnor smalltalk vs clojure, or whatever. try it in both and then you have some kind of base expectation to go off of
23:51devntake something to the extreme to understand the dosage