#clojure logs

2011-12-09

00:14semperosdevn: leiningen definitely would do the job
00:15semperoshave a Maven requirement for maintaining consistency with other parts of a larger build
00:15semperoskumarshantanu: thanks for your help, I got everything working
00:20kumarshantanusemperos: \m/
00:37viveknI've heard that code of a running Clojure program can be modified and it will be reflected immediately. What are the conditions for it and how does one go about doing it, for example if I want to change a particular defn?
00:45duck1123vivekn: if you have an editor that supports it, it's as simple as running a command to re-eval that function. Or, if you have a running repl, you can send that definition again
00:47viveknWhat if I'm already running the code in a REPL
01:17zakwilsonDoes one of the file interop libraries have a recursive delete directory function?
01:19zakwilsonc.c.java-utils had one, but I'm hoping for something maintained.
01:22amalloyzakwilson: (doseq [file (reverse (file-seq root))] (.delete file))?
01:22zakwilsonamalloy: I did not know about file-seq.
01:23zakwilsonThat's a really bloody useful function. Thanks.
01:26amalloyzakwilson: it's really just a special case of tree-seq
01:29zakwilsonI need to spend more time just reading the Clojure and popular library APIs. I'm probably duplicating things.
01:29amalloyhelp yourself to https://github.com/flatland/useful
01:31zakwilsonhttps://github.com/zakwilson/zutil-clj <-- I wonder how much of that is already in here
01:34zakwilsonA little overlap. Not as much as I thought there might be. Good stuff there.
01:35amalloyzakwilson: i just gave a presentation today on how everyone should have their own utility library. nice to see that you're already doing that
01:36zakwilsonYeah. I need to make mine a little cleaner. I'm pretty sloppy about just sticking stuff in it, and I think it still depends on clojure.contrib.
01:36amalloyzakwilson: whoa, lookup-with is a terrible function
01:36zakwilsonMy zpmap looks a lot like pcollect
01:36zakwilsonlookup-with? What's that? I can't even remember it.
01:37amalloyit's in map
01:37amalloyit doesn't let you distinguish between "not in map" and "value is nil/false". it's also duplicating a feature that maps already have
01:37zakwilsonIt looks like it does the same thing get does.
01:38zakwilsonNow I have to look to see where I actually used that, if anywhere.
01:39zakwilsonIt looks like it's used exactly once in a scratch file from a personal project.
01:41zakwilsonI have no idea why I wrote that.
01:41amalloypresumably you didn't know about the not-found behavior of get
01:42notostracahey, I am trying to figure out what to do to call a function n times and collect all the calls in a seq
01:42zakwilsonOr even get itself.
01:43amalloy&(doc repeatedly)
01:43lazybot⇒ "([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"
01:43notostracaoh, thanks
01:43notostracaI was looking right at it, I thought it was just for side effects
01:44zakwilson(dorun (repeatedly launch-the-nuclear-missiles))
01:50amalloynotostraca: well, it obviously is for side effects; either the function produces side effects or it depends on side effects
01:51notostracamy code uses repeatedly to call a function that shuffles a list differently every time
01:51amalloyyep. depends on the side effects produced by the random-number generator
01:53technomancyamalloy: is reverse on file-seq guaranteed to work?
01:53technomancyI mean for deletions
01:54technomancyit's a sweet trick, but I've avoided using it in non-test code because it feels like it's relying on implementation details
01:54amalloytechnomancy: i don't know about guaranteed
01:55technomancyzakwilson: delete-file-recursively was not promoted because pre-jdk-1.7 there was no way to distinguish directories from symlinks to directories
01:55amalloyhaha ouch
01:55zakwilsontechnomancy: I... can see reasons to want to be careful about that.
01:55technomancyyeah, it chews
01:56zakwilsonStill, I want it in this case. My app is creating the directories, so it can delete them. If a user goes and sticks a symlink to / in one, they're an idiot.
01:56technomancywelcome to the jdk, where we sometimes pretend unix isn't really a thing.
01:56amalloyyou should use clojail to set up a jvm sandbox around what you *really* want to delete, then do it
01:56technomancyyeah
01:59amalloyzakwilson: well, i'm mostly just recommending it for fun in this case
02:03zakwilsonYeah, but it sounds like something useful.
03:16kralhi all
04:05AWizzArdMoin.
05:22pyrb
06:09lnostdal_hum, java.sql.SQLException doesn't contain the query? O_o .. i'm working via org.clojure/java.jdbc
06:58kumarshantanuInostdal_: Not sure why should the exception have the query
06:59kumarshantanuthe exception can occur even when you don't fire a query yet
07:00lnostdal_true, but when there is a query; why is it not available?
07:00lnostdal_maybe i'm missing something
07:01kumarshantanuInostdal_: This is way SQLException is designed
07:02kumarshantanuhttp://docs.oracle.com/javase/6/docs/api/java/sql/SQLException.html
07:06lnostdal_yeah, it seems so .. and it seems kinda dumb
07:07Borkdudeit is the same with a lot of other exception: cannot cast a string to whatever. Please tell me what the string was! *sigh*
08:45SaturnationSometimes using emacs is a royal pain in the ass :(
08:47hhutch"sometimes" ? ;)
08:48clgvSaturnation: if "sometimes" becomes "often" check the alternatives ;)
08:48Saturnationit doesn't :)
08:49SaturnationJust trying to set up my environment after moving to a Mac and feeling some friciton, mainly around emacs at the moment...
08:49Saturnationanyone know the command in emacs for showing a key-binding?
08:49TimMcSaturnation: The command tha tis bound to a key, or vice-versa?
08:50BorkdudeSaturnation: C-h k followed by the key bidning?
08:50Saturnationthe command that is bound to a key
08:50Borkdudefor example: C-h k C-h k ;)
08:50SaturnationBorkdude, thanks, that did it
08:50Saturnation:)
08:54Saturnationhmm, slime doesn't seem to have bound C-up in my custom build of emacs :(
08:55clgvSaturnation: I heard Aquamacs would be the choise on Mac
08:55Saturnationwas hoping for a terminal based emacs, so did my own build, but thanks, I'll look into that
08:56Saturnationfirst day of 20% time and I'm fighting emacs :)
08:58Saturnationeveryone I saw at the Conj seemed to be using a terminal based version
08:58hhutchSaturnation: you built from source? homebrew didn't help?
08:59Saturnationhomebrew?
09:00hhutchhomebrew is like apt/rpm on linux
09:00hhutchhttp://www.unschooled.org/2011/10/how-to-setup-emacs-for-clojure-on-mac-os-x-lion/
09:00hhutchSaturnation: in my experience, emacs is something better gotten in binary form
09:02Saturnationhmm, wanted 24 since it had package.el built in, that's why I built me own
09:02BorkdudeSaturnation: I switched to Mac OS X recently
09:02Saturnationfrom that page, it's version 23
09:02BorkdudeSaturnation: first I tried Aquamacs but switched back to normal Cocoa based Emacs
09:03Saturnationwhat's confusing me at the moment is that one version got it right and the other didn't, but they both "appear" to be using the same .emacs.d/ setup O_o
09:03BorkdudeSaturnation: I picked the 24 version from here: http://emacsformacosx.com/builds
09:04BorkdudeSaturnation: and then 'installed' marmalade and the emacs start kit thingies, and clojure thingies from elpa
09:04SaturnationBorkdude, yeah, that's the one I picked up as well, but again, was hoping to get it running in a terminal
09:04Saturnationsounds like what i've done as well
09:04BorkdudeSaturnation: I can do that as well
09:05SaturnationBorkdude: how do you run it in the terminal?
09:06BorkdudeSaturnation: let me find out again, I think with some options to emacsclient
09:07BorkdudeSaturnation: just type "emacsclient -nw" in the Terminal, as a matter of fact I'm typing this from Terminal now.
09:08BorkdudeSaturnation: http://twitpic.com/7qshx8
09:08Saturnationoops, it's getting my custom build, so it isn't working :)
09:08Saturnationwill fix that
09:10BorkdudeI am wondering though what will happen when I quit the Emacs in the terminal...
09:10Borkdudeah
09:10Borkdudephew.. it just returns to the shell without killing the "normal" Emacs
09:10Saturnationnot quite right, it expects a server to be running?
09:11BorkdudeSaturnation: I put this at the top of my init.el:
09:11Borkdude;; To connect with emacsclient, the socket is at ~/.emacs/server/server
09:11Borkdude(setq server-use-tcp t)
09:11Borkdude(server-start)
09:11Borkdude
09:12BorkdudeSaturnation: don't know exactly why I did this tcp thing
09:12Saturnationlooks like it can communicate via unix sockets or tcp, so that makes sense
09:13BorkdudeSaturnation: and you can always be sure where to look for it, instead of some random port to connect to
09:13Saturnationwhat do you get for "which emacsclinet"?
09:14BorkdudeSaturnation: /usr/bin/emacsclient (it is probably the emacsclient from osx I realize now...)
09:14Saturnationyep
09:14Saturnationthat's what I thought
09:14Saturnationit looks like its attaching to your running 24 version?
09:14BorkdudeI disabled the OS X emacs though
09:14Borkdudewhich emacs -> /Users/Borkdude/bin/emacs
09:15SaturnationI think I need to dive into the emacs doco :)
09:15Saturnationthanks for the help
09:16Borkdudethis is weird though
09:16BorkdudeI made a script in ~/bin/ called emacs which just calls emacsclient, I thought I wanted to be clever, but never use this as such
09:17Borkdudeit calls emacsclient -f ~/.emacs.d/server/server ;)
09:20Saturnationdoesn't work for me
09:20Saturnationlike I said, I think I need to get my head around emacs a bit better :)
09:22BorkdudeSaturnation: me2
09:24SaturnationBorkdude: do you know how to get the bindings for a function? The opposite of C-h k?
09:24BorkdudeSaturnation: C-h f
09:24Saturnationthanks :)
09:24Saturnationboth instances of emacs seem to be using the same slime files, which is really weird
09:25BorkdudeSaturnation: I only use one instance
09:25SaturnationI would too, but trying to debug one of them :O
09:25BorkdudeI just disabled the OS X one
09:26Borkdudeby renaming it
09:26SaturnationI set my PATH to get my custom build before the OS X one
09:29SaturnationI'm beginning to think that slime-repl hasn't been set up in my custom build? :(
09:35Borkdudegot it figured out now. I just made a script in ~/bin/ called emacs, with this line in it: emacsclient -f ~/.emacs.d/server/server -nw $1
09:35Borkdudeso whenever I'm in the terminal and need to edit something, I can just type: emacs foo.txt
09:36Borkdudealso core.editor in gitconfig is just "emacs" now
09:36bobhopeHey clojuristas, I'm wondering if there's a way to redefine the if special form so that it behaves as normal unless the condition matches some predicate, in which case it takes the true and false results and does something else with them
09:36Borkdudebobhope: don't redefine it
09:37bobhopeBorkdude, I want to embed a DSL in clojure that has "if"
09:37bobhopeis there a way to refer to it in a qualified way?
09:38bobhopeI found a post showing that if I (def if println), then (if true 1 2) behaves as usual but ((var if) 1 2) uses the new def
09:38bobhopedo I just need to do something like h:if or something?
09:39Borkdudebobhope: if is not associated with a var, but is a special form
09:39bobhopeso i'd need to modify the clojure runtime to modify its behavior?
09:39bobhopelike, the part wirtten in java?
09:39Borkdudebobhope: just don't go there. why don't you just write a new "my-if"
09:40cemerickbobhope: special forms cannot be redefined by definition :-)
09:40bobhopesuppose I wanted to go there
09:40bobhope:)
09:41cemerickYou can certainly write a macro wherein `if` symbols are expanded into something else.
09:41bobhopeCould I, for instance, change the special form to be called clojure-default-if
09:41bobhopeand then make if a macro
09:41BorkdudeI guess not
09:41bobhopewhich I can selectively redefine?
09:41cemerickwhat are you trying to do?
09:42bobhopeif the condition's a boolean, I want it to be normal
09:42bobhopeif the condition meets a certain predicate, I'd like the quoted true & false branches
09:42bobhopeand those branches to be packed into another data structure
09:43cemerickI think that's called an "interpreter". ;-)
09:43bobhopeyeah...
09:44Borkdudebobhope: can you give an example?
09:45bobhope(if true 1 2) == 1
09:45bobhope(if ['a] 1 2) == {:cond ['a] :truebranch 1 :falsebranch 2}
09:46bobhopeIs that clear/
09:47Borkdudenot entirely, but are you building some kind of ast?
09:47bobhopeyes, but only selectively
09:47bobhopeso if I pass an ast fragment into the condition, I want to return more ast fragment
09:48bobhopebut if I pass a boolean into the condition, I want to return the result of evaluating the appropriate branch
09:48bobhopeso that clojure's runtime because a metaprogramming facility for the ast
09:48bobhopenot "because", "becomes"
09:49Borkdudeso what is the problem with using something different than if for it, for example your own my-if?
09:50Borkdudeast-if
09:50bobhopei'd really, really like to be able to use idiomatic clojure throughout
09:50bobhopeand have it seamlessly work
09:50bobhopeI suppose I could use a macro in the "defn" equivalent to transform all "if" into "my-if"
09:50bobhopebut that seem fragile
09:51Borkdudebobhope: sounds like very tricky stuff
09:51bobhopethat's the best stuff to do :)
09:51Borkdudebobhope: a lot of normal functions have their parallels in clojure.core (I think, haven't dug into it very deeply) and slightly renamed them, it makes sense to me
09:52Borkdudebobhope: because they are not the same, but are -like- it, used in a different way
09:52Borkdudebobhope: in fact it would be very confusing if the same names were just used in the logic programming context
09:53Borkdudebobhope: same with your example, my opinion
09:53cemerickbobhope: idiomatic Clojure branches control flow on `if`; doing anything else would be absolutely bizarre. Useful perhaps, but not idiomatic.
09:53cemerickThus, the macro route.
09:55bobhopeindeed
09:55bobhopethe ast I generate is executable
09:55bobhopeit just allows me to codegen for non-java
09:55bobhopewhile still also running it on the jv
09:55bobhopejvm*
09:59Borkdudebobhope: good luck with it. gtg
11:32ambrosebsgiven an existing namespace symbol, I want to slurp the file that defines it. Any straightforward ways of approaching this?
11:37wiseenare :pre and :post conditions always executed or only if *assert* is defined ?
11:38wiseenthat is is it safe to use pre and post without them being executed in production ?
11:39jeremyheiler1ambrosebs: what do you mean by "the file that defines it"?
11:40ambrosebsclojure.core -> "clojure/core.clj"
11:44ihodesambrosebs: i don't think there is. you could of course just mangle ths string into a path, but that's rather brittle and assumptive. of course, someone else might have a better idea
11:45ambrosebsihodes: I'm sure it's buried in `load` somewhere
11:45ambrosebsbut wasn't immediately obvious
11:46stuartsierraambrosebs: the `source` function in clojure.repl works this way
11:46ihodesambrosebs: oh yeah, i'm sure there's a way, but no obvious way haha
11:47ambrosebsstuartsierra: great, thanks
11:48sirvalianceI am just starting playing around with clojure, but are there any REPL's that have history?
11:49sirvalianceOr, why does the clojure repl not have history?
11:49ihodes(:file (meta (resolve 'map)))
11:49stuartsierrasirvaliance: I think JLIne will give you history.
11:49ihodesambrosebs: the above should work, i think.....
11:50stuartsierrait's a command-line wrapper, adds simple things like navigation & history to any Java console app
11:51stuartsierraAny editor / IDE environment should also work.
11:51TimMcwiseen: Good question, I've not played around with :pre and :post. I guess you could give it a try with a :pre that always fails. :-)
11:59wiseenTimMc, how do I disable *assert* ?
12:00wiseensimply set! *assert* false ?
12:00wiseenif so, it's still evaluated :(
12:01ambrosebsihodes stuartsierra: what if I don't have a var name, just the namespace name?
12:02ambrosebssource-fn takes the metadata of an existing var
12:02wiseenactually, if you (set *assert* false) before you define the function with {:pre :post} conditions they are *not* evaluated :)
12:03wiseenthat should be noted somewhere in the docs :)
12:09licenserdun dun dun mornin
12:10ihodesambrosebs: (:file (meta (resolve (ffirst (ns-publics 'clojure.core)))))
12:10ihodesambrosebs: comes to mind. might be a better way, but that works.
12:11ihodesambrosebs: though, if it doesn't have publics/anything in it to examine, that of course wouldn't work. lemme check something
12:11ambrosebsyep
12:17jebberjebI want to learn lisp. I'm familiar with java. Would it be wise for me to start my lisp journey with clojure?
12:17ihodesjebberjeb: i'd say it's as good of a place to start as any; better, in fact, because you know Java
12:18jebberjebalirght, I assumed that was the case -- just wanted a sanity check before I dove in
12:18TimMcwiseen: Yes, I think that *assert* is read by the compiler at the function's definition time.
12:21technomancyclojurebot: ಠ_ಠ
12:21clojurebotHuh?
12:30SaturnationIs anyone here using emacs 24 in a terminal? If so, where did you get it and how did you set it up?
12:30clojurebotno, anyone is a funny thing.
12:30technomancySaturnation: I just build from source
12:31SaturnationI build from emacsmirror on github, but the C-<up> and C-<down> keys aren't bound correctly in *slime-repl nil* :(
12:32Saturnationbeen on #emacs all day trying to figure what's wrong
12:32technomancycheating answer: it's best if you avoid using the arrow keys
12:32Saturnationhow do you scroll through repl history?
12:32technomancyM-n/p
12:33Saturnationhmm
12:33Saturnationthank you and WTF
12:34TimMcheh
12:34Saturnationseriously, shouldn't it just map to arrow keys as well, or is that just broken in 24? Ah, but what, it works for the windows 24 O_o
12:34TimMcSaturnation: I use arrow keys for navigation in Emacs quite frequently, but it is good to know the standard keybindings in case you are working through a weird terminal.
12:35Saturnationbut I can set-local-key bindings when in the repl and it WORKS, so I'm a bit confused
12:36technomancyyeah, generally anything using modifiers and arrow keys is going to be broken in the terminal whether using emacs or not; terminals just don't have the capability to represent certain key combinations.
12:37SaturnationBut I can get it to work on a session only basis using set-local-key, so again, color me confused
12:46kumarshantanuwiseen: Is that on the REPL?
12:47Saturnationtechnomachy: what does your M-n bind to?
12:47wiseenkumarshantanu, no "java -c clojure.jar clojure.main test.clj" changing *assert* in REPL didn't work last time i tried it AFAIK
12:48kumarshantanuwiseen: It doesn't work on the REPL AFAIK -- in the file maybe you can try (binding [*assert* false] ...)
12:49technomancySaturnation: slime-repl-next-input
12:50wiseenkumarshantanu, put the defn expression in (binding ) ?
12:50kumarshantanuwiseen: err no, use the binding when you don't want assert to work
12:53wiseenkumarshantanu, nope - still the same, https://gist.github.com/1452590 - it prints false for *assert* value but still throws an exception from precondition
12:54wiseenworks the same if you (set! *assert* false) after (defn foo ...) but if you set it to false before it doesn't throw
12:55jonasenIs it impossible to extend a protocol with another protocol?
12:57dnolenjonasen: no.
12:57dnolenjonasen: sorry I mean no, it's not possible
12:59jonasendnolen: ok. Is it a due to some technical reason or is it simply never necessary to do so?
12:59kumarshantanuwiseen: (set! *assert* false) before the defn form seems the only way to deisable it
13:00dnolenjonasen: Clojure discourages inheritance.
13:01jonasendnolen: Yes, though I don't really see why it's the same as inheritance.
13:04dnolenjonasen: the protocol is inheriting definitions from some other protocol right? What do you see is the benefit?
13:08jonasenSay I define a Point2D protocol with (x [p] ...) and (y [p] ...). Next, I define a Distance protocol containing a dist function. Now it would be nice to extend Point2D to Distance. Usually I would simply define a function dist (i.e., not a protocol) but there are other distances that are not defined between points (for examples lehvenstein distance between strings
13:22BorkdudeSimple question: how do I get "lein repl" to create a Clojure 1.3 repl, when I'm outside a lein project? (now it does 1.2.1), should I "install" or remove something?
13:22dnolenjonasen: I don't see why Point2D and Distance should be combined.
13:23jonasendnolen: I'm probably complicating things needlessly. Thanks!
13:25TimMcBorkdude: You can't, I think.
13:25TimMcBorkdude: Outside a project, Leiningen uses its own JVM for the REPL (for speedier launch).
13:26BorkdudeTimMc: yes, but what clojure version get used by default?
13:26TimMcI keep a ~/tmp/clj/project.clj lying around with 1.3.
13:26TimMcBorkdude: Whatever Lein uses, which I think is 1.2.1.
13:26BorkdudeTimMc: I see.
13:27TimMcI think it's a bit unfortunate.
13:27BorkdudeTimMc: I also have a project called "repl" just for spinning up a repl when I want one
13:28sirvalianceAny vim users that program clojure have any suggestions?
13:28TimMcsirvaliance: I've heard of something called "evil".
13:28TimMcand "vimclojure".
13:28Borkdude(waiting for the suggestion: "use emacs instead" to come up)
13:29TimMcUse whatever works. If Notepad does it for you, more power to ya.
13:29sirvalianceTimMc: I just setup vimclojure
13:30BorkdudeAt least Notepad has an almost constant learning curve. http://bc.tech.coop/blog/060302.html
13:30jodarohaha
13:31sirvalianceIt took googling to get the joke
13:32sirvalianceI really want to get into game dev through learning clojure
13:32sirvalianceNot necessarily for others to "play", more for a personal learning experience
13:37TimMc*nod*
13:40sirvalianceAre there any sort of package managers for clojure? Like pip for python or gems for ruby?
13:41BorkdudeI don't know those, but I think you might want to use leiningen
13:41jodaroif you use leiningen for your project it will handle getting dependencies
13:41jodaronot exactly the same thing but
13:42Borkdudeyou can push your things to clojars and get it using leiningen
13:42Borkdudehttps://github.com/technomancy/leiningen
13:43sirvalianceAlso, do most people (as suggested from an online book) just write a script called clj which basically links to "java -cp clojure-1.4.0-master-SNAPSHOT.jar clojure.main"
13:43TimMcsirvaliance: I don't think so.
13:44sirvalianceWhat is the best way to "install" clojure?
13:44ibdknoxleiningen ftw
13:44Borkdudesirvaliance: no, most people I know use lein(ingen)
13:44sirvalianceAhhh
13:44ibdknoxsirvaliance: https://github.com/technomancy/leiningen
13:44sirvalianceSo I did it the wrong way by compiling and building the jar
13:44TimMcYou don't really install it. It is pulled in as a dependency, and packaged with your code.
13:45sirvalianceOk, I will install it and give it a rap
13:46Borkdudesirvaliance: it's nice to see that clojure is just a jar, so for the purpose of learning it might be good to experiment a bit from the command line
13:47Borkdudesirvaliance: but if you want to get up to speed and use other people's jar files, then leiningen is a lot easier
13:48ibdknoxleiningen is easier just in general
13:48Borkdudeibdknox: yes
13:48ibdknoxif you just want to try clojure, you could check out tryclj.com :)
13:48Borkdudeibdknox: I keep running into "can't copy this character into tryclj" issues ...
13:49ibdknoxBorkdude: when you do what? (Raynes ^^)
13:49Borkdudeibdknox: for example when I want to insert a "
13:50Borkdudeibdknox: I use US International keyboard setting, it might be just that
13:50Borkdudeibdknox: wait, I'm saying it wrong. I can copy the chars, but just not type them in
13:50ibdknoxweird
13:51ibdknoxsounds like it might be a bug in the JQuery console implementation
13:51BorkdudeI use US International to create characters like ë, which are common in Dutch
13:51Borkdudethen I have to type " + e
13:52Borkdudeso two keystrokes, the same for just a ", but maybe it handles this wrongly
13:52sirvaliance Hmm, so I like from reading the docs about lein. How do I install clojure from it?
13:52ibdknoxI bet it intercepts keystrokes and freaks out
13:52Borkdudeibdknox: ah, yes, when I put it to another keyboard setting it just works
13:53ibdknoxsirvaliance: instead of thinking of it as installing clojure, think of clojure as just a dependency of your app
13:53Borkdudesirvaliance: just make a dependency in your project.clj
13:53ibdknoxsirvaliance: you just need clojure in the right place, the rest is magic
13:53Borkdudesirvaliance: or if you just want a repl, just type "lein repl"
13:53Borkdudeibdknox: it just downloads clojure right?
13:54sirvalianceGotcha
13:54Borkdudeibdknox: it even asked if I wanted to install a JVM on my machine ;-)
13:54ibdknoxBorkdude: more or less
13:54sirvalianceOooo, I like lein repl
13:54Borkdudesirvaliance: what OS are you on, just curious
13:54sirvalianceOsx, could be linux but lately osx
13:55jodarosirvaliance: one thing that i've depended on a lot is to create a "scratch" project to play around in when i want to make sure some stuff i do in the repl lives on
13:55jodarolein new scratch
13:55jodarocd scratch
13:55jodaroand bam, you have a little playground
13:56sirvalianceGotcha, doing that now
13:56jodaroput that action into source control and you'll never, ever forget how you did something again. ever.
13:57Borkdudesirvaliance: what is also cool, if you do lein swank, you can connect to it from... emacs! o wait... ;)
13:57sirvalianceI like how lein deps just downloads the clojure jar
13:57sirvalianceZing!
13:57tmciverWhat is the best way to gracefully exit a hung slime repl in emacs?
13:57tmciverIt's for a buddy of mine; he keeps writing infinite loops . . . idiot!
13:57TimMchaha
13:58Borkdudetmciver: I always start a swank session and connect to it using slime-connect, then you can just ctrl-c the swank session if things go wrong
13:58tmciverI've tried typing '.' (comma) followed by 'sayoonara'
13:58sirvalianceYEEESSSS, lein repl is awesome! I love that it has the JLine built in!
13:58TimMctmciver: Does it work to kill the repl's buffer?
13:58Borkdudetmciver: happened to me also a lot, repl consuming infinite seqs :)
13:58sirvalianceSo I am sold on clojure now
13:58ideally_worldthank goodness for re-find
13:59Borkdudesirvaliance: that's quick
13:59TimMcsirvaliance: You *like* jline? Install rlwrap, which is much better, and lein will use it.
13:59ideally_worldM-x clojure-jack-in is so much better :)
13:59tmciverTimMc: not sure, but it would be nice if I didn't have to start all over.
13:59TimMcAh, you need a way to kill the current evaluation, got it.
13:59tmciverBorkdude: let me try the slime-connect method.
14:00Borkdudetmciver: you need to enter the project directory and type "lein swank"
14:00TimMcBorkdude: C-c with your method will kill the whole REPL, yeah?
14:00tmciverBorkdude: yup, thanks.
14:00BorkdudeTimMc: yes
14:01tmciver:(
14:01Borkdudeideally_world: I tried clojure-jack-in but it doesn't work here...
14:02ideally_worldfollow technomancy's guide for getting emacs up and running
14:02tmciverSo there's no way to cleanly break the repl out of an infinite loop?
14:02ideally_worldI think it's starter-kit or something
14:03Borkdudeideally_world: error in process filter: clojure-eval-bootstrap-region: Search failed: "(run-hooks 'slime-load-hook) ; on port"
14:03Borkdudeerror in process filter: Search failed: "(run-hooks 'slime-load-hook) ; on port"
14:03Borkdude
14:03Borkdudeideally_world: did that
14:03TimMctmciver: M-x slime-interrupt?
14:03tmciverTimMc: trying . . .
14:03ideally_worldleiningen has swank insgtalled?
14:03Borkdudeideally_world: let me see, should I type smth like "lein install swank" or?
14:03ideally_worldBorkdude: have you ever gotten slime to work with leiningen? I.e. lein swank?
14:04Borkdudeideally_world: yes, doing that all the time
14:04ideally_worldlein install plugin swank something
14:04ideally_worldhmm
14:04Borkdudeideally_world: also I like this method, so I have full control over the swank server
14:04Borkdude(ctrl-c to be specific)
14:04ideally_worldI got sick of lein swank and then slime-connect
14:05tmciverTimMc: Nope. Get an exception thrown by the swank server.
14:05tmciverOh well.
14:05TimMchold on, let me see
14:06ideally_worldnot sure what that error meant, but it almost makes sense after diving into emacs today :)
14:07sirvalianceWhat is the best clojure/opengl lib, penumbra?
14:07ideally_worldBorkdude, do you use lein swank or do you start swank so other way?
14:07Borkdudeideally_world: got it working now
14:07ideally_worldYay!
14:07Borkdudeideally_world: I always do "lein swank"
14:08ideally_worldHow did you fix it?
14:08Borkdudeideally_world: I think I needed to update swank-clojure
14:09Borkdudeideally_world: when I did M-x clojure-jack-in it seemed to compile a bunch of slime elisp files also in emacs...
14:09ideally_worldah, that makes some sense, I was under the impression that it wasn't installed...
14:09sirvalianceAny thoughts?
14:09TimMcSimilarly, does anybody know how to interrupt a long-running evaluation in Leiningen's REPL?
14:09TimMc(without killing the REPL)
14:09Borkdudenow let me try an infinite loop
14:09ideally_worldsirvaliance, no ideas, sorry
14:10BorkdudeI typed (loop [] (recur)) now in the "jacked" REPL. How do I kill it?
14:11BorkdudeMy processor is warming up.
14:11Borkdudeslime-interrupt doing nothing
14:11Borkdudeah wait, it does work
14:11raekC-c ?
14:12Borkdudebut you have to type it in the repl buffer itself
14:12Borkdudewhy... , because you could have multiple running?
14:13BorkdudeWhen I try another clojure-jack-in I get an error. But fair enough, this works ok for me. Clojure-jack-in!
14:14sirvalianceWhat is the preferred clojure web framework? Or the most popular?
14:14ideally_world:)
14:14tmciverGetting in to an infinite loop in the repl is a pain because you not only have to destroy your slime-repl but you have to kill the underlying Java process.
14:14Borkdudesirvaliance: Noir
14:14ideally_worldsirvaliance, haven't tried anything, but noir sounds interesting
14:14Borkdudetmciver: slime-interrupt worked for me
14:14sirvalianceThat is what google would like to think, didn't know if there were some that didn't have the google rank
14:14tmciverBorkdude: you can 'slime-connect' back into the existing swank server but you have to find its port number.
14:14ideally_worldBorkdude, but do you still have a java process running in the backgroung some where?
14:15Borkdudesirvaliance: http://www.webnoir.org/
14:15tmciverBorkdude: really? Hmm, let me try again.
14:15Borkdudetmciver: hmm no
14:16Borkdudetmciver: let me see if there is one
14:16sirvalianceWhat is the difference between running something like "lein search noir" then "lein install" vs "lein plugin install noir" ?
14:17Borkdudetmciver: how I can discover an existing swank server and its port?
14:17tmciverBorkdude: probably not the best way but I've determine the swank session started from within emacs by trying to kill emacs; it then lists the existing running process asking you if you want to kill them first.
14:17tmciverI don't know a better way yet.
14:18ibdknoxsirvaliance: lein install will install your current project into a local cache
14:18sirvalianceOhh
14:18ibdknoxsirvaliance: lein plugin install will go get a jar from clojars and put it in leiningen's path
14:18ibdknoxsirvaliance: allowing you to use it from leiningen's process
14:18sirvalianceIe, from the repl?
14:19ibdknoxsirvaliance: in lein-noir's case, it let's you run the noir command: lein noir new
14:19raeksirvaliance: no, from lein build tasks
14:20raeksirvaliance: install library in other language == add to :dependencies in project.clj and run lein deps in clojure
14:20Borkdudeah, lsof -i | grep 'java.*LISTEN'
14:20Borkdudethen I found the port and I could reconnect
14:20tmciverBorkdude: cool
14:20sirvalianceAhh
14:22sirvalianceSo, more annoying questions from me ;)
14:22sirvalianceIs is possible to work through sicp with clojure?
14:22ibdknoxsirvaliance: a few people have
14:22sirvalianceIt has been staring at me from my bookshelf for way too long
14:23Borkdudesirvaliance: I found myself trying examples from common lisp, but things are so mutable in common lisp, it is sometimes not a direct translation
14:23Borkdudesirvaliance: for example, you can just do (setf (car my-list) 1) to change the head of a list
14:24sirvalianceI see.
14:24Borkdudesirvaliance: whereas in Clojure you always construct a new list
14:24tmciverBorkdude: Genius! That works.
14:24sirvalianceI was wondering that from briefly reading about clojure last night. Does that create memory issues?
14:25tmciverslime-interrupt worked for me that time.
14:25ibdknoxsirvaliance: because of structural sharing, no
14:25sirvalianceConstantly reconstructing new lists
14:25Borkdudesirvaliance: clojure does this very efficiently
14:25sirvalianceOhhh, so it snags pointers to gen the new list? (laymens understanding)
14:25sirvaliance*layman?
14:25Borkdudesirvaliance: exactly
14:26sirvalianceGotcha
14:26sirvalianceThat is pretty cool then
14:26tmciverBorkdude: that also kills the underlying Java process which I had to kill manually.
14:26sirvalianceI was wondering how that worked, seemed inefficient at first glance
14:26sirvaliance:)
14:26tmciverTimMc: thanks to you as well!
14:27ideally_worldsirvaliance, everything is imuttable so sharing between lists is cool, nothing will change :)
14:27Borkdudetmciver: sorry, killing? I lost track
14:28BorkdudeI guess lein could keep track of this port and reconnect after a slime-interrupt?
14:29Borkdudeeh slime
14:29Borkdudeeh never mind
14:29sirvalianceSo, just to clarify, lein install will install it in the local repo, lein plugin install will install it "globally" to lein? Right?
14:29clojurebotelein is https://github.com/remvee/elein
14:31raeksirvaliance: lein plugin install will install a leiningen plugin, this gives you new "lein ___" commands
14:31sirvalianceOh
14:32sirvalianceThat clarifies it
14:32raeksirvaliance: and lein install will package the project you are working on and add it to your local repository (so that you can include is as a dependency from other projects)
14:32tmciverBorkdude: before when I killed the hung repl I would also have to go kill the Java process separately.
14:33Borkdudetmciver: and now?
14:33tmciverBorkdude: slime-interrupt seems to take care of it.
14:33sirvalianceraek: So if I run "lein search penumbra", then lein install, I can include it as a dependency for any of my projects, not just the local repo?
14:34sirvalianceWait I am missing something
14:34TimMcI'm wondering if it's actually Clojure's own REPL that is lacking "kill currenct evaluation" support.
14:34raeksirvaliance: no, you can always include it as a dependency
14:34Borkdudetmciver: when I do slime-interrupt, the java process is still there
14:35sirvalianceOk, so lein install is to install the jar that I am currently working on. Once I run lein search x, it is cached and can be used?
14:35tmciverUh oh, let me make sure.
14:35raeksirvaliance: when you find a library you are interested in, you add it to your project.clj and then run "lein deps"
14:35sirvalianceOoooh
14:35sirvalianceok
14:35Borkdudetmciver: also I can reconnect to it
14:35tmciverBorkdude: does it take up 100% of cpu?
14:35raekafter that it is available when you start a new repl
14:35sirvalianceraek: Thank you for the explaination. Probably saved me plenty of time figuring this out via trial and error
14:35tmciverPerhaps it's not the Java process that was running your infinite loop.
14:36raeksirvaliance: think of "lein install" as "make install"
14:36sirvalianceAhhh, ok
14:37raeka certain version of a lib is downloaded and cached (added to the local repo) the first time you have a project that uses it as a dep and you run lein deps
14:37sirvalianceSo when I run lein search penumbra, and get returned "org.clojars.dnolen/penumbra "0.5.0"", I can just add that to my project.clj depen list?
14:37Borkdudetmciver: hmm. let me try this again. I'll kill all java processes first.
14:38sirvalianceThen run lein deps?
14:38raeksirvaliance: exactly
14:38raekyou add [org.clojars.dnolen/penumbra "0.5.0"] to the vector
14:38sirvalianceGot it
14:39Borkdudetmciver: ok only one java process now, resulted from clojure-jack-in
14:39Borkdudetmciver: this thing is listening on 64697. now let me do an infinite loop
14:40tmciverBorkdude: it does seem to do the right thing.
14:40sirvalianceraek: So lein install would make sense if I wanted to install from source in most cases, right?
14:40Borkdudetmciver: now I got a java process taking 100% cpu.
14:40Borkdudetmciver: pid is 11839. same as the one which is listening at the port I mentioned
14:41Borkdudetmciver: now I will do a slime-interrupt. Thread Death message
14:41Borkdudetmciver: still there is a java process listening, let me try to reconnect...
14:41raeksirvaliance: yes. you don't do that very often though (except for when you want to fix a bug in someone else's project and use the fixed version right away)
14:42Borkdudetmciver: reconnecting worked. I'm slightly confused about what happened though.
14:42Borkdudeevery operation from the repl gets its own thread which can be killed or what?
14:42tmciverBorkdude: Ahh, I think it is I who am confused. I'm looking at output from top. I guess the Java process isn't killed; it's just not at 100% anymore.
14:43Borkdudetmciver: to be sure I used this loop: (loop [] (+ 1 2 3) (recur))
14:43tmciverBorkdude: doing slime-interrupt doesn't kill my repl . . . no need to reconnect.
14:43Borkdudetmciver: it will be 99% cpu at my machine
14:44tmciverBorkdude: I think it makes sense to me now. No Java process is killed nor needs to be killed.
14:44Borkdudetmciver: wait, slime-interrupt just kills what is running, and then returns to the repl, indeed. nice
14:45tmciverBorkdude: yes, does exactly what I wanted. Thanks again.
14:45Borkdudeso, every expression is executed in a thread which gets killed by slime-interrupt I guess?
14:45Borkdudetmciver: thanks to you, I have learned this also just now
14:45tmciverBorkdude: actually, it was TimMc who initially suggested it. Thanks!
14:46BorkdudeTimMc: yeah, tnx :)
14:46TimMcnp, stumbled across it while looking for something else
14:47sirvalianceCan I run a clojure script through the lein repl command?
14:47sirvalianceOr, how can I run a clojure script with out java comp.
14:47TimMctmciver: Wait, so slime-interrupt lers you stop the current command and continue with your coding?
14:48technomancysirvaliance: try "lein help run" and also "lein help tutorial"
14:48TimMcyou still have all your defs?
14:48Borkdudesirvaliance: you can do loaf-file I guess? http://clojure.org/evaluation
14:48Borkdudeload-file
14:48Borkdudesirvaliance: but just do what technomancy tells you
14:49TimMcalways a good move
14:50tmciverTimMc: yes
14:50TimMcsweet
14:50TimMcImma start using lein swank instead of lein repl.
14:50BorkdudeTimMc: he doesn't use emacs
14:50tmciverTimMc: Oh yee-ah boi!
14:51Borkdudesirvaliance: (I learned emacs just because of Clojure..)
14:52Borkdudesirvaliance: (and still learning...)
15:10jcromartieI don't remember when I started learning Emacs, but it might have been for clojure. I know I did more Lua than anything else at first, and then started using it for pretty much everything but Objective-C and C#.
15:20jcromartieOMFG
15:20sirvalianceSo in your project.clj file, do you define the main function?
15:20jcromartiea coworker asked me some question in chat, and I responded with this image link http://imgur.com/gallery/NgkfY
15:21jcromartieand he told customer service to forward it to the client as an answer to their issue
15:21jcromartieI mean jesus christ
15:21jcromartiesorry for the OT but I am losing it here
15:21teromouch...
15:22TimMcjcromartie: At least you're not in the line of fire if that goes badly, yeah?
15:23BorkdudeIf I were that customer I would lmao
15:23TimMcsirvaliance: you define the main class: ":main foo.core"
15:23jcromartieno, I'm not in the line of fire
15:24TimMcThat's pretty wild.
15:27sirvalianceGotcha
15:36BorkdudeWhat is the recommended way to reconnect to freenode and get back to #clojure after a disconnect, just M-x erc again?
15:48fdaoudclojurebot: haskell
15:48clojurebot"you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work." -- ayrnieu
15:49fdaoudclojurebot: ML
15:49clojurebotXmL is like violence; if it doesn't solve your problems, you're not using enough of it.
15:49fdaoudclojurebot: OCaml
15:49clojurebotNo entiendo
15:49fdaoudclojurebot: F#
15:49clojurebotExcuse me?
15:49fdaoudclojurebot: Miranda
15:49clojurebotI don't understand.
15:49fdaoudclojurebot: haskell
15:49clojurebot"you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work." -- ayrnieu
15:50amalloy*polite cough* you can /msg clojurebot if there's no reason to make this interrogation public
15:50fdaoudamalloy: didn't know; noted; apologies.
15:50BorkdudeI like his opinion on Haskell though
15:51amalloyhe's more opinionated and less subtle about python
15:53BorkdudeIs there a substantial part of Clojure programmers coming from Python, like is the case with Ruby and why (not)?
15:54cemerickok, gotta do it
15:54cemerickclojurebot: survey is http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
15:54clojurebotIn Ordnung
15:54cemerick~survey
15:54clojurebotsurvey is http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
15:54cemerickBorkdude: ^
15:55hiredmanhttps://www.facebook.com/notes/facebook-engineering/the-hiphop-virtual-machine/10150415177928920 you have to wonder why they don't just adopt the php on the jvm thing
15:55cemerickThat's sort of a stupid ~ command for that :-/
15:55hiredmanclojurebot: where is the survey?
15:55clojurebotsurvey is http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
15:56cemericksure; but there's some |is| thing for defining new stuff, right?
15:56Borkdudecemerick: hehe
15:56Borkdudenice, equal part almost
15:57TimMccemerick: Yeah, you can put pipes around the verb or whatever.
15:57Borkdudeand no GW Basic..
15:57hiredmanif you want to define the relationship between the left hand side and the right hand side to be something besides is, you can use lhs | relationship | rhs
15:57hiredmanand the pipes are required when deleting
15:57TimMcand a <reply> after the |relationship| to have clojurebot only respond with the rhs
15:58TimMchiredman: I can't seem to delete the Chouser/namespaces factoid (to fix some typos and stuff)
15:58TimMcI was able to delete some spurious factoids that were getting irritating, but that one wouldn't die.
15:59TimMc~namespaces
15:59clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
16:00TimMcI tried both the "are" and the "is".
16:00BorkdudeIt is interesting to see that only 2% came from Haskell but if clojure disappeared 36% would choose Haskell next
16:01Borkdudealthough they could choose more than one
16:02TimMcHrmf, I think hiredman has me on /ignore -- he hasn't responded to anything I've said to him in the last 2 months or so.
16:03amalloyTimMc: his parser doesn't work very well if there's an "is" partway through the statement in my experience
16:03TimMcamalloy: Even if there's explicit ||?
16:03amalloyyes
16:03TimMcugh
16:10goodieboyis there a function like select-keys but instead of returning a new hash-map, it returns the values of the specified keys?
16:10cemerick,((juxt :foo :bar) {:foo 5 :bar 6})
16:10clojurebot[5 6]
16:10goodieboyahh right! thanks
16:11amalloywelllll, i'm a big fan of juxt, but this only works if the keys are keywords
16:11RaynesYou're nuts for juxt.
16:11amalloy&(map {:foo 5 :bar 6 :baz 7} [:bar :foo]) ;; works in general
16:11lazybot⇒ (6 5)
16:12Raynescemerick: I didn't realize until after I tweeted about your ideas that I might have put you on the spot (re: the apidocish stuff you plan to add to marginalia at some point).
16:12RaynesIf you don't do it, I will, just so you don't feel bad.
16:12goodieboyamalloy: ahh yep, makes sense
16:12Somelauwclojurebot: arc
16:12clojurebotPOLO! nya nya you can't see me
16:12SomelauwI don't get the joke?
16:14rmarianskiclojurebot: marco?
16:14clojurebotPOLO! nya nya you can't see me
16:14cemerickRaynes: I blame you for all my ideas. ;-)
16:14cemerickI will add some things to either marg or story, but I can't imagine working on both. I'm hardly married to marg.
16:14RaynesStory is a bit of a mess.
16:15cemerickI figure I'll get around to it soonish. Probably not this year. "Before Clojure/west" seems like a good, safe timeframe. :-P
16:15RaynesHeh
16:15RaynesDo it *at* ClojureWest. With Fogus. I'm sure he'll be there.
16:15cemerickI'm shaving enough yaks around tooling at the moment to keep my spare moments busy.
16:16SomelauwI don't get the marco polo joke
16:16cemerickI don't get the impression that either is a pinnacle of clean design. The domain sort of forces a hack-and-slash approach.
16:17`foguscemerick: If I increase the dowry, would you consider marrying Marg?
16:18cemerickGosh, I didn't know dowries were around still. I'll have to ask my wife where hers is. :-P
16:19cemerick"I've got a nice offer from this cute named Marg."
16:19`fogus:p
16:19cemerick`fogus: honestly, I suspect I'd make a hash of either marginalia or story, insofar as I'd probably run roughshod over various literate programming idioms I've no awareness of.
16:20`fogusI hope I can make it to Clojure/West... regardless of the Marg marrying situation
16:20cemerickI'd have to come up with a new proposal. The well is dry at the moment, it seems.
16:20Raynes`fogus: The ideas we're talking about are some kind of accordion-style list of vars that anchor to the vars themselves. Among other things, but that's my favorite part of it. It would make marginalia autodocish enough to be useful for API documentation while sticking to what Marginalia is and always will be good at: kinda-sorta-literate programming.
16:21ilyakI'm getting a very strange behavior in clojure
16:21hiredmanVars: What The Hell?
16:21`fogusI haven't looked at story. Is it more LP?
16:21hiredmancemerick: -^ there's your talk
16:21RaynesI want to and would work on that myself, but web design makes me want to kill myself.
16:21ilyakif I do (some-fn [calculate-int calculate-int]) I get (some-fn nil) called
16:21Raynes`fogus: http://jedahu.github.com/story/
16:22ilyakbut when I do (let [tuple [calculate-int calculate-int]] (some-fn tuple)) it's okay
16:22cemerickhiredman: what, running roughshod over other people's work? Just another day at the shop.
16:22ilyakWhat am not I getting?
16:22`fogusOh, so it's comment based too?
16:22hiredmancemerick: Vars: What The Hell?
16:22cemerickah
16:22Raynes`fogus: The outlines are what we'd like to see in marginalia. And it can actually work with the side-by-side if we can collapse things.
16:22cemerickAnd asciidoc. Don't forget about asciidoc. :-P
16:23hiredmantoo long for a lightening talk, might be a little short for a full talk
16:23ilyakI also have a problem: Color.getRGB returns int
16:23ilyakwhich is perhaps less than zero
16:23RaynesStory looks for single-semi-colon comments and not double semi-colons. The author uses Vim and thus the comments in the application are all indented weird and stuff, so I'm not sure if this would even work properly on my own projects.
16:23ilyakclojure immediately promotes it to Long
16:24ilyakand then it can't call BufferedImage.setRGB
16:24ilyakHow would I make it not do that?
16:25ilyakOops, I might be interpreting it incorrectly
16:25cemerickilyak: coerce it via (int rgb-value) http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
16:25cemerickhiredman: Yeah, maybe I should go angsty.
16:25ilyakdisregard that
16:26cemerick"What sucks about Clojure and why you'll love it anyway."
16:26`fogusI'm working on a tool called trout that is the next step above Marg... it's source files look like https://gist.github.com/1453362.
16:27RaynesI don't think I'm into that level of literate programming.
16:27RaynesI like marg style.
16:27hiredmanoh, no, how I imagine the talk it would be sort of an examination of vars, some use cases, pitfalls, maybe some javap output
16:27`fogusRaynes: So do I. :-) For most libs
16:28hiredmanthings you can run into if you do runtime conditional loading of namespaces but expect the compiler to resolve vars for you
16:28hiredmanstatic vs. dynamic vs. the now default non-dynamic vars
16:29`fogusI see autodoc -> API consumers. marg -> code readers. story -> masochists. trout -> sadists... errrr writers
16:29TimMccemerick: I could go for angsty 'round 'bout now.
16:30`fogusAlright gentepersons. I need to run.
16:30cemerick`fogus: I don't think there's much to distinguish the former two, esp. when the source is the only documentation in certain corners.
16:30cemerickoh well.
16:31RaynesWith a little tweaking, marginalia can serve much of the purpose that autodoc serves.
16:32cemerickhiredman: Sounds like you've written half of your proposal ;-)
16:32hiredmanbut I don't want to
16:36cemerickI feel pretty talked-out on foundational stuff.
16:36cemerickMakes me shudder to think of what the training grind is like.
16:36pjstadighiredman: let's present together
16:36pjstadigwe'll tag team
16:36hiredmanto my knowledge no one talks about vars
16:37technomancyI submitted a talk on vars to last year's Conj, but for some reason they wanted me to speak on Leiningen.
16:37Raynestechnomancy: Can't imagine why.
16:37hiredman"for some reason"
16:37pjstadighiredman: no one talks about atoms either
16:37pjstadigLHC
16:38hiredmanwell, atoms don't come in the same variety as vars
16:39hiredmanyes! we need threadlocal stack compare and swaps! like atoms in javascript!
16:39hiredmanclojurescript
16:39pjstadigtechnomancy: you should submit a talk titled "For: it's not a loop"
16:39technomancynot bad
16:42Raynestechnomancy: Aren't you supporting my path fixing method somewhere in the clojure-mode or swank-clojure docs?
16:43RaynesIf so, stop. It's nuts. Didn't work after I upgraded to Emacs 24 and after I actually looked at what it did, nuts. https://github.com/Raynes/dotfiles/blob/master/.emacs.d/init.el#L76 is better.
16:44Raynessdeobald: Hey.
16:50technomancyRaynes: not sure which fix you're talking about
16:52Raynestechnomancy: Looks like you've got another method for fixing it in the swank-clojure readme. Nevermind.
17:02ilyakzipmap sucks
17:02ilyakI wonder why doesn't clojure have a solid collection stream operations out of box
17:02ilyakzip, zip-with, map-entries, group-by, all of that stuff
17:03hiredmanwhat do you mean?
17:03amalloyhahaha
17:03amalloyclojure doesn't have good lazy-sequence operations. good times
17:03amalloy~zip
17:03clojurebotzip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))
17:06tscheibldamn... if I had read the "map" docs more carefully this would have spared me some "reduce"
17:08technomancymap/reduce map/reuse map/recycle
17:09boodleHiya how to I add a backslash to a space? This won't work: (.replaceAll "Add a backslash in between teh spaces" " " "\ ")
17:09boodles/to/do/
17:09tscheiblactually I meant it would have spared me some "loop recur" constructs
17:10dnolen,(.replaceAll "Add a backslash in between teh spaces" " " "\ ")
17:10clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported escape character: \ >
17:10dnolen,(.replaceAll "Add a backslash in between teh spaces" " " "\\ ")
17:10clojurebot"Add a backslash in between teh spaces"
17:10boodlelol what I'm seeing
17:10dnolen,(.replaceAll "Add a backslash in between teh spaces" " " "\\\\ ")
17:10clojurebot"Add\\ a\\ backslash\\ in\\ between\\ teh\\ spaces"
17:10SomelauwHow to iterate from 2 to infinity? (take 2 (range)). There is always a neither way that write it and one should not get obsesses with finding the neatest way to write something I think.
17:10dnolen,(.replaceAll "Add a backslash in between teh spaces" " " "\\\ ")
17:10clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported escape character: \ >
17:11amalloy,(iterate inc 2)
17:11clojurebot(2 3 4 5 6 ...)
17:11dnolen(println (.replaceAll "Add a backslash in between teh spaces" " " "\\\\ "))
17:11dnolen,(println (.replaceAll "Add a backslash in between teh spaces" " " "\\\\ "))
17:11clojurebotAdd\ a\ backslash\ in\ between\ teh\ spaces
17:11dnolenboodle: ^
17:11boodlednolen: oooh ty :)
17:12dnolenboodle: you'll see \\\\ in the string, but it prints correctly.
17:12boodlednolen: trying to escape a filename in noir with a post-route filter (I hope)
17:12amalloydnolen: surely just see \\
17:13dnolen,(.replaceAll "Add a backslash in between teh spaces" " " "\\\\ ")
17:13clojurebot"Add\\ a\\ backslash\\ in\\ between\\ teh\\ spaces"
17:13dnolenamalloy: oh yeah sorry
17:14boodleI read somewhere how clojure's regexp engine's changed (since early days) so dunno if a side effect
17:14amalloyi'd be pretty surprised if clojure ever had a regex engine
17:14boodlebased on docs, seems "\\" should be enough (per java's)
17:15boodle1.3 btw
17:15dnolenboodle: yeah clojure regexp's are just java regexp, so it hasn't really changed at all.
17:15boodlewas referring to this: http://items.sjbach.com/406/clojures-new-regex-syntax
17:16amalloyboodle: that's reader syntax, not the engine; and you weren't typing regexes, you were typing strings which java later chooses to interpret as regexes
17:17boodleamalloy: ok. is this worthy of a bug report? and I guess more java's than clojure's
17:17amalloyno, it is not a bug
17:18boodleamalloy: so 4 backslashes give the correct behavior for 1 slash in front of each space?
17:18amalloyit's just a failure to understand the three levels of quoting/escaping that are happening in your example
17:19dnolenboodle: heh yes, 2008 early days that. Matt Might and Peter Seibel on that thread.
17:19dnolencomment thread.
17:20TimMcboodle: Welcome to the Leaning Toothpicks.
17:20boodleheh ty :)
17:21TimMcUsing Clojure's regexp reader syntax helps.
17:21TimMc...but not with the replacement expression I guess.
17:22asavuhi guys! can someone explain this http://pastie.org/2993365 to me?
17:22boodleTimMc: That's what I found.. great for pulling out matches but would be sorta 'manual' for replacement… course I could just roll my own..
17:23amalloyasavu: pretend hashmaps and arraymaps are the same thing. if you care about the difference you're usually doing something wrong
17:23TimMcasavu: Clojure changes implementations under the hood for performance reasons. Ignore the man behind the curtain.
17:24asavuamalloy: TimMc thanks! that a was a bit unexpected
17:26TimMc&(map map? [(array-map) (hash-map) (sorted-map)])
17:26lazybot⇒ (true true true)
17:27asavuit seems like the conversion happens if a map has >= 10 elements
17:28asavuI was trying to use this to find the distinct elements from a sequence but maintain the initial order
17:29hiredman(doc distinct)
17:29clojurebot"([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"
17:29asavuhiredman: yeah, I know but without using distinct
17:30hiredman~soure distinct
17:30clojurebotIt's greek to me.
17:30hiredman~soucre distinct
17:30clojurebotexcusez-moi
17:30hiredman~source distinct
17:30amalloyhaha
17:30hiredmanclojurebot: do as I say
17:30clojurebotExcuse me?
17:31asavuhiredman: thanks! I was trying to avoid that - still learning clojure
17:31amalloyasavu: maps are fundamentally un-ordered. array-maps happen to preserve an order, sorta, but you should never depend on it. if you need something ordered, you don't want a map. (ignoring here sorted-map, which is a different kind of sorting)
17:31hiredmanthen you should be reading code
17:32asavuamalloy: I know but the behaviour is unexpected. I think an array-map should be handled as a sorted-map
17:32dnolenasavu: I'm surprised array-map is public, but you want sorted-map anyhow.
17:32amalloyi don't understand your suggestion but i'm fairly sure it's not a good idea
17:33dnolenasavu: actually looking at your paste - probably sorted-set
17:34asavudnolen: nope, sorted by initial position not by value
17:34hiredmanor, do what distinct does
17:34hiredmanbeing new to clojure, avoiding reading code is dumb
17:34asavuamalloy: a sorted-map remains sorted over multiple insertions (doesn't become a hash-map) - I think the same should happen for array-map
17:35asavuhiredman: I am solving things on 4clojure - reading code without trying is like cheating
17:35amalloyabsolutely not. array-map is just an optimization for small hash-maps
17:35asavuamalloy: so why not hide the array-map completely? why a public api?
17:35dnolenasavu: array-map is not something you should ever use directly.
17:35hiredmanasavu: what is better, to make up some horrible solution for 4clojure without reading good code, or reading good code and learning something?
17:35duck1123if you simply use the java methods, do they still auto upgrade?
17:36dnolenasavu: it probably shouldn't be public, it's been around for a long time, pre 1.0
17:36amalloyasavu: you should do whatever causes you to learn best. we didn't put 4clojure there as a competition, it's there as a learning tool
17:36amalloyif reading code in core helps you understand (and often it will), you should do that. if you prefer to challenge yourself to reinvent everything from scratch, then go ahead
17:37amalloybut i think a certain core level of competency is necessary before that becomes a fun/useful challenge
17:37asavuamalloy: I do that but as the last resort not after 5 minutes of trying
17:37asavuamalloy: and btw I have learned something new about array-map by asking, thanks!
17:37jgrimesIs there a way to get the protocol a function is for?
17:39amalloyjgrimes: for a function in general: no. if you have the var, then yes
17:39asavuhiredman: I would say both - first try and as a last resort or after finding a solution read existing code. thanks for info!
17:40dnolenjgrimes: look at the metadata of the protocol fn var
17:40dnolen(defprotocol IFoo (bar [this])) (meta #'bar)
17:40dnolenjgrimes: ^
17:42jgrimesdnolen: awesome thanks
17:42hiredmanasavu: if you want to learn clojure, reading core.clj and writing code is the best way, I doubt solving problems on 4clojure will get you very far
17:43asavuhiredman: don't worry, this is not the only thing I do :)
17:49jodarohttp://nakkaya.com/2009/11/16/java-native-access-from-clojure/
17:49jodarothat rules
18:37hiredmanhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java <-- it is funny how the javadoc mentions rest
18:37amalloyhiredman: clojure.core doesn't always have javadoc; but when it does, it's drastically out of date
18:38amalloywell, clojure.lang i guess
18:39amalloyhttps://github.com/clojure/clojure/commit/b8e333fb3437dca760f16136ed074a4dd463fe35#diff-19 is the commit that got it out of date, if anyone cares
18:42hiredmanalso, the file is full of \r\n
18:45sirvalianceI have another dumb question for the room. I am about to start learning clojure though sicp. What would be the best way to structure my repository?
18:45sirvalianceCould I have each chapter be a .clj file?
18:52amalloyhiredman: a sign of real quality design
19:07dnolensirvaliance: I would not study SICP w/ Clojure.
19:07sirvaliancednolen: Why so?
19:07dnolensirvaliance: Scheme is just too different from Clojure, IMO
19:08sirvalianceHmm
19:09dnolensirvaliance: which isn't to discourage studying SICP at all. just that I don't think that it's a great way to learn Clojure.
19:09sirvalianceI was trying to kill two birds with one stone
19:11dnolensirvaliance: people seems to like doing it - but I think you'll just end missing the point of Clojure.
19:11sirvalianceAnd what point would I miss?
19:13dnolena few: real function polymorphism (big), non-mutable locals, persistent data structures, good concurrency tools
19:16sirvaliancednolen: Have you gone through sicp? What repl would you recommend? I am liking gambit scheme, others say just use mit-scheme, but I don't like how the repl doesn't have history
19:17dnolensirvaliance: I used mit-scheme, didn't really care for it. I started using Petite Chez Scheme and that's pretty nice.
19:18dnolenI like Racket, but when you're trying to use r5rs and r6rs there are some annoynaces
19:21rickmodednolen: So Racket doesn't have a Scheme flavor that works well with SICP?
19:23dnolenrickmode: sorry Racket works just great for SICP, but there some impedance between features you want to use from Racket in r5rs or r6rs if you're playing around.
19:24dnolenone issue I ran into is that Racket cons is purely functional, and Scheme cons isn't. Again if your only working on SICP not much of an issue.
19:25dnolensirvaliance: I've gone through the first 3 chapters and some of the 4th. SICP is a *lot* of work, if you want to learn Clojure, just learn Clojure :)
19:32sirvalianceYeah, that is probably a good poit
19:32sirvaliancepoint
19:35sirvaliancednolen: Over how long of a period of time do you think you spent on sicp
21:33TimMc$findfn '+ `+
21:33lazybot[]
21:35clizzinanyone used incanter and know what the equivalent to R's reshape is?
22:35amalloyclizzin: just looked up reshape, and it's not easy to understand. if you actually explained what reshape does, you'd broaden your respondent base from "people who use R and clojure" to "people who use clojure"
22:39clizzinamalloy: for my use case, reshape lets you specify a column whose values then become new columns on the dataset. this is most useful when you have a dataset with columns "user_id", "month", "page views". if i then reshape with idvar="user_id" and timevar="month", i'll get a dataset with columns "user_id", "month0", "month1", etc., where the value for each month column is the associated "page views" value.
22:41clizzinso instead of [[:user-id :month :page-views], [1 "Jan" 4], [1 "Feb" 10], [2 "Jan" 20]], i'd get [[:user-id :month-Jan :month-Feb] [1 4 10] [2 20 nil]]
22:45TimMcclizzin: Interesting, not at all what it sounded like.
22:46clizzinTimMc: well, i have limited exposure to the r function, so this might only be one use case of reshape (parameterized by direction="wide"). i'm just trying to see if i can reproduce with clojure/incanter something a friend did in R.
22:48clizzinsorry, in the example above, the column names after reshaping should be [:user-id :page-views-Jan :page-views-Feb]
22:49TimMcalexbaranosky: Fn names are now linking: http://www.brainonfire.net/files/seqs-and-colls/main.html (any thoughts on licensing?)
22:50alexbaranoskyTimMc, high five
22:50alexbaranoskyTiMc: no preference licensing-wise
22:50clizzinso input [[:user-id :month :page-views], [1 "Jan" 4], [1 "Feb" 10], [2 "Jan" 20]], i'd get [[:user-id :month-Jan :month-Feb] [1 4 10] [2 20 nil]] => output [:user-id :page-views-Jan :page-views-Feb] [1 4 10] [2 20 nil]]
22:51alexbaranoskyTimMc, gotta run
23:16zackmarilHey is github down for anybody else?