#clojure logs

2010-12-15

00:04clizzinso python has this thing called the defaultdict which allows you to specify a default value that is returned if the given key is not found. clojure's get function allows you to do this as well, but you have to pass in the not-found value at the time you call get, whereas defaultdict allows you to specify the not-found value when you create the dict. is there a way to make a map in clojure and specify the not-found value at the time
00:04clizzin of map creation?
00:15amalloyclizzin: how is that different from (fn [m default] (fn [k] (or (get m k) default)))?
00:16amalloyi guess then it's hard to use keys, vals, assoc, etc
00:16clizzinamalloy: right
00:16amalloyyou certainly could do it by implementing/proxying IPersistentMap, but that's pretty heavyweight
00:17clizzinif i proxy IPersistentMap, i would *only* have to proxy the get function, right?
00:18clizzinoh, but then i'd have to play with the internals of IPersistentMap's implementation instead of using get to get the map
00:18clizzinget the value*
00:19amalloyclizzin: more would be necessary. (keys foo) can't just use get
00:23amalloysorry, that's a silly claim, i think. it's true if you proxy IPersistentMap, but of course you'd proxy PersistentHashMap instead
00:29clizzinamalloy: if i proxy a java class, can i refer to clojure functions that operate on 'this', or is use of 'this' restricted to the java methods defined for that class?
00:29technomancyok, time to unsubscribe to the clojure mailing list =(
00:30technomancygot a flood of primitive hate about three months too late
00:30technomancyor switch to digest I guess
00:31amalloyclizzin: you'd have to explicitly pass "this" to any subsidiary functions, i think
00:31amalloybut i don't do a lot of proxying
00:32clizzinamalloy: hm, well, i think i'll just pass my not-found value down through the function calls for now and think about investigating this issue in a more involved way later. thanks for the help.
00:34clizzinto clarify, what i'm trying to do is some naive bayes classification on document text. the log-likelihoods are stored in a map of token -> log-likelihoods, and in case i see a token i haven't seen before, i need a 'smoothing' log-likelihood. i determine this value at the time i make the map of log-likelihoods for known tokens, but the actual call for token -> log-likelihood comes later, and i didn't want to bother passing that valu
00:34clizzine around until that time.
00:38amalloyclizzin: if you're looking for lazy ways to use (abuse?) the language features, what about dynamic bindings?
00:40clizzinamalloy: not familiar with those, would you mind explaining further?
00:41amalloyummm, i don't use them much (ever), but basically you rebind a global variable's value for the duration of a a function call, rather than within the function's lexical scope
00:43amalloyso like (def *not-found-val* nil), then (with-bindings [*not-found-val* 10] (some-fn-that-uses-*not-found-val*))
00:49clizzinamalloy: oh, i see. yeah, that seems like a dirty way of going about it...i guess i prefer just passing the not-found value around.
00:54dnolenclizzin: you can do something like this, https://gist.github.com/741678
01:09amalloydnolen: that only works if all clients are calling his get function instead of clojure.core/get; and if that's the case why not simply do (my-get [{some-map} default-val] key)? that's only a single object to pass around, and my-get can pull apart the vector for you transparently
01:11dnolenvectors aren't free. they also muddy up the representation at the REPL. it sounded like he wanted local behavior anyway.
04:00LauJensenMorning all
04:09ejacksonsalut
04:33Licensermorning
04:54raekgood morning (UGT as well as CET)
05:25ordnungswidrighi all
06:04fliebelmorning
06:07fliebelDo any of you know Haskell? And where did you learn it? I'm trying to find something that is not to basic. Most ebooks so far assume I know a little imperative and nothing more.
06:13_atofliebel: I learnt it in university. They used this textbook, which isn't bad: http://books.google.com/books?id=a39QAAAAMAAJ
06:15fliebel_ato: This seems to be the case everywhere: "This text introduces Haskell at a level appropriate for those with little or no prior experience of functional programming."
06:16_atoah yeah, it was my first properly functional language, can't help with any non-beginner stuff I'm afraid
06:17fliebelok
06:19faust45fliebel: ask at #haskell chanel
06:20fliebelfaust45: They pointed me at a couple, which all had a sentence like the above in the introduction. I was hoping some people who already know Cloojure had more luck in finding a suitable tut for Haskell.
06:25mrBlissfliebel: I used Real World Haskell, but I suppose some of the guys in #haskell will probably have suggested this one too.
06:35ejacksonfliebel: I'm currently reading "Learn you Haskel for great good" and its totally fine
06:35ejacksonthe "Gentle Introduction to Haskel 98" is also good to get a terse view
06:35ejacksonterse as in: monads rear up by page 10 I think
06:38ejacksonsadly the combinatorics of "Language X for Y programmers" is prohibitive :)
06:54fliebelejackson, mrBliss: Thanks, Those are exactly which where suggested to me. I think I'll stick to LYAH.
07:26mduerksen /help
07:27mduerksensorry
07:49TobiasRaederhey :)
07:49TobiasRaedercan anyone tell me why map doesn't seem to use thread-local bindings?
07:51cemerickTobiasRaeder: map's results are realized lazily, so your bindings are probably gone by the time it's consumed its input seqs. You'll want to wrap the map call with doall. See http://cemerick.com/2009/11/03/be-mindful-of-clojures-binding/ for more discussion.
07:52TobiasRaeder@cemerick ah, thanks a ton. really makes sense
07:53GOSUBcemerick: The whole office is watching your deployment video now. Thanks for that!
07:55cemerickwhoa
07:55cemerickGOSUB: I guess I'm on the hook now, huh? ;-)
07:56GOSUBcemerick: completely ;)
07:56fliebelcemerick: Your pallet vid is live?
07:57cemerickfliebel: no, GOSUB is referring to my screencast post
08:02LauJensenfliebel: Just google for 'epic deployment' :)
08:02fliebelI believe sexpbot can do that for me...
08:02fliebel$google epic deployment
08:02sexpbotFirst out of 54500 results is: Web Deployment - Epic Games Forums
08:02sexpbothttp://forums.epicgames.com/showthread.php%3Ft%3D706732
08:03fliebel$google epic deployment clojure
08:03sexpbotFirst out of 77 results is: Continuous Deployment of Clojure Web Applications: Clojure Conj ...
08:03sexpbothttp://cemerick.com/2010/11/02/continuous-deployment-of-clojure-web-applications/
08:04GOSUBwoohoo!
08:07cemerick$google epic clojure
08:07sexpbotFirst out of 1320 results is: Continuous Deployment of Clojure Web Applications: Clojure Conj ...
08:07sexpbothttp://cemerick.com/2010/11/02/continuous-deployment-of-clojure-web-applications/
08:13GOSUB(swap! cemerick inc)
08:14raek(inc cemerick)
08:14sexpbot⟹ 1
08:14GOSUB(inc cemerick)
08:14sexpbot⟹ 2
08:14GOSUBhmm.
08:14fliebelNot a much used feature of sexpbot it seems. Evey time I tried, it returned 1.
08:15cemerickI don't think it's persisted. I was up to 3 at some point.
08:15GOSUB(inc cemerick)
08:15sexpbot⟹ 3
08:16fliebelMaybe someone did (dec cemeric) a few times? No, can't be...
08:17cemerickhaters gonna hate :-P
08:18fliebelcemerick: I don't understand that sentence… And btw, it does seem to be persisted: https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/karma.clj#L9
08:19cemerickfliebel: it's a (probably) American meme, that I can't believe I actually repeated.
08:26fliebelcemerick: Uhm, did you mean I came across rude? I didn't mean to imply people (dec)'d you, quite the opposite.
08:27cemerickfliebel: no, you weren't rude at all. :-)
08:27cemerickI'm sure there are some (many?) that would (dec) me, though. My comment was just me saying "oh well".
08:28cemerickI actually discovered someone that's blocked me on twitter, which was surprising (since I'm not a spammer, etc). Apparently, I'm objectionable to at least one guy, so I'm sure there's others.
08:29fliebel"How wude!" - Jar-Jar Binks :P
08:29GOSUBfliebel: hehe
08:32cemerickfliebel: I think Elmer Fudd laid claim to "how wude" about 50 years before jar-jar ;-)
08:34jweissanybody here use https://github.com/technomancy/durendal (or some other way of syntax highlighting clojure in slime)?
09:01mrBlissjweiss: https://github.com/mrBliss/dotfiles/blob/master/.emacs.d/custom-clojure.el
09:03jweissmrBliss: cool, how do i use this? (sorry i'm an elisp newb) - just (load "custome-clojure.el" in .emacs?
09:05mrBlissjweiss: add it to your load path and (require 'custom-clojure) in your .emacs
09:05jweissok thanks
09:54lpetitHello guys
09:54ejacksonhey Laurent
09:54lpetitI'd like to introduce a ring based extension to my current web application, "by the back door", if you will
09:55lpetit"by the backdoor" implies in my head : no AOT, just one or two deps in my pom.xml, and hopefully the declaration of a servlet in my web.xml, giving this servlet an init param containing the symbol name for the ring handler to use
09:55lpetitdoes this make sense ? does it exist ? what would you do ?
09:56lpetitMy goal is very simple: I want to serve a server file in the most straightforward way, and thought it could be "interesting" to leverage ring's static file middleware.
09:56lpetitI'm now listening to the ring experts :)
09:59lpetitNot everybody at the same time pliz ;-)
10:00jweiss mrBliss: is there a way for me to tweak the colors in defcljface "live" without restarting emacs?
10:00jweissevaling w C-x C-e doesn't change the color
10:04ejacksonlpetit: :)
10:04lpetitejackson: sorry if this seems a stupid question, i'm a noob in web dev in clojure, have not followed the trend
10:04lpetityet
10:05ejacksonlpetit: pah - I'm don't do web stuff either...
10:07mrBlissjweiss: maybe executing (tweak-clojure-syntax 'slime-repl-mode) ;; or 'clojure-mode.
10:08ordnungswidriglpetit: I don't see the problem yet?
10:09ordnungswidriglpetit: the servlet can lookup function by the symbol / name and use that as the ring handler function and pass the request on to it
10:10lpetitordnungswidrig: maybe I've missed something evident in the doc.
10:11ordnungswidriglpetit: so where exactly are you struggling?
10:12mrBlissjweiss: What I mentioned doesn't work. If you have your own color-theme, add for instance (clojure-brackets ((t (:foreground "#ff0000")))) to it, eval the theme with C-M-x and apply it with M-x color-theme-NAME.
10:13jweissmrBliss: hm. ok i'll see what i can do. i don't think i have my own theme. i just changed the default fg and bg colors for the default theme. i think.
10:14lpetitordnungswidrig: from the doc, i cannot see how to do in a "good old java webapp" where I have to define and configure the servlet manually in the web.xml
10:14ordnungswidriglpetit: ok, you want to reconfigure during runtime?
10:14lpetitthe handler impl. why not, but not the number of handlers, etc.
10:14mrBlissjweiss: (set-face-foreground 'clojure-brackets "#ff0000") works for me
10:15jweissmrBliss: ah cool thanks
10:15ordnungswidriglpetit: where do you want to give the input for the reconfiguration?
10:15lpetitordnungswidrig: I don't even understand the question !
10:15ordnungswidriglpetit: anyways suppose there is a ref @handler containing the name of the hander function
10:15mrBlissjweiss: there's also (set-face-attribute 'face-name :underline t :bold t)
10:15lpetitI don't know the options
10:16ordnungswidriglpetit: ok, use a ref to hold the desired handler, I'll paste sth...
10:16lpetitok
10:16lpetitthx!
10:20lpetitordnungswidrig: the missing piece (at least the idea I'm making about what the missing piece is) is an example somewhere without (run-jetty ...) at the end : a piece of clojure code, what to add in my existing web.xml (since it's a tiny addition to an existing webapp I want to do).
10:21ordnungswidriglpetit: so you need to make a servlet?
10:21lpetitWell, as stated in my initial question ^^^, yes, somehow. But I don't want to use AOT.
10:21lpetitordnungswidrig: ^^
10:22ordnungswidriglpetit: you'll need a AOT-compiled ring-handler-servlet which dispatches to a non-AOT-ring handler which is configurable at runtime?
10:23bhenrycan i stop a pending future?
10:23ordnungswidrigbhenry: people tried and failed ;-)
10:23ordnungswidrigbhenry: or where you refering to a clojure future?
10:23bhenryyes a clojure future
10:24lpetitordnungswidrig: I hoped ring was already delivering such a generic servlet (plain java would be good enough), configurable via its init-param attributes in web.xml ?
10:24jweissmrBliss: (set-face-attribute 'clojure-brackets :underline t :bold t) doesn't work for me
10:24jweissDebugger entered--Lisp error: (wrong-type-argument frame-live-p :underline)
10:24jweiss internal-set-lisp-face-attribute(face-name nil :bold :underline)
10:24bhenryi was trying to test the laziness of something with a future, in hopes that i could stop the future if it wasn't as lazy as i thought, and then i wouldn't have to restart swank.
10:25mrBlissjweiss: (set-face-attribute 'clojure-brackets (selected-frame) :underline t :bold t)
10:25jweissmrBliss: (set-face-attribute 'clojure-brackets nil :underline nil :bold t) also worked
10:26ordnungswidriglpetit: i would adjust ring.util.servlet/servlet to accept an constructor function
10:26lpetitordnungswidrig: I see that ring.util.servlet has the function for creating a servlet proxy to a handler
10:27lpetitordnungswidrig: but still, since ring.util.servlet/servlet creates a proxy at runtime, how do I reference it in my web.xml ?
10:29ordnungswidriglpetit: you can only reference to a aot compile servlet in web.xml
10:30lpetitordnungswidrig: I know that. But no, you can reference any .class servlet, of course, not necessarily AOT.
10:34lpetitok, assume I'm missing something obvious. And also let's take my AOT aversion apart for the time being. How do I go from the "use ring.util.servlet/servlet function" to "create a gen-class and AOT it so you can reference it in your web.xml" ?
10:37lpetitordnungswidrig: in other words, to sum up my current understanding : why should I start from ring.util.servlet/servlet and use this in my gen class, and not make-service-method ?
10:39cemericklpetit: Haven't been following your discussion with ordnungswidrig, but I'd point you to http://github.com/cemerick/clojure-web-deploy-conj for just about the simplest AOT'ed and jar'ed webapp possible (just ignore the jclouds/pallet stuff if you want).
10:40ordnungswidriglpetit: you simple must use defservice foo.bar/dispatcher and compile that one. then you can use foo.bar.dispatcher in web.xml as the servlet class
10:41lpetitcemerick: and without AOT ? wouldn't it be a great addition to have delivered with ring an already compiled-to-.class (AOT or proxy written in java, I don't care at all) generic proxy servlet ?
10:42lpetitcemerick: this way, I could add a bit of clojure in my webapp without to introduce too much in my pom: just a dependency to ring, not also clojure-maven-plugin, which would make my little addition much more visible
10:42cemerickWell, it'd have to be AOT to ensure a stable name. Assuming one could get a string to that class at runtime so it could resolve your top-level handler's var, then yeah, that seems like a good idea.
10:45cemericklpetit: and it looks like <servlet><init-param> in web.xml is just the ticket for that. I'd post to the ring mailing list (http://groups.google.com/group/ring-clojure) with that idea. Seems like an easy way to make things easier. :-)
10:46lpetitcemerick: no, written in plain java could suffice. A little bit of RT.var("clojure.core", "require").invoke("'" + handlerQualifiedName.split()[1])) in the init() of the servlet for requiring the namespace of the handler, one more such line for getting an storing a Var with the service method via make-service-method, and voila , just call the Var from the service() of our generic servlet ?
10:46lpetitcemerick: exactly, init-param, as I said ^^
10:47cemerickwell, I suspect it'd be written in clojure anyway, but sure
10:56joshua-choiI've got a conceptual question. If you have a ref containing a big map, is it good practice to deref it as little as possible, or should I deref it whenever I want to read something in the map?
10:56lpetitcemerick: ok, so for the moment (here at work), I'll stick with plain java, and if time permits, tonight, suggest a contribution to the ring's group
10:59cemerickjoshua-choi: the cost of dereferencing a ref is constant (and incredibly small)
11:00joshua-choicemerick: Okay. But if I need to guarantee that a bunch of values I get are consistent with one time, then I need to use one deref, right?
11:01cemerick"consistent with one time"?
11:02lpetitjoshua-choi: no, you need to do it inside a transaction
11:03joshua-choilpetit: Okay, I think
11:03ordnungswidrigre
11:04lpetitjoshua-choi: but of course there are functions to change the "in-transaction value" of the ref, and in the same transaction, subsequent calls will always give the the current "in-transaction value", not the value at the start of the transaction
11:05lpetitjoshua-choi: but your initial question "questions" me: if you find yourself derefencing the same thing too often, then probably you're propagating the transactional world over too much of your code.
11:06joshua-choiPropagating what? The var's changes?
11:06joshua-choi(I'm really new to Clojure's reference; I've never really needed them until recently)
11:06joshua-choi*references
11:07jaleyhey guys! where does the quote function live? (if that's what ' is equivalent to?)
11:07joshua-choijaley: It's a special form, I think
11:07joshua-choiSo no namespace
11:07jaleyjoshua-choi: ohhh... damn, that's why i can't pass it to map then
11:08lpetitordnungswidrig: sorry for the late answer. Ok, I saw your explanation on defservice,and I now understand the full "AOT" story. But as discussed with you and cemerick, I'll post a suggestion for simplifying this scenario to the ring ml
11:08lpetit,(doc quote)
11:08clojurebotexcusez-moi
11:08lpetit(doc quote)
11:08clojurebotPardon?
11:08lpetitgrr
11:08jaleylpetit: returns nil
11:08joshua-choiIt'll just tell you to "refer to clojure.org/special_forms" anyway
11:09lpetityes, it's a special form
11:10lpetitjoshua-choi: I suggest you read carefully the pages concerning refs in clojure.org. (I needed to read them several times, each word is important)
11:10ordnungswidriglpetit: https://gist.github.com/847630a9e5cf25d03421
11:10lpetits/pages/page/
11:10sexpbot<lpetit> joshua-choi: I suggest you read carefully the page concerning refs in clojure.org. (I needed to read them several times, each word is important)
11:11joshua-choilpetit: Okay, thanks
11:14ordnungswidriglpetit: you can then refer to "servlet" in web.xml and call set-handler-from-name to set the name of the actual handler function to use
11:14jaleyso seeing as i can't use (map quote ...), how can i turn [x (+ 1 2)] into ['x '(+ 1 2)] easily?
11:15jaleysorry, forgot to quote the first vector. it's been bound to a parameter in a macro
11:15joshua-choiIt's already quoted, but you're trying to surround it with a list with `quote
11:16joshua-choiSo, (map #(list `quote %) '[x (+ 1 2)])
11:19lpetitordnungswidrig: thanks. I guess I still prefer an approach via init-param configuration, though.
11:19ordnungswidriglpetit: yes, that is possible as well
11:20lpetitordnungswidrig: and I think that by taking care of "wiring" the handler var and not the handler fn, it'll allow dynamic development even within the production server, if a nrepl server is started inside the webapp server ... ?
11:21jaleyjoshua-choi: thanks that's what i wanted
11:21joshua-choiNo problem
11:27ordnungswidriglpetit: yes, by using a var you can modify it at runtime however you want. remote repl is a lispy-way to tweak things. I would encapsule this by a function list (set-handler-fn! [f]) or (set-handler-fn-name! [name])
11:54amalloy&(doc quote)
11:54sexpbot⟹ "Special Form: Please see http://clojure.org/special_forms#quote&quot;
11:54amalloylpetit - you seemed to be looking for this a while ago
11:57ohpauleezRaynes: So I've made some tweaks to your github api stuff
11:57ohpauleezI have a few more I want to do, but I'll ping you when I push them to my fork and we can cut over anything you want
11:58amalloyohpauleez: anything interesting? i'm using his api a little too
11:59ohpauleezI added label support, and updated some of the function names to the names used in the api
11:59ohpauleezI'm going to update some of the dependencies
12:00ohpauleezI'm writing a project metrics tool and visualizer on top of it, so I might push some of that stuff into the api repo as well
12:01amalloyohpauleez: ooo. i like github's graphs. make pretty ones
12:02ohpauleezyeah, that's the idea. Zoomable, clickable, inspect-able network graphs
12:02ohpauleezwith burn down, burn up, and velocity information
12:02ohpauleez"Show me all the commits related to this label, and also show me the velocity on that label split up in 1 week iterations"
12:02amalloyohpauleez: i don't know what that means, but the network graph is my favorite
12:03ohpauleezit's how many tickets/issues are left in an iteration, how many you did in an iteration so far, and typically how many you can expect to do in an iteration
12:03fliebelI like the commit punchcard best, for its uselessness, and for showing the average programmer day :)
12:03ohpauleezburn down, burn up, velocity
12:04ohpauleezhaha, yeah, that is a good one
12:07defn_fliebel: got a link to a commit punchcard?
12:07defn_ive never used one
12:08fliebeldefn_: https://github.com/pepijndevos/utterson/graphs/punch_card
12:08fliebelMine are all rather boring.
12:10fliebelAh, this one has quite a few commits: https://github.com/pepijndevos/PyMouse/graphs/punch_card
12:15defn_oh right! i thought you meant like a physical punchcard
12:15fliebeldefn_: What would that do?
12:16defn_Add a bit of ceremony?
12:17amalloyfliebel: useful when running CVS on a mainframe in the 60s, maybe?
12:19fliebelYea, they could be used instead of my RSA key maybe...
12:20fliebelI have 5 of them on GitHub, while I only have 2 computers. I suspect 4 are from my laptop. One punchcard would beat them all.
12:23fliebeldefn_: You where talking about a "top secret" baker a while back. Any progress with that?
12:25fliebel(does this graph work for anyone? it doesn't for me: https://github.com/pepijndevos/PyMouse/network)
12:28amalloyfliebel: weird. it's taking forever to load for me, but https://github.com/Raynes/sexpbot/network normally works and is also broken now. i'm guessing your graph is fine but something is wrong with their server
12:30ordnungswidrigboth url stall here
13:42Raynesamalloy: Oh no! Not the network graph!
13:44amalloyRaynes: the network graph looks really simple right now. we need more branches
13:46alexykwhat network graph are you talking about, sexpbot masters?
13:46amalloyalexyk: https://github.com/Raynes/sexpbot/network
13:46alexyklooks pretty flat to me
13:47RaynesI like to code in a straight line.
13:55fliebelHah, beat this network graph, I did some weird things there: https://github.com/pepijndevos/utterson/network
13:56amalloyfliebel: see early- to mid-november on https://github.com/Raynes/sexpbot/network
13:58fliebelamalloy: mine has more branches and only myself.
13:59amalloyfliebel: only because you're not deleting old branches when you're done with them
14:00fliebelhm, true. So would it be flat if I deleted those?
14:00amalloyof course, comparing complexity of network graphs is silly. they're fun to look at, but not really a meaningful competition
14:14LauJensenIs there an overview of what defrecords implements vs deftype anywhere?
14:15LauJensenamalloy: You must have that memorized by now
14:17amalloyLauJensen: i think the difference is deftype allows you to add methods not mentioned in any superclass, and defrecord allows you to treat your object as a map? i don't use either very much
14:17LauJensenNo no, you've got it all wrong :(
14:17fliebelLauJensen: I think defrecord implements PersistentHasmap?
14:17LauJensendefrecord is esentially a deftype, but with many standard interfaces implemented for you. Now I just want a list of those interfaces
14:18amalloy(filter (complement (set (supers <some defclass thing>))) (supers <some defrecord thing))?
14:19LauJensenbingo, thanks
14:19LauJensen(clojure.lang.IPersistentMap clojure.lang.ILookup clojure.lang.IMeta clojure.lang.IObj clojure.lang.Seqable java.lang.Iterable clojure.lang.Associative clojure.lang.IPersistentCollection java.util.Map java.io.Serializable clojure.lang.Counted clojure.lang.IKeywordLookup)
14:20fliebelNice
14:35LauJensenAny examples floating around of how to implement java.io.Serializable? I imagined: java.io.Serializable (writeObject [this out] ....), but that throws a "Cannot implement function not in interface", according to the javadocs, the interface has both writeObject and readObject
14:35LauJensen private void writeObject(java.io.ObjectOutputStream out)
14:35LauJensen throws IOException
14:35LauJensen private void readObject(java.io.ObjectInputStream in)
14:35LauJensen throws IOException, ClassNotFoundException;
14:35LauJensen
14:37fliebelLauJensen: I suppose you might have some luck with defrecord? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj
14:38LauJensenyea its right there https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L211
14:39LauJensenrequires a bit of concentration to read though
14:40amalloyLauJensen: serializable is a hacky "tag" interface with no methods, like cloneable
14:40LauJensen?
14:41amalloyhttp://download.oracle.com/javase/1.4.2/docs/api/java/io/Serializable.html
14:41amalloyif you have readObject and writeObject defined, the serialization library calls them magically, via reflection
14:41amalloyis what i recall
14:42LauJensenSo why does Clojure complain that its not in the interface which that javadoc says it is?
14:42amalloyLauJensen: this javadoc says it's not. there are no methods listed there
14:43LauJensenIm reading it wrong then
14:44amalloywhat i'm getting at is, those are "magic" methods that aren't part of the interface from java's point of view
14:44amalloythey're just mentioned in the docstring
14:44amalloycompare eg http://download.oracle.com/javase/1.4.2/docs/api/java/io/ObjectOutput.html which shows what actual interface methods look like
14:45amalloythat said, i think what you want to implement may be http://download.oracle.com/javase/1.4.2/docs/api/java/io/Externalizable.html
14:46LauJensenI might also be down the totally wrong trail. The problem Im seeing with my type, is if you enter its name in the repl it will blow-up. Im guessing its because its not printing correctly
14:47amalloyLauJensen: not sure i understand what you mean. gist?
14:47LauJensen(deftype mytype [fields] .........)
14:48LauJensen(def m (mytype. x y z))
14:48LauJensenuser> m
14:48LauJensen** Blow up
14:48LauJensenWhere if m was a record, it would print its fields in a special format
14:50amalloyweird. but this doesn't look related to serialization, to me. this prints fine for me with a no-method deftype; are you implementing some methods that might be related?
14:52LauJensenNo I dont think so. But you can clone ClojureQL yourself and exchange defrecord for deftype and see what happens
14:56LauJensenamalloy: If you clone it, eval the core.clj file, and in the repl type (table :test)
14:56LauJensenThat will work for a record but try to compile/execute with a type
14:57amalloyLauJensen: IDeref is the culprit
14:57LauJensenhow so ?
14:58amalloyhttps://gist.github.com/fcb633325567f677f3bd
14:58amalloyclojure thinks it knows how to print any IDeref: you deref it, then print the thing
14:59LauJensenaaaha
14:59LauJensenSo it assumes...
14:59amalloyyou can define a custom print function for your type, but i don't know the details
15:00LauJensengot a doc, link, on it ?
15:00amalloy$google clojure print-dup
15:00sexpbotFirst out of 1220 results is: Serializing Clojure data structures - Lisp - Snipplr Social ...
15:00sexpbothttp://snipplr.com/view/13559/serializing-clojure-data-structures/
15:01amalloybest i can come up with
15:01LauJensenthanks
15:01LauJensenWell you've outdone yourself today, thanks :)
15:02ohpauleezamalloy: I see you read the same thread on getopts/clargon :) you beat me too it, I was holding off until the weekend
15:02amalloywelcome!
15:02amalloyohpauleez: i was the first responder to that thread too :P
15:02ohpauleezAh, I rarely look at the names of those that reply
15:03amalloyohpauleez: well, i take the confusing stance of being amalloy on irc and Alan on google :P
15:04amalloyfeel free to contribute to cljopts, though. i've got the GetOpt engine working, and a function for reading the user's options, but they're not connected yet and it's not trivial
15:04ohpauleezah cool, I might look into that, I'm just writing some tests right now for clj-github
15:04joshua__So if one of you were building a stack overflow clone in clojure what might you be using on the backend. (wiki, nested comments, posts, tagging, searching)>
15:06ohpauleezI would probably use the latest Postgres and/or Mongo, plus SOLR
15:06ohpauleezI'd tell nginx to cache static data, and I'd use a CDN where possible
15:07ohpauleezroll it out on Rackspace cloud or AWS, then get some monitoring in place... maybe ganglia and/or monit
15:08ohpauleezusing pallet to do deploys
15:08ohpauleezjoshua__: ^
15:09joshua__ohpauleez: Thank you so much ;).
15:09ohpauleezwelcome
15:10btw0(map #(conj % "|") (partition-all 3 (range 10)))
15:11btw0guess the output
15:11hugodpallet can configure nginx, postgres, and ganglia - mongo and solr crates would be welcome contributions :)
15:12amalloy((| 0 1 2) (| 3 4 5) (| 6 7 8) (| 9))?
15:12btw0i got (("|" 0 1 2) ("|" 3 4 5) ("|" 6 7 8) ("|" 9))
15:12ohpauleezhugod: If I find some free cycles, I might take you up on that
15:12amalloywhat were you expecting?
15:12btw0i expected ((0 1 2 (3 4 5) ("|" 6 7 8) ("|" 9))
15:13hugodohpauleez: shout in #pallet if you do :)
15:13btw0sorry
15:13ohpauleezwill do
15:13btw0i expectrd "|" at the end of each sub list
15:13amalloybtw0: conj adds to wherever it's convenient/fast. for lazy seqs like those returned from partition, that's the front
15:15amalloy&(map #(conj % 1 2) [[0] '(0)])
15:15sexpbot⟹ ([0 1 2] (2 1 0))
15:16ohpauleezbtw0: you could vec, sort of ugly: ##(map #(vec % "|") (partition-all 3 (range 10)))
15:16sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$vec
15:16amalloyif you want add-end semantics, try converting to a vector first: ##(map #(conj (vec %) "|") (partition-all 3 (range 10)))
15:16sexpbot⟹ ([0 1 2 "|"] [3 4 5 "|"] [6 7 8 "|"] [9 "|"])
15:16ohpauleezthanks, forgot the paren
15:16btw0thanks guys, i will do some research on google about this, its surprising to me
15:16amalloyohpauleez: no, you misused vec
15:17ohpauleezright, the parens (vec %)
15:17amalloy#(vec %) is just vec, and how were you going to add "|" using just vec?
15:19ohpauleezthis is what I had on my repl: (map #(conj (vec %) "|") (partition-all 3 (range 10)))
15:19ohpauleezbut then went to vector
15:19ohpauleeznot realizing it's keep the seq
15:19ohpauleezand then copied the wrong line
15:19amalloyah. well, you pasted without the conj, apparently
15:19ohpauleezright, up arrow, delete letters, "tor"
15:19ohpauleez:)
15:19ohpauleezpaste... wrong line
15:24btw0is this documented somewhere? it's really not that obvious
15:24amalloy$google higher order persistent vector
15:24sexpbotFirst out of 130000 results is: Understanding Clojure's PersistentVector implementation | Higher-Order
15:24sexpbothttp://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
15:25btw0going to read that, thanks
15:25amalloybtw0: probably more detail than you need, but it's what i have handy
16:01LauJensenOnce, I thought Clojure was an elegant language... Then I read emit-defrecord: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L134
16:06jweisshow does one use extend on a protocol like (defprotocol P (myfn [x] [x y])) (extend P MyRec {:myfn [x] (blah)}
16:06jweissi want myfn to have 2 arities
16:06jweissbut i can only add it to the map once.
16:08hiredmanwell, you aren't adding it to the map correctly, so I would work on that first
16:09jweisshiredman: i think the solution must be to make the value a function with multiple arities?
16:09jweiss(fn ([x] (println x)) ( [x y] (println x y)))
16:10jweisssomething like that
16:27amalloyLauJensen: clearly not looking for style points there
16:37dnolenLauJensen: Imagine writing the Java to write that Java, and I think Clojure wins on style points by a huge margin ;) That said, getting something like syntax-rules would really clean macros up.
16:37LauJensendnolen: The java might actually end up looking cleaner
16:40LauJensenYou gotta love clojure.test
16:40LauJensenactual: (not (= "SELECT users.* FROM users" "SELECT users.* FROM users"))
16:41dnolenLauJensen: I serious doubt that, it require defining at least 5 unnecessary classes and involving ANTLR ;)
16:42LauJensen:)
16:42LauJensenOkay - I guess as long as we can keep Maven out of the discussion I should be happy
16:44brehautLauJensen: it seems that there should be a corollary to godwin's law about maven
16:44LauJensenIndeed :)
17:18joshua__So a question.. should I care about avoiding Godwin's law in a discussion of Eugenics?
17:19joshua__Nevermind. From the wikipedia article:The law and its corollaries would not apply to discussions covering genocide, propaganda, eugenics (racial superiority) or other mainstays of Nazi Germany, nor, more debatably, to discussion of other totalitarian regimes, since a Nazi comparison in those circumstances may be appropriate.
17:19joshua__Looks like I'm in the clear.
17:26cemerickIt seems that an extension to the Associative interface allowing for varargs on assoc would be a good addition -- that would enable multiple assoc's on a value to produce only one new instance when multiple k/v pairs are provided (rather than reducing through each pair).
17:26cemerickWould be particularly helpful with records.
17:27amalloycemerick: Associative is a java interface, right?
17:27cemerickYes.
17:28_schulte_stupid question, what is the name of the latest clojure to use in project.clj for lein? I've tried all variations of [org.clojure/clojure "1.3.0"] without success.
17:29cemerick"1.3.0-alpha4" IIRC
17:29cemerickor "1.3.0-SNAPSHOT" if you want to run against the absolute freshest out of hudson (which may or may not break your stuff).
17:29amalloycemerick: probably possible if you changed the interface to varargs only, then; i don't think you can come up with signatures that will work for a single interface with optional varargs
17:30_schulte_still getting "Unable to resolve artifact: Missing:" for alpha4 and SNAPSHOT
17:31cemerickamalloy: assoc(Object, Object, Object...) would work just fine
17:31cemerickleaving the existing (Object, Object) signature as-is
17:32amalloycemerick: i guess that's true. not sure what problem i thought i was anticipating
17:33cemerick_schulte_: it's definitely 1.3.0-alpha4, but the snapshot is actually 1.3.0-master-SNAPSHOT
17:33_schulte_oh, never mind, clojure is working with "1.3.0-alpha4", it was clojure-contrib that is throwing errors now
17:33cemerickamalloy: it'd be a problem if one were to add an (Object, Object...) overload. Ambiguity.
17:33_schulte_cemerick: thanks
17:44_schulte_ah, looks like I should use alpha3 if I want to use swank-clojure
17:54gtrak~clojure
17:54clojurebotclojure is the bestest programming language available.
18:00LOPPhey
18:00LOPPI'm using Enlive, but I have problem getting it to read non-ascii characters from websites correctly
18:00LOPPhow do chose the encoding it uses to read the website
18:02raekLOPP: this is how I did it once: http://raek.se/trattern/src/se/raek/scraping/baljan.clj
18:03raekI passed a reader that uses the desired coding to html-resource
18:03LOPPwhat's defvar again?
18:03raekrather letting html-resource create a reader automagically
18:04LOPP(automagically is a ruby buzzword)
18:04LOPP:P
18:04raekLOPP: (defvar- foo value "docs") --> (def ^{:private true, :doc "docs"} foo value)
18:04LOPPI figured it had to be something like that
18:04LOPPthat's 1.3 clj?
18:04raekno, contrib
18:05LOPPbtw what does private do
18:05raekif you try to take the value of the var from another namespace, an exception will be throen
18:06LOPPabout encodings and HTML
18:06jk_using the "future" function, what is considered a good practice for hanging onto the future in order to cancel it at some time in the future?
18:06LOPPdo I have to read the encoding from some header
18:07LOPPor can I just choose UTF-8 on the reader and problem solved
18:07amalloyLOPP: automagically has been around for a lot longer than ruby
18:07LOPPI know :)
18:07LOPPruby community is just using it a lot :D
18:08raekLOPP: well, there are multiple places where it can be specified
18:08raekLOPP: may I present you a lazy solution? https://github.com/raek/utf8-with-fallback
18:08LOPPyes...but let's say I specify the reader to be UTF-8
18:08LOPPand I read a random site
18:08LOPPcould I have a problem
18:08jk_LOPP: what if it's not UTF-8 encoded? i don't know how you could tell if it's not in a meta tag
18:09jk_LOPP: it won't work if you access a site in another encoding
18:09raekthe encoding can be specified with the "charset" attribute in the "Content-Type" HTTP header, or in a meta tag
18:10jk_raek: and i guess having it in a meta tag is kind of a chicken and egg problem :)
18:10LOPPeven as content type
18:10raekLOPP: the charset that I linked will treat the data as UTF-8 if it is valid UTF-8 and as Latin1 otherwise.
18:10raekjk_: indeed.
18:11LOPPI generally let other code handle content-type and http request headers
18:11raekI think that's a part of tagsoup that hasn't been coded yet
18:11jk_what about my question with futures? does anyone do this?
18:11raek"
18:11raekYou can also supply an AutoDetector that peeks at the incoming byte stream and guesses a character encoding for it. Otherwise, the platform default is used. If you need an autodetector of character sets, consider trying to adapt the Mozilla one; if you succeed, let me know."
18:11raekhttp://home.ccil.org/~cowan/XML/tagsoup/
18:12LOPP:)
18:12raekjk_: well, that's what futures are for
18:12raekto have something to hold on to that represents a computation that happens somewhere
18:12LOPPI'd rather have enlive author implement something that would try to get encoding
18:12raekin order to wait for it to finish or to tell it to abort
18:12jk_raek: my question is HOW does one typically hold onto that if you need to cancel it later?
18:12LOPP:)
18:13jk_with a global var?
18:13LOPPhow do you hold on to any other variable?
18:13raekLOPP: enlive is basically a wrapper for tagsoup in this aspect
18:13jk_LOPP: in a typical pure functional style, you don't
18:13LOPPjk_ depends on scope where you might want to cancel it
18:13jk_LOPP: it would be after a "let" returns
18:13raekLOPP: the author of tagsoup is aware of the problem (see the quote) and has proposed a piece of cod eto port
18:14raek(I have considered porting that myself)
18:14raekbut there are two few hours on the day
18:18jk_raek: what i'm getting at is the handler function for my service might have to shut down the listener. but to do that, it needs to see the future object that was returned when i first started the service
18:18jk_raek: i'm trying to figure out if i need to bind it to a global var to make sure it's accessible
18:19raekI guess this is a very general problem
18:20raekone way could perhaps be to create the handler function in the scope where the future is bound to a local
18:20raekso that it keeps a reference to the future in its closure
18:21jk_oh! duh! a closure
18:21jk_never mind...mild case of brain death here
18:21jk_thanks raek
18:21raeknp :)
19:21jk_raek: i'm pretty new to clojure. it just didn't occur to me that i could define new functions in the body of a let.
19:29raekjk_: eye opening, isn't it..? :-)
19:29jk_yes indeed!
19:33jk_raek: i guess the key insight i was missing was that "def" always applies to the root binding.
19:35amalloyjk_: you can define new functions without using (fn), too. higher-order functions like comp are often enough to do the job: ##(let [lookupfn (comp :b :a)] (lookupfn {:a {:b 10} :c 1}))
19:35sexpbot⟹ 10
19:37jk_amalloy: well... only when you're using pre-existing functions thought right? like the fact that keys are functions of their maps?
19:37jk_oh never mind
19:37jk_amalloy: you're newly creating lookupfn since comp returns the new function
19:38amalloyright
19:38amalloy&(let [f (fn [x] (+ 2 x)), newfn (comp f *)] (newfn 5 8))
19:38sexpbot⟹ 42
19:39amalloyusing one builtin and one fresh user-supplied function there, jk_
19:39jk_amalloy: got it
19:40jk_gotta run. thanks for the info amalloy, raek
20:14Lajlacemerick, how is da progress going?
20:14cemerickLajla: with?
20:15Lajlacemerick, my named recur
20:16cemerickLajla: heh, no progress, just an idea at this point. You should post a message to the clojure-dev mailing list so that others can comment and Rich can see it.
20:16Lajlacemerick, so clojure has nly one developer basically?
20:17cemerickno, there's at least a dozen people that make regular contributions to core stuff.
20:17cemerickRich is definitely the benevolent dictator, though.
20:17LajlaThey must be homosexual, there is no other explanation
20:17LajlaWhy else would you contribute to Rich's core.
20:17LajlaAll dictators style themselves as benevolent.
20:18LajlaIncluding Arcturus Mengsk
20:21cemerickLajla: why do you spout such jibberish so often?
20:22danlarkincemerick: don't feed the troll
20:23danlarkinjust /ignore him
20:23Lajlacemerick, formal thought disorder.
20:23joshua__Alright, I have a problem I just solved with a regular expression, but it has led to another problem.
20:23cemerickdanlarkin: I actually don't think I've ever /ignored anyone…
20:23hiredmanignoring him works well, until someone starts talking to him...
20:23Lajlacemerick, neither did I.
20:23LajlaYou are impersonating me.
20:23LajlaYou're being my secret sockpuppet.
20:23Lajlaadmit it.
20:23joshua__I think maybe something related to destructuring might be useful. How so do you take an argument to a function and apply a transformation to it
20:24joshua__so like (fn [(transform x)] .. )
20:24joshua__or is that not possible?
20:25Lajlacemerick, yes, answer for thy sins.
20:25LajlaThat, or buy an indulgiance.
20:25Lajlaeither is cool
20:25LajlaCatholic church needs their money yo. Lot's of parents to pay to shut up.
20:27joshua__This isn't working out either: (defn build-tree
20:27joshua__ [root-link root-page (rl-fetch-url root-link)]
20:28joshua__Should I just toss in a let after the function has been called?
20:30cemerickjoshua__: what are you trying to do, exactly? You can't put arbitrary forms in an argspec like that.
20:32joshua__I know you can do something like that in a let binding, I thought it was possible to do it in a defn binding as well.
20:32amalloyjoshua__: you can only do it in the value half of a let binding
20:33joshua__I've been having dreams of programming on clojure using a huge binding to ensure that I'm not being very functional :P
20:35amalloyjoshua__: what you're imagining is the equivalent of (let [(name x) foo]), which is clearly crazy - you want (let [x (name foo)])
20:36amalloyyou can achieve that either by calling name inside of your defn, or by calling name before you call your defn - the one place you can't do it is in the arglist for your defn
20:41joshua__I know it is crazy, but I thought this was clojure =( sorry
20:45amalloylol, i love it. it's true, a lot of crazy things are possible
20:45amalloyyou could, in fact, write your own magic-defn macro that would behave this way, but it would be pretty complicated
20:49bendlashi, folks
20:49bendlascan someone confirm a stacktrace when doing
20:49bendlaslein install org.clojure/clojure 1.3.0-master-SNAPSHOT
20:50bendlas?
20:50technomancybendlas: that variant of lein install is meant for leiningen plugins
20:50bendlasOIC
20:50technomancyerr--rather, for leiningen projects that include a shell wrapper
20:51bendlasthanks
20:51bendlasgreat tool, btw
20:51technomancythanks
20:59joshua__agreed on lein being an amazing tool. It makes me happy in the same way the python-install and apt-get utilities make me happy =) you save me hours so frequently =)
21:01joshua__amalloy: OMG your right. I half meant that last remark as a joke and you just showed me it isn't really a joke.. o.0. Wow.
21:05amalloyjoshua__: well, in the general case it's quite hard, since how can you know which symbols are args and which are functions to apply to those args? you'd be more or less forced to have a convention like "argument symbols named A!foo should be converted to foo inside the defn body; other symbols will be treated as transformations to apply to the actual arguments before binding them to foo"
21:11amalloybut yes, in general it's possible: lisps encourage you to build your own language, though imo this wouldn't be a good extension
21:11joshua__amalloy: I agree.
21:12joshua__amalloy: I got to try my hand at that recently and it has been useful! I made a macro to force a function to be rate limited. =)
21:12joshua__amalloy: you helped.
21:13amalloyrate-limited?
21:13joshua__Like lets say you have a function that you don't want to be called more than 14 times a second.
21:13amalloyoh, i see. called at most N times per T time
21:13amalloyhm. that sounds like a task better-suited for a function than a macro
21:14gertalot,(into '() (cons 1 [2 3]))
21:14clojurebot(3 2 1)
21:14joshua__(defrl new-func func-to-limit x-times per-y)
21:14amalloy(defn rate-limited-fn [f rate] (fn [& args] (while (still-too-soon)) (apply f args))
21:16amalloyjoshua__: this way you can rate-limit even a function someone passes you as a parameter, and you can manage it however you want without having to pollute your namespace with it
21:16joshua__amalloy: I can do that to a function that is passed as a parameter. The macro is a skin over the function.
21:17joshua__amalloy: It was an attempt at learning macros in a way that I hoped I might use.
21:17amalloyjoshua__: mind gisting the macro? i don't really see what the benefit to having a skin over something so thin is
21:19joshua__amalloy, http://pastebin.com/MSSDABCH
21:20amalloyheh, well, fair enough. your function is general enough, and presumably you want to (def) often enough that a macro is useful
21:22tomojseems weird to have defrlf for defns
21:22amalloyif you'd glued together the (def) and the (fn) i was going to scold you
21:22tomojoh, no its not, you give them a new name
21:23joshua__amalloy, *wishes his teachers in college were more like the people in irc*
21:23joshua__oops
21:24joshua__*wishes his teachers in college were more like the people in IRC*
21:24joshua__gah, w/e, I don't know how to /emotes
21:24amalloylol
21:24amalloyit's /me
21:25joshua__.. thanks .. ;p
21:26joshua__amalloy, so what do you mean by not gluing together the def and the fn?
21:26joshua__Like using the same rate limit let for multiple functions?
21:27amalloyi mean, your macro includes a def, but you provide a way to create rate-limited functions without having to def anything, by using the function and not bothering with the macro
21:28amalloyif it were impossible to get a rate-limited function without (def)ing something, that would be a pretty bad tool
21:30joshua__amalloy: I see your point now. It brings to mind a question though, can you undef things?
21:30amalloyjoshua__: yeah, but there's rarely a good reason: ##(doc ns-unmap)
21:30sexpbot⟹ "([ns sym]); Removes the mappings for the symbol from the namespace."
21:32amalloy&[*ns* ns-unmap]
21:32sexpbot⟹ [#<Namespace sandbox6362> #<core$ns_unmap clojure.core$ns_unmap@efba6d>]
21:40joshua__$source ns-unmap
21:40sexpbotns-unmap is http://is.gd/iOSfD
21:41joshua__&(.substring "hello" 1 2)
21:42sexpbot⟹ "e"
21:43joshua__$source the-ns
21:43sexpbotthe-ns is http://is.gd/iOSCi
21:54joshua__fortune
21:54amalloy$fortune
21:54sexpbotDID YOU SAY FORTRAN?
22:06joshua__That is the one I added =).
22:13joshua__(what-func-given-this-input :some {:some "abc" :thing 123}) would produce this output -> {:thing 123}
22:14joshua__&(doc dissoc)
22:14sexpbot⟹ "([map] [map key] [map key & ks]); dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s)."
22:15joshua__&(dissoc {:some "abc" :thing 123} :some)
22:15sexpbot⟹ {:thing 123}
22:15joshua__yeay!
22:25amalloyjoshua__: apparently there's something like a function-finder in smalltalk, to discover dissoc for you. people are always saying clojure could use one, and i totally agree; not sure why it's so hard that nobody's done it yet
22:27amalloyfamous last words, of course, but it seems like it wouldn't take more than an hour or two
22:28brehautamalloy: what does the function finder do?
22:29amalloybrehaut: (find-this-fn {:foo 10} {:foo 10 :bar 9} :bar) should return dissoc
22:29brehautthat sounds like it does magic?!
22:30brehautamalloy: does it actually take your inputs and run everything function over it till it produces the output you have specified?
22:31amalloybrehaut: search (ns-publics (the-ns clojure.core)), and try every one of them on the input to see if it matches the output
22:31brehautor is there some smarts i cant concieve of?
22:31brehauthuh
22:31amalloydoesn't seem too hard, right?
22:32brehautyour right, famous last words ;) but yeah seems managable
22:44tomoj(find-this-fn + *ns* '+)
22:45tomojunfortunately ns-unmap appears to come first in clojure.core's ns-publics
22:45tomojgood luck with that :)
22:45brehauthah
22:46tomojI guess it's the user's responsibility not to pass it anything that could be dangerous?
22:46brehauttomoj: kinda hard to know if you are searching a namespace you dont know though right? presumably if you know a NS then you wouldnt need to find-fn it
22:47tomoj(find-this-fn (range) inc 0)
22:47tomoj:P
22:48brehauthaha
22:48tomojno infinite seqs allowed
22:48cemerickIf pure functions had appropriate metadata on them (a perfectly reasonable thing to want for a variety of reasons), then you might have a fighting chance.
22:49brehauti miss hoogles search :(
22:50brehautis it reasonable to think that an inferencet could heuristically guess if a fun was pure based on what it calls?
22:51cemerickbrehaut: probably not
22:51brehaut(and presumably have some meta for pureness to let you annotate that if it cant work it out)
22:51cemerickThere's io!, but most fns don't use it.
22:52brehautcemerick: is that a meta annotation?
22:53cemerickno, it's a macro that tosses an exception if it's run within the scope of an STM transaction
22:53brehautoh right
22:55cemerickNow, if pure fns in the stdlib were annotated as pure with suitable metadata, then you could do some interesting things.
22:55brehautcemerick: im tempted to go fill out the contributers form and go do that grunt work just to let smarter people do those interesting things
22:56cemerickbrehaut: that would be a fantastic addition, as I think about it more
22:56cemerickSneaking towards forms of static analysis though, which may creep some people out.
22:57brehautcemerick: clojure already does light weight inference though right?
22:57cemerickonly as an optimization on interop calls
22:59joshua__Will (catch Exception e nil) catch all exceptions and do nothing with them?
22:59cemerickyes
22:59amalloyjoshua__: yes, and the nil isn't even necessary
23:00joshua__java.lang.UnsupportedOperationException: nth not supported on this type: Integer
23:00joshua__ [Thrown class java.lang.RuntimeException] isn't getting caught
23:01amalloyjoshua__: that's probably a compile-time error
23:01amalloyattempting to destructure something that's not a list while expanding a macro
23:02amalloyyou could (try (macroexpand '(whatever)) (catch Exception _))
23:06dnolenbrehaut: if you had the patience to learn logic programming, you could help me with miniKanren :) type inferencing, abstract interpretation, syntax-rules all possible.
23:09brehautdnolen: ive been watching the stream of commits on logos; its on my list of projects to dig into more over christmas
23:09joshua__How do you send just one sexp to slime rather than the whole file?
23:10dnolenbrehaut: cool!
23:10brehautdnolen: ever since studying prolog at uni ive been both fascinated and a bit baffled by logic programming :)
23:10technomancyjoshua__: C-M-x if it's a top-level expression
23:10technomancyC-x e for the expression behind the point
23:13joshua__&(apply (macroexpand `+) [1 2])
23:13sexpbot⟹ 2
23:13joshua__Why not 3?
23:13dnolenbrehaut: it's frustrating and very fun. Certainly the longest I've ever worked on what amounts to 300 LOC.
23:14joshua__technomancy: first lein and now this, your saving me so much time!
23:14technomancyjoshua__: '+ is a symbol. calling a symbol like a function is equivalent to (get '+ [1 2])
23:14technomancyjoshua__: which is nonsense, but Clojure doesn't stop you from trying it =)
23:14technomancyor rather (get '+ 1 2)
23:14joshua__How do you check whether or not something is a symbol compared to a macro
23:15joshua__or w/e
23:15technomancywhich tries to look up the '+ symbol in the map 1 (never mind that 1 isn't a map) and falls back to 2 as the default not-found value
23:15brehautjoshua__: technomancy is the third of the rooms trio of bots
23:15technomancybrehaut: only outside PST work hours. =)
23:16brehauttechnomancy: hah :) that must coincide quite well with NZST work hours
23:16joshua__technomancy: so it took clojure to build an ai like you, capable of passing the touring test.
23:16technomancyjoshua__: is it because of your mother that you say capable of passing the touring test?
23:16joshua__&technomancy: is there an ifmacro?
23:16sexpbotjava.lang.Exception: Invalid token: technomancy:
23:16brehaut(inc technomancy)
23:16sexpbot⟹ 3
23:17amalloy&(macro? #'when)
23:17sexpbotjava.lang.Exception: Unable to resolve symbol: macro? in this context
23:17amalloy&(-> #'when meta :macro)
23:17sexpbot⟹ true
23:18joshua__$(-> + meta :macro)
23:18joshua__&(-> + meta :macro)
23:18sexpbot⟹ nil
23:18paul`&#'when
23:18sexpbot⟹ #'clojure.core/when
23:18technomancyjoshua__: in general quoted functions like that are used in the context of a macro, and that handles eval-ing the symbol into an actual function
23:23LajlaWhat's #' ?
23:23LajlaNamespaces, right?
23:23amalloy&(macroexpand '#'when)
23:23sexpbot⟹ (var when)
23:24LajlaI hate you
23:24LajlaProving me wrong sohuld be awared the death penalty, just like journalism.
23:26amalloy&(macroexpand '~when)
23:26sexpbot⟹ (clojure.core/unquote when)
23:26LajlaAhh
23:26Lajla~ unquotes with namespace right?
23:26clojurebotamespaces 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
23:26LajlaI'm still not sure how namespaces work here
23:27LajlaAh
23:27Lajlaamespaces
23:27amalloyLajla: no. ` quotes with namespaces
23:28amalloy&`inc
23:28sexpbot⟹ clojure.core/inc
23:28LajlaAnd this works to give hygienic macros right?
23:29amalloymore or less
23:29arbschtbrehaut: you're in nz?
23:29Lajlaamalloy, do elaborate
23:29brehautarbscht: yes
23:29arbschtbrehaut: cool! do you know http://lisp.geek.nz?
23:29Lajlaamalloy, like
23:29brehautarbscht: i dont belive so
23:29Lajlasay I use (let [if 3] (and x y z))
23:29Lajladoes it then break and?
23:29LajlaBecause if has a different scope
23:30Lajla&(macroexpand '(let [if 3] (and x y z)))
23:30sexpbot⟹ (let* [if 3] (let* [and__3468__auto__ x] (if and__3468__auto__ (let* [and__3468__auto__ y] (if and__3468__auto__ z and__3468__auto__)) and__3468__auto__)))
23:30amalloyLajla: well, if is a special form so this will just barf
23:30arbschtbrehaut: now you do :) feel free to sign up to the mailing list -- there are physical meetings too, but mainly in auckland for now
23:30brehautarbscht: cool. im in muggy ham
23:30Lajla&(let [if 3] if)
23:30sexpbot⟹ 3
23:31amalloywhoa, no kidding?
23:31joshua__Alright I'm going through a for loop printing stuff and getting (nil nil nil thingiwant nil nil nil nil)..
23:31Lajla&(let [if 3] (and x y z))
23:31sexpbotjava.lang.Exception: Unable to resolve symbol: x in this context
23:31joshua__How can I do that without getting a bunch of nils?
23:31LajlaEhh
23:31Lajla&(let [if 3] (and 1 2 3))
23:31sexpbot⟹ 3
23:31LajlaHmm
23:31arbschtbrehaut: ah, not too far then. we have an irc channel too, #lisp-nz
23:31joshua__&(for [x (range 3)] (if (= x 2) (println x)))
23:31sexpbotjava.lang.IllegalStateException: Var clojail.core/tester is unbound.
23:31Lajla&(macroexpand '(let [if 3] (and 1 2 3)))
23:31sexpbot⟹ (let* [if 3] (let* [and__3468__auto__ 1] (if and__3468__auto__ (let* [and__3468__auto__ 2] (if and__3468__auto__ 3 and__3468__auto__)) and__3468__auto__)))
23:32amalloyjoshua__: for is lazy
23:32Lajla&(macroexpand '(let [if 3] (+ 1 2 3)))
23:32sexpbot⟹ (let* [if 3] (+ 1 2 3))
23:32LajlaHmm
23:32joshua__What should I do instead of for to avoid having a ton of nils?
23:32amalloyRaynes: clojail showing through again ^^
23:32Lajla&(let [if 3] (and 1 2 5))
23:32sexpbot⟹ 5
23:32amalloyjoshua__: ##(doc doseq)
23:32sexpbot⟹ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
23:33Raynesamalloy: ?
23:33amalloy&(for [x (range 3)] (if (= x 2) (println x)))
23:33sexpbotjava.lang.IllegalStateException: Var clojail.core/tester is unbound.
23:33Raynesamalloy: Oh, I haven't fixed that yet.
23:33RaynesI know the problem, but I've been sick.
23:33RaynesCut me some slack, man.
23:34amalloyeh, i think i know the issue too. but i don't want to fix clojail for fear of setting a precedent; i don't want you making me fix everything
23:34RaynesI'll fix it as soon as I can type more than two sentences without blowing my nose and moaning.
23:34joshua__&(defn find-fn
23:34sexpbotjava.lang.Exception: EOF while reading
23:34joshua__ [inputs outputs]
23:34joshua__ (doseq [x (ns-publics (the-ns `clojure.core))]
23:34joshua__ (try
23:34joshua__ (if (= outputs (apply
23:34joshua__ (second x))
23:34joshua__ inputs))
23:35joshua__ (println (first x)))
23:35joshua__ (catch Exception _)))))
23:35joshua__I've almost got it working.
23:35joshua__Only problem that lets say you do (find-fn [1 2] 3)
23:35amalloyomg joshua__ plz gist/pastie that
23:35joshua__you get back add, bitxor, and than a few 1 2s.
23:36joshua__https://gist.github.com/743037
23:36joshua__Help me to fix it? =)?
23:36amalloyjoshua__: find-ns is trying print and println
23:36amalloyer, find-fn
23:37joshua__OH.
23:37joshua__I get it.
23:37joshua__Okay that makes a lot of sense.
23:37joshua__How do you stop that though?
23:37amalloyyou can rebind *in* and *out* while you're calling the functions
23:37joshua__Alright how do I do that?
23:38amalloy&(doc with-out-str)
23:38sexpbot⟹ "Macro ([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
23:39ckyWoo! An abbreviated name for with-output-to-string. :-P
23:41joshua__with-out-str won't work it returns the string not the call.
23:42amalloyoh right
23:42amalloy$source with-out-str
23:42sexpbotwith-out-str is http://is.gd/iPa25
23:43technomancy,(let [v (promise)] (with-out-str (deliver v (do (println "DISREGARD THAT I SUCK") :value))) @v)
23:43clojurebot:value
23:43amalloyjoshua__: (binding [*out* java.io.StringWriter.] (blah))
23:43technomancytada!
23:45joshua__does that work technomancy?
23:45joshua__amalloy: I'm getting a class not found java.lang.stringwrite exception with that.
23:45technomancyjoshua__: clojurebot seems to think so.
23:45amalloyjoshua__: java.io.StringWriter
23:46joshua__kk its working
23:46technomancypromises are underrated
23:46joshua__(find-fn [1 2] 3)
23:46joshua__bit-or
23:46joshua__bit-xor
23:46joshua__+
23:46joshua__unchecked-add
23:46joshua__nil
23:46joshua__are the results
23:46joshua__gisting the newest attempt
23:47amalloyjoshua__: nice. that's like perfect
23:47amalloythough i'd do it with filter, rather than doseq/println
23:48joshua__amalloy lol.. quoting you =) joshua__: ##(doc doseq)
23:48sexpbot⟹ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
23:48joshua__don't mean that in a bad way though heh
23:48joshua__its funny because really the channel wrote that function.. I had to ask for everything related to heavy lifting
23:48amalloyyeah, i know. you asked how to do (for) with side effects, not how to find things matching a predicate :P
23:53amalloyanyway, that's how you write things in clojure anyway. talk about an idea, and ask someone else (library functions, or #clojure) to do all the work
23:54joshua__amalloy: That is how I write it or how you write things in general?
23:55amalloythings in general. farm out all the heavy lifting
23:55joshua__amalloy, (I know the first one is true at the very least lmfao, was so much better about that in other languages but things took a lot longer)
23:55joshua__Going to hack at that function again. I want it to look elegant.
23:55amalloyhurrah
23:58technomancyhttp://twitter.com/#!/SeanTAllen/status/15259440336867328 <= OH at the nyc clojure meetup: 'It is so nice to be with a group of people where everyone knows that CAPSLOCK should be mapped to CONTROL.'
23:58technomancyniiice