#clojure logs

2014-07-29

00:02danielcomptonSeeking to simplify the JMX api, I have made something far more terrible
00:05justin_smithdanielcompton: beware, those who would look into the JMX API, for the JMX API also looks into you
00:05danielcompton(inc justin_smith)
00:05lazybot⇒ 54
00:06arrdem(inc justin_smith)
00:06lazybot⇒ 55
00:06arrdemthey dug too deep and too greedily and awakened some ancient evil...
00:06Balveda(defn deffer [x] (println "heyo " x))
00:07Balvedano defns huh
00:07Balveda(deffer "e")
00:07justin_smithBalveda: clojurebot uses ,
00:07Balveda,?
00:07justin_smiththe (inc person) syntax is a pseudo-clojure command for karma tracking
00:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ? in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:07rpauloI installed ac-nrepl and now I get: which-func-ff-hook error: (scan-error "Containing expression ends prematurely" 8 9)
00:07rpaulowhenever I open a clojure file in emacs
00:07danielcomptonJMX will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your JMX parser, application and existence for all time like Java only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, MBeans lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of JMX
00:07danielcompton parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑
00:07danielcompton rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ
00:08arrdemahahahahaha
00:08arrdemTONY THE PONY
00:08arrdemCTHULU F'TAGN
00:08arrdem(inc danielcompton)
00:08lazybot⇒ 2
00:08danielcomptonMbeans leaking from your eyes
00:08arrdemI love that regex parsing thread
00:09technomancyclojurebot: batty?
00:09clojurebotExcuse me?
00:09justin_smithrpaulo: try M-x toggle-debug-on-error - that should drop you into the elisp debugger
00:09technomancyaw shucks
00:09justin_smithrpaulo: you can run M-x top-level to get out of the debugger
00:09justin_smithor interact with the debugger and look for what went wrong
00:10justin_smithrpaulo: that is to say, debug-on-error should cause *future errors to drop you into the elisp debugger
00:10technomancyclojurebot: batty is <reply>I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
00:10clojurebotHuh?
00:10justin_smithso you can figure out the source file for the code, and the file where a variable was defined
00:10rpaulojustin_smith: didn't work :(
00:10technomancyclojurebot: come on man
00:10clojurebotCool story bro.
00:10technomancyclojurebot: batty is <reply> I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
00:10clojurebotExcuse me?
00:10arrdemtechnomancy: batty |is| ...
00:10justin_smithrpaulo: it didn't pop up the debugger on your next error?
00:11technomancyclojurebot: batty |is| <reply> I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
00:11clojurebotCool story bro.
00:11rpaulojustin_smith: nop
00:11technomancyclojurebot: inventory
00:11clojurebotI am carrying 0) a poorly-calibrated inference engine, currently leaking 1) a well-worn copy of clojure 1.2 tucked deep away inside a classloader 2) the last shreds of what was once my sanity
00:11rpauloI'm using Cask to install everything.
00:11rpauloand leiningen to install nrepl
00:11justin_smithrpaulo: http://www.emacswiki.org/emacs/WhichFuncMode
00:11technomancycask? "the bundler of elisp"?
00:11arrdem~technomancy
00:12arrdem,1
00:12clojureboteval service is offline
00:12technomancy~batty |is| <reply> I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
00:12clojurebotCool story bro.
00:12rpaulotechnomancy: yeah, better than cloning git repos by hand
00:12rpaulojustin_smith: OH
00:13justin_smithrpaulo: found that by googling part of your error message
00:13rpaulook, that took care of the error, but ag-nrepl still doesn't work
00:13justin_smithac-nrepl is finicky
00:13technomancyporting the whole "why is it broken in mysterious ways" concept straight from ruby to elisp
00:13justin_smithoften I find it slowing down my clojure mode buffers significantly, until I just shut it off
00:14rpauloah, it works fine after jack-in
00:14rpaulobut, yes, it's too slow :(
00:14arrdemjustin_smith: ac-nrepl is abandoned. company-mode has replaced ac.
00:14justin_smitharrdem: good to know, thanks
00:15justin_smithrpaulo: you catch that? time to get rid of ac-nrepl and use company mode
00:15rpauloarrdem: I should try that one instead
00:15arrdemrpaulo: only if you use cider rather than nrepl.el
00:15arrdemrpaulo: nrepl.el has ac support, cider has made the company leap
00:15justin_smithtechnomancy: they even use the L word in their introduction docs http://cask.readthedocs.org/en/latest/guide/introduction.html
00:15rpauloI'm actually using ac-nrepl with cider, so no problem there
00:16arrdemrly?
00:16arrdemrpaulo: for my entertainment, can you refheap the relevant config bits?
00:17technomancyjustin_smith: aw man; what the heck
00:17justin_smithtechnomancy: at least they have admirable goals, even if they don't hit them
00:17rpauloarrdem: http://paste.lisp.org/display/143252
00:18arrdemrpaulo: remapping {} is brave given how much map crap Clojure uses :P
00:18technomancyjustin_smith: wow, that readme is incredibly arrogant
00:19technomancy"all projects that don't use cask aren't worth using"
00:19justin_smithtechnomancy: and poorly written, yeah
00:19rpauloheh, I thought exactly the same
00:20arrdemam I the only one here who build a modular .emacs.d system?
00:20Balvedai just use emacs live. should i be shot?
00:20justin_smitharrdem: I decompose my .emacs.d/init.el into separate el files, so I can toggle loading for different hosts / emacs versions / whatever more easily
00:21rpauloI haven't used Emacs much in the past. Dare I say I'm a vi person? The truth is Clojure is much better with Emacs...
00:21justin_smithone file for clojure stuff, one file for javascript, one for custom keybindings, etc. etc.
00:21arrdemhttps://www.refheap.com/88672
00:21justin_smithand when / if I switch from nrepl to cider, I will make a second version of my clojure-stuff.el
00:22rpauloarrdem: that's neat
00:22hiredmanmuch like cider the only thing I've seen cask do is break emacs
00:22BalvedaI wish I had dipped my feet in the wonderful world of lisp earlier
00:23BalvedaLisps rather since I'm barely getting started with the channel's namesake
00:24justin_smitharrdem: https://www.refheap.com/88673
00:25justin_smiththose customizations at the top of the file should be in their own file maybe
00:25arrdemjustin_smith: interesting. a better approach to ignoring config files than my system offers.
00:25arrdempossibly... all I can do is move stuff off the autoload path.
00:26justin_smithyeah, I wanted to be able to have arbitrary predicates for each one (copying the behavior of built in stuff where (foo -1) means no foo)
00:28arrdemhttp://gigasquidsoftware.com/blog/2014/07/28/the-proper-pronunciation-of-clojures-assoc/
00:28justin_smithlol, "jeremy"
00:30rpaulohmm, company is indeed much better.
00:32jeremyheileri, for one, thing "jeremy" is the correct answer.
00:32jeremyheilerthink*
00:33arrdemI DETECT BIAS
00:33taliosassoc is a word, not an abbreviation, therefor - a-sock.
00:33eggsbyassokiate
00:33arrdem$google dilbert assok intern
00:33lazybot[Intern on Dilbert.com] http://search.dilbert.com/comic/Intern
00:33justin_smithtalios: "associate"
00:34taliosjustin_smith - and? (assoc) is a function. It may be _derived_ from the abbreviation of the word associate. But the symbol/function itself?
00:35taliossame reasoning why you should never use URL or JDBC, but rather Jdbc or Url.
00:35jeremyheilerofficialy statistically analaysing didn't remove it from the results. no bias!
00:35arrdemwhere's tbaldridge with his popcorn...
00:35arrdemI want some
00:35talios'lo brehaut
00:35brehauthi talios
00:36taliosbrehaut - move to auckland, work here, join danielcompton as we subsume anyone doing clojure
00:36brehauttalios: not going to move to auckland, but happy to do some work
00:36danielcomptonbrehaut: don't believe them, they force me to do Scala and Java
00:36taliosdanielcompton - hey, you did that willingly.
00:37brehautdanielcompton: ive done VBScript for money. nothing will be worse than that
00:41taliosbrehaut - doing it for fun? :)
00:42brehauttalios: who are you kidding? nobody does that for fun :P
01:12TEttinger,(def jeremy assoc)
01:12clojurebot#'sandbox/jeremy
01:13TEttinger,(jeremy {} :a 1 :b 2)
01:13clojurebot{:b 2, :a 1}
01:13TEttinger,(def ass-sock assoc)
01:13clojurebot#'sandbox/ass-sock
01:13TEttinger,(ass-sock {} :a 1 :b 2)
01:13clojurebot{:b 2, :a 1}
01:13rpaulo,(def assok assoc)
01:13clojurebot#'sandbox/assok
01:45RaynesClojars is nice and broken
01:47arrdemRaynes: how so?
01:47RaynesAs in it does not appear to function as intended.
01:47RaynesIt doesn't load.
01:47RaynesBlasted cache and everything
01:47arrdemerm...
01:47arrdemclojars works for me
01:48gwsclojars.org
01:48RaynesTwo different browsers.
01:48RaynesNo wory
01:48RaynesNo worky*
01:49pyrtsaThe frontpage appears completely empty for me too. But I was able to jump to https://clojars.org/search via a Google search.
01:49Raynesarrdem: Roommates can't load it either.
01:49RaynesWhat he aaid.
01:49Raynessaid*
01:49pyrtsaIt was like this 1.5 weeks ago already.
01:49pyrtsa(Haven't tried in the meantime.)
01:49Raynestechnomancy: Can we go back to the old but working UI? :P
01:50arrdemRaynes: interesting. If I log out clojars.org is indeed horked
01:51pyrtsahttps://clojars.org returns "HTTP/1.1 500 Server Error" with an empty body.
02:15BronsaRaynes: there have been reports of clojars returning a blank page on this channel for weeks now
02:16RaynesThat's usually what happens when you do flashy website makeovers :p.
03:41Glenjamini get a blank page also
03:50hyPiRionI get blank page as well from the front.
03:51hyPiRionBut I didn't know it was like that for so long, I'm pretty sure I've been at the frontpage without problems in the last 2 weeks.
03:59Bronsawell I've opened an issue on clojar's github page
04:11danielcomptonI'm working on a library to provide sorted set operations over lazy-seqs/core.async channels.
04:11danielcomptonI'm tossing up between an abstract name like rummy
04:12danielcomptonAnd a more straightforward one like seq-set or chan-set. Any opinions?
04:18danielcomptonIs clojars down for everyone or just me?
04:19danielcomptonI'm just getting a white page
04:23__daniel__danielcompton: yes, everyone is saying the same
04:26mbac_what's the equivalent of map but without creating a sequence as a return value?
04:26mbac_that is, i simply want to iterate over a collection and do side-effecty things
04:27Glenjamin,(doc doseq)
04:27clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
04:32mbac_sweet
04:35H4nsis there a way to automatically use certain name spaces in all other namespaces, but only in the repl? i usually use clojure.tools.trace and clojure.pprint, but having to manually do it in every namespace gets old quickly.
04:37GlenjaminH4ns: https://github.com/gfredericks/dot-slash is an option
04:37H4nsah, nice hack, thanks!
04:41H4nsand another cider question: i've recently updated cider and now i see no backtraces anymore, just the exception message. how can i get backtraces back?
04:43mbac_mmmm, cider
04:45vijaykiranH4ns: (setq cider-show-error-buffer 'only-in-repl)
04:45vijaykiranH4ns: check the README on cider gh - https://github.com/clojure-emacs/cider for other options
04:46H4nsvijaykiran: thanks! it seems that i also forgot to install my profiles.clj on the machine that i'm working on, so that will probably help as well.
04:48vijaykirandanielcompton: regarding the naming - personally I prefer having descriptive names, and easy to remember as "that library with core.async set ops"
05:13H4nsGlenjamin: is there a way to import complete namespaces in dot-slash, or do i need to spell out all symbols that i want to import into the dot namespace? i'm not yet completely able to read the code.
05:14Glenjaminno idea, gfredericks might have some input
05:27vijaykiranH4ns: Doesn't look like it has ns mapping
05:28vijaykiranhttps://github.com/gfredericks/dot-slash/blob/master/src/dot_slash/plugin.clj#L6
05:28H4nsvijaykiran: i suspected so, but i was not sure. thanks for confirming.
05:29vijaykiranH4ns: I use :repl-options btw in profiles, btw
05:31H4nsvijaykiran: but that does not auto-import debugging namespaces into your application namespaces, or does it?
05:34vijaykiranH4ns: true - not in other namespaces, but only in the default/starter namespace
05:36H4nsi think the dot-slash hack is quite nice, and if i really want the debuggin stuff to be accessible without prefixing, i can (use '.)
05:44mbac_i love/hate how clojure automatically turns my map into a thunk that's never executed because it appears in the middle of a doseq
05:44mbac_er, in the middle of a do
05:44mbac_and i need to change the map to doseq to get the hot side-effect action
05:45mbac_is lazy evaluation really that much of an advantage in exchange for the surprising behavior?
05:45H4nsonce you got used to it, it is no longer surprising :)
05:46mbac_except until i make a mistake somewhere because i've trained my brain through 20 years of programming to expect things to happen in order from top to bottom
05:46H4nsyou _do_ need to adjust your expectations, of course.
05:47H4nsbut the fact that you've been doing it "wrong" for 20 years should not stop you from getting used to it.
05:47H4nsnote the quotes. :)
05:47blunteHi guys. I'm missing something (simple)? Trying to get a list of strings from map keys: (map #(apply name %) (keys m))
05:47mbac_it feels good spiritually that stuff that's not needed won't be evaluated, but i doubt this is something that will improve clarity in the long run
05:48llasramblunte: (map name (keys m))
05:48mbac_that is, i doubt lazy evaluation will become that much less surprising in the long run
05:48H4nsmbac_: i think that in the long run, code clarity wins over expectations from the pasdt.
05:49H4nsmbac_: and lazy evaluation does help with code clarity. that certainly is arguable and you may as well decide that you want to stay with imperative programming. nothing wrong with it, really.
05:49mbac_i disagree. making everything lazy by default can only confuse and the win *might* be optimization
05:49bluntellasram: thanks. I'm still not clear on when I need (map #(apply ...) data) vs (map foo data)
05:49H4nsmbac_: you are free to not program in clojure if you like it. common lisp is a nice lisp without all the crazy lazy stuff :)
05:50mbac_the opposite of lazy evaluation for everything is not go back to imperative programming
05:50mbac_you can have functional programming without lazy evaluation
05:50H4nsmbac_: sure. lazy is just the next logical step.
05:50mbac_functional programming is where the clarity wins come from
05:50llasramblunte: `apply` is itself a function, which "applies" another function to a sequence, turning a collection into positional arguments
05:50llasram&(doc apply)
05:50lazybot⇒ "([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args]); Applies fn f to the argument list formed by prepending intervening arguments to args."
05:51mbac_*shrug*
05:51llasramblunte: So (apply f [a b c]) <=> (f a b c)
05:51blunteAh ha, thank you
05:57nathan7mbac: being able to work with infinite sequences increases clarity a lot often
05:57nathan7mbac: you can take the space of all possible solutions and filter over it and take the first few, etc
05:58nathan7a lot of sequence-handling pipelines work thanks to laziness
06:21wizzodoes nil work the same as false in an if statement condition? or should i always check with (not (nil? ...))?
06:21SagiCZ1wizzo: it works the same way
06:22mbacnathan7, i agree and in those cases i'd definitely like to be able to opt into having lazy/infinite sequences
06:22wizzocool thanks
06:22mbaci'm just don't agree that making EVERYTHING lazy by default is a compelling argument
06:22nathan7I do
06:23nathan7but then again, I think Haskell is pretty sweet
06:23Glenjaminopt-out is sufficient
06:23mbaci disagree. probably most of the time laziness is of no advantage.
06:23Glenjaminand no disadvantage
06:24mbacexcept for the surprising behavior
06:24H4nsmbac: really, what is it that you're looking for? do you want us to convince you? then maybe you should get used to it, no convincing required. or do you want to change the way clojure works? then you're probably out of luck. just saying.
06:24Glenjaminthere's only surprises if you try and iterate with side-effects
06:25Glenjaminwell, there's only surprises if you want side effects but don't consume, which isn't often
06:25mbaci was actually wondering if there was a button i could press that would tell me my pipeline relies on side-effects somewhere
06:25SagiCZ1mbac: I am new to Clojure, programmed in Java for 4 years.. I have no problems getting used to the laziness.. it bit me exactly once. It is actually pretty simple concept.
06:25mbacor to turn the lazy evaluation off unless i'm doing something obviously lazy like iterating an infinite sequence
06:26babilenhttp://blog.ontoillogical.com/blog/2014/07/28/how-to-take-over-any-java-developer/ ← why it is a bad idea for every language community to invent their own package management system
06:26babilen(sorry for OT)
06:26mbaci'm sure the actual arguments for/against laziness by default has been hashed to death
06:26Glenjaminbabilen: as opposed to?
06:27babilenGlenjamin: Using established methods that are OS/distribution specific and have been tested for years/decades
06:29babilenIt's amazing how you see the same mistakes pop up whenever it is done which is just unnecessary and exposes many services to risks that could have been avoided.
06:29babilenAnyway, it was just a nice PoC that I thought should be shared.
06:30piranhais there something like pr-str, but that dumps metadata as well?
06:31piranhaah, *print-meta* :)
06:32SagiCZ1babilen: could we throw away leiningen and use maven instead in clojure?
06:32H4nsSagiCZ1: you can, but i won't :)
06:33wizzohi H4ns my lisp friend
06:33Glenjaminbabilen: there's a trade-off in allowing ease of sharing that OS-based package management tools don't provide
06:33Glenjaminnot to mention how to deal with apps wanting different versions of a lib on the same box
06:33wizzobabilen: what package managers would you say are tested for decades?
06:33Glenjaminbut yeah, better security would be nice
06:35SagiCZ1wizzo: ant?
06:36Glenjamini believe the comparison is things like apt
06:36SagiCZ1Glenjamin: ofc sorry
06:37wizzoi haven't used clojure enough to say but my experience with python packages is a lot of them simply don't exist in the distro package manager
06:40clgvbabilen: just use encryption for sensitive tasks^^
06:40hyPiRionbabilen: I agree -- It should be some sort of requirement to read up on already existing and well-developed package managers before you end up developing one yourself.
06:41clgvwell it's not as if they hadn't cared. it's their business model to provide https only after a donation...
06:41clgvin this caste the people hosting their stuff there are to blame, I'd say
06:41clgv*case
06:42blunteIs there a more concise way to (cons "a" (cons "b" ["c" "d"]))?
06:42blunteso you end up with one list of all elements?
06:42clgvis the leiningen and clojars.org combination using encryption as default?
06:42SagiCZ1,(cons "a" (cons "b" ["c" "d"]))
06:42clojurebot("a" "b" "c" "d")
06:42Bronsa(list* "a" "b" ["c" "d"])
06:42Bronsa,(list* "a" "b" ["c" "d"])
06:42clojurebot("a" "b" "c" "d")
06:42hyPiRionblunte: ##(list* "a" "b" ["c" "d"])
06:42lazybot⇒ ("a" "b" "c" "d")
06:42clgvlist* ^^
06:42blunteAhh, super. thanks.
06:42SagiCZ1(doc list*)
06:42clojurebot"([args] [a args] [a b args] [a b c args] [a b c d & ...]); Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."
06:43blunteperfect
06:43hyPiRionclojurebot: yes, but we check in maven central as well.
06:43clojurebotI don't understand.
06:43hyPiRionclgv*
06:43clgv$findfn :a :b [:c :d] [:a :b :c :d]
06:43SagiCZ1clojurebot: How are you today?
06:43clojurebotExcuse me?
06:43clgvlazybot: ?
06:44clgv:(
06:44lazybot[clojure.core/list*]
06:44SagiCZ1aww :(
06:44clgvah well :D
06:44clgvhe get's slower as he ages ;)
06:46clgvby the way: how do you force a signature check with leiningen?
06:46hyPiRion`lein deps :verify`
06:47hyPiRionnot sure what you mean with force though
06:57clgvusually it doesnt do that right?
06:58hyPiRionno. You want it to fail if it cannot verify a signature?
06:58clgvlein deps :veriy was what I wanted to know :D
06:58hyPiRionah, good :)
06:59clgvbut it cant know the correct public key to check the signature right?
07:00clgvso checking authenticity is not really possible?
07:02justin_smithclgv: hypothetically, you can integrate with a separate keyserver, and have a list of name to package mappings acquired via ssl
07:03clgvjustin_smith: that seems to be the long term goal with clojars.org right?
07:03justin_smithnot sure
07:03clgvlol which currently is just "blank" from here
07:04clgvclojars.org just gives me a blank page... :(
08:48ChouLinI have trouble print unicode (Chinese) in Mac terminal.
08:48ChouLin(println "你好") is good.
08:48ChouLin(seq "你好") -> (\ä \½ \  \å \¥ \½)
08:48ChouLin(count "你好") -> 6
08:48ChouLinI'm using OSX mavericks, clojure-1.6. I think it's encoding problem 'cause same code work fine in a Debian machine.
08:48ChouLinany hint ? thank you everyone.
08:50justin_smithChouLin: (count "你好") is 2 on my machine
08:50i-blisChouLin: 1) what Terminal are you using? 2) is it in lein repl?
08:51ChouLinit's not a lein repl. I use system default terminal.
08:51justin_smithyeah, I would check if your terminal is using utf8
08:51vijaykiranChouLin: same here Java 1.7 though (count "你好") => 2
08:51justin_smithChouLin: so you are running clojure.jar directly?
08:52i-blisChouLin: in Emacs with cider no issue? no issue either in iTerm2
08:52ChouLinno, I'm using 'java -cp clojure-1.6.jar clojure.main' to start a repl
08:53ChouLinI don't have iTerm2, in emacs , I start a eshell , then 'java -cp clojure-1.6.jar clojure.main', same error. I'm not using cider right now.
08:53i-blisI meant: no issue in emacs with cider, no issue in iTerm2 (OS 10.9 too)
08:53i-bliswhat is your locale in the term?
08:54clgv$seen lpetit
08:54lazybotlpetit was last seen quitting 13 weeks and 4 days ago.
08:54clgv$seen laurentpetit
08:54lazybotlaurentpetit was last seen quitting 22 weeks and 5 days ago.
08:54clgv$seen laurent
08:54lazybotI have never seen laurent.
08:55vijaykiranChouLin: I think the problem is with emacs/eshell
08:55vijaykiranChouLin: you need to set it to use UTF-8, I think
08:55ChouLin@ i-blis: LC_CTYPE="C"; LC_ALL=''
08:55clgvChouLin: encoding or font issue
08:56i-blisChouLin: then set it
08:56clgvChouLin: your terminal uses a UTF-8 capable font?
08:56ChouLin@vijaykiran, same error in system's terminal outside Emacs.
08:56i-blisChouLin: to en_US.UTF-8, for instance
08:57ChouLinit's en_US.UTF-8 outside Emacs,yes
08:57ChouLinLANG="en_US.UTF-8"
08:57vijaykiranChouLin: strange - on terminal its fine for me, but in eshell I get count => 6
09:00i-blisChouLin: what output do you get for (seq "你好") outside emacs?
09:00ChouLinI wish there's a way to make this simple code strong in both Debian and Mac. I decode string to unicode inside my Python programe then encode to 'UTF-8' before output. Is there's similiar paradigm in Clojure ? or best practice ?
09:01TimMcPython has a strange notion of character encoding that I still don't fully understand.
09:01ChouLinencoding is classical bitter in every language I think.
09:02i-blisPython and Ruby inherited custom character encoding from Perl I guess
09:03ChouLin@i-blis: I got this outside Emacs: (seq "你好") -> (\\? \? \\? \?)
09:03i-blisnever has any issue with non-ASCII stuff in Clojure
09:03ChouLinqusstion marks
09:03TimMcThere are only three problems I know of with character encodings in the JVM: It uses UTF-16 internally, it exposes this when you ask for string length, and it defaults to the system character encoding for input/output (instead of UTF-8.)
09:03justin_smithChouLin: you can encode a string to byte array, and byte array back into string, and specify encoding (def raw (.getBytes "你好" "UTF-8")) (String. raw "UTF-8")
09:04i-blisChouLin: this is not good. did you set both LC_CTYPE and LC_ALL?
09:05justin_smithChouLin: I guess the extra step along with the above is opening a file as raw bytes, then manually specifying the correct encoding
09:05ChouLinI didn't se LC_ALL, LC_CTYPE is 'C' in eshell, 'en_US.UTF-8' in system shell.
09:06justin_smithChouLin: what if you setenv LC_CTYPE properly in eshell?
09:06justin_smith(properly meaning, setting it to a UTF-8 encoding)
09:07ChouLin@justin_smith: that makes simple problem hard. what if I want make a word count for each word ? I split the string with #"" then every Chinese word become a triple ?
09:07TimMcChouLin: (By the way, in IRC it is not customary to use an "@" prefix when you're using when addressing people. It may interfere with people's nick-highlighting.)
09:08justin_smithChouLin: the place where the error happens is input / output. Once it is in your program the vm does the right thing.
09:08justin_smithif it was input properly
09:09ChouLinThank you TimMc , I feel like a fool, both with IRC and Clojure.
09:09justin_smiththis isn't a bug in how the vm handles characters, its a bug in character input
09:09TimMcNo worries.
09:10ChouLinyou're right justin_smith, real world's complexity. I do asia language text analysis, encoding is my big pain.
09:11deathknightI've been stuck at creating a barebones webapp with oauth2 functionality for weeks...is there a tutorial out there that really explains it for dummies?
09:11ChouLinI'm so jealous people deal with plain ascci only.
09:11deathknightall of the literature out there is just a bit above my skill level
09:11justin_smithChouLin: I think if you put your text into files of known encoding, and ensure that they are read using the correct encoding, the jvm should handle the rest just fine
09:12mpenetChouLin: did you try passing -Dfile.encoding=UTF-8 to java?
09:12TimMcChouLin: In your REPL, try (seq (slurp "some-file.txt")) where some-file.txt consists of 你好.
09:12justin_smithdeathknight: when I was trying to use it, my conclusion was more that oauth2 was *from* dummies
09:12mpenetsame in :jvm-opts would work
09:12TimMcThis may help distinguish between I/O problems in general and the terminal specifically.
09:12ChouLinsounds like python's way. I'm trying to figure out '.getBytes' & 'String.' , am I on rigth track ?
09:12i-blisChouLin: I deal with all kind of strange non-ascii scripts all the time. after having set LC_CTPYE, check in Terminal options if UTF-8 is set btw
09:12deathknightjustin_smith: lol
09:14justin_smithChouLin: String. to go from bytes to chars, and .getBytes to get from String to bytes is what probably works in your running code (unless your planned UI is an eshell inside emacs) - but then there is also the eshell config, for actually being able to develop and use a repl
09:14ChouLinthank you i-blis TimMc justin_smith , thank you all. I'll let you know if it works.
09:15TimMcChouLin: You shouldn't have to use .getBytes.
09:16justin_smithTimMc: I was suggesting that for the output side of things (for symmetry)
09:17justin_smithTimMc: also that combo of .getBytes / String. can be used to preserve chars but change encodings
09:21TimMcjustin_smith: Are you suggesting this for debugging or for production use?
09:24justin_smithTimMc: as a general suggestion. Of course in production the real question is "what is the actual encoding of this input / what encoding do I need on this output" but String. / .getBytes provide the mechanism for making sure the right encoding is used on each side.
09:25justin_smithand can also be used while debugging (coercing a set of bytes to a different assumed encoding, and seeing if that results in the right characters)
09:29ChouLinHi, I start from simple modification, 'java -Dfile.encoding=UTF-8 -cp clojure-1.6.jar clojure.main' did the trick. thank you friendly guys! thank you mpenet. I haven't modified LC_ALL yet.
09:30justin_smithglad that worked
09:31mpenetChouLin: np, I had the same issue with files containing french text
09:34ChouLinI feel so good after 4 hours stucking here!!
09:35ChouLinActully I've tried '-Dencoding=UTF-8' but it won't work.
09:37justin_smithalso, most things from from clojure.java.io (which underlies ie. slurp) can take an optional :encoding keyword argument (which defaults to "UTF-8")
10:17gfredericksH4ns: yo
10:17H4nsgfredericks: hi!
10:17H4nsgfredericks: thoughts?
10:19gfredericksI hadn't thought of the full-namespace idea; that kind of implicit stuff is usually avoided in clojure, but the whole thing is a dev hack anyhow so I don't think I would mind it
10:19clojurebot'Sea, mhuise.
10:19gfredericks~I hadn't thought of the full-namespace idea; that kind of implicit stuff
10:19clojurebotI hadn't thought of the full-namespace idea; that kind of implicit stuff is usually avoided in clojure, but the whole thing is a dev hack anyhow so I don't think I would mind it
10:19Bronsahar har
10:19gfredericksclojurebot: you |are| a weirdo
10:19clojurebotIk begrijp
10:19H4nsgfredericks: yeah, i'm also in the "explicit" camp usually, but i like my tools handy on the repl.
10:19H4nsgfredericks: the ./ idea is awesome :)
10:19gfredericks:D I'm enjoying it
10:20H4nsgfredericks: i'll send you a pull request when i'm annoyed enough by the lack of the feature
10:20gfredericksH4ns: any other comments/issues?
10:20gfredericksI'm adding whole namespaces to the list of future embetterments
10:21H4nsgfredericks: no. it is perfect, from what i can say :)
10:49martinklepschis there a directory of leiningen templates?
11:01jeremyheilermartinklepsch: https://clojars.org/search?q=lein-template
11:02jeremyheilermartinklepsch: it's a start :-P
11:03arrdemoh good clojars is unhorked
11:04hugodthat search seems incomplete (eg. mies is not listed)
11:05Bronsaarrdem: https://github.com/ato/clojars-web/issues/235#issuecomment-50472946
11:06arrdemBronsa: interesting. thanks.
11:07technomancywait he wasn't learning stuff last night
11:07technomancydid clojurebot fix himself?
11:08aeikenberryhow could i write a macro that takes one required argument and an infinite number of optional requirements?
11:08technomancyclojurebot: batty |is| <reply> I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
11:08clojurebotPardon?
11:08technomancyclojurebot: batty |is| I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
11:08clojurebotHuh?
11:08technomancydang it
11:08p_llol
11:08justin_smithbatty |is| I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
11:09technomancygfredericks just has the magic touch
11:09justin_smith¯\_(ツ)_/¯
11:09__daniel__aeikenberry: have it take two arguments, the second being a sequence
11:09__daniel__and walk the sequence?
11:09__daniel__i think there is a limit on the number of args
11:09Bronsa~batty
11:09clojurebotCool story bro.
11:09__daniel__@whatis batty
11:11aeikenberry<__daniel__>: thanks
11:11aeikenberry__daniel__: thanks
11:11justin_smithyou can use & in a macro argument list
11:11justin_smithif you want an optional unknown length number of extra args
11:11aeikenberrylike [required & args] ?
11:12justin_smithyeah
11:12aeikenberrythanks kindly
11:12justin_smiththat works the same way it does for functions, where args is a sequence of all arguments after required (and nil if only required was present)
11:12aeikenberryi'm very new
11:12aeikenberryto clojure
11:13justin_smithaeikenberry: writing macros may not be a good place to start
11:13aeikenberryit
11:13aeikenberry's a challenge
11:13TimMc~macros
11:13clojurebotHoly Crap.
11:13justin_smith~macros
11:13TimMchaha, was not expecting that
11:13clojurebotI added a ~' and it worked.
11:13justin_smith~macros
11:13clojurebotmacros are just a game with symbols
11:14justin_smithtoo many answers for that one
11:14TimMc~macos
11:14clojurebotHuh?
11:14TimMcclojurebot, macos |is| <reply>x
11:14clojurebotRoger.
11:14justin_smith~macos
11:14clojurebotx
11:15justin_smithclojurebot, batty |is| I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
11:15clojurebotCool story bro.
11:15justin_smith~batty
11:15clojurebotTitim gan éirí ort.
11:15justin_smithclojurebot, batty |is| <reply>I've seen things you people wouldn't believe. Build servers on fire off the shoulder of Orion. I watched maven artifacts glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears in the rain.
11:15clojurebotTitim gan éirí ort.
11:15justin_smith~batty
11:15clojurebotexcusez-moi
11:15justin_smithbleh
11:16llasramjustin_smith: clojurebot*:* maybe?
11:16justin_smithllasram: TimMc made it work with the ,
11:16TimMcWeird. I usually expect it to accept the factoid and screw it up somehow -- but at least accept it.
11:16llasramOh, nm
11:16justin_smithTimMc: yeah, I wonder why it hates that one
11:16justin_smithor maybe it hates me (and technomancy)
11:17TimMcI know it has trouble with \. but I thought that just truncated the factoid.
11:22TimMcConclusions from /query chat with clojurebot: The thing is bonkers.
11:23justin_smithclojurebot: |is| certified bonkers.
11:23clojurebotI don't understand.
11:23justin_smithyou wouldn't
11:24arrdemclojurebot also ignores people at hiredman's whim... clearly lazybot's factoids functionality should become standard and clojurebot should be abandoned :P
11:24TimMc*nod*
11:25TimMc!
11:25TimMcIt just said to me: "A nod, you know, is as good as a wink to a blind horse."
11:26arrdemgtrak: is there some special magic involved in getting cider/company to work?
11:27arrdemI've gotten Company's autocomplete to work for me in REPL buffers but it's doing nothing in clojure-mode.
11:27Bronsaarrdem: slime+auto-complete works like a charm.
11:27arrdemBronsa: quiet you
11:27Bronsajust sayin.
11:29arrdemyeah.. and auto-complete-mode "just works" as well
11:29arrdemno friggin idea what's with company-mode
11:30justin_smith¯\_(ツ)_/¯
11:31gtrakarrdem: basically, you just install company mode, don't install company-cider.
11:31gtrakI think it just works.
11:31arrdemgrrrrr
11:32gtrakthough I found it a bit unintuitive and removed it for the default completion.
11:32gtraki like seeing the massive list of syms
11:33arrdemokay... cider, cider-tracing and cider-decompile
11:33arrdemno cider-company
11:35gtrakhttps://github.com/clojure-emacs/company-cider#deprecation
11:35cbpcompany mode does just work
11:50rpaulooh, I didn't know it was deprecated.
11:50arrdemweirdness...
11:50arrdemlooks like I managed to break company with the 13 other minor modes I had attached to clojure-mode..
11:51arrdemif I throw all that out then company works fine.
12:12gfredericksarrdem: I choose to interpret these statements as referring to an actual commercial company
12:12technomancyinitech-mode
12:13arrdemM-x umbrella-corp-mode
12:13gfredericksM-x IPO
12:14arrdemheh
12:14justin_smithM-x weyland-yutani-dispose-employees
12:14justin_smith{===c
12:56slpsyshah
13:25ahoenigmannIs it possible to get eclipse-like code completion for java.lang and other java packages in emacs while coding clojure? (I have emacs and cider setup now)
13:37justin_smithahoenigmann: yeah, I have completion for java.lang using nrepl.el and autocomplete, so it should work in cider too
13:38justin_smithunless cider had a regression on that feature
13:39ahoenigmannso is it just <TAB>?
13:39ahoenigmannyup it is!
13:40sjoukewhat are the arguments against SOLID design? i remember hearing a guy from the functional programming community shuttering when he heard Kiskov substitution mentioned
13:41justin_smithsjouke: Liskov substitution?
13:43teslanickThere are a few obvious-in-practice objections to Liskov substitution.
13:45justin_smithteslanick: you mean objecting to Liskov substitution, or objecting to the demand that subclass be Liskov-substitutable?
13:48teslanickPerhaps I've not seen a subtyping implementation that actually captures Liskov substitution correctly, but it seems like if type T is a subtype of type S, unless T and S are identical, Liskov substitution cannot hold for all possible provable attributes.
13:49justin_smithteslanick: liskov (and solid) are not rules about all programs, they are criteria for good programs
13:49justin_smith(or so they claim)
13:50agarmanSOLID is good for making programs possible to reason about
13:50justin_smithof course working software can violate the constraints of solid, but the claim is that if you meet the criteria of solid, your code is more resiliant, better designed
13:51teslanickWell, it's supposed to be a "soft" correctness guarantee. Type S and T can be used interchangeably because they expose similar contracts (where S might be a superset of T). In practice for non-trivial problems, I've not found this to be the case.
13:51teslanickUnless S and T are identical (or very nearly so)
13:51justin_smithagarman: do you have a good clojure example of something that violates SOLID but would be an improvement over the SOLID alternative? (legitimate question, not an argument)
13:53justin_smithteslanick: sure, but it is not an invariant, it is a criterion by which they claim some other goal can be attained. I have never seen a claim that liskov substitution was somehow a description of algorithms as-is.
13:55teslanickThat's fair. I see enough dogma around type systems that aren't true in practice, that I'm probably too-skeptical of the claimed benefits.
14:01prcAnyone can give me a hand with this piece of code: http://pastebin.com/raw.php?i=0pgMdtmX ?
14:01prcThe problem is mentioned there, and as you can see I'm a beginner, so please bear that in mind.
14:02amalloyprc: rest returns a sequence, not a vector; and conj on a sequence adds to the front
14:03amalloyi can't actually tell if you're conjing onto something you rest'ed, but there are a lot of conj and rest
14:03llasramTHey do use `drop-last`, which has the same effect
14:03teslanickIs the goal to check if braces are correctly nested?
14:03amalloyyeah
14:03llasramYou want `pop`
14:03prcamalloy: but until that point it was adding it at the very end, no?
14:04prcteslanick: that's correct.
14:04llasramYou also want `not` instead of `complement` (although you really want `(seq ...)` instead of `(not (empty? ...))`
14:04teslanickloop/recur is usually not what you want. You can express the problem more idiomatically
14:05llasram(inc teslanick)
14:05lazybot⇒ 1
14:05teslanickmy first karma <3
14:05amalloyteslanick: loop-recur is fine for paren checking. what else is much better?
14:05teslanickI wrote one that used reduce in JS
14:05llasramI'd use `reduce`
14:06amalloyllasram: okay, and on the input (cons \) (repeat \)), you go forever? you can use (reduced false), but that's just shoehorning into reduce when you don't really want to process the whole thing
14:08amalloythe best way to shorten this is to create a map of open-delim to close-delim, rather than hard-coding all six cases
14:08llasram`reduce` already captures the pattern of eagerly iterating over collection to produce a result. `reduced` exists to support the optimization of short-circuiting
14:08llasramSeems like a good fit to me
14:08teslanickYeah; when I wrote the JS version, I wished for `reduced` and resorted to throwing a specially-formed exception to break eagerly.
14:09amalloyreduce isn't *awful*, but it's not so much better than loop/recur that i'd suggest it to someone who's asking why his code doesn't work (given that messing up loop/recur was not his problem)
14:10teslanickI guess; usually when I resort to loop/recur I'm not thinking about the problem correctly and end up rewriting the function more tersely later.
14:15llasramYeah, and actually, now that I've taken a swing at it, you want to short-circuit to a Boolean value when the `reduce` state is a vector
14:15llasramSo loop/recur may make the most sense anyway
14:21hyPiRionllasram: It can go both ways. I feel reduce is easier to wrap my head around here.
14:22hyPiRionhttps://www.refheap.com/88701 – although I shoehorn the (reduced [:nonempty]), I feel the reduction pattern matches better.
14:25amalloyhyPiRion: the indentation of your cond form is kinda disorienting
14:26amalloyi keep trying to figure out what it's supposed to line up with
14:26hyPiRionamalloy: I know, and I fixed it now
14:26amalloyi remember someone (fogus?) innovating by using ,, instead of two spaces, to "indent" a cond form in a way that emacs won't revert and is obviously not meant to line up
14:27arrdemthat's... disgusting and yet I may do so.
14:27amalloyi use that occasionally, for cond and for indenting multi-line let-expressions, but everyone hates it when i do
14:29hyPiRionI tend to use #_=> sometimes to make copy-pasteable repl examples
14:29hyPiRionperhaps I should do it here as well, muahahah
14:30hyPiRionprobably not, it would be confusing for everyone, me including
14:30arrdemfair enough...
14:30hyPiRionarrdem: oh, I was talking about inside a cond
14:32hyPiRionI do like #_=> though. Not sure if it's going to make docs easier to read, but at least you can copypaste all of it immediately
14:32hyPiRionarrdem: although e.g. http://grimoire.arrdem.com/1.6.0/clojure.core/seq/ prints out output you can't copypaste anyway, so I'm not sure how much sense it would make
14:33arrdemyeah...
14:33amalloywhat do you mean, hyPiRion, can't copy/paste? because it's not quoted?
14:34hyPiRionamalloy: yes
14:34amalloybut #_=> fixes that. and would fix it for seq as well as for whatever else. so i'm not sure how seq is relevant to the discussion of #_=>
14:35hyPiRionamalloy: oh, I thought it was meant as a replacement for user=>
14:36amalloymaybe so. i was thinking you meant it like in JoC, where they write (inc 1) ;=> 2
14:36amalloybut i guess that doesn't actually make sense
14:37hyPiRionright, #_=> is just the same thing as whitespace
14:37hyPiRionit wouldn't quote the (1) for example
14:38amalloyobviously we need the more advanced sigil #_=>#_
14:38arrdemwat
14:38hyPiRionamalloy: or just #_#_=>
14:38sjoukejustin_smith: i'm not entirely sure what type systems have to do with SOLID design
14:43justin_smithsjouke: me neither, I guess inheritance assumes some kind of type system?
14:43justin_smithsjouke: but I definitely wasn't the one making that connection in the conversation here
14:44Uraniohi, how could I use slrup being behind a proxy?
14:46justin_smithUranio: if you configure the jvm with the right proxy, slurp should "just work"™
14:46justin_smithhttp://stackoverflow.com/questions/120797/how-do-i-set-the-proxy-to-be-used-by-the-jvm
14:46justin_smithyou can set the jvm flags in project.clj
14:46Uraniothanks
14:47Uraniobut I would prefer to us declare it in each script
14:47justin_smithactually, proxy is less a per-project thing and more per-user, so likely belongs in profiles.clj
14:47justin_smithscript? what script?
14:48UranioI have a only one .clj script with my very litle program
14:48justin_smithit's still not a clojure level config, it is a jvm config
14:49Uraniojustin_smith: would be posible to declre it inside clojure?
14:50Uraniolike when using java from inside clojure?
14:50TEttingerI would guess yeah, but then your code wouldn't work for someone else?
14:50justin_smithI guess you can do (System/setProperty "http.proxyHost" "..." "http.proxyPort" "..." "http.nonProxyHosts" "")
14:50justin_smithbut yeah, that would make your code non-portable
14:51justin_smithmy bad, setProperty is not varargs, you would have to do each of those separately
14:51Uranioyep... seed
14:51justin_smithand you end up with code that only works on your computer
14:52amalloyi'm a little surprised the jvm doesn't just automatically use whatever proxy settings your OS wants
14:52amalloybut i guess i don't know anything about proxy config
14:53Uranioamalloy: me too
14:53Uranioit should work
14:53justin_smithamalloy: yeah, I thought it did, but I wasn't interested in going down the "which os are you using..." path
14:53technomancyamalloy: I think it depends on how it was packaged
14:53Uranio (set! (. Classname-symbol [...]
14:53Uranio^should work
14:54justin_smithfor what? it uses properties for proxy setup
15:00kitalliscould somebody explain to me this behaviour with (Long.)? – http://pastie.org/9429900
15:02justin_smith,(long (or (count "ok") 2)) this works
15:02clojurebot2
15:02justin_smithno idea why Long. does not work on that form
15:02stuartsierrakitallis: I suspect this is a subtle interaction of Java interop and primitive arithmetic in the Clojure compiler.
15:03gfredericks,(Long. (or (count "ok") 2))
15:03clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Long>
15:03gfredericks,(Long. (long (or (count "ok") 2)))
15:03clojurebot2
15:03kitallisheh
15:03gfredericks,(Long. ^long (or (count "ok") 2))
15:03clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Long>
15:03amalloy(or (count "ok") 2) returns an Integer, where (count "ok") returns an int
15:03gfredericks,(Long. (int 2))
15:03clojurebot2
15:03amalloygfredericks: that ^long doesn't survive macroexpansion
15:04kitallis,(type (count "ok))
15:04clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
15:04kitallis,(type (count "ok"))
15:04clojurebotjava.lang.Integer
15:04gfredericks,(Long. (count "ok"))
15:04clojurebot2
15:04amalloy,(Long. (identity (count "ok")))
15:04clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Long>
15:04amalloysimpler than using or
15:05amalloyclearly demonstrates that the issue is how (count "ok") is boxed
15:06stuartsierra,(Long. (.longValue (identity (count "ok"))))
15:06clojurebot2
15:06stuartsierrafun
15:06gfrederickswhy doesn't the compiler emit reflection after being unable to rule out that the expression returns a string?
15:06stuartsierraIt is.
15:06amalloygfredericks: it does
15:07gfredericksooooh it's failing at runtime
15:07gfredericksof course
15:07stuartsierrajava.lang.Long doesn't have a constructor that takes an Object.
15:07gfredericksokay so if it sees a constructor that takes a long and it has an Integer then it will not convert?
15:08justin_smithwhich is why we have "long" in clojure - which works with boxed numerics
15:09kitalliswhat's a boxed numeric?
15:09justin_smithInteger as opposed to int
15:10justin_smithit's in an object (its "box")
15:10stuartsierraWelcome to the JVM, where *almost* everything is an Object. :)
15:10justin_smithit can be the key in a hash-map
15:10gfrederickseh rubby is that way too a little differently. Fixnum is a fake object.
15:11amalloygfredericks: it acts like an object in every observable way though, right? the fact that the interpreter does it with pointer tomfoolery doesn't matter afaik
15:11gfredericksno
15:11gfredericksyou can't muck with its singleton class
15:11gfrederickssame with Bignum it looks like
15:12amalloyer, what does that mean? you can't monkey-patch Fixnum?
15:12gfredericksyou can't monkeypatch an instance of Fixnum
15:12amalloyah
15:13gfredericksruby is an enlightened language where you can monkeypatch individual objects
15:13arrdem"enlightened"
15:13gfredericksyou _can_ monkeypatch a boolean
15:14stuartsierraJava boxed numbers aren't fixnums, though, they're real objects.
15:15stuartsierra,(identical? (Integer. 42) (Integer. 42))
15:15clojurebotfalse
15:15stuartsierra^ That should be true in a runtime with real fixnums.
15:16amalloystuartsierra: uhhhhhh, i don't think so. (identical? 42 42) maybe, but when you call a constructor, you get a new object, every time
15:16amalloy,(identical? 42 42) *is* actually true, but only because of trickery
15:16clojurebottrue
15:16gfredericksstuartsierra: my point was that both runtimes have second-class [non-]objects
15:16gfrederickswhether primitives on the jvm or fixnums in ruby
15:16TEttingeramalloy: only on account of villainy!
15:17amalloy,(identical? 542 542)
15:17clojurebotfalse
15:18gfredericks,(->> (map (fn [a b] [a (identical? a b)]) (range) (range)) (remove second) (ffirst))
15:18clojurebot128
15:18amalloygfredericks: from -128 to 127
15:22aeikenberryif i have a sequence like (:foo (println "bar") (println "barbar") :bar (println "foo"))
15:22aeikenberryhow could i make a hash-map using those keywords as the keys, and what's between them (in :foo's case) as the value?
15:22aeikenberryor is a hash-map what i want? i'm new
15:23gfredericksaeikenberry: those printlns will turn into nil, right?
15:23aeikenberrywhen i try to make that a hash-map is says "No value supplied for key"
15:24justin_smithaeikenberry: that's an odd number of forms
15:24stuartsierraamalloy_: I mean Lisp-style fixnums, where integers aren't allocated on the heap at all. Can't remember if Ruby does that.
15:24justin_smithalso, you probably don't want (println "bar") as a value in a hash map - that's just nil, with a one time printing side effect that dissapears after the assignment
15:25TEttinger,(:foo #(do (println "bar") (println "barbar")) :bar #(println "foo"))
15:25clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :foo>
15:25justin_smith,(hash-map :a (println "prints once") :b (println "not in the data structure"))
15:25clojurebotprints once\nnot in the data structure\n{:b nil, :a nil}
15:25gfredericksstuartsierra: I believe ruby does do that, and that's exactly what makes them second-class
15:25TEttinger,{:foo #(do (println "bar") (println "barbar")) :bar #(println "foo")}
15:25clojurebot{:foo #<sandbox$eval77$fn__78 sandbox$eval77$fn__78@1ffdf86>, :bar #<sandbox$eval77$fn__80 sandbox$eval77$fn__80@1da817b>}
15:25stuartsierrathanks gfredericks
15:26TEttingeraeikenberry, it depends what you want to do
15:26aeikenberryi'm trying to build a macro for an assignment
15:27stuartsierraOf course, John Rose proposed fixnums for the JVM back in 2008 https://blogs.oracle.com/jrose/entry/fixnums_in_the_vm
15:27TEttingerthey're covering macros before "hashmaps have an equal number of keys and values"???
15:27lazybotTEttinger: Oh, absolutely.
15:28justin_smithTEttinger: we should start teaching steeplechase racing in preschools
15:28aeikenberryit takes a truthy test, and then any number of arguments with the format (macro truthtest :iftrue 'this 'orthis (println 'this) :iffalse 'nottrue)
15:28TEttingerI've heard category theory as being easier to grasp than conventional math for kindergarteners
15:29aeikenberrymy thought was to conver those arguments to a hash map
15:29aeikenberryconvert
15:29TEttinger(category theory being "box of kittens" and "box of apples and kittens" while math being all abstract)
15:30aeikenberryto be like if test do the stuff inf :iftrue part of the hash map
15:30justin_smithTEttinger: but as soon as you introduce arrows some poor kitty loses an eye
15:30TEttingerjustin_smith, haha
15:31TEttingerwhat is 'orthis there, aeikenberry?
15:31aeikenberryprint the string
15:32aeikenberry(macro (> 3 1) :iftrue 'ok :iffalse 'notok)
15:32TEttingerno I mean, if it's an if statement, then you have "test is true" "test is false"
15:32TEttingerwhere is there an alternate truth?
15:32aeikenberryinside the macro
15:33TEttingeragh
15:33aeikenberrywould test the truthiness of (> 3 1)
15:33aeikenberryand if true, evaluate what's after :iftrue
15:33TEttingeroh ok
15:33aeikenberrypassed into the macro
15:33TEttingerso it isn't an or, it's a continuous set of things to evaluate
15:34aeikenberryyeah, like (do 'ok 'true (println 'ok)) if the truth test passes
15:34TEttingeryou want to evaluate everything in the iftrue block if and only if the test is true, and if the test is false, evaluate everything in the iffalse block?
15:35aeikenberryexactly
15:35aeikenberrybut i'm unsure how to parse the arguments properly
15:35TEttingerthat makes sense
15:37aeikenberryif i have [test & args] in my macro, i'm not sure the best way to parse those args in a way to use them after the truth test
15:37arohnerin pedestal, is there no public API for terminating a request during an interceptor?
15:37aeikenberryany hints or pro-tips welcome
15:37arohnerthe only one I see is in io.pedestal.impl.interceptor
15:38rkneufeldarohner: You should be able to return a response to terminate the chain, no?
15:38arohnerrkneufeld: I don't know. The docs are unclear on what an interceptor should return
15:38justin_smithaeikenberry: if you really want to do macros before you know clojure (which is a painful way to do things), macroexpand and macroexpand-1 are really helpful
15:39arohnerbut they do say "Alternatively, an interceptor may call terminate", but then terminate is in impl
15:39aeikenberryit has been painful :/
15:39rkneufeldarohner: in honesty, there is a bunch of stuff in impl that should not be there.
15:39rkneufeldterminate included.
15:39TimMcaeikenberry: If you like pain, go right ahead. But macros really are an advanced topic.
15:40justin_smith,(macroexpand-1 '(or 1 2)) aeikenberry
15:40clojurebot(clojure.core/let [or__3975__auto__ 1] (if or__3975__auto__ or__3975__auto__ (clojure.core/or 2)))
15:40arohnerrkneufeld: thanks. Just making sure I'm not doing something The Wrong Way
15:42justin_smithaeikenberry: but you can do everything interesting with regular functions and sequence operations, macros are mostly just needed for custom syntaxes, which is an odd first thing to try in a new language
15:42justin_smithregular functions, especially sequence operations, and the built in macros and special forms, that is
15:44expezThe only way to get nil out of a core.async/chan is if someone closed! it, right? Is there some truly abject code out there that could cause a chan to return nil without someone calling close! on it?
15:45expezI just grepped by code base for close! after by db barfed on a not null constraint
15:45justin_smithexpez: well, writing nil to a chan closes it, right?
15:45expezbut that throws an exception!
15:45justin_smithoh, it's been a while since I played with that stuff, sorry
15:46justin_smithexpez: an exception in some thread somewhere, are you sure you would see it?
15:47expezI just tried putting nil to a chan, it does throw an exception and does not close it
15:47expezso you can keep using it if that was somehow something you expected
15:48expezbut that totally could've been it :)
15:55dnolen_stuartsierra: if it's possible to do the Google Closure release sooner rather than later that would be ideal - I believe for a lot of people 2277 doesn't work w/o the patch to the Closure build script
15:56stuartsierradnolen_: I doubt I'll have time before Friday. Code to build the JARs is in script/closure-library-release
15:57dnolen_stuartsierra: but I take it no button to click somewhere to release this a la ClojureScript?
15:57stuartsierradnolen_: no
15:57stuartsierraThat's been on the queue for approximately forever
15:57dnolen_stuartsierra: k
15:58stuartsierraWhat's the thing with 2277? Does the release build need to change?
15:58stuartsierraSorry, just haven't been following anything with this.
15:58dnolen_it's not 2277 that's busted rather the Closure Library changed
15:58dnolen_they used to dupe dep.js in both Library & 3rd Party
15:59dnolen_now dep.js is a blank file in 3rd Party
15:59dnolen_so I think this causes problems
15:59stuartsierraOK, so the Closure Lib build will have to change then, because it patches deps.js
16:01dnolen_stuartsierra: http://dev.clojure.org/jira/browse/CLJS-826
16:01dnolen_stuartsierra: there's already a patch for this in master
16:01dnolen_but not resolved until we release new Closure JARs
16:02stuartsierraOK I'll push up some JARs to Sonatype as soon as I can.
16:13stuartsierraWe need to make me not the bottleneck for this.
16:15stuartsierradnolen_: OK, JARs are in staging at https://oss.sonatype.org/content/repositories/orgclojure-1312 and https://oss.sonatype.org/content/repositories/orgclojure-1311
16:15dnolen_stuartsierra: awesome thanks
16:16stuartsierraJust confirm that third-party stuff works and I'll release to Central.
16:17dnolen_stuartsierra: yeah sent out a message to mailing lists to get feedback and will try it myself as well
16:18stuartsierraThose are links to staging repositories, by the way.
16:18dnolen_stuartsierra: yes
16:24arohner(go-loop [] (<! (timeout 1000)) (foo) (recur)). Is there a better way to express 'run foo once a minute'?
16:24arohners/minute/second/
16:24ztellmanarohner: using core.async, or via any mechanism?
16:25AeroNotixarohner: there are timer classes and scheduler classes in the java stdlib
16:25ztellmanscheduledthreadpoolexecutor
16:26arohnerany reason to pick one of those over core.async?
16:26AeroNotixarohner: they're purpose built for that task
16:26ztellmanarohner: your mechanism doesn't have a way to cancel, a way to specify the level of parallelism allowed, etc
16:27amalloyalso what if foo takes half a second to run?
16:27ztellmanalso, yours doesn't run it once a minute, it runs it every minute + execution time
16:27ztellmanamalloy wins again
16:28amalloymy secret is keeping quiet until there's a point someone else is bound to make, and then sniping it
16:28AeroNotixpoint sniping
16:28justin_smithhah, help-camper
16:28AeroNotix:)
16:38aeikenberryjustin_smith: I believe the reason this was supposed to be a macro was so that the arguments passed in aren't evaluated
16:39aeikenberryjustin_smith: it is very strange though, that this would be a task given to me knowing I'd never used Clojure before
16:39justin_smithaeikenberry: sure. you can also specify that the arguments supplied should be functions of no arguments, effectively gets you the same result, no new macros needed
16:41aeikenberryjustin_smith: well thank you for the help.
16:42aeikenberryjustin_smith: i'll do my best, i guess
16:49blunteforgive me if this question was already answered. My connection dropped...
16:49amalloyaeikenberry: it sounded like building that hashmap is not actually part of your requirements, but just your implementation strategy? you don't really need to build a hashmap at all; you can just create two lists, one with the if-true expressions and one with the if-false expressions
16:50blunteQ: is it possible to pass a defrecord "type" as a parameter?
16:50bluntenot an instance, but the class itself
16:50aeikenberryamalloy: how would i parse the argument to make the two lists though i was wondering?
16:51justin_smithblunte: (class my-record-instance) or your.ns.RecordName
16:51aeikenberryi have a SequenceArray of arguments, wondering the best way to parse that into the two lists or a hash map
16:51aeikenberrytwo lists would be good, i'm sure
16:51amalloy(partition-by #{:iftrue :iffalse} args) would be a start
16:51aeikenberryok
16:51aeikenberrythanks. very helpful
16:51amalloy,(partition-by #{:iftrue :iffalse} '(if x :iftrue a b :iffalse y))
16:52clojurebot((if x) (:iftrue) (a b) (:iffalse) (y))
16:53blunte(defrecord R1 [a b])... can I pass R1 the type/class as an argument to a function?
16:56justin_smithblunte: yes, I just showed you how
16:56aeikenberryamalloy: what are a b in that line?
16:56justin_smith,(do (defrecord R1 [a b]) (identity R1))
16:56clojurebotsandbox.R1
16:56justin_smithblunte: see above
16:57amalloythose are your printlns
17:04aeikenberryamalloy: (partition-by #{:then :else} (:then 'ok :else 'ok)) seems to throw an argumentException
17:06aeikenberrywrong data type for partition-by i suppose
17:06aperiodicaeikenberry: you are calling :then as a function
17:07sdegutisaeikenberry: you want {} not () probably.
17:07sdegutisaeikenberry: or maybe []
17:15gfredericks,(partition-by #{:then :else} [:then 'ok :else 'ok])
17:15clojurebot((:then) (ok) (:else) (ok))
17:15gfredericks,(partition-by #{:then :else} '(:then ok :else ok))
17:15clojurebot((:then) (ok) (:else) (ok))
17:16aeikenberryah
17:17jjwattis there a way I can control how #insts are written to a file? i know that they're java.util.Dates, but when I use org.clojure/data.csv to write them, they're written in a human readable format, and I'd rather just write them as timestamps.
17:19hiredmanignore jjwatt
17:19hiredmanwhoops
17:19hiredmanpardon me
17:20sdegutisawkward...
17:20jcromartiehahahaha
17:21jjwattlol
17:22jcromartiejjwatt: just convert your data the hard way
17:22jcromartiedata.csv has no facilities for customizing how values are printed or read back
17:22jcromartieit's not like clojure.edn
17:22gfredericksjjwatt: #inst does not exactly signify java.util.Date
17:22jcromartieor the reader in general
17:23gfredericksjcromartie: what does data.csv do? call #toString?
17:23clojurebotNo entiendo
17:23justin_smithjcromartie: or cheshire, for that matter
17:24jcromartiedata.csv just deals with strings
17:24jjwattjcromartie: right, and i know that an #inst doesn't always signify a Date, but that the reader creates that object
17:24jcromartieand anything that isn't a string gets str'ed
17:24jcromartieevery object written to CSV just gets str called on it, and then quotes get escaped if necessary
17:25jjwatti was just wondering if there was a dynamic bind similar to *data-reader* that you could use when marshalling to strings.
17:25jjwattI like the work it's doing with quotes and escaping
17:26jjwatti'll just convert the data types before-hand in the pipeline
17:26sdegutis~seen halgari
17:26clojurebotIt's greek to me.
17:26sdegutis!seen halgari
17:26sdegutiserm...
17:28gfredericksstr is customizable for IMeta
17:28hyPiRion$seen foo
17:28lazybotfoo was last seen joining on #unavailable 2 weeks and 2 days ago.
17:28stuartsierrajjwatt: There's nothing bulit-in, but you can override print-method
17:28gfredericksas stuartsierra just explained
17:28hyPiRionsdegutis: but you're probably looking for tbaldridge?
17:29gfredericksI guess for any other specific type as well
17:29tbaldridgesdegutis: greetings
17:29sdegutishyPiRion: oh, yeah..
17:29sdegutistbaldridge: oh hi...
17:30sdegutisI should have worded this before pinging...
17:30sdegutistbaldridge: oh wait, never mind.
17:30amalloyhalgari is a pseudonym for tbaldridge?
17:31sdegutisHey everyone: what's the general etiquette on naming one project the same as another project, when they're fundamentally different open source software projects?
17:31arrdemit's the name he uses everywhere but here...
17:31sdegutisFor example, let's say one's a Ruby library, and another is a Qt application for Linux that lets you play DVDs or something.
17:31jcromartiesdegutis: is there ANY chance they could collide in some context?
17:31amalloyi guess i've never looked very closely at him anywhere but here or at a conference
17:31sdegutisjcromartie: they could both be used by the same user, but the user would clearly know they're different things.
17:32sdegutisgfredericks: LOL
17:32justin_smithsdegutis: would they be parallel packages in one package manager?
17:32amalloyhey, i have to look pretty closely to read nametags. dang tiny fonts
17:32sdegutisjustin_smith: Never.
17:32jcromartiejustin_smith: that sounds like a good rule of thumb
17:33hyPiRionheh
17:33justin_smithsdegutis: on my debian based system, I can pick ruby libraries and QT based video players in one big menu, and a naming conflict would force one of them to be renamed
17:34amalloyjustin_smith: node is the worst-named package i remember seeing in debian
17:34stuartsierraThis is what group IDs are for.
17:34hyPiRionyeah, exactly
17:34sdegutistbaldridge: How would you feel if a completely unrelated open source app used the name "fafnir" also, and it happened to be completely unrelated to Clojure.. let's say it was some kind of instant messaging app for GKT+ or something...
17:35sdegutisI mean, just hypothetically.
17:35tbaldridgeI really don't care
17:35tbaldridgenot like I have a copyright to the name or anything
17:35sdegutistbaldridge: oh just wondering, thanks for your advice
17:35amalloywhat if i named my cat fafnir?
17:36tbaldridgethen no, in that case, the cat would be mine
17:36sdegutis~lawyers
17:36arrdemamalloy: then you get sued by the BattleTech guys
17:36clojurebotTitim gan éirí ort.
17:36justin_smithamalloy: see also jack, chromium (just off the top of my head)
17:37amalloymaybe i'll change my name to chromium
17:37amalloythat should make a lot of things mine
17:37sdegutistbaldridge: so you wouldn't mind if I named my OS X program Mjolnir?
17:37tbaldridgeI missed the part where it matters what I think
17:37amalloyi'd mind, but only because of the stunning lack of creativity
17:37sdegutistbaldridge: just trying to use "etiquette" or something.
17:38sdegutistbaldridge: im still not sure how this open source stuff works tbh
17:38justin_smith,(java.util.UUID/randomUUID) I declare that the name of sdegutis's new library is:
17:38clojurebot#uuid "7ce21776-9109-49f1-94d9-6db44b70633f"
17:39sdegutisha
17:39tbaldridgejustin_smith: ah so we're using COM these days?
17:39technomancydoesn't gfredericks have a patent on a system and method for choosing library names by uuid in an internet chat system?
17:39justin_smithhey, no likely name clashes
17:39hyPiRionsdegutis: You could probably use Gungnir instead, if you really worry
17:39gfredericks&(format "lib-%04d" (rand-int 10000))
17:39lazybot⇒ "lib-7816"
17:39gfredericks^ hand-made
17:40hiredmangetting a sweet domain name and use it as a group-id
17:40technomancyoh right
17:40hiredmanget a
17:40technomancynon-infringing
17:40justin_smithbut mine has "1776" embedded in it, which is way historically significant
17:41gfredericksmurica
17:41hyPiRionjustin_smith: well, 7816 is way more significant, you just don't know it yet.
17:42justin_smithheh
17:42jcromartie(ns org.afc85879-35ed-4cd7-b81f-1db66edb1950.ee10e10a-3c20-454b-974a-3371318568f7.core "Core functions for ee10e10a-3c20-454b-974a-3371318568f7" (:require [org.afc85879-35ed-4cd7-b81f-1db66edb1950.ee10e10a-3c20-454b-974a-3371318568f7.util :refer :all]))
17:42justin_smithlol
17:42jcromartieusage: (require '[org.afc85879-35ed-4cd7-b81f-1db66edb1950.ee10e10a-3c20-454b-974a-3371318568f7.core :as ee10])
17:42jcromartiesimple
17:44gfredericks,(apply * (repeat 12 16))
17:44clojurebot281474976710656
17:45sdegutistbaldridge: cool thx
17:45sdegutisfwiw, this is the app in question: https://github.com/sdegutis/hydra/issues/332
17:47celwellHello, any suggestions on making this more idiomatic and simple? https://gist.github.com/celwell/552318c5c08fc5a2bff2
17:48sdegutiscelwell: can you show an example input and output?
17:50justin_smithcelwell: #(list (:id %) (:prefill_config %)) should be (juxt :id :prefill_config)
17:50justin_smith(inc juxt)
17:50lazybot⇒ 11
17:50jcromartiewouldn't this be exactly as valid as waiting for a "real" "deadbeef-" UUID? ,(str "deadbeef" (.substring (str (java.util.UUID/randomUUID)) 8))
17:50justin_smithand (map ...) flatten should be just (mapcat ...)
17:50justin_smith~flatten
17:50clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
17:51amalloyjcromartie: if you're counting sheep, you don't just say "a million" and fall right to sleep
17:51celwellsdegutis: I've just added input and output to the gist in the first comment.
17:51aperiodicjcromartie: what, you're just letting people make up their own now? madness! anarchy!
17:52aperiodicthe system & method clearly specifies using the output of the random UUID generator in whole!
17:53celwelljustin_smith: thanks for pointing out 'juxt' that's helpful
17:53arrdemOH NO WE CAN'T HAVE PEOPLE JUST MAKING UP NUMBERS NOW CAN WE?
17:54amalloycelwell: (apply hash-map (mapcat (juxt f g) xs)) should just be (into {} (map (juxt f g) xs))
17:54cbpamalloy: I don't think that works
17:54cbp,(into {} [:a 1])
17:55clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
17:55cbper
17:55hyPiRioncbp: That's wrong though
17:55amalloycbp: it does work
17:55cbpim an idiot
17:55justin_smith,(= (mapcat #(list % %) (range 4)) (flatten (map #(list % %) (range 4))))
17:55clojurebottrue
17:55justin_smiththe function there is not the point, just noting the equivalence of mapcat to flatten on a non-nested input
17:56amalloycelwell: you're also doing a bunch of work to build a potentially-huge map, and then selecting out just the keys you actually wanted. could be better to pre-filter
17:56gfredericksto flatten variable depth structures, tree-seq is probably always preferable to flatten?
17:57amalloygfredericks: honorable suicide is preferable to flatten
17:57justin_smith(inc amalloy)
17:57lazybot⇒ 151
18:01gfredericks(->> (ns-publics 'clojure.core) keys (sort-by awefulness) (reverse) (take 5))
18:01gfredericksawfulness*
18:05cbp(take-last 5) imo
18:07amalloygfredericks: (shuffle '(test == cast fnext newline)) is my back-of-the-envelope guess
18:08justin_smith=> (flatten, pmap, defstruct, apropos, cast)
18:08justin_smithamalloy: thanks for the "cast" suggestion
18:09justin_smithI include apropos in that list because it gives you names of functions, but no namespace info
18:09justin_smithtotally annoying
18:09amalloyto-array-2d looks about as pointless
18:11amalloyman, what the heck is the deal with #'clojure.core/filter-key? how did that ever get included, or written the way it is?
18:12eskatremI'm having a problem with Monger: running (mc/update db coll {:eng eng-message} {:fr message} :upsert true) gets me an error "Wrong number of args (6) passed to: collection/update"
18:13amalloyjustin_smith: clojure.core/xml-seq
18:14justin_smithoh, that's another good one
18:14cbpwonder if anyone's ever used test
18:15AeroNotixamalloy: which version is that in?
18:15cbpit's private
18:15justin_smithcbp: I think I had a reason to use it once. I think, sort of like inot-array-2d, it's one of those things that is in there because rich hickey finds it useful, but most of the rest of the userbase will probably never touch it
18:16amalloymost of these functions i doubt rich actually finds useful. he was just starting with clojure and was like "what are some cool things i can build and/or might want someday"
18:16justin_smithlike, any sane clojure user would just use a set with keywords in it, but some crazy person maybe tests if bits are set
18:17justin_smithoh, now I remember: I was building a quad tree data structure where the lookup of data mapped to the x / y bitwise representation of the coordinates
18:17justin_smithso I found it useful to check specific bits
18:17justin_smithit sped up my lookups immensely
18:17amalloyjustin_smith: what function are you talking about?
18:18justin_smithtest
18:18amalloyyou seem to mean bit-test
18:18justin_smithahh, yeah
18:18amalloy&(doc test)
18:18lazybot⇒ "([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
18:18justin_smithoh, never mind :P
18:19justin_smithyeah, some cruft from before clojure.test I guess
18:19cbpi was confused for a bit
18:19gfredericks,(defn add {:test (fn [] :yep)} [x y] (+ x y))
18:19clojurebot#'sandbox/add
18:19justin_smithcbp: amalloy: in my defense, there is a link on the clojure cheatsheet page that says "test" and clicking it goes to bit-test (the tricky formatting fooled me)
18:19gfredericks,(test #'add)
18:19clojurebot:ok
18:20cbp#badpuns
18:20gfredericks,(defn add {:test (fn [] (/ 3 0))} [x y] (+ x y))
18:20clojurebot#'sandbox/add
18:20gfredericks,(test #'add)
18:20clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
18:20AeroNotixjustin_smith: jeez I need to go to bed I thought you said "... on the clojure cottage cheese page .."
18:20justin_smithAeroNotix: that does not sound very appetizing at all
18:21amalloyset your homepage to clojure.org/cottagecheese - something exciting coming soon!
18:21AeroNotixjustin_smith: :)
18:23gfredericksyou gotta come to strange loop to see the talk that announces it
18:23amalloynow, amusingly, clojure.test/deftest actually puts the test into the var's metadata rather than the var itself, just in case someone calls clojure.core/test
18:23justin_smithoh, so not pre clojure.test cruft, but just an unused feature compatible with clojure.test
18:24amalloyi don't think you can draw that conclusion
18:24amalloyit was probably around before clojure.test, and clojure.test structured to be compatible with it
18:24justin_smithOK - I guess it wouldn't respect any fixture definitions
18:24gfredericksclojure.core should start adding :weird? metadata to weird vars
18:25arrdemI'd take :pure as well because tracing side-effects is a royal pain..
18:25justin_smithgfredericks: each var should have a :karma metadata, dictated by the popularity of that definition on #clojure
18:26amalloyyeah, clojure.core/test was added a year before the first commit i can find clojure.test
18:27gfredericks(dec clojure.core/test)
18:27lazybot⇒ -1
18:33franklei know nothing about clojure, but thought that you guys touted something like this as more readable, right? (inc (last (take 2 (filter odd? [1 2 3 4 5]))))
18:34frankleif so, why is prismatic writing macros for clojurescript to do something like this instead: https://gist.github.com/davegolland/dd47281d1ef1e4a10f3b#file-threading-example-clj
18:34AimHereUmm, (last (take 2 foo)) is the same as (second foo)
18:35AimHerefrankle, that ->> macro is a clojure built-in
18:35frankleAimHere: thanks. didn't know that. what form is encouraged?
18:35AimHereUse that, or use the nested s-expressions, according to which you feel is more readable at the time
18:36franklewhat about consistency?
18:36AimHereConsistently aim for readability
18:36franklei like it
18:36franklehaha
18:37gfredericksamalloy elucidated an interesting rule of thumbs on that yesterday
18:38gfredericksi.e., a more specific definition of readable
18:38franklewhat's that?
18:38frankleand do you have a link?
18:39amalloyfrankle: search for "(= [1 2 2]" in http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-07-28.txt, and then follow the conversation between me and gfredericks
18:40gfrederickslazybot: you need line anchors in your irc log pages
18:40franklethanks
18:40amalloyfeel free to read http://stackoverflow.com/questions/12715577/when-should-i-use-the-clojure-arrow-macro as well
18:42amalloythe implementation of underive is bizarre. it starts with (declare flatten)
18:43gfredericksclojurebot: clojure is lisp4j
18:43clojurebotRoger.
18:47aeikenberry(partition-by #{:then :else} args)
18:47pdkclojurebot: you're my best friend
18:47clojurebotTitim gan éirí ort.
18:48aeikenberrywhat is the #{:then :else} doing exactly?
18:49justin_smithaeikenberry: when used as a function, a set returns nil if the argument is not present, or the argument if it is present in the set
18:49justin_smith,(map #{:a :g} [:a :b :c :d :e :f :g])
18:49clojurebot(:a nil nil nil nil ...)
18:50justin_smith,(keep #{:a :g} [:a :b :c :d :e :f :g])
18:50clojurebot(:a :g)
18:52aeikenberryafter i run that partition-by, i get this: ((:then) ((quote ok)) (:else) ((quote notok)))
18:52aeikenberryi'm trying to find the clojure way of grouping those by the keywords
18:53justin_smithaeikenberry: do you have a paste of your current code?
18:56aeikenberryjustin_smith: https://dpaste.de/9UEU
18:56aeikenberrythis is what i was trying to do
18:57aeikenberry(multi-if (= 1 0) :then (println "hi") :else 'ok)
18:57justin_smithaeikenberry: def is only for creating globals
18:58aeikenberryshould be using let?
18:58justin_smith(hash-map chunks) should be (apply hash-map (cleanup-keys chunks))
18:58justin_smithcleanup-keys clearly has not been written yet :)
18:59justin_smithyeah, let
18:59aeikenberrywhat should cleanup-keys be doing there?
19:00justin_smithalso, a macro needs to return that form that will run - so you may need to change (do ...) to (list 'do ...) (or maybe you need to construct your form by some other method)
19:00justin_smithaeikenberry: it would turn (:then) into :then and (:else) into :else
19:01aeikenberryhm. ok. thanks
19:01justin_smithor you could change (:then chunkmap) into (get chunkmap '(:then))
19:01justin_smithbut that is weird
19:01aeikenberryi see. thanks a lot for taking a look
19:02justin_smithnp
19:02justin_smithso now you are looking at something more like (defmacro multi-if [test & args] (let [chunks ...] ...))
19:03justin_smithyou may or may not want to learn how to use ` and ~, they are helpful for selective evaluation and form building
19:03justin_smithmost macros use them
19:03justin_smithbut that may be more complexity than you need right now (since ` changes how you use let, etc.)
19:04numbertenis there any difference between core/false? and core/not ?
19:04justin_smith,((juxt false? not) nil)
19:04clojurebot[false true]
19:05numbertenjuxt is just comp but left to right?
19:05numbertennot familiar with that function
19:06justin_smith(doc juxt)
19:06clojurebot"([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
19:06numbertenoh no
19:06numbertenyeah
19:06justin_smith,((juxt inc dec) 0)
19:06clojurebot[1 -1]
19:06numbertenit applied each to the value
19:06numbertenwow that's really useful
19:06numbertenjustin_smith: also thanks for the example
19:06numbertenfor not and false?
19:06justin_smithright, it was a quick way to say "false? and not return different results when applied to nil"
19:06justin_smithnp
19:09technomancyit's the best function
19:09technomancyno other function is as good as juxt. objective fact.
19:09arrdem$karma juxt
19:09lazybotjuxt has karma 11.
19:10arrdemJuxt is the 57th most referenced function in Grimoire
19:12technomancy(inc juxt)
19:12lazybot⇒ 12
19:37TimMc(juxt inc)
19:37justin_smith((juxt inc dec) TimMc)
19:38justin_smiththough not implemented as a command, results in a logical outcome for said unimplemented command
19:38technomancyjustin_smith: it's atomic too!
19:38justin_smithyup, no race conditions here
19:39arrdemClearly lazybot should be extended to an sexpr interpreter supporting arbitrary combinations of inc, juxt, dec, doseq and usernames.
19:39kelseygi_what's the better (or even working) way to do this?
19:39kelseygi_ (swap! state
19:39kelseygi_ #(update-in % [:deletes]
19:39kelseygi_ #(concat (seq [1 12 13]) %)))
19:39arrdemkelseygi_: refheap.com
19:39justin_smithkelseygi_: please use refheap
19:39kelseygi_whoops sorry!
19:39kelseygi_https://www.refheap.com/88703
19:40arrdem<3
19:40gfredericks(swap! state update-in [:deletes] #(list* 1 12 13 %))
19:40justin_smith(swap! state update-in [:deletes] #(conj % 1 12 13))
19:40Raynes(juxt inc inc inc inc inc inc inc inc inc inc inc inc inc inc dec #_ccccccccccombobreaker)
19:41arrdem(inc Raynes)
19:41lazybot⇒ 47
19:42justin_smith(swap! state update-in [:deletes] #(conj % 13 12 1)) ; had it backwards
19:42gfredericksjustin_smith: using conj assumes you have a seq; and if you do use conj, you don't need the anonymous fn
19:42justin_smithgfredericks: it was documented to take a seq
19:42gfredericks(swap! state update-in [:deletes] conj 13 12 1)
19:42justin_smithahh, nice
19:43gfredericksin the future we will have update
19:43gfredericksand then it gets even prettier
19:43kelseygi_heh, learning clojure feels like a constant state of having it backwards
19:44justin_smith,(swap! (atom {}) update-in [:deletes] conj 13 12 1) works, nice
19:44clojurebot{:deletes (1 12 13)}
19:44justin_smithkelseygi_: we are just very flexible about direction
19:45amalloy,(swap! (atom {}) update-in [:deletes] (fnil conj []) 13 12 1) is even more exciting
19:45clojurebot{:deletes [13 12 1]}
19:45kelseygi_,(apply update-in {} [:deletes] conj 13 12 1)
19:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
19:45gfredericksSO EXCITED
19:45kelseygi_see this is where i'm getting confused about what swap actually does
19:45gfredericks,(update-in {} [:deletes] conj 13 12 1)
19:45clojurebot{:deletes (1 12 13)}
19:45gfredericksno need for apply
19:45kelseygi_yeah i know, i'm trying to work out what gets done with the args to swap!
19:46kelseygi_"Atomically swaps the value of atom to be: (apply f current-value-of-atom args)"
19:46amalloy(swap! a f x y) => (swap! a #(f % x y))
19:47kelseygi_right, but that's why (swap! (atom {}) update-in [:deletes] conj 13 12 1) is confusing me
19:47gfredericksargs in this case is [[:deletes] conj 13 12 1)
19:47kelseygi_isn't the map getting inserted before [:deletes]?
19:47gfredericks(swap! a f x y) => (swap! a #(apply f % [x y]))
19:48kelseygi_,(apply update-in {} [[:deletes] conj 13 12 1])
19:48clojurebot{:deletes (1 12 13)}
19:48kelseygi_whooooaaaa, that's subtle
19:50gfrederickskelseygi_: have you used any other dynamically typed languages?
19:50kelseygi_javascript
19:50gfredericksjavascript has this too
19:50gfredericksf(m,x,y) => f.apply([m,x,y]) // or so
19:51gfredericksI can't remember if you can f.apply(m,[x,y])
19:51gfredericksalso there's probably a this arg I forgot?
19:51gfredericksI don't even want to think about it
19:51kelseygi_so i thought i got what apply was doing
19:51tuftthere usually is
19:51kelseygi_but i'm a lil confused by what you pointed out, the f.apply(m,[x,y]) bit
19:52gfrederickscompare these two
19:52gfredericks,(apply update-in {} [[:deletes] conj 13 12 1])
19:52clojurebot{:deletes (1 12 13)}
19:52amalloykelseygi_: (apply f x y [a b c]) => (f x y a b c)
19:52gfredericks^ which is what you pasted
19:52gfredericks,(apply update-in [{} [:deletes] conj 13 12 1])
19:52clojurebot{:deletes (1 12 13)}
19:52gfredericks^ same thing but with first arg included in the list
19:54kelseygi_right, i follow there
19:54kelseygi_i think i got led astray by the doc string "Atomically swaps the value of atom to be: (apply f current-value-of-atom args)"
19:55gfredericksyeah the docstring uses that form so as to be maximally generic
19:55kelseygi_yeah it's not *literally* that
19:55gfrederickswell it might be
19:55kelseygi_well it is, but hte args are passed as an array
19:55amalloykelseygi_: yes it is
19:55kelseygi_cause otherwise it does (f x y a b c) as amalloy pointed out
19:55kelseygi_er i totally meant vector
19:55gfredericksit does both
19:56gfredericksapply does the (f x y a b c)
19:58kelseygi_i'm trying to understand the form apply gets called in when i call (swap! atom f x y a b c)
19:58gfredericks(apply f current-val [x y a b c])
19:58gfredericksaccording to the docstring
19:58kelseygi_yeah
19:58gfredericksand that is logically accurate
19:58danielcomptonWhat's the reasoning behind clojure contrib projects having to use Jira patches? I understand that's how Clojure Core does it but it's not explained well at http://dev.clojure.org/display/community/Guidelines+for+Clojure+Contrib+committers
19:58gfrederickssometimes there are differences for performance, but logically you can ignore those
19:58kelseygi_i was trying it as (apply f current-val x y a b c) which is different
19:59gfredericksyes
19:59amalloy,((fn [a f & args] (apply f a args)) 1 + 2)
19:59clojurebot3
20:00amalloyhere a is 1, f is +, and args is [2]
20:00kelseygi_yup, i see the difference, was trying to work back to where i got entangled in the swap
20:00kelseygi_thanks!
20:01aaelonyhmmm, trying to define a defrecord with 213 fields and getting "java.lang.RuntimeException: Method code too large!" ... sigh
20:02gfredericksI got a stack overflow
20:02gfredericksfrom: (eval (list 'defrecord 'Foo (vec (repeatedly 213 gensym))))
20:02justin_smithhttps://en.wikipedia.org/wiki/Potoooooooo another awesome namesake waiting to be claimed
20:03aaelonytrying to determine what the max on my system is ...
20:03gfredericksI got method code too large for 163
20:04hiredmanI suspect 0 or 1 will work
20:04aaelonyseems about right where I'm at
20:04gfredericks122 is my largest
20:04aaelonyI guess I'll use a map instead.
20:05amalloyaaelony: what on earth. a record with 213 fields? there can't be any imaginable reason to use that instead of a map
20:05amalloyit would perform abysmally
20:05gfredericksamalloy: why?
20:06gfredericksoh the copying?
20:06amalloyyes
20:06aaelonyI've got a file with 213 columns. I like records, but in this case it'll be a map.
20:06gfredericksamalloy: but perform fine for writing amiwrite?
20:06gfrederickss/writing/reading/
20:06gfrederickss/amiwrite/amiread/
20:06justin_smithaaelony: what about nesting them? there must be some sub-categorization of the fields that simplifies the structure
20:07amalloyi dunno, maybe. (.foo ^MyRec x) would be fine, but (:foo x) might be quite poor
20:07amalloyprobably it'd be fine
20:08gfredericksclojurebot: probably it|'d be| fine
20:08clojurebotIn Ordnung
20:08gfredericks~probably it
20:08clojurebotprobably it 'd be fine
20:08gfredericksaw
20:08aaelonyjustin_smith: I could. The idea was to read it in, then clean it up, add some business logic, transform things, then ultimately the output needs to be flat. I guess I'll just zipmap keyword labels onto it to make a big map...
20:08amalloyi wonder if (keys) is cached on records
20:09amalloyi guess not, since keys is (map key (seq x))
20:10aaelonyif I was evil I could create a defrecord for the first part and another for the second, I suppose as well
20:11justin_smithaaelony: if any of the fields could be collated into an array or vector, that could simplify things a lot during the intermediate pre-flattened processing
20:13aaelonyjustin_smith: agree. I'm thinking a simple map for now, but will noodle more on it. It surprised me that defrecords don't allow a lot more elements though.
20:14aaelonyI would think it's pretty common for a file to contain a lot of columns and a defrecord is nice for that
20:14gfredericksaaelony: why is it nice for that?
20:14amalloythey don't allow a ton of elements because all of the benefits of a defrecord are related to having a small, fixed/known number of keys
20:15aaelonyif the premise is that it's like a map but faster, it's a nice idea
20:15amalloyit's not. if you gave it that many elements it would be slow
20:16amalloyas i was discussing with gfredericks
20:16aaelonyyeah, it's looking like a map is in order then
20:17aaelonyor a Java object....
20:24gfredericksdeftype goes up to 254 on my machine
20:24gfredericksthe error after that is "Too many arguments in method signature in class file compile__stub/user/Foo"
20:37rritochHi, does anyone know how to make a gen-interface with default arguments?
20:39rritochI tried using :methods [[get [String] Object] [get [String Object] Object]] with (defn get ([this k] ...) ([this k d] ...)) but I'm getting an aririty exception
20:40aaelonygfredericks: is deftype an option?
20:40gfredericksaaelony: depends on what you're doing?
20:41gfredericksaaelony: I'm sure it's a terrible option but I also think that about "a Java object"
20:41aaelonyI tested a map, it works great. But curious, suppose this file got very large...
20:42gfrederickslarge rows or large columns?
20:42aaelonyI think I'm lucky because a map might be good enough, but I can imagine a lot of other scenarios where it would be nice to have a performant thingy that feels like a map but also has the potential for polymorphism and oo stuff too...
20:43gfredericksthat's way too squishy to analyze; maps can be polymorphic w/ multimethods
20:43aaelonylarge rows and large columns. I guess then a rethink would be in order, cascalog or something hadoopy
20:47rhg135rritoch, any reason you can't use protocols?
21:03aaelonyrhg135: protocols for what?
21:04aaelonyrhg135: ahh, nevermind. question rescinded...
21:17danielcomptonI'm wanting to flatten a nested map into a collection of maps like https://www.refheap.com/88706. I had a look around and I couldn't find anyone doing this kind of thing. What would be the right approach for this?
22:14taliosis the depth constant?
22:43danielcomptontalios: nope
22:44taliosis the depth known?
22:46aeikenberryi'm new. been working on this today for an assignment
22:46aeikenberryhttps://dpaste.de/pg2d
22:47aeikenberryit's real rough, but i don't really understand the error
22:51aeikenberrysorry just learning clojure today
22:57jeremyheileraeikenberry: the error implies that you're using a keyword as a function.
22:57jeremyheiler,(:foo)
22:57clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :foo>
22:58jeremyheilersame error^
22:58jeremyheilerusing a keyword as a function is fine, but calling it without any arguments is why this error occurs.
22:59aeikenberrythanks. that does make sense
23:00aeikenberryis it line 5 that is having problems then?
23:01gwsaeikenberry: try macroexpand-1 - possibly like this: (macroexpand-1 '(multi-if (= 1 0) :then (println "ok") :else notok))
23:03jeremyheileraeikenberry: what gws suggested is exactly what i would do, too.
23:03aeikenberrythanks
23:06aeikenberryseems to give me the same error
23:06gwsdid you quote the form like I had it?
23:06gwsthat worked for me in a repl
23:08aeikenberryah, i see
23:09aeikenberryhaving (:then) as a key is certainly not the best way
23:09jeremyheileraeikenberry: looking at the macroexpanded output, you have too many parens around things.
23:09gws,(:then)
23:09clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :then>
23:09gws,:then
23:09clojurebot:then
23:10gws,(:then {:when "will" :then "be" :now? "soon"})
23:10clojurebot"be"
23:10gwsaeikenberry: you can use keywords as functions in clojure
23:11aeikenberrywhen i do that partition-by, i get something like ((:then) ((println "ok")) (:else) (notok))
23:12aeikenberryi thought making that into a map would make sense, but it's taking the whole (:then) rather than the :then
23:14gws,(map first '((:then) ((println "ok"))))
23:14clojurebot(:then (println "ok"))
23:15aeikenberryoh wow
23:20aeikenberrythanks guys. making progress!
23:21gwsnice :)
23:29aeikenberryhttps://dpaste.de/VYTT
23:30aeikenberryany idea why these both condition evaluates as if it were false?
23:30aeikenberrymacroexpand doesn't seem to help. just says (do 'notok)
23:36gfredericks,(defmacro multi-if
23:36gfredericks [test & args]
23:36gfredericks (let [chunks (partition-by #{:then :else} args)]
23:36gfredericks (let [chunkmap (apply hash-map (map first chunks))]
23:36clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
23:36gfredericks (list 'cond 'test (list 'do (:then chunkmap)))
23:36gfredericks :else (list 'do (:else chunkmap)))))
23:36gfrederickswelp
23:36gfredericksno defense for doing that.
23:37gfredericksaeikenberry: what the result of macroexpand tells you is that your problem is happening during macroexpansion
23:37TEttinger,(defmacro multi-if [test & args] (let [chunks (partition-by #{:then :else} args)] (let [chunkmap (apply hash-map (map first chunks))] (list 'cond 'test (list 'do (:then chunkmap))) :else (list 'do (:else chunkmap)))))
23:37clojurebot#'sandbox/multi-if
23:38gfredericksaeikenberry: I don't think your parentheses are balanced the way you think they are
23:38TEttingerwhat were you going to do with that multi-if, gfredericks
23:38gfredericks,(macroexpand-1 '(multi-if (= 1 1) :then (println "ok") :else 'notok))
23:38clojurebot(do (quote notok))
23:38gfredericksjust that
23:39gfredericksaeikenberry: e.g., your line 5 is a complete NOOP
23:39aeikenberrysorry, what is NOOP
23:39TEttingerno operation
23:39TEttingerdoes nothing
23:40TEttingeralso called dead code, or unreachable code
23:40aeikenberryi see
23:43gfredericksnot unreachable in this case, just ignored
23:43aeikenberrywhy ignored though?
23:43aeikenberrymacro escaping?
23:43gwsno, count parens
23:44aeikenberryohhhh
23:45aeikenberryall these parens!
23:45gfredericksit helps to have a text editor that indents based on the parens
23:46gfredericksyour manual indentation is deceptive
23:47aeikenberrywelp i fixed i thought but now i have the problem where only the truth evaluates...
23:48aeikenberry(if test (do (println "ok")) (clojure.core/cond :else (do (quote notok))))
23:49aeikenberryah ha. if test rather than the exp
23:49aeikenberrythanks a lot. you guys rule
23:50gfredericks:)
23:59Balveda(if (< 3 (count ["1" "2" "3" "4"]) (println "y") (println "n")))