#clojure logs

2015-08-07

00:28batamhelloo,,,
02:56hejkiohai, how do I use literal '?' with jdbc queries? escaping does not seem to work, neither does using double ?.
03:05ddellacostahejki: what are you using to connect to the DB? clojure.java.jdbc ?
03:05hejkiclojure.java.jdbc yes
03:05hejkiI am using PostgreSQL with jsonb-fields, and the syntax for checking json object key existence is: json_field_name ? 'keyname'
03:05hejkiso I kinda need to pass the ? without appending any parameter values into it :P
03:06hejkiwith a quick glance the lib seems to have no support for "unprepared" statements and/or skipping parameter binding
03:07ddellacostahejki: you should be able to do something like ["INSERT INTO foo (a, b) VALUES (?, ?)" "this" "that"] I believe
03:08ddellacostapassing that into execute
03:08hejkiddellacosta: yes, that works fine, what I cannot do is: ["SELECT COUNT(json_field ? 'somekey') FROM table"]
03:09ddellacostaoh sorry, I misunderstood--you want to pass the value '?' in?
03:09hejkiddellacosta: so what I want is to tell java.jdbc that the ? in the statement is literal ?, not placeholder for parameter
03:09hejkiyes
03:09ddellacostagotcha
03:09hejkimaybe ["SELECT COUNT(json_field ? 'somekey') FROM table" "?"] works :D
03:10hejki... it does not :<
03:10ddellacostahuh, maybe! Dunno if prepared statements make sense with a select, but...
03:10ddellacostaah
03:10ddellacostaone sec
03:12ddellacostahejki: so, I just tried (j/query fdb ["SELECT E'?' as foo"]), and that worked
03:12ddellacostagave me ({:foo "?"})
03:12hejkiahh! :)
03:12ddellacostamaybe that'll work for you, like COUNT(json_field E'?' 'somekey') ?
03:13hejkiy, I am currently testing
03:13hejkinah... PSQLException ERROR: syntax error at or near "'exception'"
03:13ddellacostahmm, one sec
03:13ddellacostaI think I have to be trying this on some json data to give you a useful answer
03:17ddellacostadamn, I need 9.4 for this don't I
03:17hejkiy
03:17hejki:P
03:18ddellacostaalright, well, I don't care about that actually, if I get the same psql error w/c.j.j then it should work for you
03:20ddellacostahmm, this appears to be a java issue actually
03:20ddellacostaspecifically org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet
03:20ddellacostanot that that helps you. :-p
03:20hejkihehe :P
03:21hejkiI kinda guessed it is java issue :P
03:24ddellacostatesting out a more recent postgres jar
03:24ddellacostathis suggests it may be fixed already: http://postgresql.nabble.com/problem-with-pgjdbc-prepared-statements-and-new-jsonb-exists-operator-td5834634.html
03:27hejkihmm.. the mentioned version of postgresql lib is not available from clojars
03:28ddellacostayou can get it from maven
03:28ddellacostaw00t, that did it for me
03:28hejki1102 is available from clojars, that should be even newer, testing that no
03:28hejkinow*
03:29ddellacosta(j/query fdb ["SELECT '[\"foo\", \"bar\", \"baz\"]'::jsonb ?? 'bar'"])
03:29ddellacosta PSQLException ERROR: type "jsonb" does not exist
03:29ddellacostathis is what I have in my project.clj for postgres: [org.postgresql/postgresql "9.4-1201-jdbc41"]
03:29ddellacostathat works
03:30ddellacostaanyways, hopefully that does what you need--good luck!
03:30hejkisame version, still getting PSQLException No value specified for parameter 1.
03:30ddellacostathat's the same exception you were getting before?
03:31hejkiyes, nvm my version was 1102 :P
03:31hejkitesting the 1201
03:31hejkiahh
03:31hejkiyes
03:31hejki!
03:31hejki\o/
03:31hejkiit works
03:31hejkity alot
03:31ddellacostasweet!
03:31ddellacostaglad you got it working
03:31hejkiyup, have to use double ? though
03:31ddellacostayeah, may be stuck with that for now
03:32hejki that is actually tolerable imo
03:32hejkisince it is quite special case
04:11supersymIs there a way (like in F#) that I can choose what data from a defrecord to output when printing? I am using one as a storage for blobs of text but it clutters my entire screen making it harden to sift through data
04:11supersym(just need to keep it to inspect the original texts when something goes wrong)
04:15Kneivasupersym: Like this? http://stackoverflow.com/a/3689364/1790621
04:17supersymKneiva: exactly! Thanks for the reference
04:23Kneivanp
04:26slhsenHey, anyone used https://github.com/hugoduncan/clj-ssh before? I got a question about it.
05:15cmarquesHi, I'm reading through https://github.com/technomancy/leiningen/wiki/Faster, which lists different ways of making leiningen boot faster. However, it's hard to know pros and cons of each strategy. What would be a good general strategy for faster boot time when using leiningen? Thanks!
05:30kwladykai found interesting article about performance in Clojure, just sharing with you http://www.learningclojure.com/2013/02/clojure-is-fast-is-clojure-still-fast.html :)
05:40jkogut_gskwladyka, eeee "Sorry, the page you were looking for in this blog does not exist. "
05:41oddcullynot true
05:41oddcullyloads for me at least
05:42jkogut_gshmmm
05:43kwladykait works for mee
05:43kwladyka:)
05:45jkogut_gsok, few times refresh and works
06:24kwladykahaha i solved it!!! so many days of work and solve it! So happy, i am going rest :)
06:25eaz4Ohfikwladyka: I have no idea what are you talking about, but congrats anyway :)
07:45namraah strange things :/
07:46namratests run fine, and manual http request via curl throws a cryptic exception :/
08:04kunginamra: cryptic?
10:30hefestoGood morning :) When I try to use the CIDER repl I get an "java.io.FileNotFoundException: Could not locate clj_antlr/core__init.class or clj_antlr/core.clj ..." error, but using the lein repl works fine. Does anyone know why?
10:40chouserhefesto: can you (require 'clj-antlr.core) in the lein repl?
10:40hefestoyes
10:41hefestoi even use a function from clj-antlr and it returns the expected
10:42hefestochouser: and thank you for responding :)
10:45chouserhm, maybe paste your project.clj in a gist or something? Anything weird in your .lein/profiles.clj?
10:50akabander?
10:50hefestochouser: I've never used gist. I hope i did it right: https://gist.github.com/hhefesto/0aa1a57bb6120b03ff16
10:50expezHas anyone written a lein plugin yet which converts a cljc based lib to an artifact containing only clj and cljs files? I'd like to use cljc, but I don't want to force consumers to use 1.7...
10:56puredangerthat is effectively what cljx does
10:58puredangeror rather that takes a source template and spits out new source files. doesn't exactly solve this problem, just mean it has the right shape.
11:12chouserhefesto: Hm, looks pretty vanilla. I don't really have any explanation. Are there any other errors during cider-jack-in, prior to the FileNotFound?
11:15hefestochouser: It magically got resolved. I'm sorry. I have no idea how. I just called cider-jack-in from project.clj rather than from my src file and it now works.
11:15chouserI think if someone needs to apologize, it's not you. :-) Glad it's working for you now.
11:16hefestothank you so much anyway :)
11:17chousernp
12:12{blake}Is it fair to say "cons always returns a list"? I know there are different classes that might be returned, but they're all broadly "lists" (versus, say, vectors).
12:12justin_smith,(list? (cons :a nil))
12:12clojurebottrue
12:13justin_smith,(list? (cons :a []))
12:13clojurebotfalse
12:13justin_smith,(type (cons :a []))
12:13gfredericks{blake}: if you relax "list" to "seq" then yes
12:13clojurebotclojure.lang.Cons
12:13justin_smith,(seq? (cons :a []))
12:13clojurebottrue
12:14justin_smithit's casual friday for lists, they can relax today
12:14{blake}gfredericks: So, I guess the question is, is it wrong to do so? Even though it's pretty common to be casual about the word, it could trip you up.
12:15{blake}My "lists" are all in hawaiian shirts and shorts today.
12:18gfredericks{blake}: depends on the linguistic context
12:19Ch3ck_I'm kinda confused between learning Erlang and Clojure, can anyone just give me some opinions on why I clojure might be the future?
12:19{blake}gfredericks: Yeah. There's the other, sorta M. Night Shyamalan side of this: A ha! You never noticed that when I said "list" I meant actual lists, not sequences! That's not great eitehr.
12:21justin_smithCh3ck_: if you want ultimate stability and rolling updates and highest possible availability, I'd go with erlang. If you want a modern language and number crunching speed while being good at concurrency, that would point to Clojure.
12:22justin_smithCh3ck_: then of course there is syntax, ecosystem of libraries, etc. to consider
12:22Ch3ck_justin_smith, I like clojure because of it's intersection with Java and the JVM
12:22justin_smithyeah, that is a bonus - it's the real reason I can use Clojure at work
12:22Ch3ck_so was thinking it will help me some time in the future cover for Java's mistakes with JP
12:23justin_smithJP?
12:23Ch3ck_justin_smith, sorry FP
12:23justin_smithyeah, Clojure is good for that
12:23Ch3ck_justin_smith, any recommended books?
12:23Ch3ck_It's confusing looking at the list on stackoverflow ;)
12:24Ch3ck_A newbie might not know which one to choose
12:24{blake}Ch3ck_, justin_smith: Yeah, me, too. POI FTW!
12:24justin_smiththe O'Reilly clojure book is good. Clojure From the Ground Up and Clojure For the Brave and True are free online
12:25Ch3ck_thanks justin_smith. {blake} any suggestions too?
12:25justin_smithCh3ck_: if you already have a lispy background (eg. common lisp or scheme experience), Joy of Clojure is excellent
12:25oddcullyclojure applied tackles real world problems. might be missing in "old lists"
12:25Ch3ck_I have no experience with FP.
12:25Ch3ck_Clojure will be my first
12:25{blake}Ch3ck_: I don't like the books, although I'm going through Living Clojure right now and hoping it will be better.
12:26Ch3ck_Aight, will check justin_smith's recommendations
12:26justin_smithCh3ck_: tbh I learned more about clojure by lurking here and following the conversation than anywhere else
12:26{blake}At least for me, I'd start reading one of these things, and there'd be 20 pages up front on Clojure's amazing destructuring capabilities, or some really deep abstraction stuff.
12:26gfredericks{blake}: I think technical contexts will always be that way; we don't have nearly enough words for our concepts so we overload them everywhere, and the only way to be sure you're communicating effectively is to clarify a bunch
12:26{blake}I managed by alternating between here, 4clojure, the books, and writing code.
12:27{blake}gfredericks: Yes, there's some of that. But each language has its own frailties as far as it goes. Like, for Ruby, it's this gungho "Learn 15 DSLs 'cause Ruby is so easy and it all looks like English!"
12:27Ch3ck_Alright, guess. I'll be lurking here more often justin_smith {blake}
12:28Ch3ck_I don't know any programmer who codes in Clojure in my Country
12:28justin_smith{blake}: that reminded me of a great thing I heard today "familiarity will increase, but complexity is forever"
12:28{blake}I think FP's--and especially Clojure--"weakness" is that it's demanding. Algol-type languages are easy.
12:29{blake}justin_smith: Yes! Just so.
12:29justin_smithCh3ck_: haha, actually one bonus of Clojure is there is very little syntax, so it can take a bit more effort to really do things obscurely (though we know a few tricks)
12:29{blake}And I think the problem with clojure books is that it's hard to remember what it was like to NOT be familiar with things.
12:29xemdetiaI think it is also important for clojure to at least know some rudimentary things about Java- going into clojure blind without any java background will be painful
12:30{blake}(Which is a problem with all tech books written by experts, but doubly so for Clojure.)
12:30Ch3ck_I code in Java xemdetia
12:30justin_smith{blake}: yeah, writing intro books is hard because memories of what was difficult as a beginner are very unreliable
12:30Ch3ck_my GSoC project is in java
12:30xemdetiawell then at least you understand what the JVM has under the hood that you can call out to
12:30akabanderActually I'm using Clojure so I don't have to learn Java (syntax). I don't mind learning about the JVM.
12:30{blake}xemdetia: Might be. I think any OO experience is enough.
12:30justin_smithxemdetia: eh, it wasn't very painful for me (though I had used other OO languages)
12:31justin_smithxemdetia: I think enough java knowledge to be able to read a javadoc is sufficient
12:31{blake}justin_smith: Yep. I think I'm pretty good at it, if I say so myself. =P
12:31Ch3ck_justin_smith, Yeah
12:31xemdetiajustin_smith, yeah that's all I was indicating
12:36gfredericksjustin_smith: good quote
12:41tmtwdhttp://pastebin.com/1GRW3gwX can someone help we figure out how this reagent code is supposed to work?
12:41tmtwd*me
12:42Ch3ck_tmtwd, have your tried paste.kde.org? it's cleaner
12:42tmtwdhttps://paste.kde.org/p5kjvkgxa ok here you go
12:43oddcullytmtwd: onchange gets an event object
12:43tmtwdthere was another pastebin alt that was awesome but I can't remember what its called
12:43oddcullythen the code there basically in JS would look like: event.target.value
12:43tmtwdso how would I hardcode in a value so it always changes to that value?
12:44oddcully#(reset value "lerl")
12:44tmtwdoh I see
12:45BinaryResult_Hey everyone, we are hiring remote full-stack clojure developers, hope to hear from you! http://discomelee.com/jobs/
12:45tmtwd #(reset! value @value) so why can't I just do that?
12:47oddcullyyou can do that. but thats a noop
12:47gfredericksmostly
12:47gfredericksthere's a race condition there where it might undo something else
12:47gfredericksbut otherwise it's a noop
12:49oddcullycan it? in javascript?
12:49oddcullyrace i mean
12:49tmtwdoh I think I get it :)
12:50gfredericksoddcully: probably not then
12:55sdegutisHi what's Clojure's version of the Haskell thing where you can use (< x) as a function?
12:56gfredericks#(< % x)
12:59justin_smithgfredericks: I think the retry behavior of atoms ensures that #(reset! % @%) is always a noop
12:59justin_smithgfredericks: retries man, I tell ya hwat
13:00chouserI don't think that's right. *goes off to test*
13:00amalloyjustin_smith: no, it can undo something, like gfredericks says
13:01gfredericksjustin_smith: no way man
13:01gfredericksjustin_smith: it's (swap! a identity) that's always a noop
13:01amalloyif you time things wrong, then running (swap! a inc) and (reset! a @a) at the same time will result in a returning to its old value
13:01justin_smithoh, wait - does reset! do retries at all?
13:01amalloyno
13:01justin_smithaha, that was my mistake
13:01amalloyhow could it? there's no computation to redo
13:02justin_smithd'oh, right
13:02Bronsasdegutis: partial
13:04sdegutisBronsa: partial can place unspecified arguments in arbitrary positions in a function call?
13:06chouser,(let [a (atom 0), f (future (loop [] (reset! a @a)))] (dotimes [_ 1000] (swap! a inc)) (future-cancel f) @a)
13:06clojurebot#error {\n :cause "no threads please"\n :via\n [{:type java.lang.SecurityException\n :message "no threads please"\n :at [clojurebot.sandbox$enable_security_manager$fn__857 invoke "sandbox.clj" 94]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__857 invoke "sandbox.clj" 94]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkAccess nil -1]\n [java.lang.Threa...
13:06chouseraww
13:07chouser&(let [a (atom 0), f (future (loop [] (reset! a @a)))] (dotimes [_ 1000] (swap! a inc)) (future-cancel f) @a)
13:07lazybotjava.lang.SecurityException: You tripped the alarm! future-call is bad!
13:07justin_smithchouser: thanks for the example
13:07gfrederickssdegutis: there's no precise syntactic analog; you can write functions/macros to do whatever you want, but nothing will be as succinct as #(...)
13:07chouserOh well. Guess you have to run it yourself. Anyway, if (reset! a @a) were noop then that would always return 1000
13:08justin_smithright
13:08chouserFor me, generally returns something between 850 and 900
13:08justin_smithI forgot that reset! never retries
13:08justin_smithreturned 840 here
13:09chouserI actually thought reset did retry like (swap! a (constantly x)), but the (current) code says no: https://github.com/clojure/clojure/blob/1d5237f9d7db0bc5f6e929330108d016ac7bf76c/src/jvm/clojure/lang/Atom.java#L97
13:11justin_smithchouser: https://www.refheap.com/107873
13:11justin_smithI'm actually surprised at how many times it got the right answer, considering
13:12chousernicely done
13:15justin_smithchouser: now I'm confused - that loop doesn't recur, so how does it reduce the total by that much...
13:15justin_smithalso the version with a recur doesn't return because future-cancel can't cancel it because it doesn't hit a cancellable operation (needs a sleep I guess)
13:15sdegutisgfredericks: So #(...) is the transliteration of Haskell's sections?
13:17justin_smithif I throw in a (Thread/sleep 1) it behaves exactly like the one without a call to recur
13:19gfrederickssdegutis: #() is more general; haskell's syntax only works on binary operators I believe, which isn't a syntactic concept clojure even has
13:20sdegutisgfredericks: I didn't know Haskell has "binary operators". I thought they were just ordinary functions that have special permission to be called using infix notation.
13:21chouserjustin_smith: ha, missed the loop! So the damage is caused entirely by a single reset!
13:21gfrederickssdegutis: that's what I meant, they're syntactically special
13:21gfredericksthat's all I'm using "operator" to mean
13:21chouserwhich explains why sometimes it actually gets all 1000 -- when the reset! doesn't actually fire until after the dotimes is complete
13:21sdegutisgfredericks: Oh Nice Thanks.
13:21justin_smithchouser: paste updated with proof https://www.refheap.com/107873
13:25amalloygfredericks: i mean you can partially apply either the first or second arg of any function in haskell by making it temporarily infix: filter ((0 ==) . (`mod` 5)) [1..20] == [5,10,15,20]
13:25chouser(let [a (atom 0), stop (atom false), f (future (loop [] (when-not @stop (reset! a @a) (recur))))] (dotimes [_ 5000] (swap! a inc)) (reset! stop true) (Thread/sleep 100) [f @a])
13:25amalloyso it does only work on infix functions, but those functions can have any number of args, and you can make anything inline if you want
13:26justin_smithchouser: the future-cancel works in your original if you add (Thread/sleep 1), that's enough to make the loop cancellable
13:26chouserah, nice
13:26amalloyjustin_smith: (Thread/yield)
13:26justin_smithamalloy: oh, sweet
13:26justin_smith(inc amalloy)
13:26lazybot⇒ 289
13:27amalloythat's basically a (Thread/sleep 0) that doesn't waste time talking to the system clock or whatever
13:27justin_smithvery cool
13:28amalloythis may be the first time in history anyone has called Thread/yield very cool
13:29justin_smithhaha, I'm easily impressed
13:43puredanger(.join (Thread/currentThread)) ;; the sound of one thread deadlocking
13:53chouserheh
13:59iamjarvoso i am trying to get lein repl to use a newer version of nrepl right now it uses 0.2.6 from my understanding if i put [org.clojure/tools.nrepl "0.2.10"] in the dependencies in the project.clj it should use a newer version of nrepl but its not :(
14:02justin_smithiamjarvo: it's a magic thing where you need the plugin in profiles.clj iirc
14:02justin_smithnot just the dep
14:03justin_smiththe job of the plugin is to inject the dep
14:04iamjarvojustin_smith so i see this "Retrieving org/clojure/tools.nrepl/0.2.10/tools.nrepl-0.2.10.jar from central
14:04iamjarvoRetrieving org/clojure/clojure/1.2.0/clojure-1.2.0.jar from central" but then i see this when the repl starts "nREPL server started on port 55376 on host 127.0.0.1 - nrepl://127.0.0.1:55376
14:04iamjarvoREPL-y 0.3.5, nREPL 0.2.6"
14:04justin_smithiamjarvo: right, that's because it needs to do its thing as a plugin, it's conflicting with lein stuff
14:05iamjarvojustin_smith are you talking about the :plugins in project.clj?
14:05justin_smithiamjarvo: it has to be in profiles.clj, but yes, in plugins
14:06justin_smithprofiles because that takes precedence
14:10iamjarvojustin_smith here is a pastie of my setup http://pastie.org/private/7zkcffxw4l8phzaaj9azw
14:10justin_smithiamjarvo: that's not a valid profiles.clj
14:11iamjarvocrap sorry i double pasted
14:11justin_smithhaha, OK
14:12iamjarvohere is a fresh link http://pastie.org/private/942edrwxn1tb8sybor7v3a
14:13kwladykajustin_smith, i solved my problem! :)
14:13justin_smithiamjarvo: :plugins is being treated as a profile name
14:13justin_smithkwladyka: oh wow, what was the trick?
14:13kwladykajustin_smith, algorithm was slaw because of duck duck typing
14:13kwladykajustin_smith, i need to declare datatype
14:13justin_smithiamjarvo: the tools.nrepl plugin should go inside :user :plugins
14:13iamjarvoahh because its in its own map
14:14justin_smithiamjarvo: right, also I don't think you meant to make a profile named :dependencies either :)
14:14kwladykajustin_smith, read this article, it is very interesting http://www.learningclojure.com/2013/02/clojure-is-fast-is-clojure-still-fast.html
14:15justin_smithkwladyka: someone should have mentioned turning on reflection warnings, I guess I'll remember that next time
14:15kwladykajustin_smith, all because of weak typing
14:16kwladykajustin_smith, turning on reflection warnings?
14:17justin_smith,(defn foo [x] (.length x))
14:17clojurebot#'sandbox/foo
14:17justin_smith,(set! *warn-on-reflection* true)
14:17clojurebot#error {\n :cause "Can't change/establish root binding of: *warn-on-reflection* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *warn-on-reflection* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval48 invokeStatic "NO_SOURCE_FILE" -1]\n [sandbox$eval48 invoke...
14:18justin_smithkwladyka: anyway, in a real repl you can use set! like above, and then if you run that defn it will tell you about the reflection
14:18justin_smithwhich is what makes the underspecified code so slow
14:19justin_smithkwladyka: so you can turn on *warn-on-reflection* at the top level of your project, and get warnings about the places where your code will be slow because the types are not known
14:19iamjarvojustin_smith in my endless changing and trying diff things created those maps. thanks for the second eyes
14:19justin_smithiamjarvo: np, hope that helps you solve the issue
14:20kwladykajustin_smith, so good to know
14:21kwladykajustin_smith, thx
14:21kwladykai am so happy to found out why my algorithm is slow and i learnt a lot
14:22kwladykai am also very surprise about time performance because of duck duck typing
14:44sdegutisCan anyone recommend any Clojure library that's simple yet powerful?
14:45kwladykasdegutis, ?
14:45chouserclojure.zip ?
14:49wasamasaclojure.core
14:50sdegutisNone of those show up in https://github.com/search?q=simple+powerful&amp;l=Clojure
14:50wasamasalol
14:50sdegutisI'm pretty sure you can use this as a metric of language popularity. 68 for Python, 75 for Ruby, 248 for JS
14:51amalloyis clojure.zip simple? the implementation isn't, and the api doesn't seem that simple either
14:53pbxas a clojure noob coming from python, i'm going to give a short "clojure is cool" talk to my python-using coworkers in an hour. any evangelism tips?
14:54scriptortry to use concrete examples
14:55justin_smithpbx: I'd stress the easy vs. simple thing - python is often easy, but the semantics are not simple, whereas clojure has simpler semantics
14:55scriptortons of people have said "pure functions make code easier to reason about", it's more effective to show why that's the case
14:56justin_smithahh yeah, a concrete example of where certain common bugs become impossible with immutable datastructures
14:56scriptormaybe brainstorm any bugs from your own company's codebase that might've been avoided or better handled with clojure
14:56amalloypbx: how short?
14:57amalloyi have slides for a 40-minute "why clojure" presentation on Drive somewhere
14:57scriptoramalloy: I'd be interested in seeing that in general
14:57pbxamalloy, 10 minutes
14:58amalloyoh i guess i called it "a taste of clojure"
14:58amalloyhttps://drive.google.com/open?id=1mGihUBBIKMQn5Uz-5DvQ1Vu24qSuk3o4yUoPoBZW3tI
14:59justin_smithamalloy: that's a nice demo
14:59Jaoodpbx: compare python's horrible lambda to clojure ;)
14:59justin_smiththe third page
14:59Jaoodones
14:59pbxgood stuff amalloy thanks
15:00justin_smithamalloy: btw, using Thread/yield instead of Thread/sleep led to me having to run a killall -9 java :(
15:00amalloyhaha what
15:00justin_smithamalloy: the deal is, I was launching 10000 futures, and cancelling each one
15:01justin_smiththis ran out of threads available, which fucked up nrepl - the client died, but the server was still running
15:01justin_smithit got to the point where I couldn't even start new nrepls after a few times (I was trying to figure out what was wrong)
15:02justin_smithbecause future-cancel can't kill a tight loop that is calling Thread/yield on my jvm apparently (though Thread/sleep 1 was killable by future-cancel)
15:02amalloy$javadoc Thread yield
15:02lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#yield()
15:02amalloyoops
15:02amalloyokay so that doesn't ever get interrupted
15:03justin_smithamalloy: yeah, I don't think it's on the magical list of things that lead to cancellability
15:03justin_smithwhile waiting on input and sleeping are
15:03amalloyjustin_smith: it's not so much a magical list of things, as anything that declares it can throw InterruptedException
15:03justin_smithahh, interesting
15:03justin_smithvery good to know
15:03amalloybecause those are typically generated only when someone says "hey man, stop this thread, something is happening"
15:04justin_smithanyway, this is like the first time in over a year I have had to run killall -9 java, so congrats
15:04justin_smithlol
15:06sdegutispbx: nope sorry.. the only things Clojure has over Python are destructuring and JVM libs
15:06amalloyhaha
15:06amalloyjustin_smith: (dorun (repeatedly #(future)))
15:07amalloywhat could go wrong
15:07sdegutispbx: and ->> makes map/filter/etc slightly nicer than Python just because Python's dumb and uses global functions unlike Ruby
15:08sdegutisThis week's Annual Clojure Challenge! What's the most interesting and/or bizarre thing you can do with a Set?
15:08sdegutisaaaaaand... Begin!
15:41dxlr8ris it possible to "get" all params to a function (defn) to a list without manually assigning them? like "& args" but with named arguments
15:49dxlr8r(defn [a b c] (print (abc-coll)) :) like that
15:51tmtwd I'm trying to do string concat in cljs like this : http://pastebin.com/ab0n9KEh what is the best way to do that?
15:52chouserI think you can just leave out the ++'s
15:54tmtwdchouser, thanks :)
15:58irctcanyone here using domkm/silk on a webserver?
16:04alex_engelbergdxlr8r: you could try something like (defn [& [a b c :as all-args]] ...)
16:07DomKMirctc: Most users I've talked to use Silk for frontend routing. I think it works best when used on both the frontend and backend simultaneously. Happy to field questions. :)
16:08irctcDomKM: Thanks for responding - literally just opened up an issue with you on github.
16:09irctcI can explain here too though - I'm having trouble specifying request methods in my routes... I can show you code but that might be easier on github.
16:10amalloydxlr8r: the only thing that doesn't involve retyping the arglist is what alex_engelberg is suggesting, but then you lose arity overloading, and arity checking: (foo 1) becomes legal now, setting [a b c] to [1 nil nil]
16:15DomKMirctc: Okay. I responded to the issue you opened.
16:57{blake}Does Clojure push a context on to the stack? (I'm asking because Smalltalk does but I haven't thought through if the same is necessary or useful in Clojure.)
17:01amalloy{blake}: the jvm uses the stack for locals, yes
17:02{blake}amalloy: Any non-user designated stuff? System info?
17:03amalloywell like, the return address and so on is there, i imagine
17:03amalloybut maybe not
17:03{blake}amalloy: OK, fair enough.
17:03{blake}(inc amalloy)
17:03lazybot⇒ 290
17:03justin_smith{blake}: as I understand it the jvm is relatively heap happy
17:03amalloyi was recently reading the jvm spec actually, and read the bit about stack frames
17:04justin_smithit's notorious for being more fragmented for that reason
17:04amalloybut i don't remember what is on there other than your locals
17:04justin_smithamalloy: what's on the stack will still be essentially a pointer to the actual object in the heap, right?
17:05amalloyyes, locals are always primitives or pointers to objects on the heap
17:05{blake}In Smalltalk, it's typically the sender, receiver, arguments, selector, locals and a home context.
17:06amalloyall of those are just locals on the jvm, except the sender doesn't exist and i don't know what a home context is
17:06amalloyoh or a selector
17:06justin_smithis a selector like a method?
17:06justin_smithno, that doesn't make sense
17:07justin_smithoh wait, it basically is - it's the method name essentially
17:07amalloysmalltalk has a much richer stack/environment than any language i know of
17:07justin_smithhttp://www.objs.com/x3h7/smalltalk.htm
17:07{blake}justin_smith: A selector is...a selector. =) Typically objects respond to the selector by calling a mathicng method. But they don't have to.
17:07justin_smithaha
17:07{blake}Yeah, it's one of the few languages I know where it's conceivable to debug with step-backwards.
17:09{blake}Seems like it could happen in Clojure, though.
17:09justin_smith{blake}: ocaml has a time-travel debugger
17:09{blake}justin_smith: Yeah! I'd heard that. I've only dabbled.
17:51dxlr8ralex_engelberg / amalloy: thx, but arity checking is kinda required
17:52dxlr8rI wrote some macro once to do it, but was to specific, guess I'm not good enough at them :)
18:12kwladykais it possible to write functions like https://www.refheap.com/10aff5cf186a546b78d37dac6 with iterate or something like that?
18:31justin_smithkwladyka: that first one could be simpler as a reduce
18:33justin_smith(reduce (fn [new-boards board] (increment-board-by-piece board piece new-boards)) (empty boards) boards)
18:33kwladykajustin_smith, thx, i will see
18:33justin_smithsecond one is also simple to turn into a reduce
18:34justin_smiththis general pattern (if you are taking rest on a list on each loop, and updating some value) is what reduce is for
18:35awwaiidjustin_smith: I dug into ocaml's back-stepping debugger, and as far as I can tell it is actually a fork-based time travel technique. I ported the concept to ruby via pry-byebug. Really it is a unix trick more than anything though -- they are not running their bytecode interpreter backwards as I initially thought
18:36justin_smithoh!
18:36awwaiidexactly what I said :)
18:37xemdetiayes the simplest way to travel back in time is to have multiple times!
18:37awwaiidjustin_smith: " set processcount count
18:38awwaiid Set the maximum number of checkpoints to count. More checkpoints facilitate going far back in time, but use more memory and create more Unix processes. " from http://caml.inria.fr/pub/docs/manual-ocaml/debugger.html
18:38awwaiidI think it does a combination of forking and replay
19:01kwladykajustin_smith, nice, even better performance and more readable :)
19:01kwladykaand... it is time to sleep, goodnight :)
19:08noncom|2what is the best library for doing L-systems with clojure today?
19:24sdegutisWhat an exciting competition today! No submissions yet, which means everyone's working hard on something /really cool/!
19:25sdegutisFor those just joining us: What's the most interesting and/or bizarre thing you can do with a Set?
19:25sdegutisFirst place gets first prize. Second place gets second prize. NOBODY ELSE GETS ANYTHING.
19:28sdegutisamalloy: richer how?
19:38xeqisdegutis: i imagine it would be hard to surpass Russell's fun with sets
21:06devnCould anyone tell me how (defonce ^:const foo (assoc {:a 1} :b 2)) behaves under the covers?
21:06devnIs there anything I should be concerned about when using both defonce and :const metadata?
21:26bchamI'm getting something strange. I can't resolve "rename-keys".
21:26bchamhttp://pastebin.com/uX7JmH1w
21:26bchamselect-keys works just fine
21:27bchambut rename keys doesn't, on clojure 1.6
21:27bchamWhat am I doing wrong oh wise men of #clojure.
21:27bchamand women*
21:28bchamwell I figured it out, I had to drop down to clojure.set
21:28bchambecause I'm stupid.
21:29amalloydevn: i think that would have the same effect as (defonce foo (...))
21:29amalloyor maybe something totally broken. at any rate it won't do what you wanted
21:32devnamalloy: so you think the :const metadata won't do anything?
21:33amalloydo you know what ^:const does?
21:52gfredericksamalloy: devn: I would definitely expect that ^:const changes things
21:53gfredericksdefonce means that future calls to defonce are noops; ^:const means that when you use the var elsewhere in the code it compiles to a direct reference to the data, not to the var, so redefinitions aren't seen
21:53gfredericksafaik those two things are orthogonal
21:54amalloygfredericks: i was imagining that the problem was in the actual implementation of defonce as a macro that expands to like (do (def ^:const x nil) (alter-var-root x (constantly whatever))
21:54amalloybut i think you are right that the value and the ^:const don't need to be set at the same time
21:55gfredericks,(source defonce)
21:55clojurebotSource not found\n
21:55gfredericks~defonce
21:55clojurebotdefonce is a temptation
21:55amalloy~def defonce
21:56gfredericks~defonce is pronounced more or less like Beyoncé
21:56clojurebotc'est bon!
21:56hiredmanI am amazed that ~def works
21:57amalloyhiredman: why?
22:02hiredmanat one time it was a big pain, because the version of clojure clojurebot used to look up line numbers was way behind master
22:03hiredmanwhich was back around 1.2 I think, and then I pulled the evaluator bit out of the process so it is easy to jump to new clojure versions and I haven't thought about it since
22:08amalloywell it's still linking to a really old version of core.clj
22:09amalloy~def do!
22:09amalloy,do!
22:09clojurebot#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" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: do! in this conte...
22:09amalloyisn't that a thing in 1.7?
22:10amalloyoh, it's run!
22:10amalloy,run!
22:10clojurebot#object[clojure.core$run_BANG_ 0x567f2d92 "clojure.core$run_BANG_@567f2d92"]
22:10amalloy~def run!
22:10hiredmanhuh, so the line number for defonce just happens to be the same
22:11amalloyhiredman: no, it's using the old version of clojure to look up a line number, and then linking to the corresponding line in an old blob on github'
22:11amalloywhich is why ~def run! doesn't work
22:11hiredmanOh, right, didn't you have a pr for that?
22:11amalloynot me
22:11hiredmanhmmm
22:13hiredmanand the code lookup stuff is in the main clojurebot process, I was thinking I might fix it to lookup via the evaluator service, but forget it if it involves restarting anything