#clojure logs

2014-10-18

00:01amalloyquizme: uhhhh, without seeing your code it's not necessarily clear what's going wrong, but i expect you're using a sort function which disagrees with =
00:01amalloybased on your "sorted by a particular key"
00:03hiredmanwhat does subseq even do on a sort-set?
00:03hiredman,(doc subseq)
00:03clojurebot"([sc test key] [sc start-test start-key end-test end-key]); sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a seq of those entries with keys ek for which (test (.. sc comparator (compare ek key)) 0) is true"
00:03hiredmanah
00:04quizmehttp://pastebin.com/0adaVx3Q
00:05quizmeamalloy: http://pastebin.com/0adaVx3Q
00:10amalloy,(:x 5)
00:10clojurebotnil
00:10amalloyquizme: what do you expect 5 to mean in that context? calling that comparison function with 5 as one of the arguments doesn't make any sense
00:11quizmei want 5 to be the value that the key should be greater than.
00:13amalloywhat key? your function compares the a and b of of an item to the a and b of 5
00:14amalloyi feel like you are misunderstanding both sorted sets and subseq, but i don't understand your beliefs well enough to correct them
00:15quizmei want to select all values of the sorted set whose :a key is bigger than 5
00:16quizmei mean :a value
00:16quizmesimilar to how (subseq [1 2 3 4] > 2) gives you (3 4)
00:17quizmebut i just want to look at the :a values
00:22quizmehiredman: basically, it lets you do efficient range queries in memory.
00:30amalloywell, you could do something like (subseq s > {:a 5}), which kinda does what you want but is fraught with pitfalls
00:30amalloythe point is the thing you use as your query has to be comparable to the items in the set
00:32quizmeamalloy i see thanks, i think that will do it for me... what's the pitfall?
00:34amalloyi mean, like everything. your sorted set can't contain multiple items whose :a and :b are the same, even if other keys are different
00:35amalloyyou're comparing against a nil b, and it's not totally clear your comparison function expects that
00:41amalloyit seems more like you want a sorted map, where the keys are the values of :a
00:41amalloyand possibly a second sorted map if the values of :b are also important to sort by
00:42amalloybut who knows, maybe your data is shaped such that the pitfalls of sorted sets are advantages
02:39SagiCZ1,(range 200000)
02:39clojurebot(0 1 2 3 4 ...)
02:39SagiCZ1how can i tell repl to compute but not print the return value?
02:44TEttinger,(do (range 200000) nil)
02:44clojurebotnil
02:45TEttinger,(do (print "starting... ") (range 200000) (print "ending...") nil)
02:45clojurebotstarting... ending...
02:45TEttingerSagiCZ1, does that make sense?
02:47SagiCZ1TEttinger: yes it does, thank you
02:47SagiCZ1,(dorun (range 200000))
02:47clojurebotnil
02:47SagiCZ1this is what i wanted
02:47TEttingerah ok
02:47SagiCZ1im trying to find a case where pmap is faster than map... still havent found one
02:49TEttingerhow many physical cores do you have?
02:49TEttingerif it's 16, you're more likely to find a case than if you have 2 :)
02:54SagiCZ1yeah just two
02:54SagiCZ1ok, ordering 16 core xeon
02:54amalloySagiCZ1: you want a function that's expensive to compute, like (map #(do (THread/sleep 5000) %) (apply list (range 10)))
02:55SagiCZ1amalloy: yeah so the function computing one element should take a long time.. not the whole operation right?
02:55amalloyright
02:55SagiCZ1thanks
02:56TEttingerSagiCZ1: lol, if you're just after tons of cores, http://www.ebay.com/itm/DELL-C6100-C6105-CLOUD-SERVER-6x-1-8GHz-AMD-6-CORE-HEX-CORE-144GB-RAM-3x-250GB-/181306790824?pt=COMP_EN_Servers&amp;hash=item2a36ba13a8
02:56TEttinger36 cores and 144GB RAM should be able to handle a few REPLs
02:56SagiCZ1yeah, like two or three right?
02:57SagiCZ1too bad i dont believe AMD can make a good cpu
02:58SagiCZ1wow but isnt that cheap?
02:58TEttingerif you were serious about buying for testing anything, http://www.ebay.com/itm/DELL-C6105-CLOUD-SERVER-6x-1-8GHz-AMD-6-CORE-48GB-RAM-3x-250GB-C6100-SERIES/171187983886 is the price of a netbook
02:59SagiCZ1yeah that surprised me.. i wonder if my application would really benefit from so many cores.. tehre is some inherent parallel processes in it so maybe
03:00TEttingerelectrical costs are what kill these things, I have an older server than these that I never turn on because it sounds like a jet engine and probably uses as much electricity as one
03:02SagiCZ1oh ok.. thats awful then.. i think amd cpus are pretty inefficient.. i dont think it could make enough money to pay for the running cost but maybe one day..
03:02TEttingerI would imagine the cloud ones are cheaper
03:03TEttingerthese have a fairly low clock speed
03:03TEttingerideal for clojure's intended use, massively concurrent applications like server-side code
03:05TEttingerthen again, the server I have is a 4 processor, 4U server, single-core Pentium4-based Xeon each one
03:05TEttingerquite old, probably not the best example
03:05justin_smithTEttinger: google has a server farm not far from here, just because there is a huge hydro generator and large numbers of wind farms (columbia river gorge), and they get cheaper power by being right next door.
03:06TEttingeryep
03:06TEttingerI've heard they do that
03:06justin_smithit's smart placement, bonus that it's green energy too (relatively depends on how important you think salmon are)
03:07TEttingerdelicious
03:07TEttingerI saw the salmon staircase they built at one of those dams
03:07TEttingerincredible work
03:07justin_smiththey invented a salmon hose, it works even better
03:07justin_smithliterally pumps salmon from the bottom, into a tube, then shoots them to the top
03:08TEttingerthat's the funniest image I've had in my head all day (all 8 minutes of it)
03:08justin_smithhehe
03:08justin_smithvid https://www.youtube.com/watch?v=WWpKtTjYo1g
03:11justin_smithit is remarkably similar to pneumatic system that was used at some libraries to send requests for books
03:11justin_smithnow I am imagining people in libraries using dedicated tubing to throw live fish at one another
03:11scottjwater park for fish
03:12justin_smithyeah, I bet that's fun
03:40dysfun_clojure doesn't use '&' for anything yet, right?
03:40justin_smithonly for marking varargs
03:41justin_smith,((fn [& args] args) 1 2 3 4 5)
03:41clojurebot(1 2 3 4 5)
03:41dysfun_oh yes
03:41dysfun_i can live with that
03:41justin_smith,'&
03:41clojurebot&
03:41justin_smith,(let [& :OK] &)
03:41clojurebot:OK
03:41justin_smithit's a valid binding
03:41dysfun_also not documented :(
03:42justin_smithwhat isn't documented/
03:42dysfun_& isn't listed in the permissible atom syntax
03:42lazybotjava.lang.RuntimeException: Unable to resolve symbol: isn't in this context
03:42justin_smithdysfun_: permissable atom?
03:42justin_smithis that common lisp speak?
03:43dysfun_er symbol
03:43dysfun_"Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, and ? (other characters will be allowed eventually, but not all macro characters have been determined)"
03:43dysfun_doesn't mention <> either
03:43justin_smithwhich have been function names from the very beginning
03:44dysfun_i'm looking for a punctuation symbol that isn't permitted in clojure symbol names
03:44justin_smith.
03:44dysfun_or at a minimum that isn't permitted as the first character in clojure symbol names
03:44justin_smith^
03:45dysfun_i'm already using dot :(
03:45justin_smith,(let [. :not-ok] .)
03:45clojurebot#<CompilerException java.lang.ClassFormatError: Illegal field name "." in class sandbox$eval99, compiling:(NO_SOURCE_PATH:0:0)>
03:45justin_smith,(let [^ :not-ok] ^)
03:45clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
03:45dysfun_^ is metadata
03:46justin_smithright, and . is member access
03:46justin_smithand both are not allowed in names, that's all I'm saying
03:46dysfun_ah, right, i get you
03:46justin_smith' can be in a name, but not as the first character
03:46justin_smithso we can be all mathy
03:47dysfun_i'm writing a custom reader, but i can use #^ for metadata and use ^ for something else
03:47justin_smith,(let [x 0 x' (inc x) x'' (inc x')] x'')
03:47clojurebot2
03:47dysfun_ah yes, but i want to keep convenient quote syntax
03:48justin_smith,(let [  5] )
03:48clojurebot5
03:48justin_smitheven non breaking space is a valid binding
03:48dysfun_what was that? &nbsp; ?
03:48dysfun_heh
03:48justin_smith"valid" - we can at least say "you can get away with it"
03:49dysfun_,'\'
03:49clojurebot\'
03:49justin_smith,(let [\ :?] \)
03:49clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported character: \ :?>
03:49dysfun_oooh!
03:49justin_smithahh, it's for character escapes
03:49justin_smithyou could give up on having a character syntax I guess
03:49dysfun_yes, but it doesn't have any other uses
03:49dysfun_so i could for example do #\
03:50dysfun_as a reader macro, effectively
03:51dysfun_#@ is an option too
03:52dysfun_only other use for \ is escaping in strings i think
03:57dysfun_you couldn't do ~@ either, could you?
03:57dysfun_er ~@@
04:00dysfun_ah, no, it derefs properly
04:00justin_smithanyway, you can use deref instead of the @ syntax
04:01justin_smiththough that may be inconvenient
04:01dysfun_yeah, but i don't want to make it tedious to use atoms. they're quite useful
04:02dysfun_~^ ?
04:02clojurebotExcuse me?
04:06dysfun_i think i've got enough characters for now, thanks for the help
04:06m1dnightGuys, implementation question: Why are the ensure locks retained during transaction retries?
04:06m1dnightIs there a specific reason? If you were to release them you simply re-aquire them, so I can't see a reason?
04:08dysfun_ooh, ~` wouldn't be valid, would it?
04:10dysfun_ah, yes it would
05:04dysfun_is the bugtracker the place to suggest a clojure feature?
05:09amalloydysfun_: the clojure-dev mailing list
05:09dysfun_ty
05:23r4viwhere would I put a system.properties file in a clojure project? alongside project.clj?
05:41foodoo,(let [x resolve] (doc x)); prints nothing
05:41clojurebotExcuse me?
05:42foodoo,(let [x resolve] (doc resolve)); prints the doc for the function resolve
05:42clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
05:42foodooHow can I bind a function/function name so that (doc) can work with it?
05:45dysfun_use a macro
05:46dysfun_or pass it in as a symbol
05:46dysfun_i'd probably do the latter
05:46dysfun_doc is a macro itself
05:56clj-learnerwhy is this not working?
05:56clj-learner(ns fooo
05:56clj-learner (:require a.core)
05:56clj-learner (:refer [a.core :rename {b b2}]))
05:56clj-learnervector cannot be cast to symbol
06:00TEttingerclj-learner: refer goes in one of the vectors, if I recalll correctly, and isn't its own section like (:require)
06:01dysfun_(ns fooo (:require [a.core :rename {b b2}]))
06:01dysfun_although you probably want to refer b as well because otherwise you'll get everything
06:01TEttingerclj-learner: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
06:02clj-learnerthanks
06:08amalloythat article is four years old, TEttinger
06:08amalloyit recommends some things which are today considered little better than cannibalism
06:08TEttingerwow
06:08TEttingerdid not know that
06:08TEttingerwhere's the good one?
06:10amalloybeats me
06:13clj-learnerit works like this, but im not sure if i should use refer or use https://www.refheap.com/91953
06:30TEttingerrefer
06:32foodooWhat are the current documentation tools for Clojure? Autodoc doesn't seem to be compatible with Leiningen 2
06:33ro_stcodox is another one
06:34TEttingermarginalia?
06:35foodooTEttinger: My current project won't profit from literate programming. But still thanks for your answer
06:35ro_stRing uses codox: http://ring-clojure.github.io/ring/ config: https://github.com/ring-clojure/ring/tree/master/project.clj
06:35foodooro_st: Thanks, I'll have a look
06:40foodooro_st: Just ran codox on my codebase. Nifty! Thanks :)
06:40ro_stglad it worked out
06:41ro_sti'm quite looking forward to the simulation testing webinar next friday
06:41ro_sti really hope they show how to use causatum with simulant
06:50noncom|2where is the source of "in-ns" ?
06:51ro_stin the java source
06:51ro_st-wild guess-
07:16gfrederickswell I can see where it's created (in RT.java) but not where it gets a proper value...
07:18gfredericksoh there it is
07:18gfredericksnoncom|2: look for "final static IFn inNamespace" in RT.java
07:24noncom|2thanks! :)
07:35simaowhat is the best way to test a string against a regex in a clojure test? Just want a func to return true/false, not a match or anything
07:36ro_st(boolean (re-find #"" ""))
07:36simaothanks
07:37simaoWould think there was some way more concise ;)
07:37ro_stif there was, we'd have boolean variants of all our functions :-)
07:40simaoeh :) Just thought there would be a better way to write this: (is (true? (boolean (re-find #"slave status unknow" (:status result)))))
07:40simaoquite awkward no?
07:40ro_st(is (boolean ..))
07:40ro_stboolean returns true or false. true? returns true if its arg is `true`
07:41ro_stit's unnecessary to use true?
07:41ro_styou could also just (is (re-find #".." ..))
07:42ro_sti just checked in a repl: (if (re-find #"\d" "a") 1 2) ;; 2
07:42simaoah yeah, that looks much better, thanks.
08:15gfrederickssimao: most boolean-like things in clojure respect general truthiness instead of just true v false
08:15gfredericksso it's rarel necessary to actually convert something to a boolean
08:15simaoI see...
08:16simaoIt's a bit weird then
08:16gfredericksI think that's typical for dynamically-typed languages
08:17simaoIs there a nice function that simplifies this? (assoc event :tags (vec (concat (or (:tags event) []) ["always-present-tag"])))
08:17simaokind of a deep merge of vecs inside an hash
08:18gfredericks,(def event {:tags ["foo" "bar"]})
08:18clojurebot#'sandbox/event
08:18gfredericks,(update event :tags conj "always-present-tag")
08:18clojurebot{:tags ["foo" "bar" "always-present-tag"]}
08:21simao"Unable to resolve symbol: update in this context"
08:21simao?
08:26scottjsimao: maybe you want (update-in {} [:tags] (fnil conj [])"foo")
08:26gfredericksyeah update is new in 1.7
08:28simaoah ok
08:30simaothat works, thanks
09:41TimMc"* gfredericks can't remember what erlang does" is good out of context
09:42gfredericksI wasn't even sure what java did when using a boxed boolean that turned out to be null
09:42TimMcOK, so I feel like maybe I need to make a fifo transport for nrepl. Anyone want to talk me out of this?
09:42gfredericksso I tried it -- compiles fine, but NPE at runtime
09:43gfredericksTimMc: what what why?
09:43TimMcclojurebot: gfredericks |can't| remember what erlang does
09:43clojurebotIn Ordnung
09:44TimMcThe situation is that I want to adapt LiveREPL to open a persistent nREPL session that I can connect to again later. However, that means opening up a port, which *anyone* on the machine could connect to, not just the user who launched the JVM (and therefore the user who connected via liverepl.
09:44TimMc)
09:45gfrederickserlang requires a true
09:45TimMcI *think* that the only way to secure this without passwords or an SSH lib is to use native filesystem security: Create a fifo (or pair of fifos...) with the correct permissions and read/write from that.
09:46gfredericksoh that's what fifo means
09:46gfredericksokay no I can't talk you out of that
09:48mi6x3mhello, I am trying to define a function with meta in a syntax quote
09:48TimMcgfredericks: aw shucks
09:48mi6x3m`(defn ^{:foo blabla} ....)
09:48mi6x3mbut somehow when the function is defined I don't see the meta?
09:48mi6x3mcould it be ^ doesn't work that well in syntax quote?
09:53gfredericks,(meta ` ^:foo bar)
09:53clojurebot{:foo true}
09:53thomasfustonAloha, are there a recommended gui lib for clojure or just use the jave ones?
09:54mi6x3mthomasfuston: seesaw
09:54mi6x3mit's a wrapper of Swing
09:54mi6x3mand a fine one
09:54GurkenmasterWhy would anyone recommend swing?
09:55mi6x3mGurkenmaster: because Swing is a nice library with great capabilities?
09:55GurkenmasterIt's still worse than javafx
09:56mi6x3mI think Swing does it's job
09:57mi6x3mJavaFX does it also
09:57mi6x3mbut one being better than the other
09:57mi6x3mI don't know
09:57mi6x3mtoo bold of a statement
10:11m1dnightI'm going to ask again, in case somebody's here who knows: Is there a reason readlocks on refs (ensure) are held between retries in clojure?
10:14donbonifaciohello, how can I pass a collection as a variadic "argument" ?
10:16ToxicFrogdonbonifacio: apply?
10:17donbonifacioyessss
10:18donbonifaciothat's it ToxicFrog, thanks :)
10:33jonhmoo
10:36dysfun_what causes defmacro to be run at compile time? is it a special form or is there some sort of metadata that controls it?
10:37clj-learneri'm trying to create a function that reads from cmdline using read-line but it doesnt work on the intellij repl, i get "DEBUG: unknown status need-input" and nothing happens if i submit stuff, i need to interrupt current execution
10:37clj-learnerit works if i open a lein repl
10:38dysfun_i expect it's closed STDIN
10:45clj-learnerhow do i open the stdin?
10:50dysfun_you don't. if it's that, it's a limitation of the intellij repl
10:53TimMc$seen djpowell
10:53lazybotdjpowell was last seen quitting 10 weeks ago.
10:53TimMc:-(
10:54TimMcI demand instantaneous communication!
10:54clj-learneris there an alternative to use the windows cmd then?
10:54clj-learnerfor the repl
10:57justin_smithdysfun_: regarding macros, there is a :macro true metadata
10:57justin_smith,(:macro (meta #'or))
10:57clojurebottrue
10:57dysfun_yes, which isn't set on defmacro
10:58justin_smithahh, that's what you are asking
10:58dysfun_is it a special form?
10:58Bronsadysfun_: it is set on defmacro
10:58justin_smith,(:macro (meta #'defmacro))
10:58clojurebottrue
10:58Bronsa.setMacro sets :macro true
10:58dysfun_oh. well it's not in the definition of setmacro. it must be set later
10:58dysfun_er defmacro
10:59dysfun_so the :macro property just controls whether it's evaluated at compile time?
10:59Bronsadysfun_: immediately after the definition of defmacro there is (.setMacro #'defmacro)
10:59Bronsadysfun_: yeah
10:59dysfun_oh. that cut off my screen
11:01squeedeewhy do i need to quote 'and' here? : (reduce 'and '(true true true))
11:01dysfun_and is a macro
11:02squeedeeso quoting it stops it from inlining?
11:02Bronsasqueedee: that doesn't do what you think it does
11:02dysfun_what he said
11:02Bronsasqueedee: you can't use macros as higher order functions
11:02dysfun_you are calling the symbol 'and' on every invocation
11:02Bronsa,(reduce 'foo '(true true true))
11:02clojurebottrue
11:02Bronsa,(reduce 'foo '(true false true))
11:02clojurebottrue
11:02Bronsa,(reduce 'and '(true false true))
11:02clojurebottrue
11:03squeedeeoic
11:03Bronsasqueedee: if you need to "apply" or "reduce" and/or, there are a bunch of convenience functions that you can use
11:03Bronsasqueedee: look at some/not-any?/every?
11:04squeedeeok will do
11:04squeedeethankyou
11:04dysfun_the naming of not-any? still bugs me
11:05squeedeebecause its not-every?
11:05dysfun_no, it's not, it's not-some
11:05dysfun_and nevermind the fact some doesn't end with ?
11:05squeedeeso some should be any
11:05squeedeethat is strange to read
11:06dysfun_,any
11:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: any in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:06dysfun_there is an any? in useful, but that does a different thing
11:09squeedee(every? true? list) is what i was after. i guess it reads well
11:11Bronsasqueedee: unless you need to explicitely test for true rather than for truthy, you should use (every? identity list) instead
11:12dysfun_also consider keep
11:12squeedeeyou think that reads as well? given that all arguments will be bool.
11:12dysfun_well it's more about making things more general so they can be reused
11:13squeedeehmmm
11:15squeedeeI am still quite green, but my take is that it would be an overgeneralization. I have a diff of two 'graphs' that tells me if each matching element is the same or not. Sometimes i just want to know if there are any differences.
11:16squeedeeits a pretty specific dsl with a specific signature too, which may be where i'm holding on to imperative habbits
11:21squeedeemy-way vs a-different-way ? https://gist.github.com/squeedee/bfad8db75f4664e4ad75
11:21arrdem$seen nkariniemi
11:21lazybotI have never seen nkariniemi.
11:21arrdemdamnit
11:25dysfun_can you change the line number errors will be reported on during compilation?
11:25dysfun_perhaps something involving with-meta ?
11:30justin_smith,(require 'clojure.data)
11:30clojurebotnil
11:30justin_smith,(every? nil? (take 2 (clojure.data/diff {:a 0 :b 2 :c 3} {:a 0 :b 2 :c 3}))) ; squeedee
11:30clojurebottrue
11:30justin_smith,(every? nil? (take 2 (clojure.data/diff {:a 0 :b 2 :c 3} {:a 0 :b 2 :c 4}))) ; squeedee
11:30clojurebotfalse
11:31justin_smith,(clojure.data/diff {:a 0 :b 2 :c 3} {:a 0 :b 1 :c 3})
11:31clojurebot({:b 2} {:b 1} {:c 3, :a 0})
11:31justin_smithit returns things only in a, things only in b, and the overlap as a three element list
11:32squeedeeyeah its nice. My data is a sequence tho. unkeyed.
11:32squeedeewould have to interpolate the index in i guess
11:32justin_smith,(clojure.data/diff [0 1 2] [0 1 3])
11:32clojurebot[[nil nil 2] [nil nil 3] [0 1]]
11:32squeedeeoic
11:32justin_smith,(clojure.data/diff [0 1 2] [0 1 2])
11:32clojurebot[nil nil [0 1 2]]
11:32squeedeehah
11:32squeedeeuseful
11:33squeedeethanks
11:33justin_smithnp
11:33justin_smithit comes with clojure.core iirc
11:34squeedeejustin_smith: of course some of these helpful tools i don't look for while i just try to excercise my mind a little here, but now i've done it my way i'll switch to that.
11:36justin_smithsqueedee: clojure.data is one of those hidden gems imho
11:36squeedeeugh clear liquid diet is driving me crazy. makes coding hard :P
11:37dnolen_Om 0.8.0-alpha1 is out, biggest change is refernce cursors https://github.com/swannodette/om/wiki/Advanced-Tutorial#reference-cursors
11:37squeedeehiya dnolen_ , Rasheed here. Glad to see you're still omming it up. One day I might get somewhere useful with it :D
11:38squeedeejustin_smith: i am fighting a constant urge to create proxy functions in my namespaces.. like ok, data/diff is ace, but wheres the reminder that you should use it... so I find myself wanting mapper.diff/diff
11:54christop1eGuys, is the source for the evaluator bot open?
11:54christop1eI'd like to add it to my own bot :)
12:10luxbockm1dnight: https://github.com/hiredman/clojurebot
12:10luxbockthere's also https://github.com/Raynes/lazybot
12:14m1dnightaha, great! :) thanks guys
12:15m1dnightIt took my compsci frat a few minutes and they got my Scheme evaluating bot offline :p
12:15m1dnightforgot a few key primitives :p
12:56whodidthiswas there a thingie somewhere that would run a jvm instance and then all lein tasks would use that instance
12:57squeedeetrampoline?
12:57clojurebottrampoline is http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
12:57mdeboardOh, is that what trampoline is?
12:57squeedeedont take my word for it
12:58squeedeeperhaps not
12:58whodidthisi think trampoline was 1 jvm instance per task
12:59squeedeeyeah just not nested in leins
13:01weavejesterTrampolining is the same principle in Clojure or Lein
13:01weavejesterEssentially instead of executing a function or process
13:01weavejesterYou return a callback
13:02weavejesterIn Clojure’s case, that’s a zero-argument function
13:02weavejesterIn Lein’s case it’s a shell command in a temporary file
13:02weavejesterIt prevents nesting of either functions or processes
13:06whodidthisright, grenchman
13:06whodidthisi just remembered it was built by one of the greats so found it from techiemancer's repo list
13:11mdeboardtechiemancer
13:11mdeboardlol
13:11justin_smithwhodidthis: with something like grenchman, you may also end up finding pallet/alembic useful (in case you need to add deps)
13:11mdeboardI approve of the name change
13:11bundaciaso, I'm brand new to clojure and am trying to get a feel for macros by implementing some if the built in control flow forms. I can't figure out what I'm doing wrong in my attempt to make a "condp" macro.
13:12bundaciathis is what I'm trying: (defmacro mycondp [op rhs lhs result & next] `(if (~op ~lhs ~rhs) ~result (mycondp ~op ~rhs ~@next)))
13:12whodidthisactually im just wondering how to fit more lein tasks on a 2gb server :S
13:12m1dnightrefheap.com is easier to show us code bundacia
13:13bundaciacool. here it is on refheap: https://www.refheap.com/91973
13:13the-kennydnolen_: You have just simplified the application I write at work in a massive scale on multiple levels. Thank you so much <3
13:13dnolen_the-kenny: :)
13:14eggheadbundacia: do you know the rules of macro club yet?
13:14bundaciathis is the error I'm getting: https://www.refheap.com/91974
13:15bundaciaI do not know the rules of the macro club I guess. Didn't know there was a club =)
13:15eggheadgfredericks has a pretty nice talk introducing macros bundacia - you should check it out http://www.infoq.com/presentations/macros-clojure-west-2013
13:16bundaciathanks egghead, I;'ll check that out.
13:16the-kennydnolen_: I said it some time ago at EuroClojure, and I want to say it again: Thanks for Om. Without it, I'd still fight with Ember.js and build parts of the UI from a string out of deperation
13:19bundaciaegghead: just googled the "rules" ;-) Mainly just wanting to understand them at this point so I can understand the built-in ones better.
13:22the-kennydnolen_: One question: Are there performance benefits in using (transact! (:foo root-cursor) ...) compared to (swap! app-state update-in [:foo] ...)? (It will at least have the benefit of supporting tx-listen, right?)
13:24eggheadbundacia: it may help to call (macroexpand '(mycondp < 2 1 :yep)) and consider what will happen if it keeps trying to expand
13:25eggheaddoes om support querying the tx history with datalog yet
13:26egghead;)
13:26whodidthisis there a god lein template for clojure project with cider nrepl thingies ready
13:27bundaciaegghead: got it. Didn't think it would keep trying to expend the false case.
13:29mdeboardAnyone have any indentation tweaks for clojure-mode in emacs?
13:30the-kennymdeboard: what kind of tweaks?
13:30mdeboardlike for example, there are some functions like map that always take a function, then basically an unlimited number of elements to map over
13:31the-kennywhodidthis: What do you mean by 'ready'? I just have [cider/cider-nrepl "0.8.0-SNAPSHOT"] in my :user profile and use lein repl (or `cider-jack-in') to connect. If you want something where nrepl+cider is embedded in the application itself, I'm afraid I can't help you :/
13:31eggheadgenerally just https://github.com/bbatsov/clojure-style-guide mdeboard
13:32mdeboardIt's usually about what element "hangs" on the end of a line
13:32whodidthiscool
13:33mdeboardhttps://gist.github.com/mattdeboard/614b2f2d1fdd2215133b
13:33mdeboardAn example
13:33mdeboardthe-kenny, egghead
13:33mdeboardI mean I get *why* it's like that
13:33mdeboardall just elements in a list, homoiconicity etc.
13:34mdeboardjust, feh
13:34eggheadya, that is the default and recommended indentation
13:34whodidthisi want to try this "emacs" thingie
13:35mdeboardwhodidthis: It's a flash in the pan
13:36whodidthisi did get some of that sexp sexyness in some vim plugin too
13:36whodidthismakes one wonder why all languages are not lisp
13:38eggheadmdeboard: commented on the gist
13:38whodidthishttps://github.com/weavejester/reloaded.repl is this currently still the state of art
13:39whodidthison the reloaded workflow department
13:40domokatodoes clojure box primitive return values?
13:41mdeboardegghead: Yeah, I know that's the thing but just curious if anyone had defined any custom indentation rules for themselves in emacs
13:57gfrederickswhy does `lein release` ask me if I meant to say `lein deploy clojars`?
13:57gfredericksi.e., what is the best way to make that the default?
13:59gfredericksAh I bet it is :deploy-repositories [["releases" :clojars]]
14:01domokatoto answer my own question, looks like the source of float is just a function, so no. But correct me if I'm wrong
14:02gfredericksdomokato: primitive return values from what? java interop methods?
14:02domokatoclojure functions
14:02gfredericksby default everything is boxed
14:02gfredericksyou have to go out of your way to get primitives to work across function calls
14:03domokatosigh, ok
14:03domokatothx
14:03gfredericksthere's some nuances there, but assuming things are boxed is usually safe
14:04mdeboardI just want to take a second to acknowledge this hero https://groups.google.com/d/msg/clojurescript/Bd4MthunzkQ/AJxzblvUAG8J
14:05mdeboardHe had a problem, posted to a newsgroup about it, then solved it *and then posted the solution*
14:05mdeboardinstead of http://xkcd.com/979/
14:27gfredericksjust made a plugin for doing `lein vcs tag` without a PGP signature, and for updating version documantation in README files: https://github.com/gfredericks/corncob-cigar
14:28gfredericksI used it to release itself
14:30Jaooda recursive plugin?
14:31gfredericksnot more than any other dev tool
14:36augustlI have a transient map. Can I create a record from it or do I have to create a persistent map first?
14:39hyPiRionhave to make it persistent
14:39hyPiRionOr well, eh.
14:41augustlI'm prematurely optimizing, could always write this part in Java if it turns out to matter :)
14:42gfredericks,(def m (transient {:foo 12 :bar 3}))
14:42clojurebot#'sandbox/m
14:42gfredericks,(keys m)
14:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.PersistentHashMap$TransientHashMap>
14:42gfredericks,(.getKeys m)
14:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getKeys for class clojure.lang.PersistentHashMap$TransientHashMap>
14:42augustlI'm getting chunks of messages in sequence, one chunk represents a field, so I create a transient that I assoc into and when I have all the chunks I create a record
14:42hyPiRionaugustl: yeah, it seems like map->X require a persistent map
14:42gfredericks,(get m :bar)
14:42clojurebot3
14:42gfredericksif you know the keys you prollably can
14:42augustlhmm didn't know you could get from transients
14:42gfredericks,(source frequencies)
14:42clojurebotSource not found\n
14:43gfredericksI don't think you could write frequencies otherwise
14:43hyPiRionTransients work like persistent data structures, except that you cannot use a transient after you've done an "update"
14:43gfredericksyou can't "use" it?
14:43augustlI expected there to be a separate get! just like there's assoc!
14:43gfredericks,(assoc! m :hypirion 42)
14:43clojurebot#<TransientHashMap clojure.lang.PersistentHashMap$TransientHashMap@13b7ce9>
14:44gfredericks,(get m :hypirion)
14:44clojurebot42
14:44hyPiRiongfredericks: theoretically I meant
14:44gfredericksooh that right
14:44gfredericksaugustl: oh I see; yeah there's not really a need for that I guess
14:45augustlmakes sense, only the "update" part of transients is different
14:47hyPiRion,(count (let [t (transient {})] (dotimes [i 100] (assoc! t i i)) (persistent! t)))
14:47clojurebot8
14:53augustland now for something completely different.. Is there a way to break out of a "loop" other than recur-ing with a value that causes the loop to break based on my own loop code?
14:53augustlI really should just write this part in Java :) ZMQ sockets are such imperative, wow
14:53justin_smithaugustl: just don't call recur!
14:53augustljustin_smith: ah :D
14:54justin_smithI mean, there are various reasons not to call recur, just make sure you don't call it
14:55justin_smithie. sometimes I will stop recurring based on ##(.isInterrupted (Thread/currentThread))
14:55lazybot⇒ false
14:55justin_smiththat will show as true if someone cancelled the thread (via future-cancel or whatever)
15:11augustlwhen using stuartsierra's components, are there any rules of thumb on what to create in the "create" part and what to create in "start"? Seems cleaner to me to create everything that doesn't have any state and side effects in create, such as connection objects, and call connect on them in start
15:13kenrestivoi guess if you will be calling stop and start, you'd put things you want done every time, in there. and things you only done once when first setting up the components, put in create?
15:13kenrestivoreminds me of the android life cycle onCreate onResume thing
15:15augustlkenrestivo: makes sense. If my objects/values I use in stop/start can be restarted (and in this case they can) I might as well reuse them
15:58justin_smithyeah, I think things that are values can be in create, things that are state should be in start (so they get a clean slate)
15:59justin_smithand if something is both value and state woah dude this is clojure why are you trying to write OO code?
16:39SagiCZ1briliant, check out motivational lorem ipsums http://www.loremfuckingipsum.com/
16:39mdeboardwtf
16:39mdeboardWhy does this channel get such an insane a mount of spam
16:40mdeboard(relatively insane)
16:40SagiCZ1sorry
16:40SagiCZ1im no spam bot though
16:40mdeboardYeah that's what you all say
16:40mdeboardNow you issue a pat rejoinder
16:40SagiCZ1i seriously thought that was interesting
16:40mdeboardNow I respond with how you're definitely a bot, and you say something predictable
16:40SagiCZ1(dec mdeboard)
16:40lazybot⇒ 9
16:42mdeboardThis channel is pretty rife with spam. And when you mention spam after they spam, you all respond "I'm not a bot tho" never, "I'm not a spammer"
16:42justin_smithmdeboard: he's a pretty active regular here, I think he was just sharing a silly off topic thing he found
16:42mdeboardOk
16:42mdeboardMy bad then.
16:42mdeboardI just get so many dumb whispers from bots in this room :(
16:42justin_smithalso, this channel is pretty heavily off topic
16:42justin_smithyeah, understood, very annoying
16:43justin_smithif you msg technomancy, he has ops and will kick and ban the spammers
16:43mdeboardidc about the off-topic at all, doesn't bother me. I just assume people posting random links and nothing else are bots now. Sorry SagiCZ1.
16:43justin_smithI think we need more folks with ops though
16:51squeedeeclojure.org looks mighty slow from here
16:53lvhIs there a CLJS-supporting vector addition/mutliplication lib I can use? Don't need much; really just scalar products/linear combinations.
16:54lvhRight now I'm writing them myself
17:00justin_smithlvh: is there any cljs core.matrix support?
17:00lvhjustin_smith: nope :( that was my first port of call as well
17:00justin_smithshould have figured
17:08lvhjustin_smith: fortunately I do not need particularly heavy math ops; it's pretty much just linera combinations of vectors :)
17:47arrdemjustin_smith: good luck with that
17:48arrdemI suspect tech will be our only op for the forseable future
17:48arrdemat HackTx atm, if you have feature requests for Grimoire 0.4.0 speak now or hold your peace because this release is happening
17:50justin_smitharrdem: good luck with what? core.matrix in cljs?
17:50justin_smithahh, regarding ops
17:50arrdemjustin_smith: yeah ops. sorry.
18:01pkkmis there a better way to drop n characters from the beginning of a string than (apply str (drop n my-string)) ?
18:04pkkmnevermind, (subs n my-string)
20:35andrewhranyone here that could enlight me about an issue of ClojureScript compiler? (http://dev.clojure.org/jira/browse/CLJS-851)
21:46johnwalkerhow does one assert that an argument or field satisfies an interface?
21:47johnwalkerfor example, (defn foo [^IFn bar] (bar ..))
21:49TEttingerjohnwalker: multimethods, probably
21:50justin_smith,(assert (contains? (supers (class [])) java.util.List))
21:50clojurebotnil
21:51justin_smith,(assert (contains? (supers (class [])) java.util.Map))
21:51clojurebot#<AssertionError java.lang.AssertionError: Assert failed: (contains? (supers (class [])) java.util.Map)>
21:51johnwalker,(satisfies? IFn (fn []))
21:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: IFn in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:51justin_smithall the interfaces it implements should show up in the supers (which is returned as a set, so you can use contains, subset, intersection, etc.)
21:52justin_smithahh, satisfies may be more direct yeah :)
21:52johnwalkerthere's a core function thats ,(fn? (fn []))
21:52johnwalker,(fn? (fn []))
21:52clojurebottrue
21:53johnwalkeri guess asserts are a start
21:53justin_smith(source fn?)
21:53justin_smith,(source fn?)
21:53clojurebotSource not found\n
21:53justin_smith$source fn?
21:53lazybotfn? is http://is.gd/nTvi5s
21:53johnwalkergood idea
21:53justin_smithit uses instance?
21:54justin_smithas do the other nearby predicates
21:54justin_smithsequential?, coutned? etc.
21:54johnwalker,(fn? {})
21:54clojurebotfalse
21:54justin_smith,(ifn? {})
21:54clojurebottrue
21:55johnwalkerahh
21:55jcsimsis there an idiomatic way to wrap a subset of routes in a ring app, instead of all of them?
21:56johnwalkervery helpful
21:56johnwalker(inc justin_smith)
21:56lazybot⇒ 95
21:56johnwalkerthanks!
21:56weavejesterjcsims: A subset of routes is just a handler. It’s handlers all the way down.
21:57justin_smithjohnwalker: np
21:57jcsimsthat's what I thought, but I'm trying to track down a new "Invalid anti-forgery token" problem that I didn't have before. I've got an 'anti-forgery-field' in the form
21:58weavejesterjcsims: Do you have the session middleware applied?
21:58jcsimsI'm using your ring-defaults library: https://www.refheap.com/91986
22:00jcsimswhen all routes were wrapped with site-defaults, it worked fine
22:00weavejesterjcsims: Oh, you’ve got them setup next to each other.
22:00weavejesterjcsims: You’re going to run into problems with side-effectful middleware
22:00weavejesterjcsims: Anything that acts upon the body, like wrap-params.
22:01weavejesterjcsims: I think it’s just wrap-params, actually.
22:02jcsimsso it is just not possible to use the two different defaults in the same ring app, then?
22:05weavejesterjcsims: You’d need to make sure that the side-effectful middleware was set at the top level
22:06weavejesterjcsims: I think that’s just wrap-params and wrap-multipart-params. It might be worth having a config for middleware that’s side-effectful.
22:07weavejesterjcsims: But you can do it manually by turning those off and applying them at the top level. Or just apply wrap-params at the top level, because that’s the only side-effectful middleware used by both your routes.
22:09jcsimsok, I'll have to revisit this tomorrow, but I will keep that in mind - when you say 'top level', are you referring to inside 'app's definition, or elsewhere?
22:23vanilaDid rich hickey write the entire compiler by himself?
22:27TEttingervanila: take a look for yourself, https://github.com/clojure/clojure/graphs/contributors
22:28weavejesterjcsims: You want to ensure that wrap-params is only applied once.
22:31vanilaWow!!!! What a boss
22:31vanilaso much work
22:31vanilaim sure everyones contributions are really valuable but he put so much in!
22:32justin_smithvanila: he took years on the project
22:32justin_smith(well, I guess that shows in the graphs)
22:32vanilayeah!
22:33johnwalkerdamn thats a lot
22:45TEttingervanila, rich hickey kinda discovered a few of the data structure varieties clojure uses. Persistent Immutable Hashmaps are internally represented as 32-tries I think, which was not a common method but allows the sharing of state between similar maps
22:46amalloyyou gotta remember that 178,000 lines of java is really only like a thousand lines of clojure
22:46caternTEttinger: where's his papers on them, then
22:46amalloyTEttinger: he didn't invent HAMTs; they're an implementation of phil bagwell's ideas
22:47TEttingeramalloy, is clojure the first implementation of them in practice?
22:47caternTEttinger: it's not like he's some kind of CS genius (although I will change this opinion if he actually does have papers)
22:47amalloythe first that i'm aware of
22:48caternevery language loves its BFDL
22:48TEttingercatern, the fact that he isn't a theorist is part of why clojure's so successful; it's a productive language because rich needed it for work, so it had to work
22:49caternTEttinger: okay so don't imply he is, "discovered a few of the data structure varieties clojure uses"
22:49TEttingerdid I use the term CS genius?
22:50vanilabut he wrote an entire compiler himself
22:50vanilaso he must be at least a bitof genius
22:50TEttingerhe's hard-working, certainly
22:50caternthat's not that big of a deal
22:50caterntens of thousands of students write compilers every 3 months
22:50john2xhe's above average?
22:51catern(but yes it's of course somewhat impressive)
22:52TEttingerHe's a good combination of pragmatic, experienced, and hard-working, but I wouldn't describe any of clojure's underpinnings as especially "above the limits of normal programmer understanding"
22:53vanilais there a breakdown of how the compiler works? or a series of blog posts about it
22:53vanilaim realyl intrested in learning about compilers
22:53TEttingerclojure happens to inherit most of the advantages of earlier lisp designs, which helps a huge amount design-wise
22:53caternvanila: you could read a compiler textbook or read the source of a teaching compiler
22:55TEttingervanila: most compiler writing how-tos with implementation specifics expect you to know C, or sometimes Haskell. there's a good one that walks you through creating your own forth in assembly, an old approach that still works, though it won't be a practical language
22:56vanilaTEttinger, that forth one sounds really awesome do you remember what it was called?
22:59TEttingerhttp://www.eecs.wsu.edu/~hauser/teaching/Arch-F07/handouts/jonesforth.s.txt
22:59TEttingervanila, it took me a bit to find it, but I think that's it
23:00TEttingerthere's also the "make your own lisp in haskell" wikibook
23:00vanilacheers!
23:01vanilaim going to try to do the forth one :)
23:02TEttingerah, this one https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
23:02TEttingergood luck, vanila! I'd be curious to see it translated to a platform independent assembly-like language such as JVM or CLR opcodes
23:15kenrestivohas anyone done a transit implementation for c or c++? my google-fu is failing.
23:17kenrestivohmm, nevermind, turns out i don't need it.
23:42squeedeeAnyone in Manhattan here? Im stuck in hospital and need a decent coffee!
23:44TEttingersqueedee, fake the symptoms of methanol poisoning to get them to get you drunk
23:46TEttinger(the best cure for methanol poisoning, commonly caused by bad moonshine, is to get your body to digest a ton of regular (grain) alcohol, ethanol. the body prefers to digest ethanol first, and it lets methanol pass if you stay drunk enough)
23:55kenrestivotips every clojure programmer should know
23:55MrJones98anyone here familiar with clojure.tools.nrepl.server?
23:56justin_smithMrJones98: sure, what about it?
23:56MrJones98trying to use the default-handler and pass in some middleware
23:56justin_smithoh sorry, I've never used the middleware options at all
23:56MrJones98i admit i don’t understand the first thing about it and trying to adapt someone’s PR to lein-ring
23:57MrJones98justin_smith: darn
23:57MrJones98:-)
23:57MrJones98i’m getting a runtime exception - unable to resolve var