#clojure logs

2012-03-23

00:00cemerickoooh
00:00lynaghkdespite the assurances of the folks at the desk
00:00cemericknasty
00:00lynaghkyeah, I thought maybe Silicon Valley would be the one place where stuff like that works...nope.
00:00cemerick"sign out" rarely means Sign Out anyway
00:01lynaghkthere wasn't anything, actually. I thought the first screen was "welcome to our kiosk iPad", but it turns out it was "welcome to the iPad you just purchased"
00:02ibdknoxlol
00:02ohpauleezlynaghk: ping
00:02lynaghkso I couldn't do anything but really paw at it with all combinations of my digits
00:02ohpauleezYES
00:02ibdknoxlynaghk: don't pong
00:02ohpauleezfinally!
00:02ibdknoxdon't do it
00:02ohpauleezhaha
00:02ibdknoxrun
00:02lynaghkyo Paul! I was about to send you a pull request
00:02cemerickhe's irc'ing from in the building!
00:02lynaghkneed keyword args propogated for your kibit change
00:03ibdknoxcemerick: lol
00:03ohpauleezCool, I just saw you forked.
00:03ohpauleezTotally send the request, and shoot me an email me if you have any special requests. I usually get changes in daily
00:04ohpauleezhahah cemerick
00:04lynaghkohpauleez: yeah, I think there are some other changes I need to figure out first.
00:04lynaghkohpauleez: cool thanks.
00:04cemerickibdknox: what have you been recommending for auth in conjunction with noir?
00:04cemerickohpauleez: hey paul :-)
00:04ibdknoxcemerick: define auth
00:04ibdknoxcemerick: as in just putting pages behind privileges?
00:05cemerickauthentication / authorization
00:05ohpauleezI think David is totally right, what you want to do is totally possible. I think what we might see if that we spin out a new project that we base kibitz on
00:05ohpauleezI'm not so sure yet, but we'll see
00:05ohpauleezcemerick: Hey! what are we doing up right now?
00:06ibdknoxcemerick: you can do the filtering very easily using pre-routes
00:06ibdknoxcemerick: no one has created a magical auth thing, past that
00:07cemerickibdknox: ah, I see you have a dep on jbcrypt directly; so you're providing form-based authentication yourself?
00:08ibdknoxcemerick: just an encryption util to make sure people don't do something bad... like use sha1
00:08cemerickohpauleez: heh, sometimes I'm up 'til 4 if I'm being a spaz.
00:08cemerickok
00:09muhooi dunno how magical you're looking for, but there's this: https://github.com/sumilux/ssi-java-client
00:09ibdknoxcemerick: decent example here: https://github.com/ibdknox/Noir-blog/blob/master/src/noir_blog/views/admin.clj#L51
00:11cemerickibdknox: I'm building a ring-security lib. form/basic/openid/oauth/etc, role-based authorization, channel redirection, etc. Tired of cobbling stuff together constantly.
00:12brehautcemerick: excellent!
00:13cemerickMeh. Doing it out of anger.
00:13brehautthats how many web things get written isnt it?
00:13cemerickIn retrospect, probably one of the reasons I try to stay away from webby things in general. :-P
00:13brehauthaha
00:14xeqicemerick: I've been looking for one of those
00:14xeqilike a ring version of warden
00:14brehauti certainly didnt write necessary evil for fun :P
00:14cemerickI tried *really* hard to get spring-security to work with containerless jetty. Two days later, I cried uncle.
00:14ibdknoxI want someone to build every auth for clojure
00:14ibdknoxI thought I convinced someone to do it
00:14ibdknoxI've since forgotten who that was
00:15brehautibdknox: i believe some sort of karmic transmutation has made that be cemerick
00:15cemerickI'll do form, basic, and *maybe* openid. Someone else will have to bring me patches for the rest.
00:16cemerickxeqi: link for warden please?
00:16xeqihttps://github.com/hassox/warden/wiki
00:16brehautim sure raynes would love to do the oauth portion for you
00:16cemerickbwahahah
00:16cemerickxeqi: Thanks; and, hi :-)
00:17ibdknoxbrehaut: yeah he loves that shit
00:17ibdknox;)
00:17brehauthaha
00:18xeqijust another library for inspiration; too busy making some ring testing libs based on rack-test/capybara to dig into it myself
00:18xeqiand, hi back
00:18cemerickxeqi: definitely, want to make sure I don't make too many egregious errors.
00:19cemerickYou should all be scared shitless at this point.
00:19muhoosomeone is building an everyauth thing as a service. it's this: http://www.social-sign-in.com/
00:19cemericklogin as a service as a service? o.0
00:20muhoocemerick: basically. yeah, i know.
00:20xeqiisn't that openid?
00:20muhooopenid works for some services, not all.
00:20cemericklogin as a service as a service as a service, then.
00:20xeqiwait.. theres an extra "as a service" on the end of that
00:20muhoo"as a service" means "we can charge you for it"
00:21muhooinstead of all that open-source hippie stuff :-)
00:22technomancywhat about sandbar? isn't it supposed to do auth-y stuff?
00:22muhoo(recur service)
00:22lynaghkohpauleez: pull requested.
00:22technomancymuhoo: FWIW I think the repl task in lein2 is supposed to have a :headless option
00:22technomancyoh... but that's nrepl, not raw socket repl
00:22ohpauleezlynaghk: cool, thanks, I'll check it out right now
00:22muhootechnomancy: ooh, that'd be awesome. i hacked it to work anyway though. i just started it from systemd with /dev/null as stdin and syslog as stdout
00:23cemericktechnomancy: yeah, I read its source earlier. It does 40 other things too, and makes some unfortunate choices, IMO.
00:23ibdknoxcemerick: technomancy: brenton said use at your own risk
00:23ibdknoxlol
00:23technomancygood to know, heh
00:23ibdknoxhe talked someone out of using it at clojurewest
00:23ibdknoxso
00:23cemerickhah, I didn't know that
00:23technomancysuspected it was a bit sprawling at first glance
00:23brehautits 5pm friday here, so have a good weekend everyone
00:23lynaghkyou too brehaut.
00:24cemerickI saw https://github.com/brentonashworth/sandbar/wiki/Stateful-Sessions and was immediately concerned.
00:24cemerickAnyway. There's a bunch of good ideas in there that I'm going to steal.
00:24technomancyyeah, still plenty of gaps in the web stack; somebody's just gotta step up =)
00:25ibdknoxpfft what are you talking about my few thousand lines of Noir totally covers everything ;)
00:25ibdknoxlol
00:25xeqihe
00:25muhootechnomancy: so, fyi: with :repl-port set, this basically works: lein trampoline repl < /dev/null 2> somewhere >somewherelse
00:25ibdknoxa solid everyauth would be a wonderful addition
00:26cemerickibdknox: is 'everyauth' an actual thing, or just a shorthand you're using?
00:26ibdknoxactual thing
00:26ibdknoxhttps://github.com/bnoguchi/everyauth
00:26ibdknoxI know it's node - try not to throw up
00:26cemerickhrm
00:27cemerickthat'll take a bit of effort, but I'll work on it. :-)
00:27cemerickimpressive list!
00:27ibdknoxmostly if the base of it is there, it's trivial to add in the pieces
00:27technomancymuhoo: if a simple patch could make the repl task do what you need out of the box I'd be happy to take it
00:27technomancymuhoo: planning on cutting a 1.7.1 release next week
00:27muhootechnomancy: i'm not quite comfortable with the innards of lein yet.
00:28muhoobut, i'm sure i will be :-) and i'm looking forward to contributing.
00:28cemerick`npm install everyauth` ha ha, wat?
00:28technomancyI can help you step through the code tomorrow if you like
00:28xeqicemerick: same idea for rack: https://github.com/intridea/omniauth
00:28cemerick(keep the good prior art flowing)
00:29muhootechnomancy: that'd be really helpful, thanks! i was looking for a kind of "guided tour" of how it works, but didn't find anything.
00:29muhooa lot of how to USE it, it's easy. but not a lot of HOW it does what it does
00:29technomancymuhoo: yeah, especially the repl in lein1 is not documented outside my own head; fortunately it all got rewritten in lein2
00:31xeqicemerick: https://github.com/hassox/warden_omniauth - warden + omniauth
00:34jmalonei have seen the clojurewest slides but were the presentations recorded?
00:34lynaghkohpauleez: How complex can kibit / core logic rewrites be? Does it do multiple passes over the code to make sure it finds all of the alternatives?
00:35lynaghkjmalone: yeah, I believe they will be released on a rolling basis starting in a few weeks.
00:35lynaghkdunno who's on deck though.
00:35ohpauleezlynaghk: There is no backtracking or context awareness. The upcoming will have "best rule" enabled
00:35ohpauleezright now I can only do that with loop-recur, but I'm certain core.logic can do that
00:36lynaghkhmm. I'm not so much thinking about backtracking but overlapping forms
00:36ohpauleezso (if (=0 0) :a nil) will go to :a
00:36jmalonelynaghk: thanks i guess ill just have to be patient
00:37ohpauleezalts would be when, (zero? 0), true, then just :a
00:37lynaghke.g. in a reify you need to change two of the method names, but the rule for each will be (reify ...some/none... (method-to-match) ...some/none...)
00:37lynaghkjmalone: there is a secret draft of my talk on the youtube, if you don't feel like being patient. It's just me talking over slides though, so you can't see me waving around like an idiot.
00:38ohpauleezYeah, that context can't be captured if it's a complex rule
00:38ohpauleez(reify . ?x (blah) . ?y) type of rule
00:39lynaghkohpauleez: damns. I was thinking about looping through until alts stopped popping up, but that feels like a hack.
00:39ohpauleezor the subforms need to have subrules
00:39jmalonelynaghk: haha thanks ill look it up
00:39ohpauleezlynaghk: Ahhh yeah, we can do that
00:39ohpauleezI see what you're saying
00:39ohpauleezyes, that'll be in this next release
00:39lynaghkokay, rad.
00:39lynaghkare you still keepin' it static?
00:40lynaghkIn an ideal world I could use the matching / replacement after macro expansion time.
00:40ohpauleez(if (= 0 0) :a nil) => (when (= 0 0) :a) => (when (zero? 0) :a) => (when true :a) => :a
00:40ohpauleezstill static
00:40ohpauleezif you can express the smaller parts as rules, it'll pick it up
00:41lynaghkohpauleez: okay, that sounds great.
00:41ohpauleezif-nil goes to when, = 0 is a zero?, zero? 0 is true, when true is dead code
00:41ohpauleezand we have rules for each of those
00:42ohpauleezMy master branch does this with loop/recur, but we can do it better with core.logic, I just don't know how to yet
00:42ohpauleezhaha
00:42lynaghkdid you just see that phrase on a t-shirt in your mind? Because I did.
00:42lynaghkMaybe I'll make some for the next Conj.
00:43ohpauleezhahaha
00:43ohpauleezYou'll be wealthy beyond your imagination
00:43ohpauleezSeriously, core.logic is like a real life oracle
00:43ohpauleezYou think up any reality, and all of sudden it magical is possible
00:43alexbaranoskyso on the front: "we can do it better with core.logic" and on the back: " I just don't know how to yet"
00:44alexbaranoskyI'd buy that
00:44lynaghkalexbaranosky: yep.
00:44muhooprolog will be the haskell of 2013
00:44ohpauleezIt's the alchemy of programming, except it works
00:45muhooryan senior's presentation on core.logic did definitely leave me dazzled and intrigued, sure
00:45alexbaranoskyI feel like I'm inches away from writing a logic program, after watching Senior's talk
00:45muhooalexbaranosky: jinx :-)
00:46ohpauleezWe have a "Kibit reading list"
00:46muhooi was thinking today, i need to find two resistors from my bag o' crap, to use for an op-amp, and i thought, "hmm, maybe i should write something in core.logic to tell me which ones to use"
00:46ohpauleezspecific to simplifying expressions with logic
00:46lynaghkmuhoo: just those two golden rules...
00:48Zokamuhoo: on what port are you running your repl server - is it internal testing?
00:48slyrusmuhoo: wasn't prolog the haskell of 1995?
00:48muhooZoka: yes, just an ephemeral port so i can ssh in , do port forwarding, and get to it.
00:50ZokaIf you do not mind running jetty on that port you can rin proper web based nREPl interface https://github.com/zoka/ringMon/
00:50Zokas /rin/run/
00:51Zokamohoo: see: As a replacemnet for lein repl section
00:52muhooi saw that nrepl stuff, looks very cool, but i'm happy with (-> :repl-port ssh-port-forwarding emacs-comint-mode) for now
00:53ZokaNo problem
00:53ohpauleezlynaghk: If you ever come out, you should totally come party/crash at Tutorspree HQ
00:53ohpauleezWe just finished a solid Startup Crawl
00:53lynaghkohpauleez: donezo.
00:53muhooZoka: thanks though. it's a very neat project.
00:54lynaghkLast time I was in NYC I crashed with the Mongo folks.
00:54scriptoryou slept in their iffice?
00:54scriptor*office
00:54lynaghkno, just came by for high fives
00:54scriptorah, yea their office hours thing is pretty cool
00:54lynaghkthey have office hours, and they're pretty nice. I was in the middle of a node.js+mongo project.
00:55muhooi hear they are managing risk very effectively at tutorspree
00:55lynaghkI was, er, younger then.
00:56ohpauleezmuhoo: haha I heard that too somewhere
00:59cemericklynaghk: we all have a seedy past ;-)
01:00lynaghkcemerick: I still have my fixed gear bicycle to prove how fast I went then.
01:03lynaghkcemerick: you're wise; let me know if you think the following is a terrible idea: Write JVM Clojure code, expand all of the macros manually, remove macro references from the namespace forms, run through kibit to munge away some platform differences, then write out to files for use with ClojureScript.
01:03ztellmanthe best questions begin with "you're wise;"
01:04lynaghkztellman: you're also wise! also question for you!
01:04jmalonelynaghk: do you have a link for that video?
01:04cemericklynaghk: good troll dude :-P
01:04ztellmanlynaghk: same question? different question?
01:04lynaghksame question
01:04cemericklynaghk: I dunno what the worse idea is: asking me for advice on ClojureScript, or what you're proposing. ;-)
01:04lynaghkha
01:04ztellmanha
01:05ztellmanlynaghk: I did something kind of analogous for Lamina
01:05ztellmanthere's some weirdness that is exposed when you macroexpand everything
01:05lynaghkjmalone: http://www.youtube.com/watch?v=T83P3PVSy_8 There were a few more slides at Clojure/West, but the gist is the same.
01:05ztellmanespecially w.r.t. chunked-append & co
01:05dnolenlynaghk: ohpauleez: hullo! btw, core.logic does backtracking for you.
01:05ztellmanI don't know if cljs has matching structures for that
01:06cemericklynaghk: you were there for the portability discussion; big ol' windmill, it is.
01:06ohpauleezdnolen: YES! I need to learn how to whisper to core.logic to achieve that
01:06dnolenohpauleez: it's automatic
01:06ztellmancore.logic whispers to itself
01:06lynaghkcemerick: not looking for total portability, and this will require some manual help (e.g. marking forms with metadata so that kibit will know to exclude them when generating code)
01:07ohpauleezztellman: one would expect this
01:07jmalonelynaghk: i was feeling rather silly not being able to find it, now i see its unlisted so i feel less silly
01:07cemericklynaghk: I think the first order of business would be working out conditional compilation bits. The extensible reader in 1.4 might be a reasonable basis for this.
01:07ohpauleezdnolen: Is my assumption right- core.logic could "recurse" or do I need to l explicitly loop
01:07ztellmanconditional compilation would be nice
01:07lynaghkztellman: CLJS macros are the same as CLJ ones, and happen at conversion time. The only reason I'd want to expand them manually is because it might be easier than evalin' to detect them and then munging the namespace forms.
01:08cemerickwithout that, you're going to hit a serious brick wall eventually, and have no recourse.
01:08dnolenohpauleez: it's really fun to see core.logic be used for something like kibit. It's not a bad way to see if it's fast enough for code analysis :)
01:08lynaghkcemerick: what do you mean, conditional compilation?
01:08ztellmanlynaghk: I meant whether there are cljs analogues for chunked seqs and all the other implementation details that are exposed by macroexpand
01:08cemerick#clj […clojure code] #cljs […cljs code…]
01:08ztellmanbasically, if your approach works for (for …), you're golden
01:08dnolenohpauleez: core.logic is properly tail recursive, internal uses really fancy trampolines.
01:08ztellmanbut that's surprisingly hard
01:08cemerickthat may or may not work
01:09ohpauleezdnolen: So far it's been a blast. The biggest limit is me and my understanding of the possibilities
01:09cemerickactually, it should definitely work.
01:09lynaghkztellman: thanks for the tip. I believe that macroexpand should work fine.
01:09dnolenohpauleez: I admit it's pretty daunting - and I'm too lazy to convert copious Prolog literature.
01:09lynaghkcemerick: ah, yes that is what I'm using kibit for, basically
01:09ohpauleezIt's what we're working with right now, so far, it hasn't been so bad.
01:10dnolenohpauleez: my simple rule parser from tickt #20 was recursive.
01:10ztellmandnolen: just write write an automatic translator for art of prolog
01:10ztellmanyou have the tools
01:10dnolenztellman: I have too many Clojure project as it is :)
01:10lynaghkjmalone: the secret is out now, so I just made that video public. I'll take it down once the official infoq video comes out.
01:10ohpauleezdnolen: it could achieve: (if (= 0 0) :a nil) => (when (= 0 0) :a) => (when (zero? 0) :a) => (when true :a) => :a
01:10ohpauleez?
01:10ohpauleezman, I need to go back and study that again
01:11cemericklynaghk: heh, ok, I see what you're really trying to do now.
01:11cemerickwhew.
01:12lynaghkcemerick: yeah. It's a pretty serious Yak to shave, but I want to get it done and working so that you can use pretty much all of C2 on either JVM Clojure or ClojureScript.
01:13dnolenohpauleez: oh, you want multiple passes. just call simplify again. I think simplify would terminate when the form unifies w/ itself (base case).
01:13ohpauleezdnolen: That's what I'm doing now
01:14ohpauleezcool, that's easy enough then
01:14cemericklynaghk: what is the real scale of the nonportable bits? A much dumber solution (manually coding variants for each host) would have some estimable scale, and you'd know you could always make it work.
01:14dnolenohpauleez: at certain point I might start getting concerned w/ performance, but seems like so far you guys haven't run into any issues?
01:15ohpauleezdnolen: I really have to thank you. core.logic has bent my brain in a way I haven't experienced for years, and it is truly amazing to have it be a part of Clojure
01:15ohpauleezit's been SO MUCH FUN to work with, and the benefits are clearly illustrated in kibit
01:16dnolenohpauleez: ha! well thank the miniKanreners and Prologists. but yes, I'm pretty psyched about Kibit as well as the fact that a lot of people already seem to find the tool useful.
01:16lynaghkcemerick: where's the fun in that? = ) The only thing that can't be ported is the ClojureScript dom walking stuff. Everything else is just functions that help with data visualization tasks (scales, map projections &c.). Unfortunately you can't just copy paste them into .cljs files because of trivial differences (e.g. clojure.lang.IFn on Clojure and IFn on ClojureScript).
01:17ohpauleezdnolen: Yeah, no performance concerns so far. The rule sets are small enough and the forms we're analyzing are no longer than your longest form in code
01:17ohpauleezlynaghk: I'll merge your pull req in tomorrow morning after jonas takes a quick look at it, cool?
01:18lynaghkohpauleez: sure, sounds good to me.
01:18dnolenohpauleez: I think a lot of perf stuff in the future could be addressed via rule indexing.
01:18cemericklynaghk: right, you mentioned that. Why not a conditional (import 'clojure.lang.IFn), etc?
01:18lynaghkcemerick: in ClojureScript just (def clojure.lang.IFn IFn)?
01:18cemerickBut yeah, a lot less cred in that.
01:18cemerickheh, or that
01:18ohpauleezdnolen: Awesome, definitely good to know
01:19cemerickI think conditional compilation is pretty cred-ful though, and will come in handy later anyway.
01:19lynaghkyeah, and it's not all just symbol replacements. Some of the protocol method names are different (e.g. getAt and get-in, or something like that)
01:20cemericklynaghk: conditional compilation + a definline, and the result would look damn pretty.
01:20cemericks/a/many
01:20lynaghkcemerick: yeah, that's true. I feel like it would make the code uglier, and also it would be every-man-for-himself. If I can make a precompilation step that works for 80% of CLJS, then other people could use it too
01:21cemerickwell, don't let me stop you ;-)
01:21lynaghkheh
01:21lynaghkSo this conditional compilation stuff is in the fancy reader in 1.4? I'd just plug some magic into my project.clj or some such?
01:21cemerickno, the extensible reader should enable it
01:22sritchiecemerick, got it all working, thanks again
01:22cemericki.e. you bind #clj to return nil on cljs, and #cljs to return nil on clj
01:22cemericksritchie: nice
01:22sritchiecemerick: one qq, though -- for some reason, when I query a view with a reduce function, I'm getting different results than futon shows for the same view
01:22cemericklike, different order, or actually different data?
01:23sritchiemy reduce is concatenating all values as string, and futon shows it properly -- the get-view function is returning a "nil" key with ALL vals concatenated
01:23sritchiepassing {:reduce false} shows me the proper results of the map step
01:23cemerickfuton defaults to reduce=false
01:24sritchieyeah, but when I click the reduce checkbox I get the proper pairings of key, reduced vals
01:24sritchieoh, I think I see
01:24sritchiethere's a "groupings" dropdown
01:24sritchiefuton has "exact"
01:24sritchiebut if I switch it "none", I get the behaviour I'm seeing in clutch
01:25cemerickyup, it's just different defaults
01:25sritchieso I can pass a :grouping option in the map?
01:26cemericktons of query options for views; check the table halfway down: http://wiki.apache.org/couchdb/HTTP_view_API
01:26sritchiecemerick: sorry to bug you about this stuff, not sure how to track down these options
01:26sritchieoh, great
01:26sritchieso I can pass these in w/ the map as keywords
01:26cemerickno worries. That wiki has tons of gems
01:26cemerickyup
01:26sritchienice
01:26sritchiethanks dude
01:26cemerickjust watch your underscores
01:27cemerickI burned a day because I was mistakenly using :group-level instead of :group_level
01:27sritchiecemerick: oh boy
01:27cemerickI guess I should make clutch normalize that :-P
01:27sritchiecemerick: I'm sure you've heard this before, but I'm going to write this business up
01:27sritchiecouch is too good to let folks pass it by
01:27cemerickwhack away
01:27cemerickI agree
01:27cemerickesp. cloudant
01:28sritchiehaha, control that!
01:28sritchiecemerick: this is probably a generic cljs question, but is there a problem w/ returning clojure vectors from these map and reduce funcs?
01:28sritchiesay I want to make a compound key
01:29cemerickyou mean using a cljs view?
01:29cemerickI honestly don't know.
01:29sritchieyup
01:29sritchieseems to be failing --
01:29cemerickYeah, you may need to explicitly return a js array.
01:29sritchieI suppose I just need to make a javascript array
01:29sritchieyeah
01:30sritchiewhat's the syntax for that?
01:30cemerickno clue
01:30sritchieI guess there's some conversion *embarrassed*
01:30sritchieanyone know how to make a js array?
01:30cemerickFWIW, I've not used cljs views in anything real yet.
01:30cemerickHow's that for embarrassed? ;-)
01:30sritchiehaha, kudos for getting all this working, then
01:30cemerickmaybe (js/Array 1 2 3)
01:31sritchieI'll try it out
01:31sritchieand push to cloudant immediately
01:31lynaghksritchie: you just want (array 1 2 3)
01:31sritchieno js prefix?
01:31sritchiecool
01:32lynaghkI've found it helpful to just paw through the cljs compiler source.
01:32sritchieI've been meaning to do that anyway, I'm sure that would save a lot of pain here
01:32lynaghkthere are a lot of macros in clojurescript/src/clj/cljs/core.clj that are illuminating
01:32cemericklynaghk: see, and you're asking *me* about cljs‌‽
01:32lynaghkcemerick: I asked you about macro magic = )
01:32cemerickheh, fine
01:33dnolenlynaghk: +1. also if people have suggestions / improvement ... :)
01:33scriptorI found it really refreshing how emitting code in the cljs compiler is just printing stuff out to whatever the writer is bound to
01:33scriptorvery simple and straightforward
01:33ohpauleezdnolen: Is there a logical equiv to _
01:33ohpauleez(I'm writing some dead code elimination, and I need a way to express "nothing" in a rule
01:34dnolenohpauleez: just create an lvar with that name (fresh [_] ...)
01:34ohpauleezAhhh cool
01:34ohpauleezthank you
01:34dnolenohpauleez: hmm ... oh in a rule you have ?foo
01:35ohpauleez[(when-not true ?x) _]
01:35dnolenohpauleez: and ?foo in the same expression will be the same var.
01:35dnolen[(when-not true ?x) ?_] should work I think
01:35lynaghkcemerick: as it turns out, you can't return nil from an extensible reader fn: "No dispatch macro for: e"
01:36cemericklynaghk: so return something innocuous, like []
01:36cemerickor (do)
01:37lynaghkohh, (do) sounds nice.
01:38cemerickeh, that'll get a little dicey for returns.
01:38cemerickyou'll end up having to do (or #cljs […] #clj […])
01:39cemerickside-effecting bits will be fine
01:39lynaghkyeah, but I don't think I really want it to become idiomatic for people to mix clj/cljs within forms.
01:41cemerickthat sounds very sane
01:42ohpauleezThanks for everyone's help! Kibit now has dead code elmination!
01:43dnolenohpauleez: :D
01:43sritchieif I call concat on two cljs arrays, will they stay arrays?
01:44dnolensritchie: (.concat a1 a2) yes
01:44sritchieI suppose I could do (apply array (apply concat [arr1 arr2 arr3]))
01:44sritchiednolen: this is for a couchdb view -- one of the arguments is a sequence of values, each of which are js arrays
01:45sritchiednolen: I just want to concat them all together and return a new single array
01:45sritchieI should probably go open up a cljs repl and educate myself
01:45dnolensritchie: in general you can't call cljs fns on js arrays.
01:45dnolensritchie: well you can but expect seq conversion.
01:46sritchiednolen: I'll reduce across the sequence, I guess -- (reduce (fn [a b] (.concat a b)) vals)
01:51lynaghkdnolen, fun discovery: ClojureScript IFn doesn't care what you call the method (-invoke, invoke, foobar, whatever). And it'll happily take more than one, with the last form winning
01:52lynaghk(when using reify or deftype)
03:12greeneggsandspamAny VimClojure users? Is the any way for repl (\sr) to share the nailgun session? I'm trying to get the stuff evaluated via \ef (etc) to show up in the repl
04:03gtuckerkelloggThis seems very strange
04:03clojurebotNo entiendo
04:04gtuckerkellogg,(defrecord Rule [foo bar])
04:04clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
04:12gtuckerkelloggwhy does the map-> constructor for a defrecord abort with type hints?
04:12gtuckerkellogghttp://pastebin.com/FVid7Vb5
04:14gtuckerkelloggnever mind, it's because I used ^int instead of ^Integer
04:14gtuckerkelloggarggh
04:24muhooso how does this cloudant thing work in the free tier? it says "development" but what do they actually mean by that?
04:25RaynesIt means "we'd rather you give us some money"
04:28muhoo"rather", i can live with. "oops, you're screwed, you MUST", i cannot.
04:29muhoo250gb of data is something i will probably never come even close to exhausting, so if that's what they mean by "development", then my "production" will fit that just fine.
04:31Raynesmuhoo: All of those cloud database services mark their free tier as 'development'.
04:31muhoofair enough, thanks.
04:32muhoo500k requests/month, ah. still probably fine.
04:33RaynesWhat if you get slashdotted, hacker newsed, and reddited on the same day?
04:36muhoowhat if i get hit by lightening, win the lottery, and get hit by a bus in the same day? :-)
04:36cemerickmuhoo: I have all but one of my sites on a single cloudant free tier FWIW
04:37muhoothanks
04:37cemerick(regularly replicated back to a local couchdb, but only because I'm paranoid)
04:37clgvmuhoo: chances are that your home gets hit by a hurricane as well ;)
04:38scottjmuhoo: you said 250gb. did you mean 250mb? that's what I see for free cloudant on heroku.
04:39muhooah, yes, it is MB. hmm. still, i probably won't get too close to that
04:40muhooat some point, if i get beyond that, i could always buy a linnode or something and just run couch on that, along with clojure, and whatever else i might want.
05:46fliebelDoes java have any syntax like Clojure, for (import [package class class class])?
05:46ejacksonpackage.* for the lazy folks
05:48fliebelejackson: That's... disgusting
05:49ejacksonglob it up baby
06:43_andrew_kin Java there only:
06:44_andrew_kimport package.Class; // import class
06:44_andrew_kimport package.*; // import classes from package
06:44_andrew_kimport static package.Class.*; // import static methods from class
06:44_andrew_kimport static package.Class.method; // import one static method from class
06:55ZokaIf a jar is specified in :dev-dependencies in project.clj, should it it be avaliable in class path for "lein run" ?
07:01ejacksonZoka: should be
07:02ZokaI was using lein2 - I wil retry with 1.7
07:03ejacksondunno about lein2 yet
07:04ZokaYes, that was it 1.7 is fine
07:04SomelauwWhen trying to load a certain project using clojure-jack-in, emacs says it aborts abnormally. Other projects just work, so I don't get why?
07:05SomelauwI can post the project tree if that helps?
07:05raekSomelauw: what happens if you try to run lein repl in those projects?
07:05raekalso, what clojure versions do they use? where do you have lein-swank, in the project.clj file or as a plugin?
07:05SomelauwBut it would probably help more if I could get some error message
07:06Somelauwraek: Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/reflect__init.class or clojure/reflect.clj on classpath: (user.clj:1)
07:06raekSomelauw: was that error from clojure-jack-in or lein repl?
07:07Somelauwraek: in project.clj I have :dependencies [[clojure "1.2.1"]])
07:07Somelauwraek: lein repl
07:07raekSomelauw: do you have stuff in a user.clj file?
07:08raeklooks like you use features introduced in clojure 1.3 there
07:09Somelauwraek: yes, it includes reflect.
07:09SomelauwI will try without
07:09bsteuberZoka: in lein2, the syntax for dev-dependencies is different
07:10Somelauwraek: thanks, it is working again
07:10bsteuberyou write :profiles {:dev {:dependencies [..]}] now, that it'll also be in the classpath
07:10bsteuber*then
07:12raekSomelauw: I think clojure-jack-in errors are visible in the *Messages* or *swank* buffers
07:13Somelauwraek: thanks, I found the error in the old one
07:13Somelauwwhich was the same as lein repl
07:17Zokabsteuber: do tou have a reference?
07:21bsteuberZoka: this might help a bit: https://github.com/technomancy/leiningen/blob/master/sample.project.clj
07:22bsteuberalso https://github.com/technomancy/leiningen/wiki/Upgrading, but there's not so much information yet
07:24ZokaThanks, I was just about to go through source. I would not want to go back to 1.7 if I can help it
07:25clgvdoesn't lein2 include warnings for deprecate options? if not, there should be a ticket for that ^^
07:42Zokabsteuber: I got it, here it is for Google to find, thanks again for pointer:
07:42Zoka; :dev-dependencies equivalent for Lein 2.0
07:42Zoka(defproject ringmon "0.1.2-SNAPSHOT"
07:42Zoka :description "Ring handler to inject web page with nREPL front end"
07:42Zoka :dependencies [[org.clojure/clojure "1.3.0"]
07:42Zoka [ring/ring-core "1.0.1"]
07:42Zoka [org.clojure/java.jmx "0.1"]
07:42Zoka [clj-json "0.5.0"]
07:42Zoka [org.clojure/tools.nrepl "0.2.0-beta2"]]
07:43Zoka :dev-dependencies
07:43Zoka [[ring/ring-jetty-adapter "1.0.1"]] ; keep this for Lein 1.7
07:43Zoka
07:43Zoka ; lein 2.0 dev-dependencies equivalent
07:43Zoka :profiles {:dev {:dependencies [[ring/ring-jetty-adapter "1.0.1"]]}}
07:43clgvZoka: use a oaste service
07:43Zoka :main ringmon.server)
07:43Zokabsteuber: I got it, here it is for Google to find, thanks again for pointer:
07:43Zoka; :dev-dependencies equivalent for Lein 2.0
07:43clgv*paste
07:43Zoka(defproject ringmon "0.1.2-SNAPSHOT"
07:43Zoka :description "Ring handler to inject web page with nREPL front end"
07:43Zoka :dependencies [[org.clojure/clojure "1.3.0"]
07:43Zoka [ring/ring-core "1.0.1"]
07:43Zoka [org.clojure/java.jmx "0.1"]
07:43Zoka [clj-json "0.5.0"]
07:43Zoka [org.clojure/tools.nrepl "0.2.0-beta2"]]
07:43Zoka :dev-dependencies
07:43Zoka [[ring/ring-jetty-adapter "1.0.1"]] ; keep this for Lein 1.7
07:43Zoka
07:43clgv:(
07:43Zoka ; lein 2.0 dev-dependencies equivalent
07:43Zoka :profiles {:dev {:dependencies [[ring/ring-jetty-adapter "1.0.1"]]}}
07:43Zoka :main ringmon.server)
07:44ZokaSorry, I thought this was short enough
07:45clgvshort enough are only oneliners ;)
07:46ZokaAnyway, I am very happy with lein2 - much faster
07:48bsteuberyes lein2 is getting great
10:58y3diwhats up homies
11:32unlinkWhat is Clojure's RAII equivalent?
11:39unlinkFor resources such as open files or temporary files which need to be deleted.
11:39ferdunlink: you have with-open for example, and it's easy to write your own with macros
11:41clgvunlink: with-open like ferd said. but be careful with lazy sequences within an with-open macro
11:43unlinkI'd rather not write a boilerplate-y macro like with-open for each type of finalization that I need to do
11:44unlinkand it would be nice if I didn't have to lexically scope the resources I allocate (a la GC)
11:46clgvunlink: huh?
11:47unlinkfor example, I want to do something like this: TempFile x = new TempFile(); if (someCondition) { x = TempFile.basedOne(x); } doSomethingWith(x); /* in finalizer .. delete all temp files created so far */
11:47unlink*basedOn(x)
11:48unlink(with-tempfile [x (make-tempfile)] (with-tempfile [x (if condition (tempfile-based-on x) x)] (do-something-with x))) ;; this will attempt to delete x twice if condition is false
11:48tomojcouldn't you implement that with weak references? I feel like the answer must be "no"
11:49tomojoh, I was thinking of doing it without with-tempfile
11:49clgvunlike: first you dont need with-tempfile. just use with-open. and only use it for those bindings that need to be ".close"d finally
11:50unlinkclgv: Who is going to delete those tempfiles then?
11:50clgvyou implemented TempFile yourself?
11:51unlinkclgv: well, in my putative pseudo-Java, there would be a TempFile class which deletes its underlying file in the finalizer.
11:53clgvunlink: well ok then write with-tempfile - you will be deleted twice will only happen if 'tempfile-based-on returns the same file, but then you should use the macro only once
11:53clgv*your "will be deleted twice"
11:54cemerickunlink: FWIW, finalizers have always been unreliable, and are getting moreso
11:54unlinkclgv: The issue is that I want to conditionally shadow the temporary file based on a condition, but the with-tempfile macro doesn't know that (it would have to delete idempotently).
11:55clgvunlink: then implement the deletion method that your macro will call with a check ;)
11:56unlinkclgv: yes, in fact, that is what my implementation has. I was just hoping that I could finalize resources without a dozen lines of boilerplate.
11:57unlinkclgv: It's also not clear to me how I would extend this notion to, say, a (variably-sized) list of files I want to delete.
11:58unlinke.g. how would I implement (with-tempfiles [xs (map make-tempfile ys)] ...) in terms of make-tempfile?
11:58clgvsimply (finally (doseq [x xs] (.delete x)))
11:59clgvunlink: but you have to decide if it is always a collection or whether you need a check for that
11:59unlinkwhat is "finally"?
11:59clgv(try ... (finally ...))
12:00unlinkclgv: true, but now I must duplicate the logic that recursively calls with-tempfiles, checks for symbols, the base case, etc.
12:01clgvI don't understand that comment
12:05clgvcemerick: ++ for your type flowchart
12:06cemerickthanks, glad it's useful
12:06clgvwasnt sure whether I wanted reify or proxy ;)
12:09unlinkclgv: hmm, apparently you can't doseq inside of (finally ...)
12:10clgvunlink: why should that be? you can execute any code in there
12:11unlink,(try nil (finally (doseq [x (range 10)] (println x))))
12:11clojurebotunlink: It's greek to me.
12:11unlinkCompilerException java.lang.UnsupportedOperationException: Cannot recur from catch/finally, compiling:(NO_SOURCE_PATH:1)
12:12Bronsawow.
12:12Bronsawhy is it so?
12:13unlinkbug in the compiler.
12:13cemerickbeen that way for a while
12:14clgvunlink: the put it in a function and call that function
12:14cemericka result of a prior fix to prevent recur from branching out of a recur; the easy fix was to just disallow recur within finally
12:14unlinkhttp://paste.lisp.org/display/128516
12:15unlinkanyhow, I'd like to cut down on the boilerplate there without being excessively clever.
12:17tomojdoes that paste suffer from the recur/finally problem, or does introducing a function solve it?
12:18unlinkthe function in that paste does work around the recur/finally problem.
12:18tomojoh, good
12:18tomojI was thinking the problem was much worse.. :)
12:21unlinkIt might be the case that *more* metaprogramming is the solution to my program, but at some point I'd like to just delete some files.
12:23unlink(fortunately java.io.File#delete happily proceeds when asked to delete a nonexistant file)
12:29dnolencore.logic port to CLJS is coming along ...
12:31jonasendnolen: Thanks again for your latest comment on kibit#20 and sorry I haven't had time to respond yet
12:31ibdknoxdnolen: that'll be neat :)
12:32TimMc,(try nil (finally (#(doseq [x (range 10)] (println x)))))
12:32clojurebotTimMc: No entiendo
12:32TimMcAh well.
12:33ibdknoxTimMc: ?
12:33TimMcTried it in my own REPL -- same compile error.
12:33mk"UnsupportedOperationException: Cannot recur from catch/finally"
12:34TimMcibdknox: I was seeing if a fn literal would allow me to evade the check.
12:34ibdknoxah
12:50jayunit100any tricks to print clj files to pdf ....
12:50jayunit100i.e. syntax highlighted
12:52gtrakjayunit100, I did some quick googling: http://stackoverflow.com/questions/946858/convert-syntax-highlighted-code-to-html-in-emacs
12:53gtrakapparently there's also a way to print the buffer, assuming you use emacs, of course
12:53clgvhow to get hold of the clojure classloader?
12:53zamaterianjayunit100, in vim http://www.plainlystated.com/2009/08/vim-tohtml-customization/
12:53gtrakbut once you have html, you can copy-paste into libreoffice or something
12:59jayunit100zamaterian: ok thanx
13:05jayunit100daymn that looks complicated
13:07gtrakjayunit100, you can also use pygments perhaps?
13:10gf3ibdknox: you know what'd be hawt? Source maps for noir-cljs :D
13:10ibdknoxsource maps would be at the cljs compiler level
13:10ibdknoxthere was brief discussion about them yesterday :)
13:11gf3ibdknox: ahh
13:11gtrakwhat could also be hawt, source maps for java sources pulled in by maven
13:12muhoowhat is a source map?
13:12mkgf3: link to yesterday's logs: http://clojure-log.n01se.net/date/2012-03-22.html
13:13mkmuhoo: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
13:13gf3mk: awesome, thank you
13:14muhooah, like in GCC
13:15muhoo.lss file :-)
13:26muhoosource map https://refheap.com/paste/1318 :-) hmm, looks like refheap doesn't do asm.
13:31Togoi guys. I'm new at clojure and trying to check whether a string contains only integer. Can anybody help me out. I have something like this: (defn only-integer? [string] (empty? (map integer? (.parseInt string))))
13:32stuartsierraTogo: how about a regex?
13:34Togoi've tried it, but failed with regex ;-( can give me any suggestions?
13:34ejacksonstuartsierra: now he has two problems ! (YESSSSSSSSS !)
13:34stuartsierra:)
13:34RickInGAejackson ftw
13:35stuartsierraTogo: (re-matches #"\d+" the-string)
13:35Togothanks a lot stuartsierra
13:36stuartsierraFlavor to taste for leading +/- signs, commas, etc.
13:37mkTogo: what counts as an integer? If you're going by what is accepted by parseInt, you should just use parseInt and return false when it throws its exception
13:37mki.e. "an integer is whatever parseInt successfully reads"
13:42Togoi also tried it with try and catch but my attempt failed. My plan was to give the parseInt function a trimmed String. If i can parse it give me true if i get an exception false. But i never got an return value.
13:42TimMc&(Integer/parseInt "012")
13:42lazybot⇒ 12
13:42TimMc&(Integer. "012")
13:42lazybot⇒ 12
13:43Togomy code with try and catch: (defn only-integer? [string] (try (.parseInt string) true (catch Exception e) false) )
13:43mk&(Integer. "twelve")
13:43lazybotjava.lang.NumberFormatException: For input string: "twelve"
13:44TimMcHuh, I guess Integer doesn't do the octal switch.
13:45stuartsierraTogo: your parens are misplaced
13:45VinzentTogo, (Integer/parseInt string), not (.parseInt string). parseInt is a static method of the Integer class
13:45stuartsierra(try (Integer/parseInt the-string) true (catch Exception e false))
13:47mknote that what java considers an integer is an infinitely tiny subset of what the clojure reader considers an integer
13:48Vinzentmk, hm, clojure integers are java integers, aren't they?
13:48Vinzentor longs
13:49mkclojure is fine with 48573428563426534875248792348
13:49Vinzentyeah, but technically it's a BigInteger, not integer
13:49Togook thanks guys this works for me! the further discussion is yours :-)
13:51mksure - BigInteger, not int or Integer. I just mean that clojure has a different notion of how big integers can get :)
13:51mk(by default)
13:52TimMcand then there's BigInt...
13:53TimMc&(class 4N)
13:53lazybot⇒ clojure.lang.BigInt
13:53eggsbyare there any pubsub libs for clojure?
13:53mkinteresting, I didn't know it used its own. Why does it do that?
13:54Vinzentmk, agree, you're right :)
13:54dnolenjonasen: no problem, hopefully it makes sense - basic idea would be to do a parse pass to normalize rules, you could even do this as a macroexpansion pass if you don't plan on manipulating the rules in the original form.
13:54Vinzenthm, I also thought bigint creates java's BitInteger
13:55llasram"clojure.lang.BigInt ... is similar to Java's java.math.BigInteger in allowing integer sizes exceeding 64 bits, but provides better performance by delegating to native operations when small enough." http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
13:57mkone thing that occured to me is that instead of using e.g. floats in clojure, it might be possible to define *float, which does a float multiply
13:57hyphaestusahh it's a wonderful day
13:57mkit converts its two arguments to floats, and then multiplies them in the typical lossy way
13:59mkI'm not sure how things work now, but if + yields different results for (+ .1 .2) when those are floats, that's a bad thing
14:00mk,(+ 0.1 0.2)
14:00clojurebot0.30000000000000004
14:01rhcany number with a . is a float in clojure, right?
14:01rhc,(+ 1/10 2/10)
14:01clojurebot3/10
14:01technomancyrhc: no, there are bigdecimals too
14:01rhcah
14:01mkwhat's the notation for bigdecimal?
14:01rhci thin x.yM
14:02rhc,(+ 0.1M 0.2M)
14:02clojurebot0.3M
14:05mkthat seems wrong to me. It might not be possible, but a float value should be lazily converted into a decimal when it hits a proper math operator - until then, it can be used in e.g. (*f 0.1 0.2) without a conversion occurring
14:05edwIs the a CLJS channel?
14:06dnolenedw: it's the Clojure channel, CLJS is a Clojure implementation, so yes :)
14:06mkthis connects the screwedupness of float math to the function, not to the datatype
14:06TimMcedw: There is now.
14:07edwdnolen: OMG I am not feeling well. Too much fun at Vol du Nuit last night.
14:07edwApologies for my incoherent English.
14:07TimMc(There's only one other person in #clojurescript, I'd stay here.)
14:08mkwhat's the proper name of java clojure, then?
14:08TimMc"Clojure"
14:08edwI was looking through the CLJSone demo, and I was wondering where the design/development/deployment toolbar was deactivated in the production version. I find that magic a bit bewildering.
14:08stuartsierraedw: it's a Ring middleware
14:08technomancymk: afaik we don't have the words we need to distinguish that kind of thing
14:09edwThat strips out DOM nodes based on a header or deployment type or somethng?
14:10mktechnomancy: maybe it'll come up as clojure lisps are created on more platforms
14:10edwAh, using Enlive, I suppose.
14:14chouser_I've used "ClojureJVM" when a distiction is really needed, which is pretty rare.
14:15stuartsierraedw: yse
14:15stuartsierrayes
14:15technomancy"True Clojure"
14:24skarayanwhat is the accepted best way to do distributed computing in clojure?
14:24mkskarayan: what sort of distributed computing?
14:24ChironStorm? https://github.com/nathanmarz/storm/wiki
14:26antares_skarayan: it depends on how you define "distributed computing". if you need a "real-time Hadoop", look at storm. If you just need a solid messaging protocol, AMQP with github.com/michaelklishin/langohr is a good option
14:26stuartsierraAlso check out David Liebke's Avout.
14:26antares_if you want to build something peer-to-peer, zeromq is what you need
14:27ChironSpeeking of Avout, it is "distributed" identity?
14:28stuartsierraChiron: more or less, yes
14:28antares_Chiron: it is distributed (no quotes) state
14:28stuartsierradistributed Atoms and the like
14:30ChironWhat are the typical uses cases for Avout? currently I'm using Storm
14:33edwstuartsierra: Actually, that snipping can't happen in Ring, as the page is composed on the client side (if I am not mistaken).
14:34stuartsierraedw: the server renders the base layout
14:35edwHuh. Gawd I despise magic.
14:39edwstuartsierra: ...but I love find(1) and 'grep -H ...'.
14:50ChironSometimes, I'm really locked in OOP thinking. I create an atom or ref and then start mutating. How to get ride of this?
14:51technomancymaybe kibit could suggest atom -> reduce transformations =)
14:52emezeskeedw: Have you tried ack? For the simple cases, it's a nice replacement for find ... | xargs grep ...
14:53mkperhaps simply forbid yourself from using those. If you have a particular example of where you're using them, and aren't sure what else you could do, ask here
14:54ChironI let a data structure, perform some operations and then to update the letted data structure. that is why I'm using atoms
14:54dnolenibdknox: did you the ML post about the GSoC game editor proposal?
14:57mkChiron: hmm - how about a pastebin/gist of the source?
14:59mkhow can I eval text? e.g. (eval "(+ 1 2)") -> 3, or -> (+ 1 2)
15:00TimMcmk: read-string, then eval
15:00TimMcI hope that's for a config file.
15:01mkTimMc: reading the reference and was just wondering
15:01mkthanks
15:01TimMcOK. :-)
15:02edwmk: To a first order approximation, eval is equivalent to regular expressions in jzw-land: "Now you have two problems."
15:02TimMcmk: Obligatory caution: Bind *read-eval* to false when you use read-string or read on user-provided data strings.
15:02TimMcedw: jwz
15:03edwD'oh. Again, last night...still recovering.
15:03edwLZW, on the other hand...
15:03rhcTimMc: speaking of that, is it possible to quote a literal string in clojure?
15:03rhcsomething akin to 'string' in other languages, or do you simply have to escape every \ and \t with \\ and \\t ?
15:03mkwhen is read-string usually used? The repl?
15:05Chiron@mk https://gist.github.com/2173859
15:05edwrhc: Are you asking about the existence of here-document like syntax in Perl, shell scripts, and so forth?
15:06rhcedw: sort of, but the multiline thing is unnecessary
15:07rhcits more like if i'm building up a regex, i have to do stuff like (re-pattern (str "\\s\\?\\\\" some-input))
15:07edwrhc: It usually doesn't take much before I decide to throw something in the resources directory and load it.
15:07TimMcAh, yeah.
15:07rhci wouldn't say its big enough to warrant loading it from some config, but i see where you're coming from
15:07rhcits just an annoyance, but nothing major
15:08rhcat least #"\s\?\\" works nicely
15:09mkanyone know how https://gist.github.com/2173859 can be done without using an atom?
15:11DerGuteMoritzmk: just `let' slave again
15:11emezeskemk: Couldn't you just (let [slave (:slave master) new-slave (assoc slave :status success)] ...)
15:11mkChiron: ^
15:11ChironI thought about it, but I'm trying to force myself not to overuse let forms
15:11emezeskeChiron: You should probably use let forms a lot
15:12Chironreally?
15:12TimMc&(seq (str #"\t"))
15:12lazybot⇒ (\\ \t)
15:12Chironwouldn't this complicate code?
15:12edwBut introducing mutation to reduce let forms is like commiting suicide to avoid the common cold.
15:12Chousukehehehe
15:12DerGuteMoritz(let [master (get-it-from-somwhere) slave (:slave master) slave (if (< 0.7 (rand)) (assoc slave :status success) slave)] ...)
15:12emezeskeChiron: All let does is give a name to some intermediate result, that's not complicated
15:12TimMcrhc: It's a bit horrible, but (str #"foo") is a hack that gets you a raw-like string.
15:12ChousukeChiron: you might try to see if you need the inteermediate variables at all
15:13Chironyou know, let inside let ..
15:13DerGuteMoritzChiron: just rebind the same name again in the same let
15:13Chousukein that let, for example, the rand is dubious
15:13DerGuteMoritzChiron: see my example above
15:13rhcTimMc: yeah i noticed that, pretty interesting, but handy for cutting down the \\s in regex syntax
15:13rhcand nice for compile-time regex syntax checks..
15:13DerGuteMoritzChousuke: how so?
15:13TimMcrhc: Oooohh...
15:14ChousukeDerGuteMoritz: it feels like it's putting side-effects in middle of code that could be pure
15:14Chousukethat's generally not a good thing to do
15:14Chironso this (let [master (get-it-from-somwhere) slave (:slave master) slave (if (< 0.7 (rand)) (assoc slave :status success) slave)] ...) is an idiomatic lisp/clojure?
15:14TimMcYou'd still want to inject that randomness somehow (to allow testing.)
15:14DerGuteMoritzChousuke: well if you need the result of a side-effect you have to do it this way when mutation is not an option
15:15Chironit looks like accumulating all logic in one form
15:15DerGuteMoritzChiron: I do it pretty regularly, yes
15:15DerGuteMoritzyou can still break it up into smaller functions
15:15DerGuteMoritzif it gets out of hand
15:15Chousukeyou might put that (if rand ...) thing in another function
15:15DerGuteMoritzthat's right
15:15DerGuteMoritzthe side-effect is still there though
15:15DerGuteMoritzof course :-)
15:15DerGuteMoritzthe right hand side of a let form shouldn't grow too large vertically
15:16DerGuteMoritzespecially in clojure
15:16DerGuteMoritzwhere there is no grouping of names and values
15:16DerGuteMoritzas opposed to most other lisps
15:16ChironI should hang out here much much more :)
15:16Chousukethen do (let [slave (decide-success-for-slave (:slave (get-master-from-somewhere)))] ...)
15:18Chousukethe side-effect is still there but at least it's in its own unit of code
15:18DerGuteMoritzright
15:18Chironyou mean inside do form?
15:18Chousukeinside the function
15:18Chousukeyou can mark the function with ! to make it even more explicit
15:18Chironfor example, my rand logic and save to mongo should be refactored to a seperate function
15:19Chousukeyeah. in general, keep side-effects and pure code as separate as possible
15:19Chousukethen write a couple functions where you tie them together
15:20Chousukethat way, you can develop the pure code separately from the rest of the system.
15:20ChironHmm. my FP elf is smiling
15:20Chousukesince it has no implicit dependencies on anything
15:20Chousukeso you can just make up some data for it and test it
15:21mkare metadata maps used much?
15:21Chousukethen when it works acceptably you can worry about getting real data from whatever database you have :P
15:22Chousukemk: Clojure itself uses them for docstrings and such. I think metadata in general is not very often needed but I'm sure you'll be glad it's there when you do need it
15:23mkChousuke: gotcha
15:23Chousuketype hints are metadata too
15:24mkright - I saw that, and was wondering if there were common uses besides that
15:24ChousukeI'm not sure. it seems to be one of those features that are completely useless until you need it.
15:24Chousukeand then it becomes something that saves you hours of headache
15:27mk"If the operator of a call is a symbol that names a global var that is a macro function, that macro function is called and is passed the unevaluated operand forms" - the operands to non-global vars aren't left unevaluated?
15:27amalloyprotocols use metadata on vars for something. maybe to keep up to date as protocol definitions change? it's not really obvious to me
15:28Chousukemk: there are no local macros
15:28amalloythere are no non-global macros
15:28unlinkto those intererested, here is a macro which abstracts the commonalities between with-tempfile and with-tempfiles (also with-open): https://gist.github.com/2174086
15:28mkah, I see.
15:28unlinkconcerning the earlier conversation. /cc cemerick Bronsa
15:30Chousukeunlink: why is the finalizer a function? for simplicity of implementation? :P
15:30TimMc*macrolet
15:30amalloymacrolet is great. i wish it were part of the language instead of an enormous macro
15:30Bronsawhich conversation.
15:31Chironwhat does this mean for Clojure? http://www.shenlanguage.org/
15:31unlinkChousuke: a better interface wasn't immediately apparent.
15:31Bronsai tend to forget things
15:31unlinkBronsa: about try/finally.
15:31Bronsaoh.
15:31TimMcamalloy: It just makes some gensym-named defmacros and uses them?
15:31Chousukeunlink: well, you could write a macro that is called like (defwith with-delete [x] (.delete x))
15:32tmciverWhere can I find macrolet?
15:32amalloyclojure.tools.macro
15:32Chousukemacrolet shouldn't be that difficult to implement in the clojure compiler itself actually
15:32ChousukeI wonder why it's not yet done :/
15:33unlinkChousuke: yeah, but it seemed strange that the binding would always have just one parameter...it seemed more natural to do something like #(.delete %)
15:33Chousukeno-one wants to code in java?
15:33samaarondoes anyone have any good solutions for letting people plug in logging solutions to their libraries?
15:33Chousukeisn't there a clojure logging library or two already
15:33amalloyTimMc: no, it does a lot more work
15:33samaaroni.e. I have a lib, and my own logging solution, but I want people to be able to use my library with their specific logging solution
15:33cemerickChousuke: it's been done at least a couple times already
15:34samaaronthe only thing I can think of is to use dynamic bindings
15:34samaaronand let people dynamically bind their logging fn
15:36amalloysamaaron: clojure.tools.logging tries to do this but my understanding/experience is that it's a tremendous hassle to do any kind of logging in clojure these days
15:37samaaronamalloy: ok - that's a shame
15:53hugodsamaaron: clojure.tools.logging works - using logback as the logging implementation gives zero config logging to stdout
16:05sandover_writing a tiny server -- what logging should i use? currently a lot of println
16:11niclHey, guys. New to clojure. Trying to use the find-doc function in the repl. But using (clojure.repl/find-doc "example") gets a class not found error
16:14niclany thoughts. Guessing it is something stupid
16:15Bronsayou probably are using clojure 1.2
16:15dnolennicl: you can just use clojure.repl like that, you need to require it first, (require 'clojure.repl)
16:15Rayness/can/can't/
16:15dnolennicl: I suggest that you just use lein2, it comes with a very, very nice repl.
16:16dnolenRaynes: ooops, yeah thx.
16:16RaynesThat unfortunately leaves abandoned java processes when closed at the moment. Should be fixed soon.
16:16nicldnolen: I'm trying to use lein with Emacs.
16:16RaynesBut it is indeed pretty nice.
16:17dnolennicl: if you're on lein < 2 you will need to require clojure.repl first
16:18nicldnolen: ah, ok. So even namespacing it is needs to be required. Guess that makes sense (although maybe not for a repl program!)
16:19nicldnolen: yep, apparently I'm on 1.7.0 for leiningen
16:27dnolensome more testing to do, but core.logic is basically ported to CLJS
17:24replaca_technomancy: if I wanted to read a project.clj, am I safe just skipping project and version and then doing (into {} (partition 2 the-rest))?
17:25technomancyreplaca_: depends on what you're going for; you'll miss out on all the normalization
17:26replaca_I mostly just want to get the version and dependencies
17:26technomancyshould be fine for that, yeah
17:26replaca_cool, thx
17:28antares_sandover_: github.com/clojure/tools.logging
17:47brianmI'm using the maven shade plugin to build an uberjar which includes some embedded clojure, a la
17:47brianmIFn f = (IFn) clojure.lang.Compiler.load(new StringReader("#(+ 1 %)"));
17:47brianmwhen run from the ubjerjar, this explodes with an NPE in
17:47brianmCaused by: java.lang.NullPointerException
17:47brianm at clojure.lang.RT.load(RT.java:424)
17:47brianm at clojure.lang.RT.load(RT.java:398)
17:47brianm at clojure.lang.RT.doInit(RT.java:434)
17:47brianmgoogle doesn't seem to know about it :-(
17:47brianmanyone know how to work around?
17:48brianm(clojure 1.3.0)
17:49brianmseems to be under
17:49brianm load("clojure/core");
17:59_andrew_kbrianm: is it full stack trace ?
18:04brianm_andrew_k: one sec
18:04brianm_andrew_k: https://gist.github.com/ace0db1c630356dda0be
18:04brianmline 3 is what it is trying to compile
18:05brianmswitched out to MVEL -- for minimal expression stuff mvl is actually nicer, I justw anted excuse to embed clojure :-)
18:06hugodreplaca_: you could also use leiningen.core, now that it is a lib in lein2
18:13_andrew_kso i can explain this error
18:13_andrew_klook at stack trace - top block of code
18:13brianmlooking
18:13_andrew_kat this line at org.skife.pummel.cli.Step.call(Step.java:70)
18:14brianmyep
18:14_andrew_kyou are calling some method of Compiler class
18:14brianmyes
18:14brianmIFn f = (IFn) clojure.lang.Compiler.load(new StringReader("#(+ 1 %)"));
18:14_andrew_kat clojure.lang.Compiler.<clinit>(Compiler.java:222)
18:14_andrew_kin this line <clinit> means that this is call in class loading code code
18:14brianmyes
18:14_andrew_khttps://github.com/clojure/clojure/blob/clojure-1.3.0/src/jvm/clojure/lang/Compiler.java
18:15_andrew_kline 222
18:15brianmyes
18:15muhootechnomancy: i'd like to take you up on your offer to explain the innards of lein and lein-repl, but today has pretty much evaporated already
18:15brianmit is trying to load clojure/core
18:15brianmwhich it should be pulling crom clojure/core.clj on classpath
18:15_andrew_kin this line you are calling something in Namespace class
18:16_andrew_kin constructor of namespace class you are calling method from RT class
18:16_andrew_knot look at bottom block
18:16_andrew_kagain <clinit> - it's statis code initialization of RT class
18:17_andrew_k*two line before `not` -> `now`*
18:17_andrew_kcode in RT class passes through to method load
18:17_andrew_khttps://github.com/clojure/clojure/blob/clojure-1.3.0/src/jvm/clojure/lang/RT.java
18:17_andrew_kNPE throws at line 424
18:18brianmyes
18:18brianm if(booleanCast(Compiler.COMPILE_FILES.deref()))
18:18_andrew_kNPE can be thrown when you dereferencing null pointer (or compiler does it - unboxing for example)
18:18_andrew_kin this line there only one possible dereferencing
18:19brianmyes
18:19_andrew_kit's getfield COMPILE_FILES of Compiler - Compiler.COMPILE_FILES
18:19_andrew_kand if you can see in Compiler class
18:19_andrew_kthis is 233 line
18:19brianm_andrew_k -- right, i can read the stack trace, but there is a lot of static initialization magic going on, and was wondering if anyone had thit this one before
18:19brianmI'd prefer to not debug through clojure to work out if I can ;-)
18:20_andrew_kand now - some lines before... remeber that we in line 222 go out from this class
18:20_andrew_kso out 233 line now not initialized yet
18:20_andrew_kout -> our
18:20brianmstatic final public Var COMPILE_FILES = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
18:20brianm Symbol.intern("*compile-files*"), Boolean.FALSE).setDynamic();
18:20brianmshould not
18:21brianmerg
18:21_andrew_kin 222 line of initializing Compiler class our code go out in Namespace class (top block of stack trace) and 233 line have not been initialized yet
18:21brianmoh my, static init race
18:21_andrew_kit's cycled initialization
18:22matt444Hello, new Clojurian here. Can anyone explain to me -> when it is a function name?
18:22brianmnasty
18:22matt444This is what I'm having trouble grepping: https://github.com/ibdknox/pinot/blob/master/src/pinot/util/clj.cljs
18:23drewrmatt444: it's actually a macro; called the "threading macro"
18:23brianmhmm, so if I explicitely access RT for somethign first, should correct the order
18:23pyninjamatt444: the name of that function is "->coll", it's just a name
18:23matt444really?
18:23matt444ah
18:23matt444ok, I was confused having read about the piping functionality
18:24pyninjamatt444: yeah, looks like calling ->coll on anything returns itself if it's a collection already otherwise returns a vector with it as first element
18:24_andrew_kbrianm: you can thy to initialize core classes first just by calling some static variables from them by calling Class.forName("Compiler") and others
18:24brianmyeah
18:25matt444pyninja: gotcha, thanks a lot
18:25brianm_andrew_k: thanks for help!
18:26brianm_andrew_k: explicity just called RT.init() ahead
18:26brianmworked a charm
18:26brianmof course, no need for it...
18:32mstumpis there a way to quote a blob of text (json) in a test such that I don't have to go through and escape every "
18:34gtrakmstump, dump it in a file and slurp it
18:34gtrakI made a snippets folder for my web-app just for that reason
18:36mstumpyeah, i do that for bigger chunks of json, but for something small I like to have it next to the test
18:56mkis there a way to test if a form will produce side-effects when evaluated?
18:56emezeskemk: Not in clojure; you want Haskell for that ^_^
18:58tmcivermk: the presence of (do ... is a good indicator.
18:58mkis there any reliable way, for at least some subset of forms?
19:01TimMcmk: "Some subset"? Sure. :-P
19:02mkTimMc: how? :)
19:04emezeskemk: You could parse the sexpr tree looking for specific forms in call positions, but that's going to be soooo inaccurate
19:07mkit would be nice if for example an editor could mark which functions are functional, which ones are at risk of evaluating non-functional args, and so on
19:07amalloymk: TimMc's point is that "some subset" gives him a lot of leeway. eg, for the subset '#{inc, doseq}, you can be sure
19:09emezeskemk: It's a losing battle. Imagine (defn higher-order-io [write-fn] (write-fn "stuff")).
19:09emezeskemk: Is that pure? What if you pass in a write-fn that is impure?
19:11amalloyyou need a type system as thorough as haskell's to answer this question, and that has its own problems
19:11mkyou'd mark the function as potentially executing its args. If you know that its arg function is pure, then you're safe, no?
19:12emezeskeHow do you know its arg function is pure?
19:12emezeskeOr the arg function's arg function?
19:14emezeskeWhat if higher-order-io is part of the public API for your library? You don't even know what write-fn will be passed to it.
19:16mkbecause the arg is defined somewhere in the code. If it's in the public api, you expose the fact that your function does or might or doesn't eval its arguments. Then the user of the lib can have that info
19:16mephist0it seems tedious to me to update a map redefining it every time, is there a way to keep it mutable?
19:18mkmephist0: the map never becomes mutable, if I understand you right
19:18mkyou might use a mutable map implementation, but that's probably a bad idea
19:19mephist0mk thnks. i meant dinamic.
19:22mkmephist0: maybe someone could take a look at your code and make a suggestion (pastebin/gist)
19:24mephist0somethig easy like rhis: (def map_ {:a 1 b 2}) (def map_ (assoc map_ :c 3))
19:25matt444ClojureScript gives really bad error messages :(
19:25mephist0i want to keep map_ dynamic to avoid redefining.
19:26emezeskematt444: This is true! There is discussion here on how to make them much, much better: https://groups.google.com/forum/?fromgroups#!topic/clojure/u5uFFaZpHTU
19:26matt444Just pointing to what the file and line number of the error is would do wonders
19:27emezeskeYep, that's exactly what that discussion is about
19:30ScorchinWhat's a good way to test that println has been called and a certain kind of input has been produced?
19:30Scorchins/input/output
19:30dnolenmatt444: we're working on it
19:31dnolenemezeske: is it possible to give multiple source paths? I'm trying to figure out how to easily run some tests
19:31mkmephist0: why bind when you could just do (#(assoc % :c 3) {:a 1 :b 2}) ?
19:32matt444dnolen: Thank you, very well appreciated.
19:32emezeskednolen: You can't specify multiple source paths. I think the easiest thing to do is to add another build for the tests. All of the builds are added to the classpath, so the test build can access the other builds.
19:32matt444I get some WARNs when it compiles, could those be a source of the error?
19:32emezeskednolen: Example: https://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/advanced/project.clj#L74
19:33winkhm, can't I just copy a tool-0.2-SNAPSHOT.jar to ~/.lein/plugins with lein2 and use that instead of the "official" tool-0.1.jar? lein tries to download it and fails
19:33mkmephist0: if you find yourself writing x =1; x = x+1; x = x+2, what you should really be writing is (+ 2 (+ 1 x)), or somesuch
19:34antares_I need a bit of advice. I have "factory" kind of protocol that always returns the same type of data. Should I just add a return type hint to it? then all the namespaces that use it will have to import that data type (it is not part of java.lang.*). Not sure what to do… this is in a library.
19:35antares_I see that clojure.java.io/Coercions protocol does have return type hints
19:35antares_but they seem to be using fully-qualified class names
19:35antares_is this the secret?
19:36mkantares_: does the fully-qualified class name make the namespaces not need to import?
19:36matt444My problem turned out to be I didn't close my (ns) function, lucky it was easy!
19:37antares_mk: yes, and it makes perfect sense
19:39mkantares_: were there any other problems with adding type hints, or are you going to go along with the Coercions usage?
19:40antares_mk: I sort of already have the answer
19:40mkantares_: great :)
19:40antares_using fully-qualified class names in return type hints is the way to go
19:41antares_it will both eliminate some annoying reflection warnings for lib users and they won't have to import classes they should not really know about
19:42dnolenemezeske: k tried that, any thoughts on why I would be a seeing a google.require error about not having provided a namespace?
19:42dnolenemezeske: project looks something like this, https://gist.github.com/2176408
19:43ScorchinIs there any way to catch the output of *out* ?
19:43mephist0mk: thanks. I'm starting clojure, so to test i solved a problem, a chess960 game generator (http://pastebin.com/P0kSsfUa). What seems to me "akward" is to redefine a map every time. But hey im noob here, just testing.
19:44emezeskednolen: what version of lein?
19:44dnolenemezeske: 1.7
19:44emezeskehrm, let me ponder that
19:45dnolenemezeske: https://gist.github.com/2176408 updated gist with tests.cljs
19:46emezeskednolen: did you try doing a 'lein cljsbuild clean' ? Not that I think you should have to do that, but...
19:46dnolenemezeske: I'm on 0.1.2, 0.1.3 is out I see
19:46emezeskednolen: Yeah, I saw that, might be worth upgrading but I don't think it will help XD
19:47dnolenemezeske: yeah, nicer output, same error :)
19:47emezeskehaha
19:48mkmephist0: why does redefining seem awkward?
19:50emezeskednolen: what namespace is it complaining about?
19:50antares_mephist0: sounds like you need to use an atom there
19:50matt444Where can I see the documentation for google closure?
19:50emezeskeI assume cljs.core.logic ?
19:50antares_mephist0: def is definitely not the right way to mutate data
19:51dnolenemezeske: gist updated, https://gist.github.com/2176408
19:51antares_mk: def goes against the entire point of identity/value separation in Clojure
19:51mephist0antare_: atom? will check it out.
19:52seancorfieldemacs q: i just started getting this error when i try to clojure-jack-in - Error: Invalid byte code in /usr/share/emacs/24.0.94/lisp/emacs-lisp/cl.elc
19:52mkmephist0: you've got a lot of code duplication there. Move q, n1, and n2 up to the top of the file
19:52seancorfieldit was working just the other day... suggestions?
19:52mkmephist0: then turn your assoc reduce sort vals combo into a function
19:53antares_mephist0: yes, make your state map an atom and mutate it using swap! and assoc (or any of your own functions that use assoc)
19:54emezeskednolen: I'm mystified. I have seen possibly weird issues with the compiler when a namespace is spread over multiple subdirectories, though
19:54emezeskednolen: Maybe related: https://github.com/emezeske/lein-cljsbuild/issues/54
19:54matt444nice tip
19:55mkmephist0: instead of redefining, you could be giving your pieces variable to a function. But if you'd like, you could be giving a function to the atom.
19:56dnolenemezeske: yeah, removing optimizations fixed the issue.
19:57dnolenemezeske: did you create a ticket in CLJS JIRA?
19:57emezeskednolen: nah, I was lazy and hoped pkamenarsky would do it ^_^
19:57emezeskeI probably should
19:57dnolenemezeske: I will now
19:58emezeskednolen: you da man!
19:58matt444irssi just doesn't look write in gnome-terminal
19:58matt444right
19:58emezeskexterm+tmux > *
19:58emezeskeOops, forget I said that, wrong channel
19:59mephist0thanks antares_ and mk. Very appreciated. ;)
19:59matt444yessir
20:06dnolenemezeske: actually not quite, I get files but I see that goog.provide and goog.require appearing instead of those files getting concat'ed
20:10seancorfieldhmm, google searches indicate i may have installed a package that caused cl.elc to be corrupted... i wonder how to easily get it back to a valid state?
20:11alexbaranoskywhat was the technique I saw recently for including a library using lein2 without needing a project file?
20:11emezeskednolen: Ah, yeah, if you omit optimizations I think it does produce multiple files and you have to use the deps.js and so forth
20:12emezeskednolen: Which is a pain
20:12dnolenalexbaranosky: http://sunng.info/blog/2012/03/my-favorite-feature-in-leiningen-2/
20:12alexbaranoskydnolen, thanks
20:12seancorfieldugh... i get that cl.elc error trying to install any package now :(
20:12dnolenemezeske: hmm ... but isn't deps.js for the browser?
20:12dnolenemezeske: I just want to run tests at the command line
20:13emezeskednolen: Ah, yeah, I think disabling optimizations makes that quite unpleasant
20:13alexbaranoskyguess I should add (use '[cemerick.pomegranate :only (add-dependencies)]) to .lein/init.clj :)
20:15dnolenemezeske: I was wondering why cljs's own tests don't have this problem but that's because cljs.core is hard coded to be included.
20:16alexbaranoskydoes the technique used in that blog fail if I don't have the dependency locally?
20:16dnolenemezeske: I think the bug is that goog.require's should never appear under advanced compilation
20:17dnolenemezeske: it makes me think that the compiler can't find the files on the classpath.
20:19muhoo+1 pomegranate
20:19dnolenemezeske: do you have a good way that you test against CLJS HEAD?
20:19alexbaranoskydoes the pomegranate trick require a newish version of lein2?
20:20alexbaranoskyI'm seeing an exception: "no value supplied for key [[...core.logic...]]
20:22antares_I have a Java interop question, are there any special rules about calling variadic java methods?
20:22antares_I have this signature: public EventHandlerGroup<T> handleEventsWith(final EventProcessor... processors), trying to call it as (.handleEventsWIth o processor) results in a java.lang.IllegalArgumentException: No matching method from the compiler
20:24antares_ok, looks like I'll have to use into-array
20:24antares_found in http://dev.clojure.org/display/doc/FAQ
20:25emezeskednolen: sorry, was afk, catching up
20:25alexbaranoskynone of you guys have seen?: #<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: [[org.clojure/core.logic "0.6.8"]]>
20:26emezeskednolen: yeah, it's not too hard for me to test against HEAD
20:26dnolenemezeske: what do you do? I thinking about checking out lein-cljsbuild and sorting this issue out
20:28antares_alexbaranosky: can you gist your project.clj or at least the :dependencies key?
20:29emezeskednolen: Basically, I'd build the clojurescript jar and install it to my local maven repo
20:29emezeskednolen: And then edit lein-cljsbuild/support/project.clj to point at that local version
20:29emezeskednolen: Then, rebuild lein-cljsbuild (both support/ and plugin/ dirs) and install that
20:29dnolenemezeske: what commands do you use to build and install it? sorry maven noob
20:30emezeskednolen: Haha, that's actually the part I'm fuzzy on too. I forgot that it doesn't use leiningen
20:31emezeskednolen: I guess I haven't built clojurescript myself since it was released as an official jar
20:31alexbaranoskyantares_, I thought the whole point was to not need to have a project.clj?
20:32antares_alexbaranosky: are you adding plugins to your lein2 profile? sorry, it is true that I wasn't following the channel for the last hour or so
20:33alexbaranoskyantares_, was referring to attempting to use this: http://sunng.info/blog/2012/03/my-favorite-feature-in-leiningen-2/
20:34emezeskednolen: Do you think the problem is that the classpath is not being set up correctly?
20:34antares_alexbaranosky: ahh. I haven't tried using pomegranate from the REPL
20:36dnolenemezeske: possibly
20:36dnolenemezeske: I know compiler.clj pretty well, looks like it's time for me really read closure.clj
20:37emezeskednolen: I wonder if there's some way you could, in your cljs file, print out the current classpath (perhaps with a crazy macro)?
20:37dnolenemezeske: huh, that's a good idea, and not really a crazy macro :)
20:41emezeskednolen: if the classpath is wrong, I can debug that in lein-cljsbuild pretty easily
20:42matt444goog.events is for custom events?
20:42matt444right?
20:42matt444What is the closure method for listening?
20:43winkcan anyone give me a hint in which format this function expects kw-opts? https://github.com/jonase/kibit/blob/master/src/jonase/kibit/core.clj#L175
20:44dnolenemezeske: classpath looks OK, in fact in tests.cljs I can load the macros which proves that it is
20:44dnolenemezeske: so something wrong in the compiler I think
20:45amalloywink: (check-file "blah" :opt1 val1 :opt2 val2)
20:45emezeskednolen: cool
20:46emezeskednolen: I think I'd suggest debugging that with the raw compiler (e.g. without lein-cljsbuild)
20:46winkamalloy: oh, yes. that wqrks. thanks a lot. I totally would've expected {:opt1 val1} though. hmm
20:46emezeskednolen: Using lein-cljsbuild adds a bunch of "lein install"ing and so forth
20:46emezeskednolen: I think you can pretty easily use just the compiler by editing the cljsc script and adding the classpath entries that you need there
20:47dnolenemezeske: yep
20:48mkhow do I chain e.g. (+ 4 (+ 3 (+ 2 x)))? I want something like (foo x + (2 3 4))
20:50dnolen,(let [x 1] (apply + x [2 3 4]))
20:50clojurebot10
20:50dnolenmk: ^
20:50AimHereFor things which don't accept that, 'reduce' is perhaps better
20:52AimHereWhat I mean is that '+' accepts multiple arguments, so applying it to a list can work; some functions only take two, in which case 'apply won't
20:52mkhow can that be done when the function in question should take X as the middle argument of a multi-arg function?
20:53AimHere(reduce + x [2 3 4])
20:55mksuppose I need to do the equivalent of x = (* 1 x 3); x = (* 2 x 4); and so on
20:56dnolen,(apply * [1 x 3])
20:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0)>
20:56dnolen,(let [x 2] (apply * [1 x 3]))
20:56clojurebot6
20:56dnolenmk: is that what you mean?
20:57mkthe proper way to do this seems to be (((...(* 2 (* 1 x 3) 4)...))), but I don't want to have such deeply nested function calls
20:57dnolenmk: use let then for intermediate values
20:59mkdnolen: I don't follow
20:59dnolen(let [n (* 1 x 3)] (* 2 n 4))
20:59AimHereIs what you're after just applying a list of functions to x? You might consider 'juxt'
21:00AimHereWait, not juxt...
21:00mkdnolen: how does that work if I need to apply the function 12 times?
21:02dnolenmk: if there are real subparts of the formula you can just break those out too. I don't really know what you're trying to do.
21:04AimHere,(let [x 10] (reduce #(%2 %1) x [#(* 2 %) #(* 3 %) #(* 4 %)])
21:04clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:04mkI have a value that I'm trying to push through 12 functions. Each one alters the value. But I don't want to nest the functions, because that looks ugly. The functions have many arguments
21:04AimHeremk > howabout applying it to a list of functions, like my abortive attempt above?
21:05AimHere(I left off the last right parentheses)
21:06dnolenmk: I'm not even sure I understand your example (* 2 1 x 3 4) works
21:06mkAimHere: thanks, I'll look at that - though I already have the functions defined elsewhere
21:06AimHereWell yes, I was just defining them inline for the example
21:07dnolenmk: if operator precedence matters you would be wrapping in parens anyhow.
21:07mkdnolen: * is just a placeholder. The function I use isn't commutative.
21:07dnolenmk: then you'd have parens anyhow.
21:08rhcis it possible to pass a def to a function and have the function modify the def? or am I thining about this incorrectly?
21:08rhcguess i should just return a let the caller def
21:08mkdnolen: that's fine, but I'd prefer (()()()()() a) to ((((((a)))))
21:08rhcor do what they want..
21:09AimHeremk > There's also the -> operator
21:09dnolenmk: write an infix macro or use an existing one. not worth it tho imo.
21:12mkAimHere: -> looks about right, thanks
21:13dnolenAimHere: mk: though note -> doesn't arbitrarily thread, it's mostly for dealing with things in an "object-like" way.
21:13dnolen,(-> "foo" first int)
21:13clojurebot102
21:13dnolenkinda like: foo.first().int()
21:14mkyeah, it's not perfect for this, but like you said it's probably not worth doing much more
21:33ideally_worldIs there a better way of getting the count of the longest seq in a seq of seq than (count (reduce #(if (> (count %1) (count %2) %1 %2)) x))?
21:33johnkpaul-afkI am trying to get the getting started example for clojurescript one working
21:33johnkpaul-afkCompilerException java.lang.RuntimeException: No such namespace: js, compiling:(NO_SOURCE_PATH:1)
21:33johnkpaul-afkand I keep getting that error
21:34amalloy(apply max (map count x))?
21:34johnkpaul-afkI see many mailing list posts about the problem
21:34mindbender1johnkpaul-afk: did you lein bootstrap?
21:34johnkpaul-afkthat say to run (cljs-repl), but then I get a BindException
21:34johnkpaul-afkyes, I did
21:35johnkpaul-afkI can do that again though
21:35mindbender1and lein deps with no errors
21:35johnkpaul-afkoh, no, I didn't do that
21:35johnkpaul-afkthat's not in the guide
21:35johnkpaul-afklet me try that
21:35ideally_worldamalloy, thanks, I knew mine was pertty clunky
21:36mindbender1Yea bootstra took care of deps
21:36johnkpaul-afkmindbender1: yeah, I am experiencing the same problem
21:36johnkpaul-afkeven after lein deps
21:37mindbender1Are you running the version you checked out or a copy
21:37johnkpaul-afkthe version I checked out
21:37mindbender1cos it happened to me when I copied it
21:37johnkpaul-afkI copied from here exactly
21:37johnkpaul-afkhttps://github.com/brentonashworth/one/wiki/Getting-started
21:38johnkpaul-afkmeaning, I cpied and pasted
21:38matt444How can I call a JavaScript function by string? In JS you could do object["function_name"].call(null)
21:39mindbender1johnkpaul-afk: where are you getting the errors in the browser or repl
21:39johnkpaul-afkrepl
21:40mkmatt444: not sure, but javascript objects are maps, and maps can map to functions, and functions can be called
21:40mindbender1aah.. I got mine in the browser.. what were you trying to do
21:40johnkpaul-afkmindbender1: http://pastebin.com/W28cZFRX
21:41johnkpaul-afkI'm just trying to start the repl and (js/alert)
21:41johnkpaul-afkbasically just try to make the sample app work
21:41johnkpaul-afkmatt444: I know next to nothing, but can't you do ((:function_name object))
21:42mindbender1johnkpaul-afk: did you get the browser to open with (go)
21:43johnkpaul-afkyes
21:43johnkpaul-afkit opens immediately
21:43mindbender1and when you do (js/alert) you get errors in the repl
21:44johnkpaul-afkyeah
21:44mindbender1try (js/alert "hello")
21:44johnkpaul-afkI did, that's what's in the paste
21:45johnkpaul-afkoh!
21:45johnkpaul-afkgot it
21:45johnkpaul-afkdamn, that's not obvious
21:45johnkpaul-afkit doens't work if I have a clojurescript repl running
21:45johnkpaul-afkin another terminal window
21:46mindbender1aah .. that should be noted
21:46johnkpaul-afkha, yeah, I will remember that now
21:46johnkpaul-afkI've been working on this for half an hour
21:46johnkpaul-afkso confused
21:46johnkpaul-afkthank you for your help mindbender1!
21:46mindbender1you will be cleared in a short while
21:46mindbender1you welcome
21:47mindbender1johnkpaul-afk: I think the relevant part of your errors was BindException Address already in use java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
21:48mindbender1and you were not in the clojurescript repl as you would have noted by now
21:48johnkpaul-afkyeah, I thought that made no sense because I was seeing it fine at port 8080
21:48johnkpaul-afkyeah
21:48johnkpaul-afkit makes sense now
22:29mkare structmaps totally deprecated?
22:46qbgmk: Not too much reason to use them
22:53qbgrecords are so much better
22:55mkis it safe to say you'd never use them?
22:57qbgI don't have any reason to use them
22:59mkthe reference suggests that records should be usually used instead, so I was wondering if there was some remaining use, or if they're now totally vestigial
22:59mkI guess it's the latter
23:00qbgYou don't have to generate a class to use them
23:01Lajla[badbreath]What's the exact differene between a record and a structmap?
23:01qbgThe definitions can be anonymous also
23:02technomancyjust use a map
23:02mkis there a benefit to not defining a class? There's also reify...
23:03qbgClasses have some overhead, but nothing much to worry about in almost all cases
23:03technomancydefining classes introduces hiccups to interactive development
23:03technomancyIIRC there are some cases where recompiling doesn't apply retroactively like it should
23:03qbgYou keep old instances around, and it can be confusing
23:04mkLajla[badbreath]: a record generates a real class, a structmap is like a map without having to see :property keywords everywhere
23:05qbgStructmaps are dense maps
23:19sriddid I come to clojure thinking i am smart and cool? that kills pragmatism.
23:31gtrakanyone know of an easy way to pull out files based on ant-patterns in clojure?