#clojure logs

2012-11-30

00:20nsidein your opinion, what is the greatest clojure program?
00:21muhoois there a contest? "greatest" by what criteria?
00:22nsidenot a contest
00:22nsidejust in your opinion what is the most impressive clojure program
00:22RaynesClojure?
00:22clojurebotclojure is not groovy
00:22nsidein my case it's storm
00:22nsidehttps://github.com/nathanmarz/storm
00:23jyfl987just found enlive, and i like the idea
00:24echo-areanside: But Storm's use of Clojure is not that idiomatic
00:25nsideecho-area: agreed but that it's used at such at large scale is impressive to me
00:25TimMcecho-area: How so?
00:27nsideI guess that's because there's a lot of java in there
00:27echo-areaTimMc: IMHO Storm is more using Clojure to glue many parts together. There are lots of mutation in there
00:28echo-areaAnd the mutation is not "managed", as in the facilities Clojure provide
00:29nsidei'd say orchestrate rather than glue
00:30Raynesnside: refheap is the best Clojure program, hands down, no contest.
00:31nsidenever heard of it
00:31nsidechecking
00:31nsidesounds like self promotion :)
00:32nsidehttps://github.com/Raynes/refheap
00:34echo-areaGroovy?
00:38zeirisImpression from first 30 minutes browsing Clojure libraries: what are you crazy brilliant bastards using to generate those cheatsheets?
00:40Rayneszeiris: Are you by chance the same zeiris that used to hang out on blizzhacker channels?
00:41zeirisYes.
00:41RaynesIn that case, hello old friend.
00:41zeirisTruly, a small world.
00:42RaynesWhat cheatsheets are you talking about?
00:43zeirisThe ones for, uh... Oh, I guess it's just Quil and Clojure itself. Thought there was also one for incanter.
00:43RaynesCould you link me to it?
00:43Raynes(any one of them)
00:44zeirisNevermind, I thought I stumbled into some kind of documentation secret weapon. https://github.com/quil/quil/raw/master/docs/cheatsheet/cheat-sheet.pdf
00:45RaynesYeah, I don't know about that. The only documentation tools I'm aware of are autodoc, codox, story, and marginalia, and none of them are cheatsheetish.
01:12zeirisOut of curiosity, is anyone using lighttable for day-to-day clojure development? Is it still too early, or is it worth playing with as a beginner?
01:19wingyzeiris: i am .. its definitely worth checking out
01:19wingyjust remember to fill in issue reports in github when you have improvement suggestions
01:20wingyits stable enough to be used as primary IDE imo for your clojure projects .. the live repl is amazing
01:21wingyjust remember to back up your project (im using SugarSync). sometimes a file is not saved correctly .. idk if it's my own issue or something others experience as well
01:48ucbjust in case, is there a way of changing the :encoder and :decoder of an aleph tcp-client while it is open?
01:50patchworkAnyone have any insight into this one? http://stackoverflow.com/questions/13639249/clojure-and-ring-utf-8-in-responses-comes-through-as
01:50patchworkI found very little discussion about it
02:06cemerickpatchwork: (potentiallly) answered
02:07patchworkAh nice, I will try that
02:08patchworkthanks cemerick!
02:08cemerickIn general, if you're not specifying text encodings (whether in a web context or not), bad things will eventually happen.
02:15patchworkI already fought through this issue with mysql
02:16patchworkevery step of the way I have had to vet for charset issues
02:19p_l|workpatchwork: when faced with any charset other than 7bit ASCII, I simply prefer to ditch MySQL
02:19patchworkp_l|work: I wish I had the choice!
02:19patchworkWe started with postgres which was a dream, then they demanded we host on RDS
02:19patchworkwhich does not yet support postgres
02:20p_l|workthere is a lot of issues with how it handled encodings (and way to many points of failure), and I recently heard (I dropped it back in 4.0/4.1 era) that it handles Unicode internally through UCS-2. Not sure if real, but a real blow
02:20patchworkWhoa!
02:20patchworkis that true?
02:20patchworkscandal
02:21p_l|workI don't know, I think I seen it mentioned among applications that don't support UTF-16 surrogate pairs (so basically pure UCS-2), so I'd recommend running a test
02:21p_l|workmight depend on exact version of MySQL
02:21p_l|workanyway, a mess I won't touch if I can
02:23p_l|workI had a surprise emergency migration (3.23.x -> 4.0.x -> 4.1.x iirc) once during a rush job (read: I was modifying code live while it was running, only telling users directly to save their work, then I'd push the change, then they'd reload the page)
02:23p_l|worksince that one time, I just don't touch MySQL
02:23p_l|worktoo much pain
02:47Sgeo__if (datetime.getMonthOfYear() == 2) { // February is month 2!!
02:47Sgeo__Why is that amazing, exactly?
03:20tomojhmm https://www.refheap.com/paste/b12a669c45fa02dae18e1ab73
03:21tomojis that a tree fold?
03:21tomojI suspect it's something weird
03:21tomojwhat should the semantics of returning a reduced during a tree fold be?
03:22tomojlooks more like a walk than a fold to me
03:53pingtimeoutHi guys
03:54pingtimeoutI have a question regarding agents
03:55pingtimeoutI have written a small UDP server using an agent (https://github.com/pingtimeout/android-showoff/blob/master/server/src/fr/pingtimeout/androidshowoff/discovery.clj)
03:56pingtimeoutSo the main method (line 92) send itself to the agent so that it makes a sort of infinite loop
03:57pingtimeoutThe problem is : Now I want to stop the UDP server, and I could only find shutdown-agents, which is overkill
03:58pingtimeoutSo, what do you think about that ? Should I use an atom "running" to know whether my agent have to continue ?
04:05ucbpingtimeout: why not send a message to the agent to stop itself?
04:06ucbpingtimeout: see this simple fake-erlang-processes toy example using agents for that https://gist.github.com/4c102e8c225c39037707
04:07Sgeo__I...
04:07Sgeo__WTF nrepl
04:07Sgeo__It seems to not be seeing that I'm trying to redefine a function
04:07Sgeo__It's using the old (wrong) function definition
04:10Sgeo__Oh, I was mislocating the bot
04:10pingtimeoutucb: Looking at your link, I think my problem is at line 100, when the processing function send-off itself to the agent
04:24ucbpingtimeout: thing is, your processing fn has to take the old value of the agent (the processing function itself) and it seems to take a socket, and then it has to return the new value for the agent (the processing function itself)
04:26ucbor at least that's how I did it
04:26ucbperhaps the processing fn can be a closure over the socket
04:34pingtimeoutucb: So the agent should not be the socket I am using
04:37pingtimeoutMore generally, how would you core a UDP server. I assumed that for IO operations, I had to use agents and send-off. Is this the good solution ?
05:17ucbpingtimeout: not sure, I'd probably have an agent with a closure over a socket listening
05:18ucbpingtimeout: as I mentioned before, the agent has to point to the process function (which is a closure over the socket) and it'll receive itself as argument and be evaled to itself
06:39borkdudejust a quick question - is it possible to use javascript (and therefore, clojurescript) instead of applescript to create OSX scripts?
07:09pingtimeoutucb: Thx for the advice, I'm trying to understand precisely how to do that
07:09pingtimeoutucb: So the agent should point to the behaviour, not to the data
07:10ucbpingtimeout: that's how I did it; doesn't mean you have to do that yourself :)
07:11pingtimeoutucb: Actually, I'm trying to find a good (clean) way to do that :p
07:11ucbpingtimeout: have you considered aleph?
07:11ucbI believe it has an udp-server :)
07:14pingtimeoutI have not tried it yet, I know it exist but it's on my TODO list after the "Release v1.0" :)
07:15ucbheh - cool
07:15ucbpingtimeout: the easiest option really is to just spawn a thread I'd think
07:16pingtimeoutucb: I saw an example like that, spawning a thread and using an atom to know whether the thread has to continue
07:16pingtimeoutucb: I will try that
07:20ucbpingtimeout: cool
07:20clojurebotNo entiendo
07:20ucbclojurebot: como que no?
07:20clojurebotAnyone can hack! http://images.wikia.com/pixar/images/0/0d/Http_alliedow-files-wordpress-com_2011-01_anyone-can-cook-445x355.png
07:21dyelarI've gotten to the point with my clojure understanding that to progress I need to start working on a clojure project. I have one in mind, but it's got a lot of systems programming involved. (Watching/Polling directories for file updates, running a series of external programs on said files, doing fun stuff with the output of the programs, etc.) I haven't seen anything in my somewhat patchy readings on clojure dealing with
07:22unic0rndyelar: all that is possible with java api
07:23dyelarCorrect. I just wasn't aware of if someone had written a better clojure encapsulation or if a more idiomatic way existed.
07:23unic0rntbh, i'm not aware of that either. if i would have to guess, i would say that perhaps not.
07:25unic0rnas far as my understanding of clojure goes (and it's still very little, because of lack of time), it's designed in such a way that makes using java stuff very straightforward from lisper's point of view.
07:25unic0rnso it wouldn't make much sense to encapsulate java stuff, it would probably just overcomplicate things, imho
07:26unic0rnwhat has to be encapsulated, is
07:26dyelarYeah, it hasn't been bad when I've been hitting Java APIs, but having worked with perl,python,etc, Java's not exactly been the greatest systems programming language.
07:26dyelarIt'll work though.
07:26abpdyelar, unic0rn At least there's https://github.com/pjstadig/nio
07:26unic0rnas a language, it's a boilerplate crap. but api isn't half bad
07:27ucbdyelar: for running stuff on a shell there's conch https://github.com/Raynes/conch
07:28dyelarVery nice.
07:28unic0rnabp: interesting. i guess it just goes down to the fact if someone is already very familiar with java api or not. a matter of taste, more or less.
07:50tgoossensin the namespace "roborally.piece" i have defined keywords ::robot ::wall ::battery
07:50tgoossensin the namespace "roborally.board" i want to use those keywords
07:50tgoossensbut I don't want to type everytime
07:50tgoossens:roborally.piece/robot
07:51tgoossenshow can i "import" these ns-bounded keywords?
07:53hyPiRiontgoossens: You could probably make a macro to make stuff easier.
07:53tgoossenshypirion , intersting never made a macro before (never had the need)
07:53solussdtgoossens: you can add (:require [roborally.piece :as p]) to your ns declaration at the top of the file and then refer to the namespace qualified keywords like this: :p/robot, :p/wall, etc
07:54tgoossenssolussd: that is probably the easiest solution
07:54solussdthat's what I do, frequently. :)
07:54hyPiRionsolussd: That works? Humm.
07:54solussdsure does
07:55solussdoops
07:55solussdtgoossens: hyPiRion: you have to refer to them as ::p/robot, ::p/wall, etc
07:56solussdthe two colons are still needed, but it'll expand the namespace component if aliased using require
07:56hyPiRionAh
07:56hyPiRionI wondered how : could just magically expand stuff, but that makes sense.
07:57hyPiRionSweet trick anyhow.
07:57tgoossens:D
07:57tgoossensalso another thing
07:57tgoossensif i want to play with things in the repl
07:58tgoossenssomehow i can't get it to work when having two different namespaces
07:58tgoossensin (ns roborally.board)
07:58tgoossensi do
07:58tgoossens(use 'roborally.piece)
07:58tgoossensFileNotFoundException Could not locate roborally/piece__init.class or roborally/piece.clj on classpath: clojure.lang.RT.load (RT.java:432)
07:58borkdudetechnomancy cemerick nice mostly lazy episode, tnx
07:58tgoossensapparently it searches for a file
07:58tgoossensinstead of using the namespace i created earlier (ns roborally.piece)
07:59tgoossenswhat must i do to be able to play with it?
08:04borkdudetgoossens is there actually a file roborally/piece.clj ?
08:04tgoossensthat doesn't matter here
08:05tgoossensi just open a repl session in a terminal
08:05tgoossensi copy the entire piece.clj (ns roborally.piece) into the repl
08:05tgoossensthen the same for (ns roborally.board)
08:07FoxboronLooking for someone programming Clojure with Sublime Text 2 to give their opinions on a upcomming plugin.
08:07tgoossensi work with sublime text 2
08:08tgoossensbut unfortunately i almost have to leave for class :S
08:08Foxborontgoossens, just PM me when you come back :D
08:08tgoossensk
08:08FoxboronIts about some functionality for a documentation searcher :P
08:08tgoossenssounds interesting
08:09Foxboronit is :)
08:09borkdudetgoossens https://www.refheap.com/paste/7172
08:10borkdudetgoossens you need refer
08:10tgoossensok cool
08:10borkdudetgoossens require and use both try to load from file (if I'm not mistaking)
08:11tgoossensthat did it
08:11tgoossensthanks!
08:12borkdude:)
08:13tgoossensbut now the
08:13tgoossens(use [roborally.piece :as p]) doesn't work (i mean i cannot use :as in refer
08:13borkdudetgoossens you can also use load or load-file to load files directly
08:16borkdudetgoossens look at clojure.core/alias for this
08:16tgoossensok thanks
08:16tgoossensg2g now
08:16borkdudehttp://www.clojureatlas.com/org.clojure:clojure:1.4.0?guest=t#clojure.core/alias
09:22AnderkentAny ideas why a binding might become Var$Unbound?
09:22Mr_Bonddifferent scope?
09:23Anderkentdon't think so, it's (binding [name (ref [])] (...) (code-that-crashes-with-unbound))
09:23Anderkentso it's within the binding
09:24Anderkenti guess something might be redefing the name in the (...) part
09:24@rhickeyHas everyone participated in this: http://www.infoq.com/research/next-jvm-language ?
09:25Mr_BondI have now :)
09:25fojureYes, my vote for Ceylon has been registered! ;-)
09:26Mr_BondOh, you voted Ceylon as well? :)
09:26Mr_Bond</joking>
09:26Mr_Bondah fuck, you have to sign up with facebook
09:26Mr_BondI don't want that :/
09:27Anderkentyeah that made me stop as well
09:27@rhickeyTop candidate names for test->, let-> and when-> are: cond->, as-> and some->
09:27@rhickeyMr_Bond: I used google id
09:27Mr_BondI can try that, I don't want that page accessing my facebook data, posting on my wall, etc
09:27@rhickeyI don't have a facebook account
09:28abprhickey, I voted yesterday, put Clojure so much into both axes that it fall of the diagram and wasn't counted in my vote..
09:28Mr_Bondok, that was better. voted.
09:28Mr_Bondoh noes, scala is winning!
09:28@rhickeycond-> gets this "Note that, unlike cond branching, cond->> threading does not short circuit
09:28@rhickey after the first true test expression."
09:29@rhickeycond-> and ->>
09:30@rhickeyinterested in feedback on some-> which now threads when not nil
09:31@rhickeythought about making (some coll) do same (note no pred). That would bridge some to Maybe world, without introducing Maybe to Clojure
09:32@rhickeyopen door to if-some, when-some
09:32mefistopretty dead heat between clojure and scala on that now
09:33fojureI suspect that very few people are using data literals ATM... I think we'd see more grumbling if they did.
09:34@rhickeyA Lisp's inclusion in that poll, never mind that kind of showing, is itself a big win
09:35@rhickeyabp: :(
09:38foodooI wanted to vote as well, but I also failed with the logins. I'll check back later again if they also enable infoq logins
09:40abprhickey, what's the reasoning for some->?
09:41fredyrwhere do I find information about these new threading macros btw?
09:41foodoofredyr: http://clojure.github.com/clojure/branch-master/clojure.core-api.html
09:41fredyrthanks
09:43borkdude@rhickey I voted .. twice now I believe..
09:44borkdude@rhickey so I made up for abp ;)
09:50rahcolaI want to run two computations in parallel and return with the value that finishes first
09:50rahcolawho to do this?
09:50rahcolaas a bonus, I would like to kill the remaining thread
09:51borkduderahcola erlang? (kidding)
09:52cgrandrahcola: two futures delivering to a promise, wait on the promise then kill the futures
09:53abpborkdude, thanks! :)
10:01rahcolacgrand: thx, knew this had to be possible in Clojure
10:06auastrohi all
10:06auastroI'm trying to fix a weird bug that crops up when reloading code in ring
10:07auastroit seems if one reloads some invalid code, in a try statement in that code itself the exception can't be caught
10:08auastro*code = namespace there
10:10mmitchelltechnomancy: hi there. Is there a way to alter the class path in development (leiningen 2) ?
10:12borkdudeRaynes btw I like what I see about regexps in Haskell so far
10:34borkdudeI would have preferred Haskell having dash-notation instead of camelcasing though..
10:34S11001001yep
10:36borkdudeI think the author of RWH gets camelcasing wrong
10:37borkdudesplitFileName instead of splitFilename
10:48Mr_Bondborkdude: yes
10:49@rhickeylast call on cond->, as->, some-> https://groups.google.com/d/msg/clojure/67JQ7xSUOM4/7v3M96EfJq8J
10:52antoineBthe syntax (defn add [a b] "doc" {:pre [(even? a)]} (+ a b)) don't works
10:52antoineBhttp://clojuredocs.org/clojure_core/clojure.core/defn
10:53antoineBbut: (defn add [a b] {:pre [(even? a)]} (+ a b)) works
10:55stuartsierraantoineB: your docstring is in the wrong place
10:56antoineBright
11:00TimMcabp: You voted incorrectly in the infoq JVM language thing because their poll was a piece of crap. Go back and re-read those axes...
11:01fojureIf I have a project B that uses project A, I can break B by adding the use of internal tagged literals in A and then updating B with the new code. B *never* uses A's literals, but building B fails with an unbound tag literal failure.
11:01TimMcabp: The lower left corner is where a fanatic would vote.
11:02abpTimMc, yes, I'am absolutely fanatic and pulled over the axes. :D
11:03abpTimMc, at least I can't see Clojure when I look at my vote. Probably I should've put competitors into the upper right corner, out of the axes, too.
11:04abpcompetitors => other languages
11:06TimMcOh, you mean you put Clojure too far to the lower left? I see.
11:06TimMcANyway, I suspect the results are going to be unusable -- that chart is rather confusing.
11:09zaisteis it possible to upgrade Clojure to 1.5 in lein repl ? I cannot find it in docs
11:09TimMcNooope, not voting -- infoq wants to see my name, photo, gender, birthdate, country, language, timezone, and email address -- from now forward.
11:09abpTimMc, yes, besides everything else that's wrong with such a poll in general.
11:10nDuffzaiste: the version of clojure you want goes in your project.clj
11:10zerokarmaleftseqs aren't Iterables, are they?
11:11nDuffzaiste: ...in this case, 1.5.0-alpha4
11:12zaistenDuff: yes, but i'd like to load that version by default in repl (not for a specific project)
11:13@rhickeyzerokarmaleft: in general, yes they are
11:13nDuff...I mean, you're going to have libraries and whatnot you want to use when you're experimenting from a REPL
11:13nDuffso it makes sense to have a project even then, even if it's just one you keep around for only that purpose
11:13zaistenDuff: ok ;)
11:15zerokarmaleftrhickey: so if a java method is expecting an Iterable<T>, i can just pass a seq or is there some munging required?
11:15TimMc~generics
11:15clojurebotjava generics are http://en.wikipedia.org/wiki/Generics_in_Java
11:15TimMcbah
11:16TimMczerokarmaleft: Generics are a Java fiction, mostly. Those <T>s get erased at compile time.
11:16@rhickeyzerokarmaleft: no munging required
11:17S11001001zerokarmaleft: which, believe it or not, is a highly positive feature from the java-alternative perspective, in more ways than clojure exploits
11:24zerokarmaleftcool...thanks, all
11:37cwye
11:39ivenkyshmm - is anyone else having problems with the IDEA clojure repl - it stops responding in between
11:40ivenkys- latest version of everything - if that helps
11:48AnderkentIdeas for why jvm shutdown might be taking forever (~ 50s)?
11:48llasramAnderkent: daemon vs non threads. Use http://clojuredocs.org/clojure_core/clojure.core/shutdown-agents before exiting
11:49AnderkentThanks, lets see if that helps :)
11:49Anderkentright, that does it
12:10jondavidjohnis there a quick way to flip a positive int to a negative?
12:10jondavidjohnother than...
12:10jondavidjohn,(- 5 (*5 2))
12:10clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *5 in this context, compiling:(NO_SOURCE_PATH:0)>
12:11jondavidjohn,(- 5 (* 5 2))
12:11clojurebot-5
12:11ibdknox,(let [x 5] (- x))
12:11clojurebot-5
12:11ucb,(doc bit-flip)
12:11clojurebot"([x n]); Flip bit at index n"
12:11ucbjondavidjohn: ^^
12:11jondavidjohn,(bit-flip 5)
12:11clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$bit-flip>
12:11jondavidjohn,(bit-flip 5 0)
12:11clojurebot4
12:11jondavidjohn,(bit-flip 5 5)
12:11clojurebot37
12:12jondavidjohnhah, i guess i don't get what it means by index
12:12ibdknoxjust do (- x)
12:12ucbthat'd do too
12:12jondavidjohn,( - 5)
12:12clojurebot-5
12:12jondavidjohnnice
12:13jondavidjohnpretty obvious...
12:13llasramucb: You need the 2s complement to do it via bit-flipping. I bit awkward to do a bit at a time :-)
12:13jondavidjohnidiot
12:13jondavidjohnmyself ^
12:14ucbllasram: indeed, I was just trying to confuse matters there :)
12:14jondavidjohnam I gaining much by converting a range to a vec before using for rand-nth?
12:14jondavidjohnI know random access on vecs is quick, but what about the time it takes to convert a seq to a vec?
12:14llasramjondavidjohn: Honestly, I'd convinced myself there was a `negate` function and was confused about where it had gone
12:15llasramjondavidjohn: Conversion only helps if you're going to many indexed lookups into the structure. Otherwise `vec` is O(n) and `rand-nth` is O(n)
12:16jondavidjohncool
12:26hyPiRionPsh
12:27jondavidjohncan someone help me understand the #() function shorthand?
12:27jondavidjohnwhen I try to use it, it gives me an arity error
12:27hyPiRionReal men negate through ##(inc (bit-not 5))
12:27lazybot⇒ -5
12:28jondavidjohnand when you expand it into (fn [i] ) even when I don't actually want to use `i` it works fine
12:31dnolenbbloom: patch applied - analysis errors are much more informative now.
12:32piranhahmmm... I cannot 'lein test' my cljs library, right?
12:32piranhaor maybe I can publish clj library as cljs somehow on clojars?
12:32joef_jondavidjohn, you need to have at least '%' (or '%1'/etc) inside the #() to indicate the arity of the function
12:32joegallo_jondavidjohn: you are probably trying to create a function of one argument that will disregard the argument or arguments that it is called with. #() doesn't work very well for that.
12:33jondavidjohnthanks
12:33joegallo_(fn [_] ...) or (fn [& _] ...) is probably more conventional for that.
12:34AnderkentDoes anyone know when and why are dynamic classloaders created? I'm having issues with a class being defined twice (by defrecord), and then instance? checks fail
12:35llasramAnderkent: Because you can't ever really redefine a class. Instead you create a new class with the same name backed by a new classloader which answers future resolution attempts for that name
12:36llasramOtherwise deftype at the REPL would be horrible (or "even worse," depending on your perspective)
12:36Anderkentmhm, but it seems the static references are not resolved to this new definition
12:36Anderkenti.e. (instance? my.record.Type coll) will start failing
12:36Anderkentwhen coll is created using the new my.record.Type
12:38llasramHmm... Are you sure that's what's happening? Example:
12:38llasramActually, lazybot won't let you deftype
12:39llasramBut still -- fully qualified name resolution hits the most recent version of the class for me
12:39llasramIf you're crossing namespaces and imported the class into another namespace, I believe that one will have the class basename symbol still referencing the old version
12:39Anderkent
12:39Anderkent 22 incanter.core.Dataset #<DynamicClassLoader clojure.lang.DynamicClassLoader@dcca29c>¬
12:39Anderkent 21 incanter.core.Dataset #<DynamicClassLoader clojure.lang.DynamicClassLoader@c6cb458>¬
12:40Anderkentwell, I'm doing quite a bit of magic so it might be a bug in my code
12:40Anderkentstill I'm surprised it's even possible to get the old reference
12:41llasramIt's just names pointing at immutable objects
12:41llasramBut yeah, does cause some occasional annoyances
12:41Anderkentin general the way it treates class names specially sometimes-but-not-always is a bit annoying
12:42llasramI think there's been some recent tooling work to help reload affected namespaces when these things happen, but the details are alluding my lunch-needing mind
12:42Anderkenti.e. I can't do (. -classname- getClassLoader)
12:42AnderkentI have to do (let [clazz -classname] (. clazz getClassLoader))
12:43AnderkentI guess (. (do -classname-) getClassLoader) works.
12:44llasramHuh. My model of Clojure evaluation does not explain what's happening there
12:45Anderkent. treats class names specially (. Class method) -> static method on class
12:45Anderkent(. (do Class) method) -> dynamic method on Class.class
12:45Anderkentit's really confusing and magical
12:45llasramAhh, that makes sense, while agreed being confusing
12:55Anderkentwell, managed to fix it, even though I don't yet understand how D:
12:56llasramyay?
12:56clojurebotyay is sweet
13:00seangrovebittersweet, I think you'll find, clojurebot
13:13lynaghkping: alex_baranosky
13:32pinkiesOutAnyone present who can give advice on using seesaw for GUIs? I have a GUI button whose font color is set (using (config!)) depending on whether a port on the localhost is open. It works perfectly, but I would like the color state to change automatically whenever the port is opened/closed by another service. Any suggestions on how to monitor for this without listening for specific actions (mouse clicks, mouseover, etc)?
13:50FoxboronNeed some testers for a Sublime Text 2 plugin. Any takers?
14:35lynaghkping: dakrone
15:26dakronelynaghk: pong
15:27lynaghkdakrone: I just commented on a github issue for cheshire; I ran into an issue where I couldn't do custom serialization of one of my types
15:27dakronelynaghk: okay, I'll take a look at it
15:28lynaghkdakrone: the cheshire.generate/generate function has a toplevel condp that runs before protocol dispatch has a chance
15:28lynaghkdakrone: cool, thanks. I'm not blocking on it though---that and another issue and I've decided to go with EDN instead.
17:16augustlany suggestions for getting a list of items twice or more in a vector?
17:17AimHereYou want a list of all the items that have more than two entries?
17:17augustlyeah
17:18augustlI can think of a few ways, but perhaps there's something built-in
17:18AimHereSomething like (map first (filter #(> (second %) 1) (frequencies myvector)))) is my first thought
17:19AimHereOr if performance was an issue, knocking up some function to sift them properly
17:19augustlnice :)
17:19augustlwasn't aware of frequencies
17:21clj_newb_2345does clojure reserve vars that start with the _ character?
17:21TimMcI recently used frequencies as a quick way of checking what characters were in a file.
17:21clj_newb_2345I'm thikning of a programming style where all local bindings start with "_", this way, when I look at a function, I can clearly see what is and what is outside of the current lexical scope
17:21clj_newb_2345just by looking at the var name
17:22muhoofrequencies is pretty awesome. basically a historgram
17:22TimMc(->> (slurp "suspicious-characters.txt") frequencies keys (remove #(< 31 (int %) 127)) sort (map (juxt identity #(format "U+%04x" (.codePointAt (str %) 0)))))
17:22muhoohistogram
17:22AimHereTimMc, why not use distinct for that?
17:22TimMcAimHere: Because I didn't think of it. :-)
17:23TimMcIt was a one-off.
17:23TimMcAlternatively, ##(into #{} "hello")
17:23lazybot⇒ #{\e \h \l \o}
17:36bbloomLately I've been experiencing "[trace missing]" with nrepl… what causes that?
17:52devnWhere do I set the option for nrepl to boot with more memory?
17:53cemerickdevn: just use your lein options
17:53devnand nrepl-jack-in respects that?
17:54cemerickjack-in just starts a headless nrepl process via lein AFAIK
17:54cemerickso, yeah
17:54devnalso, nrepl doesn't seem to showing anything that would have went to *out* in my repl
17:54devnit might just be emacs-live, which i should stop using...
17:54cemerickdevn: note, I mean the relevant options in project.clj, not whatever heap lein itself starts with
17:54devn*nod*
17:55cemerickPresentation of *out*, etc. is entirely up to the client. I'm blissfully uninvolved in the nrepl.el. ;-)
17:55cemericks/in the/with
17:56Sgeo__I tried println'ing in another thread, it went to where I started lein repl :headless
18:02spaceshipswhen i print to *out* from lein run, it works. but when i try to use an uberjar, println works, but my function taht goes to *out* doesnt... confused.
18:04devnthis is the reason im still using swank :\
18:04devnunfortunately it is not compatible with the latest 1.5.0
18:07muhoodevn: it's been discussed,IIRC there was an issue open on it
18:07muhooon nrepl.el. it's been a very long time though, maybe it's been fixed already
18:11TimMcAnyone else unable to use Home and End in nrepl?
18:11TimMcC-a and C-e are great and all, but...
18:21clj_newb_2345with defrecord, is there a way to have the defrecord be in one file, and the implementation functions be in another file?
18:22nDuffclj_newb_2345: protocol implementations, you mean? Certainly.
18:23clj_newb_2345nDuff: yes, can you point me to sample code?
18:24nDuff The only code I personally have isn't public, but... it's also not complex enough that it _needs_ an example; you just qualify your namespaces.
18:24nDuffWhere are you having a problem?
18:25clj_newb_2345err, if I can just see a 5-line example, with a defrecord in src/foo.clj and the implemenration in sr/bar.clj, i'd be convinced
18:25clj_newb_2345i'm not even sure how to "split" it right now
18:25bbloomclj_newb_2345: defrecord's body is just shorthand for extend-type
18:25bbloom(doc defrecord)
18:25clojurebot"([name [& fields] & opts+specs]); Alpha - subject to change (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given fie
18:25bbloom(doc extend-type)
18:25clojurebot"([t & specs]); A macro that expands into an extend call. Useful when you are supplying the definitions explicitly inline, extend-type automatically creates the maps required by extend. Propagates the class as a type hint on the first argument of all fns. (extend-type MyType Countable (cnt [c] ...) Foo (bar [x y] ...) (baz ([x] ...) ([x y & zs] ...))) expands into: (extend MyType Countable {:cnt (fn [c] ...)} Foo {:baz (fn (
18:26clj_newb_2345bbloom: nice, this is what I was looking for; thanks
18:26bbloomwhich is, in turn, shorthand for extend :-)
18:26bbloom(doc extend)
18:26clojurebot"([atype & proto+mmaps]); Implementations of protocol methods can be provided using the extend construct: (extend AType AProtocol {:foo an-existing-fn :bar (fn [a b] ...) :baz (fn ([a]...) ([a b] ...)...)} BProtocol {...} ...) extend takes a type/class (or interface, see below), and one or more protocol + method map pairs. It will extend the polymorphism of the protocol's methods to call the supplied methods when an AType is
18:26clj_newb_2345in particular, http://clojuredocs.org/clojure_core/clojure.core/extend-type
18:26bbloomlikewise with extend-protocol, but from the other direction
18:27clj_newb_2345this is kind of insane: so I can define a record, later define a protocol -- and after having defined the record, then extend the record to implement th eprotocol?
18:27bbloomclj_newb_2345: the power of "open" :-)
18:28bbloomclj_newb_2345: embrace the dynamism
18:28bbloomclj_newb_2345: it lets you extend your protocols to types you haven't defined too! especially nice because protocols are themselves namespaced, so you won't break anybody else as long as you own the protocol
18:33clj_newb_2345let's take this slowly
18:33clj_newb_2345let me rewrite my code first
18:34clj_newb_2345then one day, I will be facing some problem I can't solve, and I'll be: hmm, I wish I could extend protocols to types I haven't defined yet,
18:34clj_newb_2345then I'll remember this conversation, :-)
18:34bbloomheh
18:35clj_newb_2345extend still doesn't quite do what i want.
18:35bbloomclj_newb_2345: you generally shouldn't use extend directly, prefer extend-protocol or extend-type
18:36clj_newb_2345I want "type.clj: (defprotocol IFoo "IFoo" (foo [obj])) (defrecord Foo [] IFoo)" "impl.clj: (extend Foo IFoo {:foo (fn [] ... )})" -- the problem here, is that Foo already implements IFoo
18:37clj_newb_2345so in the type.clj file, I wna tto make it clear tat record Foo implements protocol IFoo
18:37clj_newb_2345however, I just want to impelment Foo.foo later
18:38bbloomclj_newb_2345: what is the quoted "IFoo" about?
18:38clj_newb_2345it's a comment
18:38clj_newb_2345habit
18:40bbloomclj_newb_2345: omit the "IFoo" from the defrecord
18:40bbloomclj_newb_2345: you don't need to declare it up front
18:40clj_newb_2345I do want to declare it up front
18:40clj_newb_2345so that when I'm viewing my types.clj files
18:41clj_newb_2345I know what records implements what protocols
18:41clj_newb_2345when I look at types.clj, I want to know whicih record implements which protocol; I just want the implementation to be elsewhere so as to not clutter the file
18:41bbloomwhat benefit does declaring it up front provide you?
18:41clj_newb_2345when I look at types.clj, I know what record implements which protocol
18:41clj_newb_2345without having to dig through all the implementation files
18:42bbloomclj_newb_2345: don't do that :-P code to protocols, not to types
18:42clj_newb_2345I am coding to protocols; I just want to know which records implement whic protocols ...
18:42bbloomrecords are types
18:43bbloomgenerally, if you have a lot of kinds of records with complex protocols, you're probably thinking OOPs and not clojure-y
18:44bbloommost meaty use cases need to define a very small number of protocols
18:45bbloomsometimes zero :-P
18:45clj_newb_2345argh; time to hack up some macros :-)
18:45bbloomclj_newb_2345: and don't overuse macros either :-) prefer data and functions!
18:46bbloommacros are primarily useful for shorthand, but you shouldn't really write a macro until you've written it long hand at least 3 times
18:46clj_newb_2345i had some amazing macros for extending let forms to allow ajax calls
18:47clj_newb_2345(in clojurescript)
18:47bbloomthat's neat. i started doing that more generally for any type of future/promise with a CPS transform
18:50clj_newb_2345I figured out aw ay to avoid using macros here
18:50clj_newb_2345instead, I will write, in types.c: (defrecord Cat [ ... ]) ; IAnimal . Then, in impl.clj, I can (extend-type Cat IAnimal ... )
18:50clj_newb_2345comments are pretty powerful too
19:51antoineBstill someone here?
19:52abpantoineB, yes
19:52antoineBok
19:53antoineBI have a (defprotocol IAbc (abc ...)) and (defprotocol IEfg (efg ...)) and two deftype ObjA and ObjB
19:54antoineBhow do i make those two type ObjA and ObjB share the same implementation of IAbc without copy and paste?
19:55antoineBi work with clojurescript
19:55dnolenantoineB: doesn't matter - break out the shared functionality and call it.
19:55abpantoineB, dnolen was faster. :)
19:56antoineBdnolen: i don't understand
19:56dnolencreate a fn that the protocols fn implementations call
19:56abpdnolen, let me ask you a thing or two about graphs.. ;) No, what's the best way to traverse clojure-code like a list?
19:57abpdnolen, so I can filter out just the symbols in a fn-body for example
19:58dnolenabq: clojure.walk is one way if you have modest requirements.
19:59dnolenantoineB: (defn foo [x]) (deftype A [] IFoo (-foo [this] (foo this)) (deftype B [] IFoo (-foo [this] (foo this))
20:00antoineBdnolen: so i need a little of copy paste
20:01antoineBok
20:01dnolenantoineB: yes, though I haven't found it to be much of a problem myself.
20:02dnolenantoineB: you could also build some kind of delegation system - but I think your use case would really need to be able to gain some benefit that kind of additional complexity.
20:03dnolenantoineB: and game or a very complex gui maybe are only two cases where I'd personally bother.
20:03antoineBmy current solution is a central map like {:type #{:foo :bar}) and then dispatch with multimethods
20:04antoineBdnolen: i try to do some complex gui
20:04dnolenantoineB: so you can delegate, delegation is inheritance at runtime.
20:05dnolenantoineB: you can define a default case for a protocol that looks for a component in the delegate that actually implements the protocols
20:05dnolen(deftype Foo [a b components])
20:06dnolen(extend-type default IBar [x] (-bar (-> x :components :bar-component) ...))
20:06abpdnolen, I'm already using clojure.walk, but don't get how to pull symbols into a list.
20:07dnolenabp: I generally use an mutable to collect what I want during the walk
20:07dnolenabp: tree-seq is a more functional way to do this.
20:07dnolenmutable atom
20:08abpdnolen, so tree-seq is probably a performance hit?
20:08dnolenabp: no idea, never benchmarked
20:08antoineBdnolen: you mean (deftype Foo [a b components] IBar) no?
20:09dnolenantoineB: I do not.
20:09abpdnolen, ah ok, then how comes that you used walk with an atom?
20:09dnolenabp: no real reason - I tried it first and it worked
20:09antoineBok "default" don't care the type has IBar as protocol
20:10abpdnolen, thanks for the hints. :)
20:10dnolenantoineB: exactly, default means it will by tried for all values.
20:11antoineBdoes protocol use javascript prototype? and is protocol more performant than multimethods?
20:11dnolenantoineB: I recommend reading "Organizing Programs w/o Classes" or any posts about Entity/Component systems for games
20:12dnolenantoineB: CLJS protocols are way faster than CLJS multimethods - multimethods in CLJS have seen little performance work.
20:13dnolenantoineB: that said CLJS protocols are also 1.5X-2X slower than JS fns because of indirection - which isn't true for protocols in Clojure JVM.
20:14antoineBis use transient for make a map mutable, is this better to do (set! (.-prop this) (assoc map :some "stuff")) than (assoc! transient-map :some "stuff") ?
20:15antoineB*i use
20:16dnolenantoineB: if perf is the main concern - (set! (.-prop x) ...) is much faster
20:16dnolenantoineB: though for guis I'm not really convinced that this matters - for games yes.
20:16solussdwhy can't multimethods have pre/post conditions, as a way to enforce constraints on methods added to a multimethod?
20:17antoineBdnolen: i plan to do some sort of schema drawer (in svg), so performance does matter as much
21:07Hodappare the contents of :sigs in a protocol considered pretty much an implementation detail, liable to change?