#clojure logs

2015-05-15

01:45shalom1024does have any ideas about a most convenient way to display an incanter graph in a seesaw app?
02:38oddcullytieTYT: it has. try youtube-dl to fetch it (unless you meant blocked blocked)
03:11myguidingstartieTYT, you can use this to download from infoq https://github.com/myguidingstar/infoq-downloader
03:42escherizeis there a trick to using dedupe on a channel?
03:44escherizeBasically, I am using a pipeline with a chan like (chan 1 (dedupe)) and it's not working. I'm pretty sure I'm doing something wrong
08:18sw1nnescherize: (unique (chan)) ?
08:35piranhahey all! So I have this base64 value, which I can't decode properly with data.codec: http://paste.in.ua/10729/ - any ideas what's going on here?
08:41hyPiRionpiranha: I guess you should remove the newlines in the base64 value
08:41piranhaoh
08:41piranhawhere they came from!
08:42piranhahyPiRion: yeah, that helped
08:42hyPiRionno idea. Weird that b64 doesn't complain about that though
08:43piranhacarmine gave me newlines inside of a value
08:43piranhawhy'd it do that to me :(
08:44piranhaoh, newlines are there in the first place, ok
08:44piranhathat seems like a feature of python's base64
08:45hyPiRionYeah, most base64 decoders seems to skip whitespace
08:47piranhahyPiRion: thanks! :-)
09:41ChaunceyHas anyone an idea what might cause a (defrecord Foo ..) to define a my-ns/->Foo instead of a my-ns/Foo ?
09:43luxbockChauncey: it should define both
09:43luxbock->Foo is a constructor function that gets defined for each record you define
09:44luxbockthere's also map->Foo
09:44Chaunceyaha, interesting, never knew that
09:44ChaunceyBut the original Foo is missing Oo
09:45ChaunceyI had it in a different namespace before, where I could create records that the other namespace would later complain about as not implementing the protocols I made them implement
09:48xeqiChauncey: are you `:import`ing Foo?
09:49Chaunceyxeqi: no, the namespace in question only has quil and ... stacktraces required..
09:51Chaunceyit does have [quil.core :refer :all], but I don't see how that could be a problem
09:52ChaunceyAlso, there are two records that have only these constructor methods available
09:52ChaunceySo if it was shadowing, it'd be a pretty large coincidence
09:58Chaunceyanyone? I am really confused, and not making any progress
10:01TimMcChauncey: You need to (:import other.ns.Foo), not just (:require other.ns)
10:01chouser_log(defrecord Foo) doesn't define a var named Foo, but a class named your.namespace.Foo
10:01TimMcVery common mistake. Require'ing the ns loads the defrecord and creates the class, but to *refer to* the class as Foo you need to import it.
10:01TimMc^ ANd that, yeah -- Foo isn't a var.
10:02Chaunceyok, I see, thanks
10:02ChaunceyThat clears that up... So if I have a main drawing quil namespace with a drawable protocol, and I implement the protocol in another namespace, do I need to import that namespaces record into the quil ns too to make it know about it?
10:03Chaunceyfor some reason that doesn't work either
10:05fourqmorning all
10:05Chaunceyfourq: Morning
10:05ChaunceyDoes namespace loading order have anything to do with the quil thread knowing about implementations?
10:13TimMcIt shouldn't!
10:13TimMcUnless the Quil thread uses reflection to load it, like Class/forName.
10:14TimMcIf the ns block requires the ns that has the defrecord, you should be fine.
10:14Chaunceywell, if it does I didn't write that :)
10:14Chaunceyhmm
10:14Chaunceyweird
10:15xeqiChauncey: so you have a quil ns that defines the protocol. You have a second namespace that defines a record that implements the protocol. Which one is creating the instance of the record?
10:15TimMcYou only need to require or import where you're going to reference something. (Exception: Making sure protocols and multimethod implementations get loaded.)
10:15ChaunceyTimMc: yeah, that's what I expected too
10:15Chaunceyxeqi: I create the instances in the other, non-quil ns that defines them
10:16ChaunceyI tried moving them around, that's when the missing Foo occured ;)
10:18Chaunceywell, I moved everyhing into the ns defining the protocol and imported it into the other, that seems to have done the trick
10:18ChaunceyStill confused though
10:19ChaunceyThanks for your help guys! Moving on...
10:19xeqiChauncey: were you reloading the file with the `defprotocol`? That would redefine it and make it so any instances of it before redefinition were invalid
10:20Chaunceyxeqi: I noticed that too, but I changed the code to recreate the instances after reloading
10:21Chaunceythere is basically one test function that does all the setup (conj drawables into an atom which is in the quil state)
10:29luxbockare there any other attributes besides :pre and :post that are used?
10:37timvisheram i supposed to use extend or extend-protocol to extend a protocol to a new type?
10:42puredangerextend should be considered low-level and not used directly
10:42puredangeruse extend-protocol to extend a protocol to one or more new types
10:42puredangeruse extend-type to have a type extend one or more protocols
10:43puredangerif you have 1 type and 1 protocol then flip a coin :)
10:45gfredericks(defmacro extension-roulette [one-thing another-thing & methods] (if (zero? (rand-int 2)) `(extend-protocol ~one-thing ~another-thing ~@methods) `(extend-type ~one-thing ~another-thing ~@methods)))
10:47Chaunceygfredericks: that is a little buggy, but I like it :D
10:48TimMcgfredericks: Would you accept a PR moving the if expression into the head of the extension call?
10:48Chaunceyalso on of your things is a protocol and the other is a type, so one-thing can't always be first
10:49Chaunceybut apart from that, it's core-worthy :D
10:50gfredericks@TimMc I think everything that can reasonably vary should vary
10:52Chaunceyhaha, you evil, evil man
10:53gfredericksgood morning everybody
10:54xeqidoes cider have a load this file into the repl, and any files that :require it command?
10:56TimMcxeqi: As in, reload this file and all dependants?
10:56xeqiyes
10:57xeqicfleming: ^ that is what cursive's" Load file in REPL" does right?
10:58xeqior am I reading https://cursiveclojure.com/userguide/repl.html backwards
11:01crocketclojure for the brave doesn't explain destructuring comprehensively.
11:01crocketDoes anyone knk
11:02crocketDoes anyone know a better learning material?
11:03gfredericksirc is pretty good
11:03gfredericksbecause destructuring isn't too complicated
11:04gfredericksso if you just ask questions about whatever info you're missing it'll probably be comprehensive pretty quick :)
11:04TimMccrocket: I don't know why it's on this page, but here's something: http://clojure.org/special_forms#binding-forms
11:06TimMcpuredanger: ^ I'm guessing destructuring used to be part of the compiler and was later moved to the destructuring macro?
11:06puredangerdunno, predates me :)
11:08crocketgfredericks : I will not know what I miss.
11:09puredangerhttp://blog.jayfields.com/2010/07/clojure-destructuring.html is pretty good
11:10crocketDu....
11:15TimMcpuredanger: Oh, I'm in the comments there, being an adorable Scheme immigrant!
11:16puredangerwelcome to our land of many types of brackets
11:16mdrogalispuredanger: Predates almost everyone https://twitter.com/chrishouser/status/599221332715307008
11:16crocketbraveclojure.com doesn't explain :or keyword in destructuring.
11:16alexbaranosky999dumb question guys: I thought in cider on Emacs I could M-. into a jar and compile changes in it. Is that true?
11:17TimMcpuredanger: I remember finally realizing that let and let* did not mean the same thing as in Scheme. (I think let* allows multiple bindings? I've forgotten by now.)
11:18puredangeralexbaranosky999: I think you can M-. into a jar and change .clj files (which I think is pretty evil actually)
11:20arohneralexbaranosky999: puredanger: both are true
11:20TimMcCan confirm, have done this on a running server and reloaded the code.
11:20arohneryou can edit files in the jar, and you can also C-c C-k the modified source file, w/o saving
11:20TimMcHave not needed to do this on a production server, thank goodness.
11:29TimMc("What do you think this is, an Erlang shop?")
11:35alexbaranosky999puredanger: arohner: I thought so, thanks. I need to basically debug a jar we're using, and wasn't seeing my changes reflect when compiling
11:35alexbaranosky999In general I agree, it's a little evil
11:35arohnernot something you should make a habit of, but it can be a lifesaver
11:36puredangerit's ok if you actually notice you're doing it. I've done it accidentally before though and really caused myself some head-scratching later.
11:36alexbaranosky999arohner: as you an see I haven't done it in so long, I forget if it is possible! :)
11:38TimMcpuredanger: Oh yikes, hadn't thought about the implications of M-. specifically. I don't have that integration running most of the time, so I just open the jar file directly and find the appropriate .clj.
11:38TimMcI can totally see doing it by accident.
11:38puredangerI've had that happen where we had a multi-module project so I was still in "our" code, just different "project"
11:40alexbaranosky999puredanger: yeah if you don't notice, that can be a big-time pain later to figure out
12:09crocketDoes anyone know a better book than braveclojure.com ?
12:10pbxcrocket, i'm enjoying the o'reilly book
12:10pbxaka http://shop.oreilly.com/product/0636920013754.do
12:10wasamasacrocket: living clojure is cool
12:11TimMccrocket: Better in what sense? Is the style just not matching? Too fast? Too slow?
12:11TimMc~books
12:11clojurebotbooks is http://www.pragprog.com/titles/shcloj/programming-clojure
12:11TimMcamong others
12:13crocketTimMc, braveclojure didn't mention :or keyword when describing destructuring maps.
12:14mp.wc
12:26crocketI think braveclojure is ok in overall, but I'm afraid that it might be missing important details.
12:26tmarblemacro help needed! I want to create a defrecord with type hints http://paste.debian.net/plain/177667 (but as real ^String not "^String")??
12:26lazybottmarble: What are you, crazy? Of course not!
12:26puredangerno one resource covers 100% of the details
12:27sdegutisWhen is Clojure 1.7.0 expected?
12:27puredangerbraveclojure is a great fun introduction that covers lots of useful stuff. I would augment with at least one more to get more complete coverage.
12:28puredangersdegutis: at this point, I think there is maybe 1 or 2 items that need attention. assuming no other reports from beta 3, I'm hoping we can do rc1 next week and then it's just a matter of getting enough feedback that we feel ok cutting a release
12:28crocketpuredanger, one more book?
12:28sdegutisNice.
12:28crocketduh
12:28sdegutispuredanger: thanks
12:28crocketDo people use :or keyword in destructuring maps?
12:28puredangercrocket: yes, for defaults
12:29crocketpuredanger, defaults?
12:29puredangerwe actually cover that use case in "Clojure Applied"
12:29crocketpuredanger, We?
12:29puredangerlike: I get a map of options, but want to supply defaults if some options aren't supplied
12:29puredanger"we" = me and Ben Vandgrift, as authors
12:30puredangerIn https://pragprog.com/book/vmclojeco/clojure-applied
12:31crocketWhich book do I better read after 'braveclojure?
12:31chousertmarble: maybe ~@(map #(vary-meta % assoc :tag 'String) args)
12:31puredangerthat book is designed as an *intermediate* book btw, and is use-focused (I need to do X) rather than feature-focused. it intentionally leaves out lots of features.
12:32puredangercrocket: if you want other intro books, I think the O'Reilly and Pragmatic ones are also pretty thorough. Programming Clojure and Clojure Programming, whichever matches those correctly. :)
12:33puredangerit's pretty old now, but I like the treatment of certain subjects a lot in Practical Clojure by Apress too.
12:34crocketI don't see a difference between clojure's built-in repl and lein repl.
12:34crocketlein repl seems to use nREPL which just looks like clojure's built-in repl.
12:36zerokarmaleftcrocket: it also incorporates REPL-y, which provides some niceties summarized at the top of the README https://github.com/trptcolin/reply
12:41crocketzerokarmaleft, How do I get lein repl outside leiningen?
12:42vermahey, in cursive, is there a quick way to reformat a form, like the Meta-q stuff in emacs?
12:43vermaI see some talks/screencasts that seem to do it, but I am not sure how that is done
12:45fourqHow is the addition symbol considered a truthy value? Just because it's not a false/nil value?
12:45fourq;; Return value of "or" is first truthy value, and + is truthy
12:45fourq(or + -)
12:45tmarblechouser: thx, but I get (clojure.core/defrecord fred [a b]) ;; this is a real brain teaser!
12:45fourqsince (or - +) returns -
12:48zerokarmaleftcrocket: I'm not sure I understand your question...you can run `lein repl` independent of any particular project
12:53gfrederickstmarble: you do need vary-meta
12:54gfrederickstmarble: try (set! *print-meta* true) at the repl, then inspect the output again
12:54gfrederickstmarble: the ^String syntax sets metadata on the symbol, and metadata normally isn't printed
12:54tmarblegfredericks: ok, i'll try that
12:55tmarblegfredericks: you and chouser are correct! thank you!
12:55gfredericks(inc me-and-chouser)
12:55lazybot⇒ 1
12:56TimMc$karma zerokarmaleft
12:56lazybotzerokarmaleft has karma 1.
12:56TimMchmmm
12:58justin_smith(identity justin_smith hyPiRion)
12:58lazybotjustin_smith hyPiRion has karma 1.
12:59justin_smith(identity hyPiRion justin_smith)
12:59lazybothyPiRion justin_smith has karma 1.
12:59justin_smithsymmetry
13:00crockethttp://shop.oreilly.com/product/0636920013754.do contains 630 pages, and https://pragprog.com/book/shcloj2/programming-clojure contains a lot less pages.
13:00crocketDoes it mean the former has a lot more details?
13:00crocketOr, is it just verbose?
13:01TimMc(identity gfredericks and chouser)
13:01lazybotgfredericks and chouser has karma 0.
13:02gfredericks(identity me-and-chouser)
13:02lazybotme-and-chouser has karma 1.
13:02gfrederickswoooh
13:09m1dnight1guys, im having some issues importing a java class in clojure. I have done it before and I think i have reproduced everything I had to, but its giving me "no such namespace"
13:10m1dnight1What I have done so far is: add :java-source-paths ["interop"] to my project.clj, give the class the packagename "actors", and then in my code I do: (:import [actors BlockingStore]))
13:10m1dnight1when I do lein run, it compiles the java class. so thats good, I guess.
13:12m1dnight1the parts in my source are literally copy pasted from my other project, so i dont see whats wrong. the only difference now is that the class that is trying to import it is not in my "root" namespace, it is in projectname.foo.bar
13:12crocketShould I read http://shop.oreilly.com/product/0636920013754.do or https://pragprog.com/book/shcloj2/programming-clojure ?
13:14zerokarmaleftcrocket: I've read both...you won't regret reading either of them
13:16crocketzerokarmaleft, It seems I better read the larger book...
13:16crocketOne book to rule clojure.
13:17crocketAs I guessed, the larger book goes very deep.
13:48andyfgfredericks: I see you did some changes to dynalint a while back, and I think you noted that lein-dynalint seems to be giving warnings for the Leiningen JVM. Do you know if it gives warnings for both Leiningen JVM and project JVM, or only Leiningen JVM?
13:53irctcIs there a core function to test if a String contains a number? (numeric? "-0.3") ; true (found one here as a backup: http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Clojure)
14:01andyfirctc: Only Java interop available, or a sufficiently complex regular expression and re-match
14:02andyfirctc: Java's parseDouble may be what you want: https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#parseDouble(java.lang.String)
14:03irctcandyf: thanks. I'll use the rosettacode for now, which of course uses interop.. True, I could try to proactively parseDouble and catch the exc, but generating a stack trace is too costly.
14:04andyfirctc: There is no need to generate a stack trace if you catch the exception, yes?
14:05irctcandyf: the act of throwing an Java exception creates a stack trace in the exception object. Not talking about printing it.
14:06irctcandyf: in other words when a Java exception is thrown the stack is captured and stored in the exception in case you need it.
14:06andyfirctc: I was not aware of that. Out of curiosity, have you measured performance impact of that?
14:07irctcandyf: this is how you can ask the exception object later to print the trace.
14:09irctcandyf: not with this particular issue. There's a lot on the topic. For instance. http://stackoverflow.com/questions/299068/how-slow-are-java-exceptions
14:09irctcandyf: bottom line, if performance matters don't throw exceptions.
14:09tcrayford____Not always though
14:10tcrayford____Some exceptions don't have stacktrace said after getting JITd
14:10tcrayford____Which makes for fun debugging :/
14:10irctctcrayford: Yes, I suppose there are always *exceptions* to the rule. :/
14:11tcrayford____See http://yellerapp.com/posts/2015-05-11-clojure-no-stacktrace.html
14:11tcrayford____There's links to good references on the perf side in there
14:12irctctcrawford: Thanks for the link. They mention, "perf implications" for turning stack trace generation.
14:13tcrayford____(I wrote that post)
14:13irctctcrawford: ... on
14:13gfredericksandyf: I don't recall, but if I had to guess it would be lein-vm-only
14:13gfredericksseems more complicated to somehow end up doing both
14:13tcrayford____There are references in it to real perf posts on the topic
14:14irctctcrawford: sweet!
14:14tcrayford____ See http://shipilev.net/blog/2014/exceptional-performance/
14:14andyfgfredericks: So lein-dynalint isn't terribly useful as is now, then?
14:14tcrayford____And http://normanmaurer.me/blog/2013/11/09/The-hidden-performance-costs-of-instantiating-Throwables/
14:15gfredericksandyf: that sounds right
14:16andyfgfredericks: Have you learned of any simple way to use dynalint to check for errors in your own project's code?
14:16irctcandyf: this is the performance hit when throwing, Throwable.fillInStackTrace(). It walks up the stack.
14:16andyfirctc: Makes sense.
14:16gfredericksandyf: my wording in the issues "just lint the leiningen process" backs up my previous guesses
14:17gfredericksandyf: I haven't been using it personally, but your question is confusing -- isn't that the entire point of using it?
14:18andyfgfredericks: Definitely it is the entire point. If lein-dynalint doesn't do it, is the only out-of-the-box way to use dynalint on your own project's code to invoke the documented commands in a REPL session?
14:19gfredericksandyf: being totally ignorant I imagine some sort of lein alias could accomplish it as well
14:19gfredericksor `lein run` command rather
14:19gfredericks(which could be aliased)
14:20andyfgfredericks: I'm being a bit lazy by asking you, sorry. I can figure it out given enough time. Just checking what you recalled off the top of your head.
14:23gfredericksno problem
14:28borkdudedo you guys ever feel the urge to refactor something you think can be better, outside work hours without getting paid for it by the customer?
14:28brucehaumanborkdude: yep
14:29gfredericksI try to resist though
14:29borkdudeI thought about it all day while I'm having a vacation...
14:29brucehaumanborkdude: I feel like its a natural response, but yeah, you should probably not do it, unless it will make your life that much better
14:30brucehaumanborkdude: you can sometimes get paid fo rthis down the line
14:31brucehaumanborkdude: but you are much better off selling it and getting paid for it
14:31gfredericksI at least put refactoring ideas in comments so they don't get completely lost when I forget about them
14:31winkborkdude: I can easily reist this. but what I have done was "we need to do x" - "we can only do this if there's an opensource lib for it" .. next day "here look, I found this open source lib [in my github account...]"
14:32brucehaumanlol
14:32borkdudewink :)
14:32borkdudein my case it's more about a database schema. it now uses "table per concrete type" while things would be more simple with "table per type"... 2 days work probably
14:33winkit was a simple ragel parser for js. I couldn't just let them eval() userr input
14:33winkI did for the greater good :|
14:33borkdudeas long as it's fun to do (researching a new library or technology) I don't mind it
14:33gfredericksI once had to deal with a legacy project that used a many-to-many join table to model a one-to-many relationship
14:34gfredericksbut it was too legacy/complicated to refactor it
14:34gfredericksall that could be done was regular weeping
14:34SeyleriusDo most win7 machines already have a JVM that can tolerate clojure?
14:35SeyleriusAnd we can use java GUI kits from clojure, right?
14:35andyfSeylerius: You mean for Clojure development, or deploying some kind of application?
14:35Seyleriusandyf: deployment.
14:36SeyleriusI'm dev'ing on my linux box. Just want to know that if I drop properly compiled bytecode on 'em, it'll work.
14:36brucehaumanborkdude: yeah database refactors … that desn’t sound like it could get out of control.
14:36borkdudebrucehauman joking or serious?
14:37brucehaumanborkdude: joking, sarcasm
14:37brucehaumanborkdude: depends on the project size right?
14:38brucehaumanborkdude: or rather the surface area that interacts with the data layer
14:39borkdudebrucehauman right, I'll probably better make an inventory of changes before naively starting this
14:40kaiyindoes the counts of s1 and s2 really matter here? https://github.com/clojure/clojure/blob/master/src/clj/clojure/set.clj#L37-L43
14:41kaiyinit's basically a nested loop over s1 and s2 anyways.
14:42andyfkaiyin: One way of doing it is linear time in size of s1, the other way linear time in the size of s1 (times the log of the other for each contains? call, but I'm leaving that out)
14:42andyfoops, 'other ... s2' is what I meant.
14:44kaiyinandyf: you mean contains? is way faster than reduce in this case.
14:44andyfkaiyin: reduce is doing a linear iteration over elements of s1 there.
14:45kaiyinok, i see.
14:45andyfkaiyin: contains? is log time
14:45kaiyincontains? is probably traversing over some kind of tree structure.
14:46kaiyinthat could "return early".
14:46andyfOr as some Clojure folks like to call it, "effectively O(1)" :)
14:46kaiyincool.
14:48borkdudebrucehauman thanks for the talk at clojure/west btw, I recently watched it
14:48devn+1
14:49devn(inc brucehauman)
14:49lazybot⇒ 1
14:49andyfFine print: contains? can be linear time, but only if you use a hash set and work reasonably hard to pick many set elements that collide to same hash value
14:49brucehaumanborkdude devn thanks, you guys are too kind, it was a lot more fun than I expected it to be
14:55devnbrucehauman: all about your delivery man
14:55devnwell done :)
14:55devnalso, from where i was sitting i thought maybe you were wearing a smoking jacket, which made it even cooler
15:03kaiyina function working on maps is sitting in set.clj: https://github.com/clojure/clojure/blob/master/src/clj/clojure/set.clj#L77-L86
15:04hkjelsI'm getting a really vague error-message without line-num etc. Even with DEBUG env. Is there a way to get an even more verbose error-output?
15:05hkjelsThe error is : Error: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named
15:06devnhrm
15:06devni need a project to tinker with
15:07amalloyhkjels: are you in the stock clojure repl? you can get a real stacktrace with (.printStackTrace *e *out*)
15:08amalloyanyway, the error means you have a vector where a keyword/symbol/string is expected, of course. i'd guesss this is in your ns form
15:09epicheroany suggestions for working with websockets?
15:10hkjelsamalloy: That's the one place I haven't looked :) One sec
15:23hkjelsamalloy: Nope, LGTM. I'm running `lein garden` when the error appears. I've now tried my styles-file with the stock repl without errors, so the problem lies elsewhere
15:29andyfkaiyin: Yes, that function has been in clojure.set namespace for a long time. I doubt it will move.
15:30andyfkaiyin: There are several functions for working on sets of maps with identical keys to each other, i.e. relations, in clojure.set namespace.
15:30kaiyinandyf: yeah, I am reading them.
15:46cflemingverma: You can select the form and then reformat, and it will format the selection. I'm planning to add a "reformat top form" action
15:47kaiyinis there something similar to peek for a set?
15:47cflemingxeqi: Right. AFAIK to get that in Emacs you need to use tools.namespace
15:49andyfkaiyin: No. peek is only implemented for data structures with a notion of order. Sets and maps are unordered.
15:50andyfOh, well, I guess there are sorted sets and maps, too, but they also do not implement peek.
15:50andyfSo, peek for list, vectors, queues, I think lazy sequences, too.
15:50kaiyinI think peek can be useful in both scenarios.
15:51andyfWhat would you want peek on a set to do?
15:51kaiyinwell, to have a peek at it.
15:51kaiyin:)
15:51andyfYou mean, return an arbitrary element of the set?
15:51andyf(first (seq my-set)) may do what you want
15:52kaiyinah, i see.
15:52angusiguess,(first #{3 4 2 6 5 1})
15:52clojurebot1
15:52kaiyin,(next #{3 4 2 6 5 1})
15:52clojurebot(4 6 3 2 5)
15:52andyfoh, and of course, first calls seq on its argument, so is unnecessary in my example.
15:53kaiyincoll
15:53kaiyincool
16:06hkjelsamalloy: Found the issue. It was in my project-file
16:20kaiyinarray-maps are automatically converted to hash-maps when it's over a certain size, right? what is that size limit if so?
16:26justin_smith,(count (first (drop-while #(= (type %) clojure.lang.PersistentArrayMap) (iterate (fn [m] (assoc m (gensym) true)) {}))))
16:26clojurebot10
16:26justin_smithkaiyin: 10
16:26kaiyincool.
16:29kaiyinjustin_smith: so {} is an array-map by default.
16:29justin_smithyes
16:29justin_smith,(type {})
16:29clojurebotclojure.lang.PersistentArrayMap
16:34kaiyin,(inc justin_smith )
16:34clojurebot#error {\n :cause "Unable to resolve symbol: justin_smith in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol:...
16:34kaiyin(inc justin_smith )
16:34lazybot⇒ 10
16:35kaiyinHow do you overide this behavior then, if you want to use array map with size greater than 10.
16:38TimMcIn 1.7 they won't be array maps, I think.
16:38TimMckaiyin: Why would you want to? Anyway, you can use sorted maps from some library.
16:39kaiyinTimMc: sorted maps aren't the same thing. I want preserve order of insertion, not by some cmp func.
16:40TimMcMmmm, I see.
16:40justin_smithkaiyin: the number of incs of "justin_smith " is equal to the number of elements in the first hash-map that is auto-promoted from array-map
16:40justin_smiththat's a nice coincidence
16:41kaiyinIndeed, :D
16:41justin_smithTimMc: clojurebot is running 1.7
16:42justin_smithkaiyin: there is an insertion-ordered map out there - maybe amalloy made it? I am forgetting right now.
16:42whodidthisi heard ordered map is all about that insertion order
16:42amalloy$google amalloy ordered
16:42lazybot[amalloy/ordered · GitHub] https://github.com/amalloy/ordered
16:42amalloyi guess i did make it!
16:43justin_smith(inc amalloy)
16:43lazybot⇒ 268
16:43kaiyin(inc amalloy)
16:43lazybot⇒ 269
16:43kaiyinamazing.
16:43justin_smithI'm catching up
16:43justin_smith(identity justin_smith)
16:43lazybotjustin_smith has karma 253.
16:44kaiyinit's also entirely in clojure.
16:45kaiyinamalloy: it's not uploaded to clojars, though?
16:45amalloyof course it is
16:45amalloy(defproject org.flatland/ordered "1.5.2" ...)
16:47kaiyinamalloy: https://clojars.org/ordered here it says 1.3
16:47amalloykaiyin: org.flatland/ordered. it has a groupid
16:49kaiyinyeah, what does that have to do with the version of this package? maybe a stupid question, I don't know much about maven.
16:49justin_smithkaiyin: every artifact has a group and a project
16:50justin_smithkaiyin: but lein has a convenience where if you don't have a / it makes group and project the same
16:50justin_smithso asking for ordered is the same as asking for ordered/ordered
16:50justin_smithas opposed to org.flatland/ordered
16:50kaiyinok.
16:51kaiyini see, there is another one. https://clojars.org/org.flatland/ordered
16:52kaiyinthis means it's been pushed twice.
16:53whodidthisartifacts also sound pretty cool, they are mystical and once posted on clojars under a version you cant alter them
16:54kaiyinamalloy: it might be nicer if you added one or two lines about how to add this dependency in a lein project, as many clojure library github pages do.
16:54kaiyinjust a suggestion.
16:55cddrSo I'm writing a with-test-logger macro that catches logs so that test code can verify they have been emitted....
16:55cddrI've seen people suggest this might be implemented by emitting logs to a channel
16:55cddrWhat does that buy you over just appending them to a vector?
16:57sdegutis,[do (prn 1) (prn 2)] ;; why?
16:57clojurebot#error {\n :cause "Unable to resolve symbol: do in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: do in this context"...
17:00sdegutisCLJ-1184 should have made that work
17:01sdegutisOh wait, that's fixed. Good.
17:02TimMcUnfortunately. It made for some fun prank code.
17:04justin_smithis there any plan for cljc to support tags other than clojure implementation (:clj :cljs) ?
17:04justin_smithplus :default, of course
17:05justin_smithI see :arch/osx briefly on this page, but no explanation about how this is set up stands out http://dev.clojure.org/display/design/Reader+Conditionals
17:06puredangernot in 1.7
17:06justin_smithahh, OK
17:07justin_smithso it's not just reading comprehension fail on my part
17:07puredangercustom features were there and we pulled them out
17:07puredangerjust narrowing scope
17:07puredangermay reconsider in the future
17:07justin_smithcool, now the puzzle pieces fit :)
17:16weiIs there a data structure that’s like a 1-1 map, with two-way lookup? Alternative is to use two maps, a->b and b->a
17:16the-kennywei: I'd just go with the two-map approach.
17:16TimMcwei: Either amalloy or ztellman has probably written a library for that. :-P
17:17kaiyinhow do you change shift width in cursive?
17:17amalloywell, it's not my style. who knows, maybe zach did
17:18justin_smithwei: I think that's known as a bi-map
17:18the-kennycommons has one iirc. Non-persistent, of course
17:19justin_smithhttps://gist.github.com/semperos/3835417 here is one from cgrand
17:21TimMcamalloy: You're the two people who write most of the collection libs.
17:21weithanks for the tips! now that I have a name for this, I also found org.apache.commons.collections.bidimap.TreeBidiMap
17:22TimMc(Weighted by number of references I see in IRC.)
17:22weigonna test out cgrand’s implementation first though, since it supports assoc and dissoc
17:23TimMcwei: Yeah, TreeBidiMap is mutable, which might be a problem for you.
17:25andyfkaiyin: You may have already gotten your question answered, but Clojure cheat sheet has several variants of ordered maps and sets linked from there: http://clojure.org/cheatsheet but versions at "Download other versions with tooltips" link near top of that page are more up to date and have tooltips
17:28kaiyinandyf: you mean this one? http://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html
17:28kaiyinlooks quite nice.
17:31andyfkaiyin: There are several variations depending on whether you want links to ClojureDocs or Grimoire, but yeah
17:31kaiyincool
17:54TimMcAnyone know of a leiningen plugin to compare dependency versions across two git commit IDs?
17:54TimMcI'll write it myself if no one has done this, but I don't want to do the work if it exists...
17:56TimMc(When I change a dependency version, I want to see what other dependencies that has changed so I can check for potential breaking changes.)
18:23aperiodichey so... I feel sorta crazy for asking, but has anyone run into a problem where leiningen's `deploy` task creates jars that... don't have any code?
18:23aperiodicwhen I create a jar with `lein jar` it has my code in it
18:23aperiodicbut when I deploy to clojars with `lein deploy clojars`, then open up the jar that gets pushed, it contains no code
18:23aperiodicthis is with leiningen 2.5.1
18:24TimMcaperiodic: Do you have a public project I could look at?
18:24aperiodicand this project.clj: https://github.com/puppetlabs/clj-ldap/blob/master/project.clj
18:26TimMcaperiodic: My first recommendation is to try to reproduce it with a local filesystem repo -- add :local-test "file:///home/aperiodic/tmp" to your :deploy-repositories and do lein deploy local-test
18:26TimMcthen move your lein profiles out of the way and see if it still happens.
18:28aperiodicTimMc: alright, I'll give that a shot.
18:29TimMcaperiodic: For what it's worth, when I deploy to a local repo, I see clj_ldap/client.clj in the jar.
18:32aperiodicwell it doesn't happen an another project
18:37aperiodicyeah, I see it there too
18:39TimMcaperiodic: Bet it's a lein user profile.
18:42aperiodicTimMc: why would it only manifest in the one project?
18:43TimMcHmm... another idea. Move ./target elsewhere (for forensics) and try again.
18:43aperiodicTimMc: yeah I still get no code in the jar that gets deployed to clojars
18:43TimMcOr lein clean if you just want to try and fix it and not figure out why it's busted. :-P
18:43aperiodicoh... I did turn off AOT in this project recently
18:44aperiodicthanks for your help
18:45aperiodicyup!
18:45aperiodicmoving target out of the way fixed it
18:47aperiodicthough there is no difference in terms of files present between the old target and the target after deploying a jar that actually had code
19:01weiprotocol question. in cgrand’s bimap implementation (https://gist.github.com/semperos/3835417) i see that “without’ is defined as a protocol function. so why can I not call (without (bimap :a 1) 1) ?
19:07amalloy.without is a method in some interface from clojure.lang. it's not a protocol function
19:07TimMcaperiodic: /me waves hands and mumbles about timestamps
19:17SeyleriusGrr... CIDER complains thusly on load: http://ix.io/izO
19:21xeqiSeylerius: add something like https://gist.github.com/xeqi/05d3e955aed4810302ca to your ~/.lein/profiles.clj
19:29Seyleriusxeqi: That did the trick (with an additional "}"), thanks.
19:37SeyleriusCan mikera's core.matrix handle 3D matrices?
20:24SeyleriusOkay... clojure and 3d matrices. Anyone got some advice? Can mikera's core.matrix do it? Maybe a vector or matrices?
20:36dmkolobovHi y'all. On the http://clojure.org/lazy page, the last paragraph describes a way of triggering `lazy-seq` compiler optimizations with a `filter` example. I've heard this referred to as "local clearing" before. From the example, does the function `f` have to declare `p` as one of its parameters? Will the compiler not optimize if `f` take the single argument `c`?
20:37dmkolobovmy bad, the function `f` is called `step` in the example
20:53crocketHow is lein repl different from cider repl?
20:53crocketAre they the same?
21:15gfrederickscrocket: cider starts its repl via leiningen I believe
21:28crocketIt seems cider repl is lein repl.
21:28crocketHow clever.
21:28gfredericks:)
21:29TimMc(def cider lein)
21:29crocket(sum 1 help)
21:29TimMcFun fact: There is actually only one program in the world; it behaves differently when called by different names.
21:38crockethmm......
21:40crocketHell
22:15tolstoy(Emacs/Cider): Is it possible to re-evaluate a defmulti and have it take?
22:29gfredericksdefmulti is inherently re-eval-hostile
22:29gfredericksone workaround is to eval (def my-multi nil)
22:29gfredericksthen eval the defmulti again
22:34tolstoyAh, thanks gfredericks.
22:34gfredericksnp
22:50tolstoyWorked! ;)
23:00tmtwdhm -
23:01tmtwdclojure is interopperable with java, why do wrappers exist for java libs to interact with clojure?
23:01tmtwdie https://github.com/pelle/bitcljoin
23:03gfredericksit can make things more fluent
23:03tmtwdi see
23:03TEttingerjust to make it easier, really. you can do a lot with certain clojure features that often is tricky from java, like how Seesaw is a wrapper around Swing that takes anonymous fns instead of java-style anonymous inner classes (that might be possible anyway)
23:03TEttingerseesaw adds a lot of functionality, like being able to get a GUI element by an ID or selector
23:04TEttingermany wrappers try to do the same
23:04tmtwdCool
23:04devnTimMc: how do you mean?
23:04tmtwdI may take a look at seesaw, since I have some experience with swing
23:05TEttingersome things are kinda a pain to use from clojure if they use java conventions. arrays aren't quite as easy as they could be, and varargs in java are really just an array of arguments
23:05tmtwdswing is so awful, I can't believe that is how I learned to program
23:05devnTEttinger: IIRC someone wrote a lib to make arrays a little easier to work with
23:05devntmtwd: haha
23:05TEttingerhiphip, yep
23:05tmtwddevn, java arrays?
23:05devnseesaw isn't so bad
23:06devntmtwd: yeah
23:06devnTEttinger: yeah, that's the one
23:06tmtwddevn, why not just use vectors?
23:06TEttinger(arrays aren't preferred in idiomatic clojure because they aren't immutable and aren't persistent, etc.)
23:06devntmtwd: performance
23:06devnor interop related reasons
23:06TEttingerbut yeah they do perform very well
23:06devnwhich kind of dovetail
23:06tmtwdinteresting
23:06devni mean, there is a tradeoff
23:07TEttingerit's harder to get highly-mutable code that uses arrays a lot to work on the first try
23:07tmtwdI would have thought vectors were just arrays with a different name
23:07devnit's why they're a little more cumbersome to use in clojure, and frankly, i appreciate that design choice
23:07tmtwdbut I guess vectors in clojure have to conform to lisp patters or something
23:07devnfor java programmers, they'll want to start using arrays right away, better to lead them down the path of sanity
23:07devnand let them choose arrays only where they're truly necessary
23:07gfrederickstmtwd: they're immutable; it's a huge difference
23:07tmtwdgfredericks, ah of course
23:07devntmtwd: are you familiar with structural sharing and all of this business?
23:08tmtwdbut vectors are random access, no?
23:08gfredericksyep
23:08devnyeah
23:08tmtwd@devn no,
23:08tmtwdnever heard of it
23:08devnvectors are very much like ArrayLists, except they're totally different
23:09tmtwdAnd the fact that vectors can't change size
23:09devntmtwd: so, if you do this: (conj [1 2 3] 1)
23:09tmtwd(I think)
23:09devndo you make a copy of [1 2 3]? [1 2 3 1]?
23:10tmtwdnot sure
23:10tmtwdis there a copy function
23:10tmtwd?
23:10tmtwdah
23:10devntmtwd: http://en.wikipedia.org/wiki/Persistent_data_structure
23:10devn"While persistence can be achieved by simple copying, this is inefficient in CPU and RAM usage, because most operations make only small changes to a data structure. A better method is to exploit the similarity between the new and old versions to share structure between them, such as using the same subtree in a number of tree structures."
23:10devn"However, because it rapidly becomes infeasible to determine how many previous versions share which parts of the structure, and because it is often desirable to discard old versions, this necessitates an environment with garbage collection."
23:11devnthis works out on the JVM because the GC is marvelously good
23:11devntmtwd: read this also: http://hypirion.com/musings/understanding-persistent-vector-pt-1
23:12tmtwdvery interesting
23:12tmtwdso in a naive implementation of immutability, you would just copy the old version of the data structure?
23:13devnthat's one way, yeah
23:13tmtwdwhereas, a better way would be with persistent data structures?
23:14tmtwdcool links
23:14TEttinger&(let [v [1 2 3] a (int-array [1 2 3])] (do (pr v) (print (vec a)) (print " changing values... ") (map inc v) (amap a i a2 (aset a i (inc (aget a i)))) (pr v) (print (vec a))))
23:14lazybot⇒ [1 2 3][1 2 3] changing values... [1 2 3][2 3 4]nil
23:14devntmtwd: i dont want to say categorically better
23:15devnlike everything, there are tradeoffs
23:15TEttingerthe map on v won't change v. the map on a actually by default won't, but it can easily
23:15tmtwd(conj [1 2 ] 2)
23:15TEttinger&(conj [1 2] 2)
23:15lazybot⇒ [1 2 2]
23:15devntmtwd: add a , or &to the front of what you just wrote
23:15tmtwd&(conj [12 32 44] 4)
23:15lazybot⇒ [12 32 44 4]
23:16tmtwdcool! I want one
23:16devncopy on write collections were added long ago in java
23:16TEttinger,(into {} [:a 1 :b 2 :c 3 :d 4 :e 5 :f 6])
23:16tmtwdOh, I already have on
23:16devnalong with conurrent hash maps
23:16clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 528]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 528]\n [clojure.lang.RT seq "RT.java" 509]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 4...
23:16devnand this was to allow concurrent reads
23:16devnbut it's only decent to use it when your reads vastly outweight the number of writes
23:17devnbecause it does a copy, with a lock
23:17TEttinger,(zipmap [:a :b :c :d :e :f] [1 2 3 4 5 6])
23:17clojurebot{:a 1, :b 2, :c 3, :d 4, :e 5, ...}
23:17devnso, i have to run, but now we're kind of getting to some important bits for you to understand about clojure
23:17TEttingerclojurebot, which is called with comma, will cut off output
23:17clojurebotc'est bon!
23:17TEttinger&(zipmap [:a :b :c :d :e :f] [1 2 3 4 5 6])
23:17lazybot⇒ {:f 6, :e 5, :d 4, :c 3, :b 2, :a 1}
23:17devncheck out atoms, read up on persistent data structures (the link i posted above)
23:17justin_smith~which,
23:17clojurebotHuh?
23:17TEttingerlazybot will not
23:18TEttinger~which
23:18clojurebotwhich is called with comma, will cut off output
23:18tmtwd@devn I actually was watching a talk on persistent data structures today
23:18tmtwddidn't finish it though
23:19TEttingerfor certain tasks they're absolutely invaluable, for the rest they're just handy
23:19devnthey're a sensible default
23:19devnIMO
23:19TEttingeragreed
23:19devnbetter to have the persistent immutable properties, and then flip them mutable if you need to
23:20devndoing it the other way around is a true pain
23:20tmtwdgood to know
23:20devntmtwd: anyway, like i said, gotta run, but welcome!
23:20tmtwdthanks :)
23:21crocketMost mutations are bad.
23:21devnhappy clojuring :)
23:21crocketThe same applies to genes.
23:21crocketJavascript is a mutant ninja.
23:21justin_smithturtle with a jetpack
23:22devnokay really leaving now
23:22devnlater all
23:22justin_smithis it teenage yet?
23:22justin_smithwas it made before 1992?
23:23justin_smitherr wait, people born in 2002 are teenage
23:23justin_smithanyway, definitely a teenage mutant ninja turtle
23:24TEttingerisn't javascript older than, or approaching, 20 years old?
23:24tmtwdTEttinger, today
23:24tmtwdit is 20 years old
23:25TEttingerwowza
23:40justin_smithnext year we are gonna have to get javascript soooo wasted
23:47epicherojavascript already makes me drink...