#clojure logs

2014-04-03

00:07sm0ke,(prn 'foo)
00:07clojurebotfoo\n
00:07sm0ke##(prn 'foo)
00:07sm0kehmm being lazy?
00:14nopromptplease stop the :use.
00:14nopromptno more :use.
00:15rootexnoprompt: not even in the repl?
00:15sm0ke,{:use :use}
00:15clojurebot{:use :use}
00:15sm0ke:)
00:15nopromptrootex: that's fine. but i don't even do that. bad habits die hard. typing two letters isn't hard.
00:15noprompt(:require [this.thing :as t])
00:15nopromptt/x
00:16nopromptbut mostly i'm ranting about ns :use.
00:16sm0keoh that use, yep i also dont use :use
00:16nopromptin library code.
00:16sm0ke(:require [abc.efgh :refer :all]) can be used un place f :use
00:16sm0keright?
00:16TravisDnoprompt: I agree that it's not very clear, but is there another reason?
00:17TravisD(like, it can be difficult to know where functions are defined. Is that the only issue?)
00:17nopromptTravisD: because when i'm trying to read code, you know, to understand it, i have no clue where functions, etc. are coming from.
00:18TravisDthat's the issue I mentioned :) No others?
00:18sm0kenoprompt: cant you do `where-are-you ?
00:18nopromptno that's about it.
00:18sm0ke,`inc
00:18clojurebotclojure.core/inc
00:19noprompti basically have to end up cloning the library, greping, nrepl-jumping, or some other form of sluthery.
00:20sm0kehurm
00:20nopromptbut hey it's cool. whatever bro, if that's your style.
00:20sm0kesounds complicated
00:20nopromptsm0ke: well github search aint much beter.
00:21sm0kemoreover, does it matters if the library is using :use because it surely isnt propogated to your code
00:22nopromptsm0ke: context: i'm trying to READ the fucking code.
00:22nopromptiow i'm trying to UNDERSTAND something.
00:22sm0keoh ok got it
00:22nopromptlol
00:22TravisDnoprompt: I wasn't saying it's okay to :use. I was just curious about the reasoning
00:22sm0keyea me too
00:23sm0kenormally i dont READ code on github if really want to understand
00:23sm0kei open up ide and jump to functions
00:23sm0kebut its ok bro, if its your style
00:24nopromptbasically imho, if you're going to release a library for public consumption use :require :as because someday someone's gonna want to understand the code. if you have buckets of :use and a lot of namespaces it's basically like telling the would be reader of the code to go fuck themselves.
00:25noprompti mean it's pretty much like ruby's require 'lol' <= who knows what's in there?!
00:25sm0kenoprompt: If its so badly written chances are you will not work with it
00:25nopromptdon't matter yo, cuz, it's so much easier to type :use than :require :as.
00:26sm0keyea man pont noted.
00:26sm0keits bad to use ;)
00:27nopromptthe worst is that people do this in their READMEs which teaches new comers bad habits.
00:28noprompti mean even for internal projects it's a bad idea because YOU may have to come back someday and read that code.
00:28tmciverI've heard it said here many times: only use :use with :only.
00:28noprompttmciver: and that's fine.
00:29rootexsm0ke: you use a IDE for Clojure?
00:29sm0kerootex: i consider vim + fireplace as an ide
00:30sm0keor whatever you want to call it, but it lets me jump onto runtime definitions
00:30nopromptsm0ke: did you mess with timl?
00:31sm0keyep its nice
00:31noprompthell if i hadn't invested all this time into evil-mode with emacs i might be jumping out a window over timl.
00:31sm0ketpope has created a monster
00:32sm0ke:) jumping ships is never good man
00:34sm0keotoh i am feeling a lot of lost souls using evil in emacs would come back to vim once timl gets well documented and has a few plugins written in it
00:35sm0kesjl has written a plugin in timl https://github.com/sjl/tslime2.vim/blob/master/plugin/tslime.tim
00:35nopromptyeah...
00:36noprompti dunno. i'm pretty happy with me setup right now.
00:36nopromptsyntax highlighting is better in vim i'll say that though.
00:38sm0keyea, i think that smart people will make better use of notepad than a snob with his fancy ides
00:38sm0kealso there is much more in emacs than vim for clojure
00:39noprompthahaha
00:39nopromptthat's awesome.
00:39sm0keisnt that true?
00:40sm0kethat isnt debatable emas is powered by elisp, which not to mention blows viml out of the waters
00:41n_bPHP practically blows viml out of the water ;)
00:41n_bI'm interested to see whether the NeoVim fork goes anywhere
00:41nopromptwhoa hersey bro.
00:42sm0keyep neovim is much anticipated
00:43sm0kebut i am not very sure about it. Can they deliver what moolenar has done for over 10 years
00:45sm0kethat too in 3 months? afa the funding goes
00:47ruzuwhat's the point of neovim again? some hipsters don't think the source is pretty, i guess?
00:47ruzuseems more like self-pomotion bs
00:47sm0keruzu: :) dont burn it man
00:48sm0kethere are some sensible objectives, cant ignore that
00:49sm0keyea but the source isnt pretty part was the first objective :D hahaha
00:52sm0kehmm future looks scary for timl in neovim, timl -> viml -> lua -> luajit bytecode
00:59TravisDI kind of want emacs to have some nicer GUI features, like smooth scrolling, et
00:59TravisDetc
01:00nopromptTravisD: https://github.com/noprompt/matilde/blob/master/emacs.d/init.el#L29-L31
01:01nopromptTravisD: whoops! https://github.com/noprompt/matilde/blob/master/emacs.d/init.el#L25-L31
01:02TravisDnoprompt: I have similar settings. I wish it didn't scroll one line at a time
01:02TravisDit's a very small thing
01:06Guest50112I'm trying to test a namesapce containing an atom and this is what I'm getting
01:06Guest50112ERROR in (search-user-test-true) (core.clj:2108) expected: (= [] (search-user "username")) actual: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.util.concurrent.Future at clojure.core$deref_future.invoke (core.clj:2108)
01:06Guest50112can anyone help?
01:07seancorfieldThe exception says your variable isn't defined to have a value when it is used...
01:08hiredmanGuest50112: you are derefing the contents of a var with no value
01:08hiredman,(def x)
01:08clojurebot#'sandbox/x
01:08hiredman,x
01:08clojurebot#<Unbound Unbound: #'sandbox/x>
01:08hiredman,@x
01:08clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.util.concurrent.Future>
01:09sm0kehmm weird error
01:10sm0keit assumes x to be a future, can only fututres be @
01:10Guest50112but at the start of the namesapce I've initilized the atom as (def search-details (atom {:search-term "" :count ""}))
01:11sm0keGuest50112: can you show the test as a gist/paste?
01:11seancorfieldmaybe that's not what your code is trying to deref?
01:12hiredmanor the code that is running is not what you think the code is
01:12sm0ke:D
01:12hiredman(unsaved file, stale repl state, etc)
01:25maxthoursie,(clojure.math.combinatorics/selections '[b w] 3)
01:25clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.math.combinatorics>
01:25maxthoursie$(clojure.math.combinatorics/selections '[b w] 3)
01:26maxthoursiecan I use deps somehow?
01:42amalloynot in clojurebot or lazybot, no
01:43TravisDAre there tools for doing literate clojure programming?
01:45beamsoliterate?
01:45TravisDbeamso: Literate programming is where you mix prose and code in a single document
01:46TravisDbeamso: sometimes there are tools that will produce nice PDFs of the files or run all the code and produce outputs
01:46amalloythere was a guy on the mailing list who was always going on about literate programming. is he still around?
01:46TravisDbeamso: http://en.wikipedia.org/wiki/Literate_programming
01:46TravisDI really like the idea, but I never manage to write the prose clearly enough to be of any use
01:47beamsohave you seen https://github.com/gdeer81/marginalia before?
01:47TravisDand that makes me sad :(
01:47TravisDI saw it after a quick google search, but wasn't sure if was the de facto standard
01:48TravisDbeamso: Ah, but that is pretty much exactly what I was looking for
01:51amalloyTravisD: there's no de facto standard: i don't know of anyone who seriously tries to write literate clojure. if they did, i guess they would probably use marginalia
01:51TravisDamalloy: Cool, thanks. Out of curiosity, what's your opinion of literate programming?
01:51amalloyi think it's a lovely ideal
01:52amalloyi've never tried to become very well informed on it, but my impression is that nobody ever does a good job of it
01:53TravisDyeah, that sounds about right :)
01:54alewseems like literate code would be really awesome if it was released alongside research papers
01:54TravisDalew: That's one of the main reasons I wanted to start writing literate clojure
01:55amalloyevery so often i read a well-written blog post, with code embedded in it, and they say "aha, gotcha! this was literate programming!"
01:55amalloybut i don't really see why it's any better than writing a blog post and also some code
01:56alewTravisD: are you writing a dissertation?
01:56TravisDalew: yep :S
01:56amalloylike, how important is it *really* that you have a codebase that you can run generate-blog-post.sh on
01:57TravisDamalloy: the only advantage I can think of beyond the writing experience is that you get some guarantee that the code and results stay consistent
01:58alewamalloy: Well it might be cool to say that all your programmers are also authors and you're going to release a book simultaneously with the product :P
02:01alewTravisD: what's the topic for your dissertation?
02:02TravisDalew: the title is "Gradient Methods for Reinforcement Learning"
02:03TravisDI'm looking at a few different problems that can roughly be characterized by that title :)
02:03alewTravisD: I was just reading up on Reinforcement Learning recently as I had the thought that it must be pretty much how the first organisms evolved
02:05TravisDalew: ah, cool :) I'm not sure how much of a role it plays in evolution, but I think it's one of the mechanisms that animals have for learning motor skills and things. I have no psychology or biology background whatsoever, though
02:06TravisDalew: if you want to talk more about it, perhaps we should move to private messages. This is getting pretty off topic
03:14wagjoGood morning (ugt) everyone
03:31knight_hi, How can I change my str encoding from utf-8 to gb2312 ? #(info (new String (.getBytes "测试") "GBK") %)) doesn't woks.
03:36priyanka_hey!!!! I am new to Clojure and need to test my web application.... can anyone tell me how to test the following html page rendering method : (defn login [& [pass]] (layout/render "login.html" {:user-pass-mismatch (vali/on-error :mismatch first)}))
03:50vijaykiranpriyanka_: can't you use selenium ?
03:50vijaykiranor https://github.com/semperos/clj-webdriver rather
03:51priyanka_can such functions be tested using clojure.test?
03:51priyanka_vijaykiran_ can such functions be tested using clojure.test?
03:52vijaykiranpriyanka_: what do you want to test ?
03:52priyanka_This one
03:52priyanka_(defn login [& [pass]] (layout/render "login.html" {:user-pass-mismatch (vali/on-error :mismatch first)}))
03:54vijaykiranpriyanka_: yeah, you said that already - what I meant what's the behaviour do you want to test ?
03:56priyanka_I'm using noir validations on the html page. How will I test this function if there's a password mismatch? As in, on password mismatch :user-pass-mismatch has a value "Password does not match"
03:56priyanka_and the html page displays that error
03:57vijaykiranpriyanka_: I guess you should prefer using clj-webdriver to test what the output is in the browser
04:31wunkiwhen you have a function which returns a boolean, is it OK to wrap a `when-let` in `boolean`. E.g `(boolean (when-let ...)`
04:33wunkiinstead of OK, I meant to say, idiomatic
04:33cmdrdatswunki: why would you need that?
04:34beamsowouldn't the idiomatic version be (if (predicate?) () ())
04:34beamso?
04:34ssqq_How to make run a clojure script file more faster instead of use 'lein run'.
04:34wunkicmdrdats: because my function needs to return a bool, not a bool or nil
04:36wunkissqq_: just a matter of opinion, but I find (if (predicate?) (...) false) ugly
04:38wunkissqq_: one way is to use drip: https://github.com/flatland/drip
04:38wunkibeamso: just a matter of opinion, but I find (if (predicate?) (...) false) ugly
04:38beamsoi get that, but you asked for idiomatic
04:38beamsoidiomatic need not be what looks good to you
04:39ssqq_wunki: thanks
04:40wunkibeamso: yes, that's why I was asking, could well be the "uglier" version is the idiomatic way
04:49clgvwunki: nil is falsey, so just use when-let without the "boolean" except you really really really need a boolean, which you seldom do
04:50clgvwunki: and yes, (when (pred? ...) val) is idiomatic and NOT (if (pred? ...) val false)
04:50clgv,(macroexpand-1 '(when (pred? x) y))
04:50clojurebot(if (pred? x) (do y))
04:51clgvthat's what the when macro expands to ;)
04:52ssqq_Someone tell me that use repl with require or include 'script file' to make run faster.
04:53wunkiclgv: thanks for the explanation. I wanted a boolean because my function name is `valid-credentials?`
04:53wunkiclgv: implying a boolean is always returned
04:55clgvwunki: I wouldnt be so strict about that semantic associated with "?" since most of the time in clojure code there is no difference if you really get a boolean or something truthy/falsey
04:56clgvwunki: if it makes your code much more complicated it's probably not worth the effort
04:56wunkiclgv: ok, I spend too much time in Haskell lately I guess
04:57wunkiclgv: thanks for the insights
05:08lgs32ais there a clojurescript minor mode?
05:08lgs32ai only care for hl
05:08lgs32a(emacs)
05:09donbonifacioI'm feeling the urge to learn clojure
05:09clgvdonbonifacio: then do not hesitate :)
05:14lgs32acemerick: how much work do you think it would be to write piggieback so that it provides the clojurescript nrepl on a different port - so that I can fire up a second cider-jack-in for cljs?
05:16ssqq_Have Vim 7.4 support Clojure syntax highlight?
05:28diomsh
05:56cemericklgs32a: Just connect to the same server; it'll be a totally different session. You can have N REPLs going at a time, each one can be either Clojure or ClojureScript.
05:58lgs32acemerick: that is awesome. I will try that now
06:09ssqq_Have Java 8 support Tail recursion?
06:32lgs32aif I have multiple nrepls, what command do I use to tell cider which nrepl to use with a buffer (for e.g. c-c etc.)?
06:37CookedGryphonlgs32a: you can cycle through them with C-c M-r
06:38lgs32aCookedGryphon: thank you
07:06tpopebbloom: yeah not my circus, not my monkeys
07:19harshitahello i have found exception in clojure java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.util.concurrent.Future plz some one tell me why this exception is occured
07:21wagjoharshita: you have an unbound var somewhere. Most likely you have declared a var and forgot to define it later.
07:21wagjoharshita: and most likely you were trying to dereference this var with @, which causes this casting to future exception
07:28gunsgrrr... Is there a way to delete a SNAPSHOT release on clojars? I Ctrl-C my deploy once I realized I was uploading a SNAPSHOT
07:30clgvguns: why? you can easily overwrite it with another snapshot or release something stable
07:31gunsclgv: I tried that, but clojars says it's messed up
07:31gunshttps://clojars.org/slamhound/versions/1.5.5-SNAPSHOT
07:34clgvguns: should work, see the following url there are 2 snapshots for 1.3.0 http://clojars.org/repo/slamhound/slamhound/1.3.0-SNAPSHOT/
07:35clgvand a release for 1.3.0 as well
07:35clgvhttp://clojars.org/repo/slamhound/slamhound/1.3.0/
07:36gunsclgv: I see, thanks for the link. I'll just assume the page is cached or something
07:38gunsor actually, all the SNAPSHOT pages look like that
08:10mskoudhi
08:59mskoudusing map to generate a string from a list of maps, but the maps also has a value which must be summed. Hvo can i do this?
09:00dnolen_mskoud: sounds like you want reduce
09:01AeroNotix,(macroexpand-1 '(ns lol))
09:01clojurebot(do (clojure.core/in-ns (quote lol)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core))) (if (.equals (quote lol) (quote clojure.core)) nil (do (clojure.core/dosync (clojure.core/commute (clojure.core/deref (var clojure.core/*loaded-libs*)) clojure.core/conj (quote lol))) nil)))
09:01AeroNotixwhat's the need for the (if (.equals 'lol) 'clojure.core) here?
09:02AeroNotixsurely that could be removed and if peopole did that then it's Their Fault.
09:02gfrederickswell it does happen once
09:02AeroNotixis (ns clojure.core) evaluated twice, somehow"?
09:02mskoud(map #(% :name) [{:name "a" :price 3} {:name "b" :price 5}]) : => ("a" "b") , would like to get 8 returned as well... without iterating again.
09:02gfredericksI just mean that the check is true at the top of src/main/clojure/clojure/core.clj
09:03AeroNotixmskoud: you want a reduce
09:03gfrederickswith tjuxt
09:03gfrederickswhich doesn't exist
09:03gfredericks(reduce (tjuxt conj +) [[] 0] maps)
09:03mskoudok. seperate the 2 issues and dot think about that i have to "iterate" again?
09:04gfredericksmskoud: you don't have to iterate again with reduce
09:05AeroNotix,(doc tjuxt)
09:05clojurebotGabh mo leithscéal?
09:05AeroNotix,(doc 'tjuxt)
09:05clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol>
09:05AeroNotixWELL FINE
09:05gfredericksAeroNotix: I just said it doesn't exist
09:05AeroNotixoh didn't read that bit
09:05AeroNotixwhat would tjuxt do?
09:06AeroNotixahh I think I understand
09:06gfredericksyeah my reduce doesn't make complete sense though
09:06gfredericks,(->> maps (juxt :name :price) (reduce (tjuxt conj +) [[] 0]))
09:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: tjuxt in this context, compiling:(NO_SOURCE_PATH:0:0)>
09:06gfredericksthat would be how you'd have to do it
09:07gfredericks,(defn tjuxt [& fns] (fn [& tuples] (apply mapv #(apply %1 %&) fns tuples)))
09:07clojurebot#'sandbox/tjuxt
09:07gfredericksI think that's it
09:07gfredericks,((tjuxt + *) [3 4] [4 5])
09:07clojurebot[7 20]
09:08gfredericks,((tjuxt + *) [3 4] [4 5] [6 7])
09:08clojurebot[13 140]
09:08mskoudok, thanks!
09:08gfredericks,(def maps [{:name "a" :price 3} {:name "b" :price 5}])
09:08clojurebot#'sandbox/maps
09:08gfredericks,(->> maps (juxt :name :price) (reduce (tjuxt conj +) [[] 0]))
09:08clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$juxt$fn__4213>
09:08gfredericksoh right
09:09mmitchellAnyone every seen this as a result of leiningen attempting to fetch dependencies? "java.util.zip.ZipException: invalid CEN header"
09:09gfredericks,(->> maps (map (juxt :name :price)) (reduce (tjuxt conj +) [[] 0]))
09:09clojurebot[["a" "b"] 8]
09:10gfredericksemacs: I want to setup some alternate keybindings for cider, but doing it in a clojure-mode-hook doesn't work: https://github.com/fredericksgary/dotfiles/blob/master/.emacs.d/init.el.symlink#L189-191
09:11gfredericksI think it just silently fails to execute the rest of the function
09:14ned- /join #golang
09:14gfredericksned-: hi welcome to #golang
09:14ned-why thank you sir!
09:15ned-caffeine pills do not work anymore ugh
09:15gfredericksplease make sure to run all your comments through gofmt before sending them to the channel
09:15ned-gfredericks: lol.
09:15bodie_lol
09:15ned-gfredericks: ive ran into that same cider issue whent rying to rebind, im busy now but ping me in a few hours and ill try to help ya out
09:18gfredericksI love that tests for testing tools inevitably have to test that a test can fail and name things with english reassurances
09:18gfredericksclojure.test.check.clojure-test-test/this-is-supposed-to-fail
09:43gfredericksreiddraper: https://github.com/fredericksgary/test.check/commit/b6b24585a65807ab03b76e04727d230725181bed
09:43gfredericksthe simpler test currently passes, but the more complex one fails (due to not implemented yet)
09:43gfredericksthis is the same code I had two days ago, I just didn't have it on github yet
09:47gfredericksI feel like it should be rather simpler than this
09:51a3gishey! would someone have a good talk to advise for a clojure beginner? I am actually new to any lisp family language
09:51a3gis(I watched the serie by Brian Will already)
10:04Guest84448Hi, I'm using (clj-time.coerce/to-sql-date (new java.util.Date)) to insert date into postgresql and the inserted date is 2014-04-03. But when I'm trying to retrieve it from the DB, the date returned is 2014-04-02. How can I resolve this issue?
10:05antonvGuest84448: maybe it is timezone related somehow
10:08gfredericksa coworker was using test.check to test that dates roundtripped through the db the other day; the db type was a postgres timestamp without timezone
10:09gfredericksturned out there was one hour a year that didn't roundtrip
10:09gfredericksusing the "with timezone" type fixed it
10:13ambrosebsgfredericks: badass
10:15clgvgfredericks: witching hour? :P
10:17gfredericksI believe it was the point when daylight savings time jumps back an hour, making that hour ambiguous since it happens twice
10:24TimMcNICE.
10:25jcromartieSWEET
10:26mdrogalisThat's hella awesome, gfredericks
10:27gfredericksthe funny part is that we were already using test.check in the project, but when I was thinking about testing db-timestamp-roundtripping I couldn't think of any reason to use test.check and figured a couple hardcoded examples would be sufficient
10:27gfrederickscoworker used test.check anywas
10:29reiddrapergfredericks: very cool
10:30jcromartiesorry I actually missed the cool thing, gfredericks: what was that?
10:30ambrosebshttp://clojure-log.n01se.net/#10:08
10:30gfredericksjcromartie: http://clojure-log.n01se.net/#10:08
10:35TimMcgfredericks: Shoulda been using https://en.wikipedia.org/wiki/International_Atomic_Time
10:37TimMcgfredericks: POSIX time can be ambiguous around leap seconds.
10:38TimMcalthough I guess TAI isn't defined before 1971
10:39llasramTimMc: Yeah, but the current definition of UTC wasn't specified until 1972
10:39llasramUnix epoch time was originally defined in terms of GMT
10:39llasramand was only later reconned to UTC-except-for-before-1972-where-we-fake-it
10:41TimMcPoint.
10:43pjstadighumans shouldn't be allowed to mark the passage of time, and I'll just leave it at that
10:45gfredericks"TAI as a time scale is a weighted average of the time kept by over 200 atomic clocks in over 50 national laboratories worldwide."
10:45TimMcand adjusted to sea level, I believe
10:45gfrederickswhich is rising
10:45lockslol
10:45gfrederickshey that's interesting are we going to keep updating elevation stats as the sea level rises?
10:46pjstadighttps://twitter.com/pjstadig/status/401349780359483393
10:46locks"Mount Fuji is the current tallest peak, standing at 102m" - Wikipedia, 2056
10:46pjstadighttps://twitter.com/tef/status/410797003489427456
10:47jcromartie#FiveWordTechHorrors is always good
10:47pjstadighttps://twitter.com/pjstadig/status/441646573806968832
10:48pjstadigi'm done
10:48pjstadigoh one more https://twitter.com/pjstadig/status/450406019525787648
10:48mdrogalisMic drop
10:49pjstadignow i'm going to turn in my computer and become an orchard farmer
10:49mdrogalisSometimes I want to do something like that.
10:50locksdo it
10:50locks"oh, let me just code a little calendar to help with the cro-D'OH"
10:50clojurebotExcuse me?
10:50mdrogalisSeriously though. Doesn't it occassionally drive anyone else nuts that you generally have to be creative every single day?
10:51locksmdrogalis: my code is pretty uncreative, so idk
10:51mdrogalislocks: Maybe that's the answer.
10:51jcromartiemdrogalis: being a programmer is existential torment
10:52mdrogalisjcromartie: Yup, that's it. Time to quit and head west to be farmer. IRC told me to.
10:52jcromartie"The http://en.wikiquote.org/wiki/Programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand http://en.wikiquote.org/wiki/Conceptual_structure....&quot;
10:53jcromartieWTF is that OS X or Adium or wikiquote.org doing that?
10:53locksprobably wikiquote
10:53jcromartie"The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures...."
10:53locksright-click hijacking is ugh
10:53mdrogalisYuuuup
10:53locksjcromartie: that's so masturbatory
10:53jcromartieand yet, we build CRUD apps to track inventory
10:53jcromartieyes it is
10:54jcromartielocks: but it's true
10:54clgvright-click jacking is the DRM of around 2000 ;) :P
10:54locksyyeeaahh…
10:54jcromartiethere's cognitive dissonance in the capability and the possibility that the *idea* of programming offers, and the reality of what needs to get done
10:56mdrogalisI came to #clojure to sober everyone up about our CRUD lives :P
10:58jcromartiethanks mdrogalis
10:59mdrogalisYou're welcome everyone.
10:59mdrogalisBACK TO WORK
11:02mskoudSeems like pr-str can print stuf that read-string cannot read, getting a RuntimeException Map literal must contain an even number of forms.
11:04lgs32anrepl question:
11:04lgs32aI have two nrepls running, one for clj and one for cljs
11:05lgs32athe files belong to the same project
11:05lgs32ahow can I make sure that cider interacts with the correct repls in the specific buffers
11:05gfredericksmultiple repls w/ cider has always confused the crap out of me
11:05gfredericksI mostly avoid doing that
11:06lgs32athis won't help
11:06lgs32aI want clj and cljs repls simultaneously
11:06gfredericksat worst you can have a shell buffer open with a traditional `lein repl` running there
11:06lgs32ai don't want that
11:06gfredericksbut I do think cider is supposed to support this, I just know none of the details
11:07sritchie_I think you do C-c M-r to switch -
11:07sritchie_but I don't know how to tie each repl to a buffer
11:07lgs32asritchie_: this results in changing the nrepl for the entire project
11:07mikerodSo, I'm working with nrepl.el in emacs. I accidentally cause an infinite loop on the nrepl server. I kill the server at this point, but when I am in emacs it won't respond, as if it is still stuck in the loop. Is there any good way to get Emacs to get out of this?
11:07mikerodI know I can just force-kill Emacs
11:07sritchie_lgs32a: yeah, I don't know how to tie each one to a specific buffer, I just sort of stick to clojure or clojurescript mode
11:07mikerodwhich is my current approach :)
11:07sritchie_mikerod: C-c C-c
11:08sritchie_kills the current running thread
11:08mikerodsritchie_: oh cool
11:08gfredericksemacs always responds promptly when I kill the jvm
11:08mikerodI figured there was something, I guess I didn't search for it hard enough
11:08mikerodgfredericks: interesting
11:08gfredericksI'm using cider though
11:08lgs32ahonestly, I find this is terrible
11:08mikerodgfredericks: I need to, I tried to update and got a bunch of errors, so I abandoned it. I need to take a look at that again.
11:09gfredericksmikerod: you gotta make sure nrepl.el isn't around anymore
11:09mikerodgfredericks: I thought I did, but perhaps I failed at that part. :)
11:09lgs32awhat are my alternatives? vim won't be supported much better, lighttable is too early
11:09mikerodI'll dig into again since I'd like to stay up to date with the cider versions
11:09clojurebotHuh?
11:10gfrederickslgs32a: learn elisp and read the cider source code?
11:10lgs32aYeah I did read it
11:10gfrederickswhat did you find out?
11:11lgs32aIt's a mess
11:12gfredericksI guess there's just no good way to do clojure development. You should use another language.
11:12stainwhat's the best way to do content negotiation in a tiny Clojure REST app? I've found various bits and pieces around the Githubs. Ideally the way I want to do it is to just thread in a handler that converts the JSON to other formats.. I might just write that from scratch if there isn't anything.
11:13gfredericksstain: does liberator do that?
11:13stainsorry, I've used Compojure so far
11:13stainperhaps, but it seemed a bit "taking over".. so not sure if it really is liberating!
11:13stainit has the functionality, but I guess I woul dhave to restructure everything.. or can I use compjure with liberator?
11:14sritchie_stain: you can use compojure w/ liberator
11:14sritchie_stain: just use an ANY route
11:14sritchie_and liberator'll take over the route
11:15stainOK.. because now I have it like https://github.com/stain/scufl2-info/blob/master/src/scufl2_info/run.clj#L85 defines a compojure context, which I then just write in at the main app https://github.com/stain/scufl2-info/blob/master/src/scufl2_info/handler.clj#L13
11:16stainso would I let Liberator just take over at the top level?
11:16stainit seems to me I would have to replicate every endpoint per every format
11:18stainI'll give it a go
11:18staintwo random voices on the internet mentioning the same project.. so it can't be too bad. Also it does the Vary header for me, so that's a plus!
11:19stainwhat about exception handling..? I want to be able to throw an exception 4 levels in, say because a parameter passed in is not a non-negative Integer - and give an appropriate HTTP error code rather than a 500. Anything exist for that, or should I make like a NotFoundException etc?
11:20stain.. and catch it with another middleware
11:27clgv,(apropos "exception")
11:27clojurebot()
11:27clgv,(apropos "info")
11:27clojurebot(ex-info)
11:27clgv,(doc ex-info)
11:27clojurebot"([msg map] [msg map cause]); Create an instance of ExceptionInfo, a RuntimeException subclass that carries a map of additional data."
11:28clgvstain: you can use that ^^
11:29gfredericksstain: if you stick a :bad-request key in the map, or similar, you can catch it easily in a middleware with github.com/fredericksgary/catch-data
11:32asthasrHey guys! Random question time. If I want to have non-blocking queueing of I/O (i.e., a file writing queue) but want to wait on all of them to complete before moving on to another step, what's the standard way to do that?
11:33asthasrMy initial attempt used agents, but somehow that ended up leaking memory all over the place, and trying to use shutdown-agents to force everything to resolve just caused my program to hang... :-\
11:33coventrylgs32a: To get around the "which repl should the code go to" I run the cljs and clj repls in separate emacsen, and use one for cljs, one for clj. Still a bit clumsy, but it mostly works.
11:34asthasrShould I do something like put promises in an atom, constantly appending to it with all of the promises, and then just loop over it asking for the values?
11:34asthasr(this seems a little gross, because it's a side-effect I'm after, i.e. file IO, not the value)
11:37coventryasthasr: How does the waiting thread know that all the file writing is done, if it can be queued up from multiple threads?
11:38stuartsierraasthasr: core.async could be one tool for that
11:40asthasrcoventry: True.
11:40asthasrstuartsierra: Thanks.
11:42coventryI was actually curious about how you addressed that issue in your earlier implementations, because it would effect the answer.
11:43asthasrcoventry: I didn't think about it. My agent approach was very naive, and I didn't address the issue.
11:43asthasrcoventry: Previously I'd just been doing the file IO in the loop, my attempt was to make it non-blocking
11:44asthasr(this is the first time I'd used agents, and I've applied pmap a couple of other places, my naivete is because pmap is so nicely transparent I guess I was thinking of the IO issue too simply)
11:44asthasrstuartsierra: Is there a good tutorial on core.async?
11:45abakerquestion on clojure best practices -- have an API that returns a list of things (via a network resource), is it idiomatic to provide only a lazy version of that list, a regular eager list, perhaps both and let the user pick?
11:45asthasrcoventry: My biggest issues are, if the writing is async, it still has to be atomic (i.e. one line at a time), like a logger stream; and all of the writes have to happen.
11:46asthasrabaker: I'm not an expert, but I would think the best would be lazy only. After all, can't the user simply call doall on the LazySeq to get a realized list?
11:47coventryasthasr: Oh, OK. A core.async channel is a good way to ensure that.
11:48asthasrthat is to say, maintaining one version seems superior for your purposes, and calling (doall (get-expensive-resources)) is not much of a burden for the consumer
11:48asthasrcoventry: Cool. Is there a good article on them?
11:49asthasrcoventry: And is there a good way to say "Okay, main thread, now you wait until all those channels are done with their writing."
11:49coventryThis is pretty good. The video for the talk must be out there somewhere by now. https://github.com/halgari/clojure-conj-2013-core.async-examples
11:50stuartsierraThat video should be on the Clojure TV channel on YouTube.
11:50abakerasthasr: thanks, that does seem like the natural way ahead
11:51tbaldridgecoventry asthasr: video for that code https://www.youtube.com/watch?v=enwIIGzhahw
11:52asthasrtbaldridge: thanks
12:06lgs32agfredericks: coventry: sritchie_: I wrote this to allow you to associate any open nrepl connection directly with a buffer https://www.refheap.com/71069
12:06lgs32a(instead of having to change the global connection)
12:09gfrederickslgs32a: sweet! thanks
12:10gfredericks(inc lgs32a)
12:11stainclgv / gfredericks: great, an Exception with a map was basically what I would make!
12:12gfredericksstain: yeah, clojure's built-in is great for throwing but still clunky for catching
12:12rasmustodoes make-parents destroy directories if they already exist?
12:16rootexis the use of exceptions a normal/frequent thing in Clojure?
12:16gfredericksmuch more frequent than the Either monad
12:18mdrogalisI still don't *get* monads.
12:18mdrogalisMaybe it's just me.
12:19rasmusto~Maybe
12:19clojurebotPardon?
12:19tbaldridgemdrogalis: they're a nice abstraction....of something that rarely needs to be abstracted, imo.
12:20mdrogalistbaldridge: I guess therein lies the problem.
12:20hiredmanI know I've seen people complaining about compilation errors involving clojure.core.cache/through in here before, does anyone know what the resolution to that is?
12:20mdrogalisI should just suck it up and learn Haskell.
12:20arrdemmdrogalis: take me with you :P
12:21technomancylearning monads in a dynamic language is like learning FP in ruby
12:21technomancytheoretically possible
12:21arrdemmdrogalis: I got frustrated trying to type foldr (Data.Map String Int) [Int] :P
12:21tbaldridgemdrogalis: I try that every once in awhile...and then I come to my senses after reading "Learn you a Haskell" for about 1 hour
12:21gfredericks(inc technomancy)
12:21tbaldridgeThe syntax is just too much for me I guess.
12:21Bronsahiredman: IIRC you might have the last version of core.memoize and an older version of core.cache in the classpath
12:21rasmustoyou're supposed to switch to some other book when LYAH stops making sense
12:22hiredmanBronsa: nuts
12:22arrdemLYAH is terrible :c
12:22hiredmantechnomancy: does deps :tree show plugin deps too?
12:22rasmustoarrdem: got a counter-pick?
12:22mdrogalisHeh
12:22gfredericksI enjoyed LYAH I think
12:22tbaldridgearrdem: I find the text in LYAH to be fine, the problem is I don't understand why I need ++ vs <- vs whatever other wacky syntax they devised.
12:23technomancyhiredman: no; no simple way to do that currently unfortunately
12:23Bronsahiredman: yeah, if you're using core.memoize in a plugin, you cannot use the last version as lein has an older version of core.cache in its classpath because of stencil
12:23tbaldridgethat's really it....I find the Haskell syntax too complex
12:23arrdemrasmusto: TBH I don't... I read LYAH and didn't get a lot out of it.. I have "Haskell the craft of functional programming" and some datastructures in Haskell books on my shelf... and bitemyapp 20 minutes south of me on call.
12:23gfrederickstbaldridge: fixity!
12:23technomancyBronsa: I think the stencil thing was fixed on master; let me check
12:24arrdemBronsa: got a minute to comment on GSoC stuff?
12:24seancorfielddnolen_: what is the best IRC channel to ask questions about Om?
12:24rasmustoarrdem: kk
12:24Bronsatechnomancy: on master yes
12:24hiredmanBronsa: the only plugin I have loaded right now is eastwood
12:24dnolen_seancorfield: #clojurescript probably, but answer questions here too
12:24dnolen_"but I answer"
12:24Bronsaarrdem: I don't really have much time but tell me
12:24mdrogalistbaldridge: How do you feel about Erlang, then?
12:25technomancyhiredman: well lookit that... someone added support for lein deps :plugin-tree
12:25technomancythanks, whoever did that
12:25tbaldridgemuch the same, but at least they know their syntax is bizarre. And Elixir fixes most of that.
12:25pjstadigtechnomancy: haha! open source FTW
12:25Bronsahiredman: .. yeah. t.a.j requires the last core.cache, stencil from lein pulls an older core.cache
12:25technomancyah, it was hyPiRion. should have known. ==)
12:26technomancyoops
12:26hyPiRion?
12:26technomancythe thing that confused me the most with ocaml was the precedence rules, which erlang doesn't really have problems with
12:26hiredmanBronsa: ah, so the new eastman doesn't work with older versions of lein?
12:26technomancythey're a lot less operator-happy
12:26arrdemBronsa: Daniel Gomez commented on my proposal saying that there's interest from Rich in doing a lightweight clojure atop the existing compiler rather than atop your toolchain. I'm not such a fan but was wondering if you had compelling reason to move away from the existing compiler I could cite in a response.
12:26technomancyhyPiRion: the `lein deps :plugin-tree` feature
12:27hiredmanBronsa: or the reverse, the newest eastwood works with older versions of lein
12:27seancorfield'k, I'll join #clojurescript then for a more focused discussion :)
12:27hyPiRionoh yeah, I think someone added an issue, and it was really straightforward to do
12:27tbaldridgearrdem: I was there for that meeting, it was a bit simpler than that. Rich said that most of the stuff has already been implemented before and reverted. Namely static vars and lazy vars.
12:27gfrederickshyPiRion: you must be wrong; technomancy said it was difficult
12:28Bronsahiredman: you should ask Andy Fingerhut for that, but I think eastwood no longers uses :eval-in-leiningen to avoid that issue
12:28gfredericksperhaps you accidentally implemented something else
12:28tbaldridgearrdem: all you need to do is enable that code again, add compiler switches to turn them on and off, fix how things are handled with maven, and boom! you're done.
12:28Bronsaarrdem: err, it's written in java? :/
12:28arrdemBronsa: that was my reaction :P
12:28technomancygfredericks: hehe; I meant no way to do it without hacking lein
12:29Bronsaarrdem: also it's a closed system with no support for passes etc
12:29pjstadigis someone going to fix transitive AOT as a GSoC project, because I'd pay money for that
12:29tbaldridgearrdem: Rich's opinion was that this code could be done in a matter of a few weeks of work. Opposed to a matter of at least a year based on another compiler.
12:29technomancyarrdem: good way to keep people from submitting patches tho
12:29Bronsaarrdem: but I can see why Rich would want the Lean stuff to be done on the current compiler
12:29tbaldridgearrdem: a compiler that doesn't have 100% parity with the existing compiler, (no offense to Bronsa).
12:30arrdempjstadig: shoulda written a project idea up GSoC apps are closed already
12:31tbaldridgeI mean long term I think we need CinC, but if we can get what we want in a fraction of the time with existing compiler should we wait?
12:31arrdemtbaldridge: I mean if it's Rich's oppinion that upgrading the existing compiler is that trivial I'm happy to add a "code monkey the existing compiler before working on Bronsa's infrastructure" clause.
12:32Bronsatbaldridge: right, support for that stuff is mostly already there in the Compiler, but I tested it a bit and it has a bunch of bugs
12:32mdrogalisWhat exactly are we talking about? I read up and still don't follow.
12:32tbaldridgeyeah, perhaps that's a good route as well, that way the lean stuff can get into 1.7 and yet we can still do cool CinC stuff
12:33arrdembesides, it'll be an exercise for me in the existing compiler, which isn't a bad thing.
12:33arrdemmdrogalis: https://www.google-melange.com/gsoc/proposal/review/student/google/gsoc2014/arrdem/5629499534213120
12:33arrdemmdrogalis: and CinC at large
12:33Bronsaarrdem: I completely understand why it might be preferable to add support for that in Compiler.java first and in part agree. There's no way CinC is going to become "official" anytime soon
12:34mdrogalisarrdem: Ah, okay. Thanks
12:34rootexwhat would be the benefits of CinC besides not writting Java for the compiler anymore?
12:34tbaldridgeBronsa: yeah, although getting CLJS switched over will be a major step. I've been pushing hard to get that project approved.
12:34mdrogalisWas thinking the same thing, rootex.
12:34arrdemrootex: adding support for passes..
12:35arrdemrootex: bringing cljs and clj onto one compiler in the long term...
12:35arrdemrootex: potentially enabling cljc and other instanity on a common toolchain...
12:35mdrogalisarrdem: You mean additional compiler passes?
12:35tbaldridgemdrogalis: there are no passes currently. The sexprs get analzyed and that AST is compile directly to bytecode
12:35arrdemrootex: core.typed hooks into the compiler... the list goes on and on
12:36Bronsatbaldridge: sure, even not considering the benefits of having one unified infrastructure, it will be definitely easier to integrate t.a in the official compiler for cljs and will provide really useful testing before we can think of making a move for clojure
12:36Bronsaarrdem: actually, since yesterday core.typed uses tools.analyzer.jvm :P
12:36rootexarrdem: thanks
12:36arrdemmdrogalis: that is to say it punts on "real" compilation and analysis to the JIT.
12:36mdrogalistbaldridge: Oh, huh. I didn't know that.
12:37arrdemBronsa: right. since yesterday. which is awesome! congrats!
12:37mdrogalisInteresting.
12:37tbaldridgenice! And core.async is switched over in a branch. I haven't tried to switch over core.async CLJS yet.
12:38Bronsaso if 1.7 gets feature expressions, writing clj/cljs tools based on tools.analyzer will become so much easier
12:41arrdemmeh... I'm with Kevin here... platform specialization at read time feels dirty to me.
12:42Bronsaarrdem: it's not just platform specialization though. take tools.reader as an example
12:42Bronsatools.reader and tools.reader.edn are almost the same code
12:42ambrosebsarrdem: FWIW It seems both projects are equally valuable. The tool.analyzer one is probably better suited for the 3 month timeframe of GSoC.
12:43ambrosebsprobably worth investigating whether extending Compiler.java really is just a few weeks work.
12:43Bronsabut I had to do a lot of manual copy-pasting simply because tools.reader.edn doesn't support a bunch of read-macros
12:44asthasrRe the haskell discussion earlier, I haven't gotten far in it yet but so far "The Haskell Road to Programming, Maths, and Logic" is pretty good
12:44arrdemambrosebs: I'd agree with that... I have a spare week or two in my proposed schedule, so part of me was thinking about a rewrite to try and do the Compiler.java mucking about first, at the cost of letting the t.a work slip possibly.
12:44asthasrvery textbooky, with exercises, which is good for me
12:44Bronsawith feture expressions or something like that I could just write the code one time, prefix #-edn the clj specific read-macros and load that code in the two different namespaces with 'edn in *features*
12:46gfredericksdoes autocompletion work with cider yet?
12:46arrdemgfredericks: sorta...
12:46arrdemgfredericks: ac-nrepl is ported to cider and worked last time I loaded it
12:47gfredericksby just loading 'ac-nrepl' via marmalade?
12:48arrdem$google ac-nrepl github
12:48arrdemgfredericks: more or less
12:48arrdem~botsmack
12:48arrdemhttps://github.com/clojure-emacs/ac-nrepl
12:48gfredericksrightright
12:48gfrederickstrying that now
12:55ambrosebsarrdem: It would probably be safest to choose to dedicate the entire time to either Compiler.java or tools.analyzer. This seems to be what Daniel is suggesting.
12:56arrdemambrosebs: yep... after this conversation I think I'll reply and stick with tools.analyzer
12:56ambrosebsarrdem: for the safe of morale if anything
12:56ambrosebs*sake
12:57ambrosebsor go for the internship ;)
12:59hlshipIn Leiningen, is there a way to include a dependency w/o its transitive dependencies?
12:59pjstadighlship: you can specify exclusions
13:00technomancy:exclusions :* would be interesting
13:00pjstadighttps://github.com/technomancy/leiningen/blob/master/sample.project.clj#L48
13:00technomancybut currently not supported
13:01Bronsaah btw tbaldridge I never had the chance to thank you for the talk you gave at clojure/west, I saw it and it was really good
13:01hlshipJust switching from log4j to logback and it comes with a bunch of optional dependencies
13:01hlshiplein deps
13:01ambrosebstbaldridge: here here!
13:01hlship(woops, wrong window)
13:02Guest77325http://www.marketglory.com/strategygame/galahad1st for online gamers, if you didn't already, use this link to register on MerketGlory: a free2play financial strategy game where virtual currency can be converted into real money. It starts out slow but in time you can turn a good profit that is if you have the necessary patience to grow a little bit every day :P
13:02arrdemlawl @ spambot
13:03pjstadigwho would have ever guessed that Guest77325 could possibly be a spammer?
13:04tbaldridgeBronsa, ambrosebs: thanks!
13:04ambrosebstbaldridge: so I beat you to integrating tools.analyzer?
13:04tbaldridgeambrosebs: nah....I did my work a few months ago :-P
13:05ambrosebstbaldridge: ah didn't realise it was in master
13:05tbaldridgeI haven't published it yet though since I haven't figured out how I want to port over the CLJS macro
13:05tbaldridgeand no, it's in a branch
13:05ambrosebsunified analyser plz
13:05tbaldridgeI may end up shipping the JVM side before I port the JS side. Simply because any work I do will have to get re-done once Bronsa does his GSoC stuff
13:06tbaldridgewhat I need for the JS side is tools.analyzers.js
13:06ambrosebsthat would be handy
13:11tjdi'm organizing my "external state" with stu sierra's components library ... and i'm thinking of making a "config" componenet on which all other components depend. not sure if this is a stupid idea or not. any thoughts?
13:12stuartsierratjd: not stupid.
13:12tjdi'll take that as an authoritative answer :)
13:12tbaldridgea new age dawns for Microsoft?!?!? http://roslyn.codeplex.com/
13:12mdrogalistjd: I do it, it works great.
13:12stuartsierraIf getting the configuration requires calling an extra service like zookeeper then it would be very useful.
13:13jcromartieeverybody keeps saying they are having success with stu's component library
13:13stuartsierraIf your configuration is just data, like something you read from a file, then it might not be necessary to have a component for it.
13:13tjdso i've got (defrecord Database [config] ...) instead of (defrecord Database [host port username password dbname] ...)
13:14tjdstuartsierra: it's a file right now, but i am anticipating having to fetch it from an external resource in production
13:14tjdi feel like making it a component buys me that extensibility, for not a whole lot of upfront work
13:15stuartsierraThat sounds reasonable.
13:15tjdthanks for that library, btw :)
13:15stuartsierraYou're welcome.
13:16tjdi learned about it from your talk at clojure/west. i really appreciated how you talked about the tradeoffs at the end.
13:17stuartsierraI certainly don't want to claim that it's perfect. And there are some scenarios it deliberately doesn't try to handle
13:18otfromwhat are people using for charting in clojurescript & om? c2 seems to overlap a fair bit with om. Anyone have examples?
13:19danneuI have a forum built with datomic. Each post has a {:post/topic <TopicRef>} attribute. And right now to show a topic, I naively (-> (:topic/_post topic) (sort-by :post/uid) (paginate 10)). Is there a faster way to do this now that some topics have a huge number of posts?
13:21stuartsierradanneu: you can use the index APIs to iterate over posts lazily, instead of loading them all at once
13:22stuartsierraBut you can only read them in the natural sort order
13:29danneustuartsierra: would datomic ever support ordered sets on a has_many attribute? is that something people have ever asked about?
13:30stuartsierradanneu: storing ordered collections is certainly a question that comes up. I'm not aware of any specific plans
13:34danneustuartsierra: cool, thanks
13:35gfredericksarrdem: how do I start ac-nrepl manuall?
13:36arrdemgfredericks: er... you M-x cider-jack-in RET and then M-x ac-nrepl-setup I think.
13:36arrdemgfredericks: it's been a while.
13:39arrdemit's been a while and ac-nrepl was never too ahem tractable.
13:39arrdemit either worked or didn't and I never manage to bludgeon it into submission.
13:47ucbwhat's the best/most idiomatic way of doing a conditional (.method Object) call in a (doto...) block?
13:48justin_smith ucb: you could use cond-> but once you have conditionals you may just want to make a let block binding the object and returning the object
13:48ucbhrm, yeah
13:48TimMcucb: I think you don't.
13:49gfredericksTimMc: I used cond-> inside a doto once; should I be ashamed of myself?
13:49ucbTimMc: I'm all ears as to what's best here. I have a flag ala :config-the-thing? and I'd like the equivalent to (if do-the-thing? (.theThing Object) Object)
13:50justin_smith,(doto "hi" (cond-> string? (println :OK)))
13:50clojurebothi :OK\n"hi"
13:50TimMcYes, but not necessarily for that.
13:50ucberr, s/do-/config-/
13:57justin_smith,(cond-> :not-string string? println) ;what did I do wrong here?
13:57clojurebot:not-string\n
13:57ohcibihi, I'm having an NPE with this function: https://gist.github.com/ohcibi/9959348 it happens in line 5.. does anybody has an idea what could cause this? I tried around setting all params to nil with the expression in line 5, but the NPE wont happen on the repl then
13:58justin_smithfrom reading the doc string that should not have printed
13:58justin_smith,(doc cond->)
13:58clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
13:59justin_smithohcibi: probably the npe is happening on the call to <=
14:00ohcibijustin_smith: hm, good point.. thanks
14:00justin_smithkeyword as fn / = will not trigger an npe, ever
14:01justin_smithbut if (:weight input) or (:token ...) return nil, that would make <= thrown an npe
14:01stuartsierrajustin_smith: cond-> does not pass the threaded value to the test expression
14:01justin_smithahh, that would explain it, thanks
14:02stuartsierraIs there a place to report a spambot that sent me a private message?
14:02TimMc,(= (reify Object (equals [_ _] (throw (NullPointerException. "Oh yeah?")))) 5)
14:02clojurebot#<NullPointerException java.lang.NullPointerException: Oh yeah?>
14:02TimMcjustin_smith: ^
14:03justin_smithTimMc: fair enough, got me on a technicality
14:03TimMcThat's my job.
14:04a3gisyop! I've got a quick question: in the expression (f (+ 3 4)) where f is a macro, why is (+ 3 4) passed as a list and not evaluated first? Doesn't it behave like a function call?
14:04TimMcIt's also a plausible scenario if you have a data structure checking for equality by parts.
14:04gfredericksclojurebot: TimMc is a DSL for getting you on a technicality
14:04clojurebotAlles klar
14:04bbloomgfredericks: sounds like a high-concept talk-idea for TimMc in the making
14:04justin_smith~TimMc
14:04clojurebotTimMc is a DSL for getting you on a technicality
14:04TimMca3gis: Because that's what macros are for!
14:04Bronsastuartsierra: try #freenode
14:05a3gisTimMc: haha I know but I would expect it to evaluate (+ 3 4) unless I do (f '(+ 3 4)) if it behaves like a function call
14:05TimMca3gis: Macros take in code and spit out other code. The later is what is evaluated.
14:05TimMc*latter
14:06gfredericksbbloom: I'm a DSL for high-concept talk ideas
14:07a3gisTimMc: ok, but my point is that in the case of a function call, arguments are evaluated. So does the compiler somehow differentiate between a function call and a macro call and in the latter case does not evaluate the arguments (= quoted)?
14:07bbloomclojurebot: gfredricks is a DSL for seeding clojurebot with high-concept talk ideas
14:07clojurebotAck. Ack.
14:07bbloomd'oh typo
14:07ToxicFroga3gis: yes.
14:07bbloomclojurebot: gfredericks is a DSL for seeding clojurebot with high-concept talk ideas
14:07clojurebotOk.
14:07bbloomclojurebot: forget gfredricks
14:07clojurebotGabh mo leithscéal?
14:07ToxicFroga3gis: macros are executed as part of compilation and are passed the code being compiled, not the result of executing that code.
14:07justin_smith a3gis: yes, that is exactly why macros exist, otherwise things like fn and let and def would be very very ugly
14:07gfredericksclojurebot: bblum is a DSL for seeding clojurebot with fun facts about slightly mutated people
14:07clojurebot'Sea, mhuise.
14:07TimMca3gis: Yes, the compiler knows that f is a macro as it is compiling that expression.
14:07bbloom:-)
14:08ToxicFroga3gis: otherwise they would be heavily restricted - you would not, for example, be able to pass something "invalid" to a macro and have it generate valid code from it, which mostly defeats the purpose.
14:08gfredericksbbloom: that was how my name was spelled on the clojure 1.6 contributors slide at clojurewest
14:09bbloomgfredericks: i'll pretend like i wasn't too busy reveling in the presence of my own name to notice, such that i can blame that slide for my typo
14:09a3gisok, that makes things clearer, thanks! (and sorry if the answer was obvious, I just started looking at lisp-family languages)
14:09gfredericksbbloom: my revelry is that I wrote ->
14:10bbloomgfredericks: are you saying that invented that macro?
14:10ToxicFroggfredericks: wait, seriously?
14:10justin_smitha3gis: the easiest way to understand it may be to consider that macros are for creating syntax, and if the args were evaluated you wouldn't really be able to do anything with macros
14:10gfrederickswell I thought I did
14:10gfredericksgit blame is now telling me different
14:10TimMchttp://dev.clojure.org/jira/browse/CLJ-1121
14:11gfredericksI'll try github's git blame
14:11a3gisjustin_smith: yep; I mean I understand what macros are for, I just thought that the compiler wasn't making a distinction between function-calls and macros
14:11gfredericksoh right
14:11justin_smithgfredericks: github git blame often credits the one who did the merge rather than the author of the thing merged
14:11gfredericksI just didn't write the title line
14:11a3gisjustin_smith: but since macros need to be excecuted at compile time it makes sense
14:11gfredericksthis finds it: git blame src/clj/clojure/core.clj | grep -A10 'defmacro ->'
14:12hiredmanI wrote a macro early on with clojure called |> and I thought it was really clever, until I found out about -> and ->>
14:12ToxicFroghiredman: oh thank god it's not just me~
14:12TimMca3gis: There are languages where you can have different evaluation strategies with macros.
14:12ToxicFrogAlthough I wrote |> in Scala.
14:13rasmusto86bfa996 src/clj/clojure/core.clj 1552 (Gary Fredericks 2012-12-06 20:20:02 -0600
14:13TimMca3gis: Check out fexprs, I think?
14:13bbloomyou can tell git-blame --before or --follow or a few other things to trace changes back past attribution-overriding events
14:14a3gisTimMc: cool, thanks!
14:14justin_smithbbloom: cool
14:14TimMcMind you I don't understand fexprs, so I can't help you understand them. :-P
14:14a3gisTimMc: also, is it common in a clojure project to define your own macros? or only when you need a DSL for some reason?
14:14ToxicFrogAnyways, gfredericks, [-> ->> some-> some->>] all own. Thank you.
14:14bblooma3gis: not nearly as common as it would be in common lisp
14:14TimMcIt's relatively rare.
14:14gfredericksToxicFrog: I just rewrote them :P
14:15bblooma3gis: i'd expect a project with a few dozen public API functions to have 0 to 3 macros
14:15gfredericksI can't claim anything actually cool, just that git-blame thinks I'm cool
14:15a3gisright, that's pretty rare indeed
14:15justin_smitha3gis: in my opinion macros are mostly for the rankest beginners who want to know how the language works, and the people implementing language features, those in between should usually avoid them
14:15ToxicFrogAah
14:20a3gisjustin_smith: ok! one last thing: any advice for a beginner in lisp family languages?
14:21justin_smithmaybe visualize your program in terms of the flow of data from source to destination and the new versions created in between? I am sure the rest of the channel has better advice
14:21clojurebotExcuse me?
14:21marcuscreoI don’t think that’s how most lispers think of macro, justin_smith
14:21justin_smithmarcuscreo: yeah, I did mark it very much as my opinion :)
14:21marcuscreotrue!
14:21marcuscreo;-)
14:21technomancya3gis: when in doubt, macroexpand
14:22technomancywell, that and don't write macros
14:22gfredericksdon't *write* macros, expand them!
14:22arrdemI think yall could back off on the "macros are evil" tack and point out that the don't generally do anything _good_ instead...
14:22alandipertwrite macros, they're awesome! you'll know you've written too many when your program stops doing anything
14:23a3gishaha ok, noted.
14:23technomancyarrdem: well he's specifically asking for beginners
14:23bblooma3gis: if you're learning, write LOTS of macros... just don't ship them to people in libraries :-)
14:23gfredericksalways do the *right* thing and never do the *wrong* thing
14:23bblooma3gis: in fact, implement a simple lisp with macros
14:23tbaldridge(inc bbloom)
14:23bblooma3gis: there is no better way to learn
14:23technomancyIMO the homoiconicity stuff is overrated compared to the mental shift of splitting out the pure parts of a program from the imperative shell.
14:24technomancysyntax is superficial in comparison
14:24tbaldridgeand besides writing macros will get you used to syntax quote which is useful in so many places.
14:24michaniskinjust… wow. this conversation is preposterous
14:24a3gistechnomancy: what's the big selling point of clojure if not homoiconicity then?
14:24michaniskinmacros are a thing. accept it
14:24bbloomtechnomancy: maybe, but you can get that same mental shift from other languages
14:24gfredericksa3gis: immutable data structures
14:24a3gistechnomancy: you can do the whole functional/imperative separation in scala for example
14:24bbloomtechnomancy: or rather other families of languages
14:24technomancya3gis: well, *bad* syntax is a big impediment
14:25bbloomtechnomancy: homoiconic is not unique to lisp, but it's much easier to learn there
14:25technomancygood syntax just works
14:25joeltscala uses a ton of syntax.
14:25gfredericksScala is a DSL for making new syntax
14:25tbaldridgeWhen we write applications we want them to be extensible. I want my compiler to be the same. I'm just sad that Lisp doesn't go far enough (e.g. I can't extend the VM semantics)
14:25justin_smithgfredericks is a DSL for describing things as DSLs
14:25seangrovetechnomancy: In fact, I wish there were stronger ways of marking pure-from-impure functions
14:26gfredericksif you can't describe something as a DSL you're not trying hard enough
14:26technomancyseangrove: totally
14:26bbloomtbaldridge: contribute to eclj! fork that bad boy and start adding the "precision jit" :-)
14:26technomancyseangrove: after Option, I'd say isolating Unit is the most useful thing HM gets you
14:27gfredericksjustin_smith's lunch is a DSL for getting strawberry preserves all over your sleeve
14:27tbaldridgebbloom: It's on my list...
14:27coventryWhat is Option/Unit/HM?
14:27bbloomtbaldridge: i'm probably going to explore tools.emitter a bit before attempting jit. my code-gen skills suck generally
14:28gfredericksbbloom: hey this interesting
14:28technomancycoventry: HM is the hindley-milner type system; Option is a way of ensuring functions that may return None are handled correctly; Unit is the return type of a side effect.
14:29tbaldridgebbloom: nah, just emit clojure and run core/eval on it
14:29tbaldridgebbloom: that'll get you most of the way there.
14:29coventrytechnomancy: Ah, thanks.
14:29bbloomtbaldridge: haha that's not a bad idea... would work for js too
14:29a3giserm and on the whole functional programming side of things, do you guys have an opinion on clojure versus haskell?
14:29bbloomtbaldridge: i actually already do that in order to accomplish deftype
14:29tbaldridgebbloom: I noticed that last night
14:30bbloomtbaldridge: but sadly defprotocol doesn't work b/c it assumes a mutable method cache on the Function object... which my symbolic Fn record type doesn't have
14:31tbaldridgea3gis: .....that's like going to MoveOn.org and asking if people have an opinion on Obama vs Romney
14:31joelta3gis: opinion of what kind? if you are interested in Haskell, check out Elm language, I thought it was more approachable, even though its very similar.
14:31ToxicFroga3gis: I find Haskell more ideologically appealing but I actually get work done in Clojure.
14:32coventryYeah, I think Clojure is more pragmatic.
14:32joelta3gis: yeah i was going to say Clojure seems more practical than Haskell.
14:32tbaldridgea3gis: bbloom has a really balanced view about Haskell.....
14:32tbaldridge:-P
14:32bbloom:-P
14:32arrdemlolz
14:32amalloytechnomancy: calling Unit the return-type of a side effect doesn't seem right to me. it's a type inhabited by only one value; some side-effecting functions return Unit for lack of anything better to do, but stuff like read-data-from-file is a side effect whose return type is String (or whatever)
14:32arrdemfamously balanced.
14:33a3gistbaldridge: haha fair enough, I was just wondering because my uni is teaching haskell to freshers as an introduction to functional programming
14:33bbloomas much as i rag on haskell, i've learned a lot from it
14:33ToxicFrogYeah, that's kind of my attitude
14:33technomancyamalloy: true; maybe "the side effect of writes" is better
14:33ToxicFrogUsing Haskell has taught me a lot and given me more mental tools
14:33bbloomi view it as more of a wildly successful thought experiment than a language intended for use
14:34ToxicFrogBut I don't actually do anything with it other than learn new things
14:34ToxicFrogI then take those things and apply them to the languages I do actual work in
14:35joelta3gis: Haskell is "spooky" in that when you get the compiler to accept your program it runs correctly the first time, not something I'd say in any other language.
14:35bbloomjoelt: yeah, that's not true... at all
14:35bbloomcan we please kill that trope?
14:35joeltbbloom: I know I'm not the first to say it though.
14:35hiredmanbbloom: but it is an increasingly popular meme
14:36AverellIt's still closer to half-true than with other languages
14:36hiredmanbbloom: that is like the 4th or 5th time I've seen someone say it this week
14:36joeltI know first hand so I can't retract that statement.
14:36justin_smithsimilarly, natural language is remarkable because if you can manage to construct a grammatical sentence you can be sure the statement is true
14:36bbloomyou have to run your haskell compiler as many times (or more!) as i have to evaluate forms in my repl before you get a successful compile or i get a sane output....
14:36pjstadigFACT: if your code type checks it has no bugs
14:36tbaldridgeI suggest we give more time to another meme: "If that's the case then we should write every OS in Haskell. Then we'd never have a system fault again."
14:37rasmustojustin_smith: this statement is false
14:37bbloomrasmusto: that's his point...
14:37ToxicFrogI will say that Haskell and Scala both have a higher rate of working on the first run than any other languages I've used. Clojure with core.typed is probably #3.
14:37technomancyit's as silly to say that happens all the time as it is to say that it never happens
14:37michaniskinFACT: in Haskell you don't need tests, because the compiler is enough!
14:37tbaldridgeThat's because you're already debugged them.
14:37rasmustobbloom: i'm just connecting dots slowly today
14:37joeltof course its a false statement, but its also the experience you get with haskell.
14:37bbloomToxicFrog: yeah, what tbaldridge said echos what i was saying
14:38bodie_I get the sense that Haskell is less about programming and more about program definition.
14:38hiredmanyou can tell if you are in an echo chamber if suddenly as from nowhere the same thing is everywhere
14:38bbloomToxicFrog: mandatory static typing just means that you debug your programs before they run, rather than after they've run... frankly, i rather run them and SEE the bug than get an abstract description of a hypothetical bug
14:38bodie_if you can flawlessly define your program, Haskell will do the rest for you. :P
14:38yoheydere(new java.lang.ProcessBuilder "python")
14:38yoheydereIs that syntax correct?
14:38bbloombodie_: generally: most bugs are in the spec
14:39Averellthat is the worst argument against strong typing i ever heard :)
14:39joeltAverell: hear hear.
14:39arrdem.... are we getting invaded by #haskell today?
14:39arrdemwtf
14:39technomancystrong typing isn't a thing anyone actually argues against
14:39bodie_there's always Typed Clojure
14:39hiredman,(macroexpand '(Foo. "bar"))
14:39clojurebot(new Foo "bar")
14:39pjstadigtechnomancy: sigh
14:39bodie_most of the time, what you need is not a flawless program definition, but a good definition of what you want your program to actually do
14:39yoheydereBecause I get "No matching ctor for class java.lang.ProcessBuilder blah blah".
14:39bodie_in my opinion
14:39bbloomAverell: i'm not arguing against strong typing, i'm arguing in favor of delayed verification
14:40technomancy,(+ 12 "hello") ; hello strong types
14:40clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
14:40bodie_lol
14:40bbloomfrankly, core.typed is too little too late. a next gen dynamic language should come with a modern type system baked in, not as an after thought
14:40hiredmanyoheydere: the processbuilder construct takes either a list of strings, or a java vararg of strings (which means it takes an array of strings)
14:40a3gisok I think I got the general feeling about haskell on this chan xD
14:40bodie_see, you shouldn't have tried to add 12 and "hello" ;)
14:40yoheyderehiredman: I see, thanks.
14:40tbaldridgeThis is when I link this video
14:40Averellfine, i was lax with my terminology. seeing the crash at runtime is still worse.
14:40tbaldridgehttps://www.destroyallsoftware.com/talks/useing-youre-types-good
14:41bbloomAverell: compile time is just run time for the compiler
14:41bbloomexceptions aren't crashes...
14:41arrdemtbaldridge: oh gods...
14:41bodie_clearly technomancy's program definition was poor
14:42bodie_Clojure lets that be your responsibility
14:42bodie_Haskell doesn't
14:42ToxicFrogbbloom: in general I would much rather see the potential bug at compile time, because seeing it at runtime is not, generally, reliable. The bugs that make me swear at dynamic typing aren't the ones where it dies instantly with an obvious stack trace, it's the one where it fails one time in a thousand when it hits a rarely-used codepath that your tests missed.
14:42bodie_there's a good argument for each, respectively
14:42ToxicFrogBut which would trivial fail typechecking.
14:42ToxicFrog*trivially.
14:43Averelli don't think that you rather have runtime failures is one of the good ones.
14:43bodie_again, if your tests missed it, Clojure would say that's your problem, not the compiler's
14:43ToxicFrog< tbaldridge> That's because you're already debugged them. -- Yes. I am saying that I like debugging my code before it actually runs.
14:43bbloomToxicFrog: so run a type checker as part of your test suite....
14:44gtraktbaldridge: genius!
14:44bbloomToxicFrog: i'd rather not be interrupted by the global type checker while i'm solving a local problem. i don't care if the bug is caught at compile or run time, i care that they are NOT caught during unrelated-development-time. as long as they are caught at before-deploy-time i'm happy
14:44ToxicFrogbbloom: with scala and haskell, I get that for free at compile time. With Clojure, I get it with core.typed. But not all dynamically typed languages have useful static type checkers.
14:45a3gistbaldridge: hahaha gary bernhardt is always a lot of fun
14:45bbloomToxicFrog: consider javascript.... you can pick what type system you want
14:45bbloomToxicFrog: jshint is essentially a bag of ad-hoc type systems
14:46bbloomor you can pick Google Closure compiler
14:46bbloomwhich has a real type system
14:46bbloomthe problem isn't static vs dynamic, the problem is cultural
14:46ToxicFrogI'm not sure why you assumed I'm using javascript.
14:46bbloomis there a *default* and automatically available type checker
14:46bbloomi didn't assume that, i said "consider"
14:46bodie_javascript is the ultimate sloppy dynamic language, just a good example :P
14:46joeltbodie_: ++
14:46bbloomjshint catches lots of dumb bugs
14:47bbloomif js was a better designed language, jshint could catch more bugs
14:47ToxicFrogYes, and so does core.typed. Neither are available for, for example, Lua.
14:47bbloomhttps://github.com/philips/lualint
14:47bodie_i wonder what language that is written in
14:47bodie_lua... interesting
14:47bbloomlol that was just a random result
14:47bbloomnot saying that's any good
14:47arrdemcore.typed catches dumb bugs.. when you can explain the types of what you are doing to it.
14:47pjstadigi'm just glad that static type systems catch all kinds of bugs like buffer overflows, and sql injection, divide by zero errors and stuff
14:48arrdempjstadig: I mean.. that's all stuff that you could do with a real userspace dataflow analysis like the Broadway compiler..
14:48gtrakimplements NonSQLInjectable
14:48bodie_sql injection isn't a bug, it's a feature
14:48bodie_:P
14:48bbloompjstadig: there are type systems for catching those sorts of bugs! for example, microsoft has a c++ verifier for driver code: http://msdn.microsoft.com/en-us/library/windows/hardware/hh454825(v=vs.85).aspx
14:48arrdempjstadig: and you can totally do taint analysis with Haskell's types, it's just awkward :P
14:49pjstadigwell good
14:49pjstadigthen it's an easy sell
14:49bbloomToxicFrog: my point is that i favor optional, pluggable, modular type systems that *do not influence semantics* and live in the term language, not a separate type language
14:49arrdembodie_: quiet in the peanut gallery, string formats are never a legitimate technique for code generation
14:49bodie_you can do a lot of things awkwardly in haskell
14:49technomancyur/web has a type system that prevents internal links from 404ing
14:49pjstadigobviously there are no downsides, and only upsides
14:49bbloomtechnomancy: haha that's kinda awesome
14:49arrdempjstadig: lulz...
14:50bodie_I get the sense that Haskell is all about right implementation while clojure is all about right action
14:50gtrakarrdem: sarcastic or have you not seen the cljs compiler?
14:51bodie_the drawback there is that "right implementation" is a really broad subject which requires you leave no stone unturned
14:51bodie_while right action is only as complex as it needs to be
14:51arrdemgtrak: I can imagine the CLJS compiler, and I still hold that opinion firmly.
14:51bbloomgtrak: that's by far the worst part of the cljs compiler :-P
14:51bbloomgtrak: sadly we depend on gclosure & they don't have a stable AST
14:52gtrakwell, someone's gotta be doing the concatenation, might as well be us.
14:52arrdemgtrak: that isn't to say I'm clean of the sin of string code generation, but acknowledge your sins for what they are :P
14:52arrdem especially when I come sailing by with the sqlmap/sqldump lulz boat
14:53danstoneSooo.... immutant, anybody using it? - tried spinning up connecting to my instance (fresh out the box) immediately gotten an error with core.cache/memoize deps... :S
14:53arrdemhttp://securityreactions.tumblr.com/post/81592960057/this-is-our-production-network-so-be-careful
14:55gtrakbbloom: yea.. I followed that rabbit hole myself trying to implement a feature in austin, tell me about it :-)
14:56dnolen_bbloom: gtrak: still not convinced that generating a proper JS AST has any real value beyond pointless NIH over the person years poured into Closure
14:56gtrakwas trying to reload a browser repl on refresh with compiled cljs state, got stuck on a crazy gclosure stacktrace.
14:56gtrakmight settle for just clearing out the compiler state on refresh
14:57gtrakcouldn't figure out how to just take that as input and generate the right stuff to run it through the optimizer.
14:57bbloomdnolen_: agreed. you already know my position, but i'll reiterate for onlookers
14:58bbloomcreating a proper JS AST is only a good idea if we do all the optimizations on the CLJ side and have no need to optimize the outputted JS
14:58tcrawley-awaydanstone: come see us in #immutant and we'll see about getting you fixed up
14:58bbloomwould be nice to have the JS AST as data so that the emitter can be functionally pure, but that's one of those "ew it feels icky" things that doesn't actually matter for a successful compiler
14:58dnolen_case in point Uglify is a total joke compared to Closure on Closure optimized source http://gist.github.com/swannodette/9939192
15:00dnolen_gtrak: have you look at my CLJS analyzer/compiler tutorial - it ends w/ putting the source through Closure optimization
15:00dnolen_gtrak: though I don't see why you want that in a REPL context really
15:01dnolen_(but maybe I missed something)
15:02gtrakdnolen_: I'll take a look, I was reverse engineering the closure/build function.
15:03gtrakin a repl context, it would effectively provide the same state at the start that running a polling cljsbuild would give, though maybe I could just hack that in instead.
15:04dnolen_gtrak: closure/build is a bad place to start for anything do w/ the REPL
15:04dnolen_gtrak: https://github.com/swannodette/hello-cljsc/blob/master/src/hello_cljsc/core.clj#L317
15:05gtrakyea, I get what you're saying, but here's why I looked there :-): https://github.com/cemerick/austin/blob/master/src/clj/cemerick/austin.clj#L327
15:05gtrakhit my head on it for about 6 hours, learned a lot :-)
15:05gtrakso I was trying to concatenate the :compiled-cljs stored in analysis state with that repl bootstrap snippet.
15:12gtrakran into issues with dependency ordering, so i found the relevant functions, ran into an issue with a closure prelude, fixed that, then hit a weird exception in closure itself.
15:14gtraklooked a lot like this one: https://github.com/emezeske/lein-cljsbuild/issues/155 java.lang.NullPointerException: Compiler.java:945 com.google.javascript.jscomp.Compiler.newTracer
15:22dokyhello does anybody know how to swap list ? to update it when i remove/add item ?
15:23gtrakdoky: huh?
15:23brunov(def t (f t))?
15:24dokygtrak: is it possible ? or only define new ?
15:24gtrakdoky: you mean like a state-change?
15:24coventrydoky: Do you understand about persistant data structures?
15:24dokygtrak: yes
15:24arrdemcoventry: we just set! everything, right?
15:25gtraktry to express it as a lazy seq, first, then if you really need it, an atom or something.
15:25dokygtrak: ah ok thanks i will try it
15:26gtrakdoky: maybe helpful ##(take 10 (iterate inc 0)))
15:26gtrak,(take 10 (iterate inc 0)))
15:26clojurebot(0 1 2 3 4 ...)
15:27gtrak,(reductions + (range 10))
15:27clojurebot(0 1 3 6 10 ...)
15:28dokygtrak: i have list of user and need to decide who isnt/is in list when i get new data
15:28gtrakdoky: sounds like a great use-case for filter
15:28dokygtrak: maybe it will works with drop to remove then ? or maybe filter ?
15:29dokygtrak: as you wrote
15:29gtrak,(filter even? (range 10))
15:29clojurebot(0 2 4 6 8)
15:29gtrak,(remove even? (range 10))
15:29clojurebot(1 3 5 7 9)
15:30dokygtrak: hmm ... i will think how to check two lists with it
15:46CapitalSigmahello all
15:48CapitalSigmawhat's the proper way to map a java method over a list of objects? i was expecting "(map (fn [x] (.toUpperCase java.lang.String x)) ["some" "strings" "here"])" but that isn't working
15:48jcromartie,(.toUpperCase "x")
15:48clojurebot"X"
15:48jcromartie,(map #(.toUpperCase %) ["some" "strings"])
15:48clojurebot("SOME" "STRINGS")
15:50CapitalSigmaah, okay. so i don't need to specify the type? if i had two different types of objects that both implement a .toUpperCase method, will clojure call the appropriate one on each?
15:50jcromartieand #(foo %) is just a shorthand for (fn [x] (foo x))
15:50jcromartieCapitalSigma: yes, it will
15:50CapitalSigmai.e. is clojure duck typed in some sense
15:50CapitalSigmainteresting, thanks
15:50jcromartiereflection and some type hints
15:51jcromartiefor instance, if you were to go in your REPL and say:
15:51jcromartie(set! *warn-on-reflection* true)
15:51jcromartieand then compile:
15:51jcromartie(fn [x] (.toUpperCase x))
15:51jcromartieyou would see that reflection is needed to resolve .toUpperCase
15:51jcromartiebut, if you defined:
15:52jcromartie(fn [^String x] (.toUpperCase x)) then Clojure will compile the function and treat the Clojure local x as an object of class String
15:52jcromartieand it will resolve to String.toUpperCase
15:52jcromartieyou mostly don't have to worry about this
15:53CapitalSigmaah, okay. yeah i can't imagine that i would be disturbed by it -- i'm just very recently looking in to clojure and i'm curious
15:54jcromartie,(let [f (fn [x] (.toUpperCase x))] (time (count (doall (map f (repeat 10000 "hello"))))))
15:54clojurebot"Elapsed time: 139.511392 msecs"\n10000
15:54jcromartie,(let [f (fn [^String x] (.toUpperCase x))] (time (count (doall (map f (repeat 10000 "hello"))))))
15:54clojurebot"Elapsed time: 9.302624 msecs"\n10000
15:54CapitalSigmawow, that's a pretty big difference
15:54jcromartiebut try to only worry about it if you notice that your interop code is slow :)
15:55jcromartieit's doing a silly thing 10K times
15:55CapitalSigmamakes sense. that's good to know
16:10tuftjust read that steve yegge software political spectrum essay. funny but also strangely satisfying to see clojure in the "conservative" category
16:10jcromartieclojure is all over the chart
16:10gtraktuft: I like a lot of stuff he writes, but that one was really weird.
16:10lemonodor“A news feed of Clojure GitHub repos being talked about on Twitter”: https://twitter.com/github_clj
16:11jcromartieyou can import a library and have a subset of your code be extremely conservative
16:11tuftjcromartie: yeah it was the difficulty in classification that was the satisfying part i think
16:11jcromartiewhile other parts throw caution entirely to the wind
16:11jcromartiehttp://content.worldcarfans.co/2013/7/30/big/1270233903587876992.jpg
16:11gtrakdidn't have any zing value like the kindgom of nouns or the 'all class members are now public' essays.
16:11tuftgtrak: yeah -- he made it sound like clojure was a front for haskell or something, heh
16:12gtrakjust forced and bizarre
16:12technomancytuft: there's some backstory to that which he didn't refer to in the post
16:13cbpgtrak: I thought he had gone completely insane after that post :-P
16:13technomancytuft: https://groups.google.com/forum/#!topic/seajure/GLqhj_2915A
16:13technomancy"I tend to blog when I get upset enough about something, so left unchecked
16:13technomancyI will most likely produce a volcanic rant about how Clojure is deliberately
16:13technomancytrying to fend away potential new users with a shotgun and a mean glare."
16:13technomancyoops
16:14gtrakthe yes-lang stuff?
16:14technomancyyeah
16:14gtrakhaha
16:14gtrakI loved that
16:14technomancyI mean, this was the thread that led up to that
16:14gtrakclearly we should remove all lines on the road for fear of them 'limiting' us.
16:15gtrakwell, I'd be ok with getting rid of stoplights, actually.
16:15gtrakat least in some cases :-)
16:15mdrogalisJust looked up Steve Yegge to find something and ran across this: "Clojure is strongly conservative, with a core overriding bias towards protecting programmers from mistakes."
16:15mdrogalisI.. Don't agree with that at all.
16:15mdrogalisThe second part I mean
16:16technomancymdrogalis: yeah, he's just got a bone to pick
16:16coventryMistakes arising from state management, maybe...
16:16mdrogalistechnomancy: I was actually digging for the Seajure post you were telling me about. :P
16:17gtrakthing is, clojure doesn't actually prevent you from doing anything.
16:17technomancymdrogalis: get some popcorn too while you're at it
16:17technomancygtrak: he's talking about batshit stuff like for loops
16:17gtrakit just makes certain favored things much easier to do, but EVERYTHING is easier than in java.
16:18mdrogalisI think I found it, given that Rich posted
16:18technomancyhe's also talking about the community more than the language
16:18michaniskinand macros are money in the bank
16:18mdrogalishttps://groups.google.com/forum/#!msg/seajure/GLqhj_2915A/E0crn6zHLi0J
16:18gtraklike.. immutability needs to be idiomatic and easy, and it normally isn't.
16:18gtrakclojure fixes that, but we can still write to java fields.
16:18technomancylike, you can write an imperative for macro, and people will make fun of you. and he's saying that's bad.
16:18gtrakif it's sufficiently clever and horrible, I'd applaud it again :-)
16:19brehautlols about a language ‘protecting programmers from mistakes’ without AR static types and also including nil
16:19mdrogalistechnomancy: God. lol "How do we make you more upset?"
16:20mdrogalisPeople are just egging him on
16:20technomancythe problem is he's conflating clojure's policy of saying no to ptaches with the clojure community's policy of rejecting bad ideas
16:20gtrak'Whenever I've blogged like that in the past it has been *incredibly* effective. People pay attention and get to work fixing whatever I ranted about.'
16:21gtrakit's been 3 years already..
16:21mdrogalisI feel like I'm watching a movie as I read this.
16:23gtrakwell, debugger tooling sounds like a good thing, we're still working on that.
16:23gtrakbut we need it less b/c of immutability ;-)
16:23mdrogalisSo what I don't get, technomancy, is why he got upset in the first place? Did someone PO him and he just went crazy?
16:23technomancyactually it kind of sounds like he half meant to write this post: http://sealedabstract.com/rants/conduct-unbecoming-of-a-hacker/ but then got distracted with some other things and wrote something completely preposterous instead
16:23mdrogalisOr is he always like this?
16:24mdrogalisHahah
16:24technomancyall the stuff that actually makes sense that he's talking about is covered in the post above, but none of the crazy parts
16:24technomancymdrogalis: he was very reasonable when we were talking in person
16:25technomancy(which is exactly the opposite of how you're supposed to do it; the optimal way is to say all your crazy inflammatory shit in person and be very reasonable and level in posts which are public record forever)
16:25lemonodori read “"How do we make you more upset?” as someone hoping that yegge would give more details about his criticisms because they expected them to be worthwhile, not egging on.
16:25brehauttechnomancy: he seems to be afflicted with being able to type exactly as fast as he can think
16:25technomancy#lifehacks
16:25lemonodori met erik naggum in person. he was very friendly.
16:25technomancyhehe
16:26lemonodorlots of smiles.
16:26mdrogalislemonodor: I'm an instrigator - my perspective :)
16:26mdrogalisInstigator*
16:26brehautis that an aligator that goes left and right ?
16:27brehautwait that would be an instagator
16:29mdrogalis*Skips to part where Rich replies*
16:30technomancymdrogalis: there's more lulz in the HN thread too
16:30jcromartie(inc mdrogalis)
16:30mdrogalisWork day - shot
16:30technomancyI vaguely recall that going further off the deep end
16:31therikhello
16:32mdrogalisWell that was mildly entertaining.
16:40a3giserm why isn't defn a macro?
16:40gtrakit is
16:40tbaldridgea3gis: it is
16:41justin_smith,,(:macro (meta #'defn))
16:41gtraka3gis: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L318
16:41clojurebottrue
16:41gtrakdefmacro is later ;-)
16:41mdrogalisDon't tell Steve Yegge that.
16:42gtraktrue.. he'd want a forward declaration there too. stupid single-pass compilers
16:42gtrakthat make code readable
16:42justin_smith,(map first (filter (comp :macro meta second) (ns-publics 'clojure.core)))
16:42clojurebot(when-first cond->> gen-class while import ...)
16:43justin_smitha3gis: in a repl the above will list all macros in clojure.core
16:43a3gisjustin_smith: (macroexpand (defn hello [x] (* 2 x))) returns #'user/hello though?
16:44gtraka3gis: quote it
16:44justin_smitha3gis: quote it
16:44justin_smithjynx
16:44justin_smith,(macroexpand '(defn hello [x] (* 2 x)))
16:44clojurebot(def hello (clojure.core/fn ([x] (* 2 x))))
16:44a3gisoh right; great thanks!
16:44mdrogalis,(doc when-first)
16:44clojurebot"([bindings & body]); bindings => x xs Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once"
16:45a3gisan argument to macroexpand should always be quoted justin_smith?
16:45justin_smitha3gis: as far as I know? I wonder about the exceptions
16:46a3gisjustin_smith: k; I don't really get when something should be quoted or not. I mean, I do get that quoted avoids evaluation, but as I asked earlier if you have (f (+ 3 4)) where f is a macro I would also expect the argument to be quoted
16:46sritchiea3gis: macroexpand isn't a macro
16:47gtraka3gis: you have to understand what actually happens underneath
16:47gtrakreader reads it into data, eval evals it, macroexpansion happens at that point.
16:47coventryYou might not want to quote the input to macroexpand if you're testing some code-generation function.
16:47gtrakcodegen emits jvm bytecode, object is instantiated, that's what you get as a return value.
16:48gtrakquoted just means, don't eval it.
16:48a3gisoh right, ok
16:49gtrakmacros see it as the same data structures that the reader emits
16:49gtrakand it happens at a different time than a function call, that's the 'compile-time'.
16:50gtrakyou can grab the function value of a macro and call it yourself as a function if you're really curious ;-)
16:50gtrakthere are some extra args in the front, but it can just take data.
16:51gtrakhere we go :-)
16:52gtrak,(@#'defmacro nil nil nil)
16:52clojurebot(do (clojure.core/defn nil) (. (var nil) (setMacro)) (var nil))
16:53blake__&(reduce max (map count '( #{} #{:1} #{:1 :2} #{:1 :2 :3})))
16:53a3gisgtrak: right; I find it a bit confusing to have parts of your code which is executed in a different phase but I guess I will get used to it :p
16:53blake__,(reduce max (map count '( #{} #{:1} #{:1 :2} #{:1 :2 :3})))
16:53clojurebot3
16:54dokyi'm trying to find out how to use filter function, can anybody help me with this small example ? https://www.refheap.com/71178
16:54blake__Hey, if I have the above situation, but I want the set the with three elements rather than just the number itself...Do I have to filter that or is there a better way?
16:55rasmustoyou can use (set ["viktor" "jana"])
16:55blake__Set! I was gonna say "into #{}"...
16:55dokyrasmusto: thank you :)
16:56justin_smithdoky: maybe you want remove rather than filter there
16:56rasmustodoky: you can also use a set directly as a predicate
16:56justin_smithbecause u should be empty
16:56rasmusto,(remove #{"a" "b"} ["a" "c" "b" "d"])
16:56clojurebot("c" "d")
16:57justin_smithdoky: oh, never mind, reading failure
16:57a3gisgtrak: mmh mind to explain what "@#'" means here?
16:57bbloomtechnomancy: aw man, i missed the steve yeggie rant. i didn't get a chance to link to https://en.wikipedia.org/wiki/Steve_Yegge#Server-side_JavaScript and mention how i know ppl that i really respect who worked with him at google and wrote him off as a crazy person
16:57gtraksteve yegge would be proud
16:57clojurebotExcuse me?
16:57justin_smiththough remove would eliminate the need to use not
16:57dokyrasmusto: yes i really want to do it thanks
16:57dokyjustin_smith: no problem
16:58gtraka3gis: #' means the var, @ derefs it to get the function, lemme see if it works with out that.
16:58gtrakah yea, deref isn't needed
16:58a3gisgtrak: so that's a special form?
16:58gtrakyea
16:58gtrak#' is a reader macro
16:59gtrakand so is @, but you could also use (deref ..) and (var ..)
16:59technomancybbloom: I love how that was seen as really forward-thinking and visionary by a lot of people
16:59gtraka3gis: while we're on the subject, reader macros work at read-time
16:59gtrakbefore compile-time even
16:59gtrak,(read-string "@a")
16:59clojurebot(clojure.core/deref a)
16:59a3gisgtrak: I was actually googling that
17:00coventryWhat's the selling point for server-side js, anyway? Just that you can have the same language on client and server?
17:00bbloomtechnomancy: i think he's proof that if you write A LOT and try to avoid saying anything too stupid, then people will find SOMETHING to agree with you about
17:00bbloomtechnomancy: it's like politics, you just tell everybody what they want to hear & they'll ignore all the stuff they don't care about
17:00blake__coventry: Yeah, pretty much. You can share libraries and what-not.
17:01gtrakcoventry: we can get our lean-runtime with cljs on nashorn :-)
17:01gtraknot sure if that's actually leaner yet
17:01technomancybbloom: his posts about emacs are actually really good
17:02bbloomtechnomancy: you're proving my point :-P
17:02technomancysure =)
17:06justin_smithcoventry: it means that one guy can do client and server sides of a small app, in terms of workplace flow it can boost productivity
17:07justin_smithand reduce the need for an design that isn't duct tape and string :)
17:07a3gisgtrak: erm so with a reader macro you could potentially parse json into maps or something like that?
17:07gtraka3gis: yea, cljs has one that does the opposite
17:08coventryjustin_smith: Because it cuts down on communication costs? I guess that makes sense.
17:08gtraka3gis: http://dev.clojure.org/jira/browse/CLJS-717
17:08justin_smithcoventry: and the inefficiencies that can come with collaboration
17:08gtraka3gis: 'tagged literals' are just a special, extensible reader macro
17:09a3gisgtrak: wait so you could literally embed anything inside a clojure program (like xml literals in scala) with the appropriate read macro?!
17:09gtrakhrm.. I think it still has to be valid clojure data
17:09a3gisoh ok
17:10gtrakbecause that just gets passed into a function at read-time, and the reader has to understand how to parse it
17:10justin_smitha3gis: it would confuse emacs, thus it would not fly
17:10justin_smith:)
17:10a3gisjustin_smith: as long as it doesn't confuse vim...
17:10tufthow does one set up read macros, btw? i was trying to use some datomic # literals the other day and couldn't figure it out...
17:10gtrakie, you can't specify what's a token or not, just how to deal with the data.
17:11a3gisgtrak: right that makes sense
17:12gtraktuft: http://clojure.org/reader#The Reader--Tagged Literals
17:13sritchiea3gis: that's how it is in common lisp, btw
17:13sritchieyou can embed, like, XML or Python directly, and have the reader macro parse it into valid data
17:13a3gissritchie: clojure is the first lisp-family language I am learning though
17:13a3gissritchie: but if you can do that kind of thing it's really cool :o
17:14gtrakslightly terrifying :-)
17:14gtrakI balk enough at DSL's as it is
17:14sritchie:)
17:14a3gishaha well I didn't say you should actually use it but it's nice to have that power
17:16gtrakyou can get it here, just not inline in the source
17:16gtrakor use your own reader :-)
17:17tuftgtrak: thanks
17:17gtrakor just embed python, we're on the jvm
17:32lemonodorbbloom: when i was at google, i didn’t work with yegge but he created some really useful tools and his posts (“we don’t get platforms”) etc. were pretty right on
17:32bbloomlemonodor: i'm not saying he's of no value, he's written some things i quite like
17:35blake__Aha!
17:35blake__,(last (sort-by count '( #{} #{:1} #{:1 :2} #{:1 :2 :3})))
17:35clojurebot#{:1 :2 :3}
17:36amalloyblake__: ##(doc max-key)
17:36amalloyRaynes: lazybot still seems to be having trouble talking
17:36amalloy,(doc max-key)
17:36clojurebot"([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
17:36Raynes$kill
17:36Raynesbops*
17:37Raynes$kill
17:37Raynesplz
17:37lazybotKILL IT WITH FIRE!
17:37RaynesThnx
17:38RaynesIt isn't.
17:38blake__amalloy: That doesn't look like the same to me. I guess could map count and then use it?
17:38amalloy&(max-key count #{} #{:1} #{:1 :2} #{:1 :2 :3})
17:38lazybot⇒ #{:1 :3 :2}
17:39blake__So...clearly it is. =P
17:40blake__Oh, okay. Literacy problem.
17:40justin_smithblake__: you would need to use apply if all of the things are in a list
17:40gtrakI have never used that function
17:41gtraklooks useful though :-)
17:41gtrakreminds me of the github based clojure.core heatmap I want to write.
17:41blake__Wait, my real example is giving me a different result.
17:42amalloyblake__: you probably made the mistake justin_smith just warned about
17:42blake__the apply?
17:42amalloyindeed
17:42bbloom&(max-key count [#{} #{:1} #{:1 :2} #{:1 :2 :3}])
17:42lazybot⇒ [#{} #{:1} #{:1 :2} #{:1 :3 :2}]
17:42bbloom&(apply max-key count [#{} #{:1} #{:1 :2} #{:1 :2 :3}])
17:42lazybot⇒ #{:1 :3 :2}
17:44blake__OK, that works. WTF was I getting before? *puzzles*
17:44blake__Everything? %^P
17:46blake__Oh...okay, so without the apply, I have just one item of everything, which is returned.
17:48justin_smithright
17:49justin_smithnesting levels, the hurdle that trips every learner at least 100 times
17:49blake__Hey...only 87 times to go...
17:51gtrakget used to it, it's lisp after all
17:51TravisDooh, get used to what? I just joined
17:51gtraktraversing levels of nestedness :-)
17:52gtrakwith your mind!
17:52justin_smithand errors caused by anticipating the wrong level of nestedness
17:52TravisDis nestedness really a lisp thing?
17:52blake__I'm getting there.
17:52gtrakmaybe just the uniformity of the nesting
17:52blake__lists of lists
17:52justin_smithTravisD: in another language it would be method not found / type errors
17:53gtrakmakes it look like a bowl of macaroni
17:53gtrakinstead of OO spaghetti
17:53TravisDjustin_smith: I wasn't here for the earlier conversation. Not sure what errors are being discussed
17:53justin_smithfor dinner I will have ravioli, stuffed with ravioli, stuffed with ravioli, stuffed with nil
17:53justin_smithahh, just generic "too many / few levels of sequence expected"
17:53gtrakyou can't unsee it: http://images.pictureshunt.com/pics/m/macaroni-5853.jpg
17:53pjstadigmmmm ... spaghetti O's
17:54TravisDgtrak: Heh. All those little delicious parens
17:57brehautadding ‘cat throws up on the carpet’ to list of things that take me out of the coding zone
17:59yediin om: i have a block of text (with new lines, other spaces). I also have a map with a mapping from index of a word in the text=> to color. I want each word in the block of text to have a background color according to the word=>color mapping
18:00yedii was going to create a function that returned a span wrapping the word with the proper color applied. and then map that function to the text split on whitespace
18:00yedihowever when rednering this, all the whitespace would get removed
18:00yediis there a better way to accomplish this and preserve white space
18:01justin_smithyedi: convert white spaces to html entities representing white space as appropriate?
18:02coventryTry (apply str (interpose " " spans))
18:02amalloycoventry: never (apply str (interpose anything)) - it's just clojure.string/join
18:02coventryOh, I guess str isn't appropriate anyway.
18:03coventryThanks, had forgotten about join.
18:03yedijustin_smith coventry amalloy: here's some starting code: https://gist.github.com/yedi/9963775
18:04gtrakstaring at the macaroni makes me both uncomfortable and excited.
18:04yedimy main issue is that i have to get rid of the whitespace in order for the indexes to be correct. (since the indexes are only for words)
18:04gtrakuncomfortable because of the disorganization, excited because of the possibilities.
18:05yediit'd be cool if i could split on whitespace but still retain the whitespace info. and then call the word-span fn on just words (while preserving the index correctly), and render the whitespace normally
18:05yedinot sure if any of that made sense
18:08amalloyyedi: i mean, there's partition-by
18:08blake__yedi: Don't you retain the whitespace info by virtue of still having the original immutable string around?
18:08justin_smith,(partition-by #{\space \tab \newline} "this is a string\nwhatever")
18:08clojurebot((\t \h \i \s) (\space) (\i \s) (\space \space) (\a) ...)
18:08justin_smiththat could help?
18:08coventry(do (require '[clojure.string :as s]) (s/split "foo bar baz" #"\b"))
18:08coventry,(do (require '[clojure.string :as s]) (s/split "foo bar baz" #"\b"))
18:08clojurebot["" "foo" " " "bar" " " ...]
18:09coventryThat's going to break on punctuation, though.
18:09dokyis it possible to to extract from set of maps -> list of values for key (for example :name) ?
18:10dokywithout to do it through sequence ?
18:10justin_smith(map :name #{{:name "a"} {:name "b"}}) ; don't know if you mean set of maps literally
18:10justin_smith,(map :name #{{:name "a"} {:name "b"}}) ; don't know if you mean set of maps literally
18:10clojurebot("b" "a")
18:10yedithanks for the help guys, partition-by looks promising as well splitting on \b
18:11justin_smithif you can make native string/regex stuff work, that will perform better
18:11dokyjustin_smith: woow thanks :)
18:14justin_smithdoky: yeah, clojure is good at that kind of stuff
18:14dokyjustin_smith: yes it is but im not as good as i should :)
18:15dokyjustin_smith: i think that sometimes it os really hard to construct this stuff
18:16gtrakdoky: you just gotta memorize clojure.core, 4clojure will help with muscle-memory.
18:16AimHereWell the clojure cheatsheet is my go-to clojure reference
18:16AimHereFor those bits I never quite memorize
18:17dokygtrak: AimHere thanks i will try it :)
18:35yedigawd i just love the repl
18:36justin_smithyedi: indeed, I think large numbers of small rewarding tasks is pretty much the perfect structure for acquiring a skill
18:37justin_smith(or solving specific problems for that matter)
18:39brehautwith Om, how do you make render output two sibling nodes without wrapping them in some container element?
18:40seangrovebrehaut: You'll need to wrap them
18:40brehautseangrove: well, thats a bit pants then
18:40Guest88442hello, learning clojure right now, what does ^ mean? i.e. ^HtmlPage
18:40seangroveIt is what it is
18:40brehautGuest53104: metadata
18:40Guest88442Metadata>
18:40Guest88442?
18:41brehautGuest53104: it associates the metadata {:tag HtmlPage} with the following form. 
18:41justin_smithspecifically in that case, it is a type hint, telling the compiler what type a binding should have
18:41justin_smithor maybe not?
18:41brehautjustin_smith: s/should/probably/
18:42justin_smithahh, right
18:42Guest88442What exactly can metadata be used for?
18:42justin_smithto prevent type reflection
18:42justin_smithto allow unboxing
18:42brehautGuest53104: anything you like. the compiler uses it for abunch of things like doctypes, type hints
18:42justin_smithto mark forms as macros
18:42brehautGuest53104: its also used for contracts (pre and post conditions)
18:43technomancyto track who you're calling on the phone, for evil NSA usage
18:43justin_smithadd documentation strings
18:43justin_smithetc.
18:43justin_smith,(meta #'meta) ; you can use meta to see metadata
18:43clojurebot{:ns #<Namespace clojure.core>, :name meta, :added "1.0", :file "clojure/core.clj", :static true, ...}
18:43justin_smith(meta #'meta) is so meta
18:44brehautseangrove: does om replace the contents of the root completely, or append to the bottom of it?
18:44seangroveWhat's your use case?
18:44brehautseangrove: i have a section that represents a root, and i want to add a header to it (its a static header)
18:45brehautseangrove: if i can just slap it straight into my markup thats fine
18:51blake__I moved working code from my REPL to my clj and am getting errors... Where's a good place to look to figure them out? (It doesn't appear to be a definition issue.)
18:53justin_smithwhat kind of errors?
18:54blake__"Key must be integer".
18:54blake__So I'm thinking something's being interpreted as a value passed to a vector.
18:54justin_smithyeah, sounds like a vector ended up in the calling position somewhere
18:54justin_smithor some number was nil
18:55blake__ooh...nil...maybe it's a definition in my REPL =not= in my clj...
18:55blake__(wish I could see what's actually happening when it's called...)
18:57technomancyyou could try tools.trace
18:58blake__technomancy: thanks!
18:59justin_smithcool
19:02a3gishello again; I was trying to write a macro to sum up a list: (defmacro sum [x] (concat '(+) x)) works for (sum (1 2 3)) but not for (sum (range 10)) (since range is not evaluated). I changed it to (defmacro sum [x] (concat '(+) (eval x))), which now works for ranges but not for list literals. Any idea on how to make it work on both? (I know I should use reduce for that kind of thing; just playing with macros)
19:02tolstoyIs there a way, in EBNF (or ABNF) (instaparser) to describe that two things must be present, but they can be in any order?
19:03tolstoy(Or three, or four, or five things.)
19:03justin_smitha3gis: why not use [1 2 3] or '(1 2 3) - other than the fact that in this case the fact that it is a macro is useless
19:03a3gisjustin_smith: right that works; thanks!
19:07cbptolstoy: if you want a permutation then I don't think so (without enumerating all possible permutations). If you just want a combination you can use or?
19:08tolstoycbp: Alas. (Though understandable.) I'm kinda using it to "validate" some docs.
19:32tpopeis leiningen 2.3.2+ uptake high enough that I can drop support for repl port files other than .nrepl-port yet?
19:36technomancytpope: maybe? https://www.refheap.com/71269
19:36technomancytpope: I would say as long as the error message is good, go for it
19:37technomancytpope: that log file is just under one day's worth of traffic fwiw
19:37technomancynot a very representative sample, but whatever
19:38xeqione days of logs, presumably greping the user agent string used to download deps
19:38xeqitechnomancy: 1.7?
19:38technomancyxeqi: zero hits for Leiningen/1
19:38xeqi!
19:39xeqihurray
19:39technomancybut I think that's because it's reported differently
19:39technomancyI mean, 1.x didn't use aether
19:39xeqihmm, thats right. it's a different string entirely
19:44tpopetechnomancy: hmm yeah maybe indeed. I assume that doesn't even factor in existing installs
19:45technomancytpope: not sure I follow
19:45tpopetechnomancy: I mean those logs are just the number of installs happening, not a survey of what's already installed on people's machines
19:45tpopeunless I'm missing something
19:46technomancytpope: sorry, that's the nginx log from clojars.org
19:46technomancyso each hit is a separate lib or maven-metadata.xml file being fetched
19:46technomancynot downloads of lein itself
19:46tpopeoh!
19:47yediin om: does anyone know why this line: (dom/h2 #js {:color "red"} "No View hooked Up") isn't giving me an h2 element with color="red" set?
19:47yediit's also seeming impossible to get style to work right
19:48amalloyyedi: i don't think color is a legal attribute for hN?
19:48yedi(d/h2 #js {:style {:color "red"}} "No View Hooked Up") => style="cnt:1px;arr::color,red;cljs$lang$protocol_mask$partition1$:8196px;cljs$lang$protocol_mask$partition0$:16123663px;"
19:48amalloylike, it's supposed to be style="color:red" or something?
19:49`szxyedi: shouldn't that be #js {:style #js {:color "red"}} ?
19:49amalloyand #js can't magically know you want that map collapsed into a string
19:50yedioo lemme try
19:50amalloy#js {:style "color:red"}
19:50amalloybut i guess maybe d/h2 does that
19:50yediamalloy: i tried using string at first, but i get an error from an om protocol saying the style attr expects a map
19:50seangrove`szx: Yes, you're right. it must be a #js obj
19:50pandeirois it possible to connect cider to a drawbridge (nrepl over http) connection?
19:51technomancypandeiro: sadly no
19:51technomancysomeone needs to write an adapter
19:51pandeirotechnomancy: :headless works fine for my use case; i was just wondering
19:51yedi`szx: thanks, that did the trick!
19:52technomancyheadless?
19:52technomancyhuh... I wonder how hard it would be to write an nrepl brige
19:52pandeirotechnomancy: i am running a server locally so i will just start it up with `lein repl :headless ...` rather than `lein run`
19:53malyntechnomancy: I wrote one, but it's kind of a mess and I haven't wanted to share it yet...
19:53malynlein-catapult FTW! ;)
19:54technomancymalyn: cool!
19:54pandeirowhat is lein catapult?
19:54malynI'll try and get it cleaned up in the next couple of days. I used it this morning and had forgotten about the shocking number of println's in there...
19:55technomancypandeiro: I don't see how drawbridge comes into play for that though
19:55technomancyyou can :connect without http
19:56malynpandeiro: It's what I called my Leiningen plugin that lets you go from TCP/IP nREPL to Drawbridge. You know, maybe you're cozied up to your (vim-)fireplace and can't quite make it to the Drawbridge... well, here's a catapult then!
19:56pandeirotechnomancy: so i have a server that groups together several APIs that are useful for my day-to-day workflow: since i am starting it on xinit, i thought why not let it be my go-to REPL as well
19:56technomancypandeiro: huh, cool
19:57technomancydefinitely simpler to fall back to socket nrepl for that though
19:57yedijustin_smith blake__ amalloy coventry: wrt to my earlier question, this is what I came up with: https://gist.github.com/yedi/59f934b4f83ac396741c
19:57yedithanks for all the help
19:57pandeirotechnomancy: that's what i will do; i was just curious if drawbridge was an option
19:58pandeiro(i need the repl integrated into emacs to be useful; so, no)
20:02tpopeadds up to just under 80% fwiw. enough to make me want to kick this down the road a bit
20:20blake__Does "expect" have any elaborations, like, "expect (this or that)"?
20:21ToxicFrog,(doc expect)
20:21clojurebotHuh?
20:22coventryDo you mean this? http://clojuredocs.org/clojure_contrib/clojure.contrib.mock/expect
20:22blake__good question...I've got "require expectations"....lesseee
20:23blake__"expectations 2.0.6"
20:23coventryOh, this http://jayfields.com/expectations/
20:23blake__Maybe that's a little toooo minimalistic.
20:24staingfredericks: clgv: Thanks for the tip earlier.. my ex-info-status works like a charm: https://gist.github.com/stain/8aa635304664473054bc
20:25stainI did initially feel a functional itch as I used exception handling for handling exceptions rather than some (or ) magic
21:06gfredericksstain: aw man another failed sell for catch-data
21:06gfredericksmaybe I wasn't meant to be a library salesman after all
21:07stainhow would it look with that..
21:07stainyour example is too complete!
21:08gfredericks(catch-data :status {:as data, :ex e} (assoc data :body (.getMessage e)))
21:08gfredericksI think
21:08gfredericksthe conditional is implicit in the `:status` predicate
21:08gfredericksalso technically I did the merge backwards compared to yours
21:09stainyeah, it's important to not do the merge backwards, otherwise you can't override the :body
21:09stainas I'm sure there will be someone trying to do a 404 with a picture somewhere
21:09gfredericksah ha
21:10holoIn https://github.com/clojure/tools.namespace/ reads "If the reloaded namespace contains defmulti, you must also reload all of the associated defmethod expressions." I don't get this. aren't all defmethods defined in the same namespace as defmulti anyway?
21:11gfredericksholo: when the defmulti gets redefined it lacks all the other defmethods
21:12amalloyholo: no, defmethods typically are written in namespaces different from the one defining a defmulti
21:13amalloythis has the effect of mutating the defmulti, so in one sense that's "in the same namespace", but you have to re-eval the defmethod, which is in a different namespace, to get the same effect again
21:13gfredericksI thought s/he meant something different by "defined in"
21:15hologfredericks, you're answer is also right for my question because I didn't know multimethods internals
21:16holo(map inc [gfredericks amalloy])
21:16holo,(map inc [gfredericks amalloy])
21:16clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: gfredericks in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:16holo:D
21:16staingfredericks: hhmm.. now I tried with our thing, and it broke everything! :( I want my money back!
21:16stainyour
21:16brehautinc is not a function, its a lazybot command
21:17gfredericksstain: read the fine print
21:17holooh yes, i remember
21:24staingfredericks: it was Ring silently not telling me in the browser that I had screwed up the [:require] syntax - you're in!
21:25gfredericksPHEW
21:28tuftis anyone using immutant? i'm pretty burned on containers, but it does seem convenient
21:29miseria"no mendigues jamas calor y abrigo, la lastima nunca llega hasta tu puerta y el afecto prestado es un castigo" bienvenidos: http://castroruben.com *temo_a_un_ser_sin_rival*
21:43arrdemdo we have a standard implementation of floor and ceiling that people turn to? I hate to do weirdness with inc and dec...
21:43jcromartieMath
21:43arrdemmore stuff that was lost in contrib.math T_T
21:44arrdemyeah Math/floor and Math/ceil
21:44arrdemsuggestions for a testing engine besides core.test?
21:45jcromartiepeople like midje
21:45coventryWhat's wrong with clojure.test?
21:45arrdemcoventry: just making sure it hasn't morphed into a pile of glowing radioactive waste since last I spun it up :P
21:45jcromartieclojure.test is rock solid
21:47amalloyclojure.test does very little, and is good at what it does. midje does a lot
21:48amalloyi haven't used midje, so i won't state anything authoritatively, but i hear a lot more people debugging or complaining about midje in here than i hear about how awesome midje is
21:48jcromartieI had problems with midje
21:48jcromartieI had to abandon it
21:58alewtuft: there is the #immutant channel you might want to check out
22:00holoI had to port a lib from midje to clojure.test recently. clojure.test feels like having too many parens when compared to midje, and not very direct to describe tests
22:00jcromartieholo: but why did you have to port it?
22:01holojcromartie i wanted portable tests between clojure/clojurescript, and clojurescript.test/clojure.test was the obvious answer
22:04holojcromartie, sorry, I didn't mean "port", but "change to" :)
22:04jcromartiesure
22:04jcromartieI know what you meant
22:06ToBeReplacedarrdem: clojure.math.numeric-tower
22:12holojcromartie, there's some midje like syntax for cljs included in purnam.test, but I wasn't brave enough to try it
22:23_BravadoDoes anyone know a good tutorial on getting a browser connected clojurescript repl up and running? I managed to get cemerick's austin working before but am having no luck with a fresh copy
22:29xeqi_Bravado: I've been using the om-start template to start new projects with all that setup already
22:29_Bravadothanks
22:39seangrovexeqi: om-start or mies-om?
22:46xeqiseangrove: om-start, but mainly for things like https://github.com/magomimmo/om-start-template/blob/master/src/leiningen/new/om_start/profiles.clj
22:46xeqiauto setup of austin and injections to make it easier for dev time
23:03arrdem,(doc defrecord)
23:03clojurebot"([name [& fields] & opts+specs]); (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given f...
23:35chareSo trying to understand how to make something like reddit with clojure. How does reddit or hacker news do comment pagination, how do they pull out from the database the first page of comments and the comment's replies, but do so without pulling out a potentially gigantic amount
23:36beamsothe comment is probably linked to a parent comment plus a parent thread
23:36beamsoso you could do a limit and an order by in the sql query
23:36_Bravadoin short, granularity. The question is too vague to really take on though
23:37sm0kechare: every sensible database has pagination buitin
23:37charebeamso: limit on the top level comments only or what?
23:38beamsolimit in general i'm guessing
23:38beamsoreddit gives you 200 comments by default
23:38chareso how do you know that ahead of time when dealing with a comment that has a deep tree of replies
23:38beamsobut _Bravado is right in that i've answered it too simplistically
23:39chareif one comment has a deep tree of repiles that counts towards the 200 limit right? but you won't know it until you pull the entire comment's tree before looking at the next top level comment
23:40chareand how would that sql query look like?
23:40sm0kejust select * from comments limit 1000 ?
23:41sm0keand have refrences of parent in each comment
23:41sm0kelet the ui take care of tree view?
23:41chareso that doesn't grab the replies of those 1000 comments
23:42_Bravadoit's not a single query, i think you should look up sql to understandn why it doesn't grab 1000 comments
23:42sm0kemay be if you dont care
23:42chare_Bravado I don't understand
23:43_Bravadoyour questions seem to be more about how SQL queries work
23:43sm0keyea, if you really are so strict about how many replies, you can have order in replies i.e. comment -> 0 reply -> 1 reply of reply -> 2 and so on
23:44sm0kethen fetch by orders and limit
23:44sm0kewould no longer be a single query though