2012-11-22
| 00:00 | ChongLi | and also note that if you ask for rand-int |
| 00:00 | ChongLi | it returns instantly |
| 00:00 | ChongLi | it does not compute the stock-price |
| 00:01 | amalloy | ChongLi: yikes, don't use .foo for protocols. just foo |
| 00:02 | ChongLi | I was merely illustrating that it really is a reified java interface |
| 00:02 | ChongLi | .foo breaks if you use try to extend the protocol, I know :) |
| 00:03 | Frozenlock | I really like the example, helps me understand the whole reify thing. However I don't think it will apply in my case; I would just use the java methods on the existing java object, which is what I'm trying to hide. |
| 00:03 | Frozenlock | But thanks for the example, I really appreciate it! |
| 00:03 | amalloy | even if you know it's best to point out that it's not the only (or indeed best) way to use it |
| 00:04 | ChongLi | Frozenlock: may I ask why you're trying to hide it? |
| 00:04 | ChongLi | amalloy: it can be helpful if you want to ensure you're not using an extended protocol (for some odd reason) |
| 00:05 | ChongLi | such as wanting to call it from java code I guess |
| 00:11 | Frozenlock | ChongLi: Sure. I want to make an abstraction layer. There's a great number of objects, each with their own properties, and each of them with their own methods. I would prefer to work with a map, and only when necessary fallback to the underlying library. This way I could do (:name custom-map), instead of (get-name custom-object). |
| 00:12 | ChongLi | what do all of these objects do? |
| 00:12 | ChongLi | you mentioned stock price |
| 00:12 | ChongLi | is this some kind of dashboard thing? |
| 00:14 | Frozenlock | It was only an (unrelated) example. I'm working with a BACnet library. You can look there if you want to see http://dl.dropbox.com/u/40737386/bacnet4J-doc/index.html |
| 00:16 | ChongLi | you don't need to use a map |
| 00:17 | ChongLi | you can just implement the interfaces necessary to support what you want |
| 00:23 | Frozenlock | *cricket* |
| 00:24 | ChongLi | sorry, I went down a long path of googling |
| 00:24 | ChongLi | clojure.lang.ILookup |
| 00:24 | ChongLi | is the interface |
| 00:24 | Frozenlock | No no, I was trying to figure out what you meant I failed miserably... |
| 00:24 | ChongLi | that's what reify does |
| 00:25 | ChongLi | it implements an interface |
| 00:25 | ChongLi | it's a pretty weird thing you want to do here |
| 00:25 | ChongLi | hehe |
| 00:25 | ChongLi | (:method-name a) |
| 00:26 | ChongLi | instead of (method-name a) |
| 00:27 | Frozenlock | So http://stackoverflow.com/questions/5583841/overloading-keywords-in-clojure/5586959#5586959 is near the solution? |
| 00:27 | ChongLi | yeah |
| 00:27 | ChongLi | that's what I looked at |
| 00:28 | ChongLi | I still can't figure out why you'd want to do this though |
| 00:28 | Frozenlock | I'll make a blog post if I can put it in words. Or I'll scratch everything tomorrow morning when I'll realize it won't work :p |
| 00:28 | ChongLi | it may be that you are fixated a little bit on a specific implementation |
| 00:29 | ChongLi | when there's a much simpler path to take |
| 00:30 | Frozenlock | Story of my life. If you knew how I tried to seduce my first 'real' love.... :P |
| 00:35 | wingy | ChongLi: have you been using clojure for a long time? |
| 00:35 | ChongLi | wingy: maybe 2 months |
| 00:35 | ChongLi | so no |
| 00:36 | ChongLi | I'm trying to learn right along with everyone here |
| 00:36 | ChongLi | I hope if I say something stupid I'll be corrected :) |
| 00:38 | wingy | ChongLi: why clojure? |
| 00:38 | ChongLi | wingy: I started off with Haskell |
| 00:38 | wingy | cool .. the legendary haskell |
| 00:39 | ChongLi | I had heard some good things about Haskell programmers who moved to Clojure |
| 00:39 | ChongLi | I decided to try it and was very happy |
| 00:40 | ChongLi | there were just some things about Haskell that really bothered me |
| 00:40 | wingy | what? |
| 00:40 | clojurebot | What is @ |
| 00:40 | ChongLi | the standard Prelude, for one |
| 00:40 | ChongLi | so much of it is defined in terms of concrete data structures such as lists |
| 00:41 | ChongLi | every project ends up using a ton of libraries just to patch over this flaw in the Prelude |
| 00:41 | ChongLi | and then you run into cabal hell |
| 00:43 | ChongLi | I've also grown to love lisp enough that Haskell's syntax (particularly layout) bothers me |
| 00:44 | wingy | i see |
| 00:44 | ChongLi | and the fact that Template Haskell has this weird syntax; macros in lisp being much better integrated |
| 00:44 | ChongLi | but there are things I really like about Haskell |
| 00:44 | ChongLi | lazy evaluation is really cool, as is currying |
| 00:44 | ChongLi | you can't have everything you want in one language though |
| 00:44 | ChongLi | and I think Clojure has more of what I want |
| 00:46 | wingy | clojure has lazy eval |
| 00:47 | ChongLi | I know |
| 00:47 | wingy | does it have currying? |
| 00:47 | ChongLi | but it's not by-default |
| 00:47 | ChongLi | you can do currying as well |
| 00:47 | ChongLi | but it's also not by-default |
| 00:47 | wingy | (partial) |
| 00:48 | ChongLi | in Haskell you can do partial application without any special operator |
| 00:48 | amalloy | it's more like clojure has partial application, which is like currying but done by hand |
| 00:48 | ChongLi | it has other implications |
| 00:48 | ChongLi | like the flip example mentioned hours ago |
| 00:49 | Raynes | You don't do partial application in Haskell. |
| 00:49 | Raynes | Everything is curried. |
| 00:49 | Raynes | Every function in fact only takes one argument. |
| 00:50 | Raynes | It's awesome. |
| 00:50 | ChongLi | it's great for that |
| 00:50 | ChongLi | less great for variable args functions |
| 00:51 | ChongLi | yeah, I know about the printf type trickery |
| 00:51 | ChongLi | it's a hassle |
| 00:51 | Raynes | Yeah, it's sad you can't do it in Haskell. |
| 00:51 | Raynes | I still like Haskell though. |
| 00:51 | Raynes | I like Haskell around as much as I like Clojure. |
| 00:51 | Raynes | And lately I've been doing as much of it as I have Clojure. |
| 00:52 | ChongLi | they're both really great languages |
| 00:52 | ChongLi | Haskell would be amazing though if its libraries were rebooted |
| 00:53 | ChongLi | it's kinda funny |
| 00:53 | Raynes | My biggest gripe is the lack of documentation for the JSON parsing libraries (aeson is amazingly easy and fun to use, but it's almost impossible to figure out the easiest way to use it) and the fact that the http lib is documented for the hard things and not the simpler cases. |
| 00:53 | ChongLi | like how people declare .emacs bankruptcy |
| 00:53 | Raynes | I've got blog posts to write. |
| 00:54 | Sgeo | I saw a proxy-type in some reflection and thought it was some Java weirdness leaking through, so I filtered looking for stuff that would be only from the library |
| 00:54 | Sgeo | Turns out the library does in fact have VP_PROXY_TYPE |
| 00:55 | ChongLi | Sgeo: yay |
| 00:55 | ChongLi | you can dispatch on that then? |
| 00:55 | Sgeo | I have working(ish) code now, which uses more reflection |
| 00:55 | Sgeo | Is there a way to delete an entire form? |
| 00:55 | Sgeo | In paredit? |
| 00:56 | ChongLi | yeah |
| 00:56 | Raynes | I prefer using evil-mode for that. |
| 00:56 | ChongLi | paredit-kill |
| 00:56 | Raynes | dab |
| 00:57 | ChongLi | paredit-kill is just C-k |
| 00:57 | ChongLi | if you're inside the form |
| 00:57 | ChongLi | use paredit-backward-up |
| 00:57 | Sgeo | I'm sure there are less repetitive ways to write the code than what I wrote |
| 00:57 | ChongLi | C-M-u |
| 00:59 | ChongLi | paredit is another reason I love Clojure |
| 01:00 | ChongLi | despite Clojure having no responsibility for it |
| 01:04 | amalloy | wellll, C-M-k is better for "kill single form". C-k is a bit more aggressive |
| 01:05 | jyu | how to execute a block of test in emacs |
| 02:03 | bbloom | i love how i was able to implement a syntax-quote like system in 19 lines of code :-) |
| 02:03 | bbloom | <3 clojure, you're so pretty |
| 02:04 | tomoj | I'm curious, why? |
| 02:04 | bbloom | tomoj: all will be revealed soon :-) |
| 02:05 | bbloom | i'm almost certain that i know what i'm doing |
| 02:05 | bbloom | almost... |
| 02:05 | bbloom | heh |
| 02:06 | wingy | clojure has made my life better |
| 02:09 | tomoj | I didn't mean to suggest it seemed crazy to do that |
| 02:10 | tomoj | datomic makes me want a custom syntax-quote-alike |
| 02:11 | tomoj | almost... |
| 02:11 | bbloom | tomoj: you can built one pretty easily: https://gist.github.com/4129774 |
| 02:13 | bbloom | tomoj: and i'm doing a code-as-data type thing, just like datomic's transaction data… so hence the desire for such a syntanx-quote type system… |
| 02:17 | bbloom | tomoj: worth noting: my syntax quote thing doesn't do symbol/namespace resolution |
| 02:18 | bbloom | tomoj: probably pretty easy to add with a (symbol? form) (list 'quote (resolve form)) provided you have a resolve function |
| 02:19 | tomoj | ... interesting |
| 02:20 | tomoj | you _could_ set up custom resolution for keywords like :x/foo, and maybe symbols |
| 02:25 | tomoj | (qq :alias [(blog [post :as p] [comment :as c])] |
| 02:25 | tomoj | [:find ?d ?c :in $ ?p :where [(p/comments ?p ?c)] [?c :c/postedAt ?d]] db post) |
| 02:25 | tomoj | :/ |
| 02:26 | ucb | lovely perl code you got there |
| 02:27 | tomoj | datalog is small and contained at least.. :/ |
| 02:27 | ucb | :) |
| 03:37 | WokenFury | does anyone else have a problem with lein install installing to current dir target/ instead of ~/.m2? 2.0.0-preview10 |
| 03:46 | WokenFury | nmind. it does actually install, just doesn't print anything about it |
| 04:15 | p_l|work | recommended IDE for Clojure? I have both Eclipse and IntelliJ, but I don't exactly know recommended setups for them for clojure. Emacs is (unfortunately) completely out. |
| 04:15 | sporkball | p_l|work: why is emacs completely out? |
| 04:16 | sporkball | p_l|work: I tend to either use emacs or Sublime Edit (not an IDE, I know) |
| 04:16 | p_l|work | sporkball: because I'm fed up with god-damned-ancient version of SLIME used by Clojure |
| 04:17 | WokenFury | p_l|work: try nrepl for emacs |
| 04:17 | thorwil | p_l|work: you can get rid of slime and use nrepl |
| 04:17 | p_l|work | hmm |
| 04:17 | p_l|work | how does it compare to SLIME? |
| 04:18 | thorwil | haven't used enough of either to say |
| 04:18 | p_l|work | hmm |
| 04:19 | WokenFury | it's solid. I use it every day at work |
| 04:19 | p_l|work | what about stuff for Eclipse/IDEA? I have to use Eclipse for some of the projects at work anyway |
| 04:19 | wink | I'm actually using vim with vim-clojure right now |
| 04:19 | WokenFury | counterclockwise then. think it's come a long way and has some paredit support now as well |
| 04:19 | wink | and using maybe 5% of the features besided highlighting |
| 04:20 | wink | I suck at productivity? :( |
| 04:20 | wink | p_l|work: try CCW, I found it really good actually |
| 04:20 | p_l|work | another question: how is the debugging support, and debugging from IDE? |
| 04:20 | p_l|work | Last time I checked, it was "holy fuck stack salad" |
| 04:20 | wink | it's not that it does things so special there's a cost for learning :P |
| 04:24 | WokenFury | don't know about CCW, but emacs has ritz now |
| 04:24 | p_l|work | lol |
| 04:24 | WokenFury | haven't tried it though. printlns have solved most of my problems...so far :) |
| 04:25 | p_l|work | though truly, my clojure use will be very limited (I'm just investigating using it instead of java for a selenium test suite) |
| 04:25 | p_l|work | shouldn't hit debugging much :) |
| 04:25 | WokenFury | then you'll be fine. our entire tech stack is clojure from the browser to devops automation :) |
| 04:27 | ucb | WokenFury: nice |
| 04:27 | ucb | p_l|work: you should check out (if you haven't yet) clj-webdriver |
| 04:28 | p_l|work | ucb: I did :) |
| 04:28 | p_l|work | that's why I'm considering clojure |
| 04:28 | ucb | heh, nice |
| 04:28 | p_l|work | otherwise I fear the code would make the guy coming after me to curse me :D |
| 04:29 | p_l|work | still might |
| 05:00 | bbloom | i'm trying to learn how to use `lein deploy clojars` |
| 05:00 | bbloom | not sure why i get all sorts of weird errors on this page: https://clojars.org/backtick |
| 05:22 | Bergle_1 | anyone got an opionion if its worth getting Oreilly "Clojure Programming" if ive been through Pragmatics "Programming Clojure" and liked it? |
| 05:23 | ucb | Bergle_1: I've not read it but in my experience I went from the pragmatic book to the joy of clojure and it turned out ok |
| 05:23 | ucb | i.e. I didn't bomb a shopping centre or anything like that |
| 05:24 | Bergle_1 | heh uhm good hear, not sure i dont think im in that level of risk scenario |
| 05:25 | ucb | I'd go for it anyway |
| 05:25 | ucb | there's always the web, irc and lots of practise :) |
| 05:28 | augustl | Bergle_1: I would recommend Joy of Clojure, it's my favorite :) |
| 05:29 | Bergle_1 | have you read the pragmatic one ? |
| 05:30 | augustl | I haven't |
| 05:30 | augustl | only the two on manning |
| 05:30 | Bergle_1 | k looking at joy of info |
| 06:19 | p_l|work | gah. Can someone explain to me why CounterClockWise doesn't support Java EE perspective, only Java and Plugin ones? |
| 06:32 | jakubH | because Clojure and Enterprise (in the bad meaning of it) are contradictions? :-) |
| 06:32 | p_l|work | ha ha very punny |
| 06:44 | ambrosebs | Is it possible to (.setDynamic #'v) some var v that is in another namespace? Any downsides? |
| 06:48 | foodoo | I want to add a local jar to the project's classpath using the leiningen localrepo plugin. I used the following command: lein localrepo install java-otr.jar ca.uwaterloo.crysp.otr/java-otr 0.1.0 #but after that, lein localrepo coords doesn't find java-otr.jar. What am I doing wrong? |
| 06:55 | deg | Style question: I want to pass a boolean parameter to a function, to cause it to perform an auxiliary action. (In my case, to graph or trace some results). Obviously, clojure is a lisp-1, so I need different names for the parameter and the function supplying the auxiliary action. What is the most accepted Clojure naming style for this? |
| 06:57 | deg | My first though is to write (defn my-fcn [... trace-results?] ... (when (trace-results? (trace-results)))) But, does the "?" prefix imply a function, rather than a boolean? If so, what is the common convention? |
| 06:58 | ucb | deg: ? implies a predicate I'd say |
| 06:59 | deg | Right. Oh, I had a typo above... Add ")" after the "trace-results?". As is, I really muddied my attempt. |
| 06:59 | deg | ucb: Is there a Clojure convention for naming boolean parameters? |
| 07:00 | deg | And, please, no one suggest the Redmondian Hungarian bTraceResults. That would be so beyond wrong here. :-) |
| 07:00 | wink | b-trace-results *ducks* |
| 07:01 | deg | Yikes... I need some sleep. I miswrote my correction. Should have said "no '(' before" not what I said. Let's do this again (sorry folks). |
| 07:01 | ambrosebs | why not ^boolean trace-results |
| 07:01 | deg | (defn my-fcn [... trace-results?] ... (when trace-results? (trace-results)))) |
| 07:02 | deg | ambrosebs: That won't solve the naming clash with the function I'm calling. |
| 07:02 | deg | To my mind, this is the one weakness of lisp-1s. |
| 07:03 | ambrosebs | I'm too biased to lisp-1 to give a balanced view. But lisp-1's behaviour here seems much more pleasant :) |
| 07:04 | ambrosebs | how about namespace qualifying trace-results |
| 07:05 | deg | ambroseb: Agreed. I come from a CL background (years ago), but I still agree that lisp-1 is nicer for most thing. It's only in this kind of situation that a naming clash hits. Arguably, it's a problem of English, since we don't distinguish well between verbs and nouns. |
| 07:06 | deg | Namespace would be overkill here. This is a helper function that, if not one-time-use, is certainly not going to be widely used. It's coupled with the function calling it. (do-something and trace-something-results). |
| 07:07 | deg | It could almost be an anonymous function (which would solve the problem nicely) but, because it is doing trace output, it is relatively long and ugly, and will read better at top-level. |
| 07:07 | alexnixon | deg: it's not answering your question, but provided you're docstring is insightful and your code clear, I wouldn't get too hung up on it |
| 07:08 | deg | alexnixon: Sure. And there are a lot of easy answers like "do-trace-something" for the function. If I was in a rush to get the code out, sure. But, I'm using this project as a learning exercise to get the feel of Clojure, so I want to invest extra time into learning standard practices. |
| 07:09 | alexnixon | sure, and it's a good question :-) |
| 07:10 | alexnixon | you could avoid the situation altogether with named parameters |
| 07:10 | alexnixon | although personally I find them a bit cumbersome |
| 07:10 | ambrosebs | deg: if it's coupled with the function calling it, use letfn |
| 07:12 | alexnixon | ambrosebs: bearing in mind that that prevents you from unit testing |
| 07:13 | deg | ambroseb: I don't understand your solution. |
| 07:13 | ambrosebs | deg: also, giving an anonymous fn a name like (fn my-name [a b] ...) shows up in exceptions |
| 07:13 | deg | ambroseb: It seems like letfn leaves me with both problems. I have the name clash with the parameter and I've got more complexity nested in one textual scope. |
| 07:14 | deg | alexnion: I don't understand your solution either. A named parameter would still give me the name clash, no? (or do I misunderstand what you mean?) |
| 07:16 | alexnixon | (defn foo [trace & {:as arg-map}] (if (:trace arg-map) (trace))) |
| 07:17 | alexnixon | though I don't think it's idiomatic |
| 07:17 | alexnixon | personally I think a ? suffix is the best solution |
| 07:17 | deg | alexnion: I think that fails, since it binds trace to the local. |
| 07:18 | alexnixon | deg: 'trace' is the tracing function, and (:trace args) is the boolean |
| 07:18 | ucb | deg: so you have a fn called trace which when passed a boolean (potentially named trace) it should also trace? |
| 07:19 | deg | alexnixon: I'm currently divided between param= trace-x?; fnc = trace-x or param=trace; fnc=do-trace. Neither is brilliant. |
| 07:19 | alexnixon | deg: I'd go for trace-x? and trace-x |
| 07:19 | alexnixon | I think it's clear |
| 07:20 | deg | Yes, except for ucb's very valid objections that trace? would normally be a predicate function. |
| 07:20 | alexnixon | well in my mind, a predicate *should* have a ? suffix, but a ? suffix does not imply a predicate. |
| 07:20 | deg | ucb: Fcn named x gets parameter (maybe named trace-x?) and if true, calls fcn named trace-x |
| 07:21 | alexnixon | just use a docstring and either is fine |
| 07:21 | ucb | deg: if the fn is called x and the parameter is called trace-x where's the issue then? the use or not of ? |
| 07:22 | deg | ucb: (defn x [trace-x?] (when (trace-x? trace-x)) ...do-other-stuff..) |
| 07:23 | ucb | ah, gotcha |
| 07:23 | ucb | here's yet another poor name for trace-x?: should-trace-x |
| 07:23 | alexnixon | deg: you mean (defn x [trace-x?] (when trace-x? (trace-x)) ...do-other-stuff..) |
| 07:23 | oddy | lads and gents, does someone have a couple of free minutes to help newbie? The question is regarding leiningen |
| 07:24 | ucb | oddy: just ask :) |
| 07:24 | deg | alexnixon: Yes. Did I typo and not write that? |
| 07:24 | alexnixon | deg: you were using trace-x? as a function |
| 07:25 | deg | Yes, I typo'd, sorry. Lack of sleep and a 15 year digression into C, C++, and Java. |
| 07:25 | ucb | regression you mean? |
| 07:25 | oddy | ucb: running lein run gives Exception in thread "main" java.lang.ClassNotFoundException: |
| 07:25 | ucb | oddy: difficult to diagnose without extra context |
| 07:26 | deg | ucb: Yes, 100% agreed. Before that, I was in CL for many years, in the Lisp Machine world. |
| 07:26 | oddy | ucb: I know, I only started :) The project is https://github.com/zerg000000/mario-ai |
| 07:26 | ucb | deg: :) |
| 07:26 | ucb | oddy: sorry for being impatient :) |
| 07:27 | oddy | ucb: Project is full Java except for an agent which is Clojure |
| 07:27 | deg | oddy: Do you have a :main clause in your project.clj? |
| 07:27 | ucb | I see no project.clj |
| 07:27 | oddy | deg: yes |
| 07:28 | oddy | ucb: https://github.com/zerg000000/mario-ai/tree/master/example/mario-ai-example-clj |
| 07:29 | ucb | oddy: I've very little experience with creating classes and stuff from clojure, but you've no gen-class in core.clj |
| 07:29 | oddy | deg: it tries to compile main, but cannot find one of the imports, even though it physically there |
| 07:29 | oddy | ucb: I don't even know what it is :) |
| 07:30 | oddy | ucb: I only started with Clojure, and Leiningen is totally alien to me so far :) |
| 07:30 | ucb | :) |
| 07:31 | ucb | lunch - biab |
| 07:31 | oddy | ucb: Enjoy! |
| 07:31 | ucb | ta |
| 07:31 | antares_ | oddy: add (:gen-class) to the namespace you intend to be runnable, like so (ns my.service (:gen-class)), this will cause Clojure compiler to generate .class file ahead of time that leiningen or java -jar can use to start your program. |
| 07:32 | oddy | antares_: will try right now |
| 07:32 | antares_ | oddy: gen-class and runnable namespaces are mentioned in the Leiningen tutorial: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md |
| 07:34 | oddy | antares_: Yes. I just wanted to run the agent. My intention was just to look at how it works :) Trying it |
| 07:34 | antares_ | oddy: then why not use lein repl? |
| 07:34 | oddy | antares_: I.e. yes, my fault I didn't read carefully |
| 07:35 | antares_ | oddy: agents are covered with examples in http://clojure-doc.org/articles/language/concurrency_and_parallelism.html |
| 07:35 | antares_ | oddy: http://clojure-doc.org is your friend, use it |
| 07:35 | deg | ucb: (if you see this when back from lunch). Thanks for the should- idea above. Perhaps no more idiomatic than my other two ideas, but I like it better. |
| 07:36 | oddy | antares_: because I never used repls before (except for IPython for some time, but that doesn't count) |
| 07:36 | antares_ | oddy: REPL is much easier to use than creating and running one-off programs :) |
| 07:38 | Mr_Bond | `lein run` is nice for running one-off problems as well, when you are done testing code in `lein repl` :) |
| 07:38 | maleghast | Hello All :-) |
| 07:39 | oddy | antares_: same thing. My runable (class defined in :main) has now this definition: ns mario-ai-example-clj.core (:gen-class) |
| 07:39 | oddy | antares_: runing lein run gives the same |
| 07:40 | antares_ | oddy: can you paste full trace of java.lang.ClassNotFoundException? |
| 07:41 | oddy | antares_: sure. D:\Development\Home\Projects\ai-mario\mario-ai\example\mario-ai-example-clj>lein |
| 07:41 | oddy | run -ag example.agents.ForwardJumpingAgent |
| 07:41 | oddy | Compiling mario-ai-example-clj.core |
| 07:41 | oddy | [~ Mario AI Benchmark ~ 0.1.9] |
| 07:41 | oddy | Exception in thread "main" java.lang.ClassNotFoundException: example.agents.Forw |
| 07:41 | oddy | ardJumpingAgent, compiling:(mario_ai_example_clj/core.clj:7) |
| 07:41 | antares_ | oddy: any particular reasons why you use that repository? it seems to be full of pretty weird code |
| 07:42 | oddy | antares_: it's not mine github :) |
| 07:42 | antares_ | oddy: yes but to try out agents you can just open the repl in a completely fresh Leiningen project |
| 07:42 | oddy | antares_: I really don't know why the guy does not use local jars |
| 07:43 | si14 | is there any way to evaluate stuff from nrepl in *nrepl* buffer? |
| 07:43 | oddy | antares_: I'll try. What should I do except for `lein repl`? %-) |
| 07:43 | si14 | I would really like to get evaluated form and it's result there instead of echo area |
| 07:44 | antares_ | oddy: nothing, lein repl and then enter some code and hit enter |
| 07:44 | antares_ | oddy: you can start with (+ 1 2 3 4 5), for example |
| 07:44 | maleghast | Has anyone in here had occasion to use SpyGlass (Clojurewerkz memcached library)? |
| 07:45 | antares_ | maleghast: I am the author of Spyglass, so yes |
| 07:46 | maleghast | antares_: Oh cool - I never know who anyone is in these IRC rooms… Thanks for putting your hand up :-) |
| 07:46 | oddy | antares_: Ah, no, agents are quite leghty. I'm new to Clojure itself and thus trying lengthy Clojure scripts in repl which extend and implement various interfaces and base classes is not gonna work for me %-) |
| 07:47 | Foxboron | Newb question, whats the right way of assigning anothers var's value to a var? |
| 07:47 | Foxboron | would it be with def? |
| 07:48 | pyr | are there any gotchas for protocols in clojurescript ? |
| 07:49 | pyr | given this simple ns which works in plain clojure: https://gist.github.com/4131010 |
| 07:49 | maleghast | I'm pretty new to Clojure and I'm certainly new to using it "in anger" but I am building a prototype at the moment, and I have run into two issues (with my implementation of it I am sure) with SpyGlass that I've as yet had no joy in unravelling… The first is: How do I get spyglass to stop trying to connect to a server when it's tried and failed? The second is: I need my code to try to connect and then either use the cache + DB for uncached / expired or |
| 07:49 | maleghast | the DB if the cache is absent. How would you achieve that, and for a bonus point, how would you implement a mechanism to check back in case the cache has come back up? |
| 07:49 | maleghast | antares_: Sorry, took a while to type this ^^ |
| 07:50 | antares_ | maleghast: I will need to take a look at Spymemcached to answer the first part. As for the second, I'd probably implement core.cache and use that. There are examples in Monger and Welle. |
| 07:51 | pyr | ah it seems reify doesn't exist in cljscript |
| 07:52 | antares_ | maleghast: this is what it takes to implement core.cache on top of mongodb, should be even less code with spyglass and memcached: https://github.com/michaelklishin/monger/blob/master/src/clojure/monger/cache.clj |
| 07:52 | pyr | so no reify means doing a defrecord and wrapping that in defn + let |
| 07:53 | maleghast | antares_: Thanks, that's a great place for me to start :-) I appreciate it :-) |
| 07:53 | antares_ | maleghast: if you give me a few hours, I will finish something and then implement core.cache in Spyglass |
| 07:53 | antares_ | it's pretty trivial |
| 07:53 | maleghast | Wow, that would be awesome |
| 07:53 | maleghast | :-) |
| 07:53 | antares_ | looking at how to limit reconnection attempts right now |
| 07:54 | oddy | antares_: Wow, something new now: Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to |
| 07:54 | oddy | create ISeq from: clojure.lang.Keyword |
| 07:54 | antares_ | oddy: in the REPL? |
| 07:54 | antares_ | oddy: in a new project? |
| 07:54 | oddy | antares_: that's after I added :gen-class, no, `lein run` |
| 07:55 | antares_ | oddy: it means that the (ns …) macro is misused, can you paste the exact code? (only the ns part) |
| 07:56 | oddy | antares_: ns mario-ai-example-clj.core :gen-class |
| 07:56 | oddy | antares_: bracets, I c |
| 07:56 | maleghast | (OT) This is weird, I don't seem to be able to set myself to "away"… Anyway, I'll be gone for a bit *waves* |
| 07:57 | antares_ | maleghast: ok, I found it, there is a way to make Spyglass retry, redistribute attempts across other servers or cancel operations |
| 07:57 | firesofmay | Hi, How do I make the nrepl to always start paredit mode? in Emacs 24 |
| 07:57 | antares_ | maleghast: that will also need a small feature added to spyglass if you want to avoid direct Java interop |
| 07:57 | maleghast | antares_: That got my attention, was about to go and buy lunch |
| 07:57 | antares_ | oddy: can you paste it exactly to gist.github.com please? |
| 07:58 | antares_ | maleghast: no problem, bon appétit |
| 07:58 | maleghast | antares_: If you are prepared to make the mod, I would love having it without Java InterOp; thanks :-) |
| 07:58 | antares_ | maleghast: all in all it is maybe 40 minutes of work this evening |
| 07:58 | maleghast | antares_: à bientôt |
| 07:59 | oddy | antares_: https://gist.github.com/4131055 |
| 07:59 | foodoo | has anyone here worked with lein-localrepo before? Does the .jar file have to have anything special in it? |
| 08:01 | antares_ | oddy: ok, that looks fine |
| 08:02 | oddy | antares_: but it still complains on ClassNotFoundException: example.agents.ForwardJumpingAgent |
| 08:03 | antares_ | oddy: that class needs to be compiled, too |
| 08:03 | oddy | antares_: which is defined in another script |
| 08:03 | oddy | antares_: can I compile whole stuff at once? :) |
| 08:04 | oddy | antares_: or is there a way I can use repl? |
| 08:04 | antares_ | by adding :aot [mario-ai-example-clj.agents] |
| 08:04 | antares_ | :aot :all if I remember correctly |
| 08:04 | antares_ | that repo uses non-standard source layout, it wasn't supposed to be used as a runnable app as far as I can see |
| 08:04 | antares_ | only loaded from the REPL |
| 08:05 | oddy | antares_: project has aot |
| 08:05 | antares_ | but what is listed for AOT? |
| 08:05 | oddy | antares_: :aot [mario-ai-example-clj.agents] |
| 08:05 | antares_ | oddy: does lein compile succeed? |
| 08:06 | antares_ | oddy: I am trying that repo here |
| 08:06 | oddy | antares_: No. Complains on missing class |
| 08:06 | oddy | antares_: I'm using lein 2.0 preview10 |
| 08:07 | oddy | antares_: If that matters at all %) |
| 08:23 | Foxboron | So i got a loop-recur, i want the varible a's value to replace b's value. Tried let and def, nothing works so far. |
| 08:25 | antares_ | oddy: ok, so it looks like it first tries to compile :main namespace |
| 08:25 | antares_ | oddy: if you comment out :main, run lein compile, then comment it back in and run lein run, it works |
| 08:26 | antares_ | Foxboron: post your code to gist.github.com or something |
| 08:27 | oddy | antares_: Cool! I'll try that right now. Is there a normal way of making that work? :) I.e. is there a way to compile sources and then run as opposed to compile-first-file-run-see-what-happens? |
| 08:27 | antares_ | Foxboron: "replacing" variables is exactly what you don't generally do in Clojure but with locals can do that |
| 08:28 | antares_ | oddy: it seems to be the issue with that project's non-standard source layout |
| 08:29 | oddy | antares_: hmmm... I'll take a closer look at an official doc as you've suggested and try to follow official prescriptions. |
| 08:29 | Foxboron | antares_, hard getting used to functional programming <.< |
| 08:29 | oddy | antares_: btw, I have an error again %) |
| 08:30 | oddy | antares_: another one |
| 08:30 | antares_ | oddy: I am working on a fix |
| 08:30 | Foxboron | antares_ http://hastebin.com/yehitudiwo.lisp |
| 08:30 | Foxboron | Basic fib sequence, (fib 10) prints the 10 first numbers. |
| 08:30 | oddy | antares_: Exception in thread "main" java.lang.NullPointerException |
| 08:30 | oddy | at ch.idsia.tools.MarioAIOptions.setArgs(MarioAIOptions.java:89) |
| 08:31 | antares_ | Foxboron: you can use an atom and mutate it very similarly to how you reassign variables. http://clojure-doc.org/articles/language/concurrency_and_parallelism.html#atoms |
| 08:31 | antares_ | oddy: well, that's something from their Java code |
| 08:31 | Foxboron | antares_, i have yeat to actually use or read about them. Can look at them tho. |
| 08:31 | Foxboron | yet* |
| 08:32 | oddy | antares_: Hmmm... Strange, I can run java just fine. And tests run as well. have you managed to run the code locally? |
| 08:32 | antares_ | Foxboron: you are on the right path but I don't understand the intent on line 6 and what "rang" is for |
| 08:32 | oddy | antares_: I've submitted an issue to that project for zerg000000, jsut in case |
| 08:33 | Foxboron | antares_, hah. Because i forgot an if there :P rang is x, and c counts how many steps we have taken. when (= rang c) we stop the loop. |
| 08:33 | Foxboron | but i actually forgot the if, so yeah.... |
| 08:35 | antares_ | oddy: now I am getting the same null pointer as you do |
| 08:35 | oddy | antares_: :D |
| 08:35 | antares_ | oddy: it may be an issue in Leiningen when it tries to first compile the :main namespace even though you want the opposite order |
| 08:35 | hugod | Would anyone have a set of emacs indentation rules for core.logic? |
| 08:36 | oddy | antares_: mate, I don't want to waste your time on it. I'm really gratefull you've pointed where to look (project config). It's night here, I'll take a fresh look at it tomorrow. Thanks you! |
| 08:37 | antares_ | oddy: good night |
| 09:05 | p_l|work | hmmm... nrepl might make me pick up clojure again for serious use |
| 09:09 | wink | good luck! |
| 09:14 | gfredericks | dangit it didn't work |
| 09:14 | gfredericks | well it probably upgraded all the things but it is still an older emacs |
| 10:00 | gfredericks | is IFn a special case in cljs? it seems (extend-type js/Number IFn ...) doesn't work? |
| 10:00 | gfredericks | well I mean the extend-type call seems to go okay but (8) still emits 8.call(null) |
| 10:01 | wink | can you work with IFn in proper clojure code? I've always just noticed it in errors :P |
| 10:02 | gfredericks | yeah you can make a type that implements IFn |
| 10:02 | gfredericks | what you can't do in clj-proper is extend IFn to existing types, because it's not a protocol it's an interface |
| 10:02 | gfredericks | in cljs it's actually a protocol but I'm thinking you still can't use it all the time |
| 10:08 | Anderkent | In Midje, how can I specify that a function should be called with an argument that matches some check? |
| 10:41 | tomoj | https://www.refheap.com/paste/38243d70af02f0a6816f694ab .. interesting, clojure.test/are seems unhygienic |
| 10:42 | tomoj | I guess the do-template args should be replaced by gensyms? |
| 10:46 | iosica | Need some macros help ppl |
| 10:46 | iosica | I'm trying to write a clojure wrapper around apache crunch http://incubator.apache.org/crunch/ |
| 10:46 | iosica | this is how I want the classical word count example to look like https://gist.github.com/4090665 or the average bytes by ip log parser https://gist.github.com/4090665 |
| 10:46 | iosica | here mem-pipeline is a macros transforming the body into a sequence of java calls |
| 10:47 | iosica | problem I'm having is with parallelDo it translates to java call PCollection.parallelDo |
| 10:48 | iosica | taking 2 params: a function and a type T |
| 10:48 | ivenkys | folks - anyone here using La-Clojure (IDEA clojure plugin) - how do you set breakpoints in clojure scripts ? (latest version of IDEA) |
| 10:48 | iosica | now T can have 2 values A or B |
| 10:49 | iosica | so it should be (parallelDo function A) or (parallelDo function B) |
| 10:50 | ivenkys | failing - LaClojure + IDEA - any other preferred way of debugging clojure apps ? |
| 10:52 | iosica | now I want my macros to decide if it's A or B depending on first param to parallelDo |
| 10:53 | iosica | if function returns a vector of 2 elements I want value to be A otherwise B |
| 10:53 | thorwil | iosica: what's the range of possibilities for the first param? |
| 10:54 | iosica | is this possible? |
| 10:54 | iosica | any fn |
| 10:55 | thorwil | i think you have to call an fn to get to know what it returns |
| 10:55 | tomoj | curious, you only use two PTableTypes? what are they? |
| 10:56 | iosica | PType and PTableType |
| 10:56 | iosica | only one PTableType |
| 10:56 | tomoj | oh, I see |
| 10:57 | iosica | so I need to decide if it's a PType or a PTableType |
| 10:57 | tomoj | why not make different names for the two different parallelDo calls? |
| 10:58 | iosica | because parallelDo here is not a clojure method |
| 10:58 | iosica | it's amethod on a java class |
| 10:58 | iosica | not under my control |
| 10:58 | tomoj | I mean make two different names for yourself, maybe: |
| 10:58 | iosica | I'm translating it directly to .parallelDo func type |
| 10:59 | iosica | parallelDoAsTable ? |
| 10:59 | iosica | and parallelDoAsNotTable |
| 11:00 | tomoj | pmap / pmap-kv ? |
| 11:00 | tomoj | hard for me to tell what those parallelDo actually do |
| 11:00 | iosica | it's possible with different names but I want to ake that decision out from the user |
| 11:01 | iosica | mainly because this is an internal thing in crunch |
| 11:01 | iosica | clojure users would have no idea which one to use |
| 11:01 | tomoj | there is no way to determine whether an arbitrary function will return a vector pair |
| 11:01 | iosica | I have another criteria I could use |
| 11:01 | iosica | maybe that one is possible |
| 11:01 | tomoj | the only other option I can think of is to annotate the function or var with metadata |
| 11:02 | tomoj | but that still requires the user to make the choice when defining the function |
| 11:02 | iosica | yep |
| 11:02 | iosica | in this example |
| 11:02 | iosica | https://gist.github.com/4091142 |
| 11:02 | iosica | parallelDo groupdByKey combineValues are methods on java classes |
| 11:03 | iosica | PCollection and PTable (extends PColelction) |
| 11:03 | iosica | so in theory I could use the next method to decide if this parallelDo needs to return a type or a table type |
| 11:04 | tomoj | e.g. if it's groupByKey, table type? |
| 11:04 | iosica | and specifically if this is a method on PColleciton -> ptype else if this is a method on PTable -> table type |
| 11:04 | iosica | yes |
| 11:04 | tomoj | seems like the user ought to know whether it's a table, to me |
| 11:04 | tomoj | but I don't know crunch |
| 11:06 | tomoj | what if you want a PTable, but you call some PCollection method first (since PTable extends PCollection) and then some PTable method second? |
| 11:06 | iosica | yep it's not that simple |
| 11:07 | iosica | I'd have to carry the state somehow from the bottom up |
| 11:07 | iosica | state means is it type or tabletype |
| 11:10 | iosica | here in readme is how I have it working now |
| 11:10 | iosica | https://github.com/viacoban/crackle |
| 11:10 | iosica | not the most fluent dsl |
| 11:38 | Anderkent | gah. Anyone got any code coverage tool to work with clojure? JaCoCo 'almost' works, except it outputs *a lot* of noise like missing branches that don't exist... And the line number support is not that good ;/ |
| 11:47 | ambrosebs | In CLJS: I want to implicitly load another CLJS namespace when I `:require-macros` a specific Clojure namespace. Ideas? |
| 11:47 | ambrosebs | load = :require |
| 11:48 | gfredericks | ah because the macros should expand to calls to some other hidden ns? |
| 11:48 | ambrosebs | Yes. |
| 11:48 | ambrosebs | I might be stuck with just needing an extra :require in the `ns` declaration |
| 11:48 | gfredericks | that's certainly the easiest thing |
| 11:49 | gfredericks | might be able to call into the compiler from the macro namespace? but that'd be terribly ugly. |
| 11:50 | ambrosebs | That's possibly the only other option. |
| 11:50 | gfredericks | the whole macros-in-clj thing makes everything a bit awkward :/ |
| 11:51 | tomoj | hmm |
| 11:51 | ambrosebs | It's kinda useful in my situation. I'm calling Typed Clojure (written in Clojure) via CLJS's macros. |
| 11:51 | ambrosebs | ... to check CLJS code |
| 11:51 | tomoj | (ana/analyze-deps '(your/ns)) ? |
| 11:52 | tomoj | couldn't be that easy.. |
| 11:52 | ambrosebs | tomoj: that sounds about right? |
| 11:52 | tomoj | so since (I assume) you will fully qualify in the macro, you just need the file to have been analyzed? |
| 11:54 | ambrosebs | I want to properly :require the internal CLJS namespace. |
| 11:54 | noidi | does cljs have the plain `require` function? you could have your macro inject the `require` call into the generated code. |
| 11:54 | gfredericks | I'm 98% sure it doesn't |
| 11:54 | ambrosebs | noidi: no |
| 11:54 | gfredericks | it handles the ns form as a very-special case |
| 11:55 | nicl | hey all, I'm developing an API using compojure and connecting to a mongodb database. Just wondering if there is an existing config library/solution so that I can store db connection info for dev/prod and use the correct one automatically (based on some kind of environment setting). If something doesn't exist, any tips on how to do this (in particular how I can distinguish between prod and dev environments automatically) |
| 11:55 | tomoj | you want the analysis output of your macro-using namespace to show the require? |
| 11:55 | tomoj | what other effect of require would there be besides having it analyzed? |
| 11:56 | nicl | - in PHP I would set an env variable using apache. But what are my options for clojure? |
| 11:56 | weavejester | nicl: Environment variables are a solution used in a lot of applications |
| 11:56 | tomoj | if you really want the analysis output to show the require, I think you will have to patch the analyzer.. |
| 11:57 | noidi | nicl, this library was announced recently on the mailing list https://github.com/sonian/carica |
| 11:57 | weavejester | nicl: As they're very universal - most languages and most OSes support them |
| 11:58 | tomoj | oh, of course you want the dep |
| 11:58 | nicl | weavejester: ok thanks, will investigate |
| 11:58 | tomoj | otherwise the code won't get included :) |
| 11:58 | ambrosebs | tomoj: Just looking through, I think I really want cljs.compiler/compile-file |
| 11:58 | nicl | noidi: thanks - will check it out |
| 11:58 | ambrosebs | analyze doesn't emit :) |
| 11:58 | noidi | re: different configs for different environments: I'd have one master configuration file with env-specific settings marked with placeholders |
| 11:58 | noidi | then you can generate env-specific configuration files as a part of the build process |
| 11:59 | noidi | gradle makes that trivial, don't know how to do that with leiningen, though |
| 12:00 | tomoj | (swap! ana/namespaces update-in [*cljs-ns* :requires] conj 'your/ns) ? |
| 12:00 | nicl | noidi: ah ok, so you'd run something like 'lein build prod' / 'lein build dev' (just as an example) |
| 12:00 | noidi | yeah |
| 12:00 | nicl | noidi: and the process would then update/insert the correct config |
| 12:01 | tomoj | would be very odd to emit in your macro I'd think |
| 12:01 | tomoj | dunno about the format for the require either, it's probably not 'your/ns |
| 12:01 | ambrosebs | tomoj: no, my thinking is that :require-macros loads the CLJ file, so just put a call to the CLJS `compile-file` in that CLJ ns |
| 12:02 | gfredericks | ambrosebs: only loads it the first time probably |
| 12:02 | tomoj | but how will that js get included in the final output? |
| 12:03 | ambrosebs | I'm completely new to CLJS. So deps *must* be in the `ns` form? |
| 12:03 | tomoj | I don't understand the compiler/analyzer all too well myself, but, yes |
| 12:04 | ambrosebs | I understand the compiler much better than the lang, but I didn't notice that. |
| 12:04 | ambrosebs | Hmm, that's easy then, no choice but an extra dep. |
| 12:05 | tomoj | well, no |
| 12:05 | antares_ | maleghast: hey |
| 12:05 | tomoj | (swap! ana/namespaces update-in [*cljs-ns* :requires] assoc 'your/ns 'your/ns) |
| 12:05 | tomoj | er, ana/*cljs-ns* |
| 12:05 | gfredericks | I don't think he wants to emit js, I think he just wants to throw if the type-check fails? |
| 12:05 | gfredericks | u. |
| 12:05 | gfredericks | ~ping |
| 12:05 | clojurebot | PONG! |
| 12:05 | tomoj | I think that should work |
| 12:06 | tomoj | obviously not a great solution since if the cljs compiler changes it could break |
| 12:06 | tomoj | but note that e.g. the binding macro in cljs does this kind of thing |
| 12:06 | ambrosebs | I'll explain my use case |
| 12:06 | tomoj | er, no, I guess it doesn't |
| 12:08 | tomoj | macro expands to call to internal cljs function, right? so in the macro, do the swap! above, and the calling ns gets the internal ns added to its requires |
| 12:08 | tomoj | oh and you also need to analyze the file.. |
| 12:09 | tomoj | which the ana/analyze-deps bit above should do? |
| 12:09 | noidi | ambrosebs, seeing you here reminded me to finally give Typed Clojure a try! I'm very excited about the project, thanks so much for working on it :) |
| 12:10 | ambrosebs | tomoj: Ok, that sounds kinda reasonable. |
| 12:10 | ambrosebs | noidi: :) |
| 12:11 | tomoj | then when the compiler emits the analyzed code, it will follow the :requires and compile your internal ns |
| 12:12 | ambrosebs | tomoj: ah got it. |
| 12:13 | tomoj | the analyzer could maybe be refactored a bit to provide ana/require for macro use |
| 12:14 | ambrosebs | tomoj: makes sense. It's just the side effect which is important, not the `ns`, which I'm just realising :) |
| 12:15 | Anderkent | Anyone knows why clojure produces unreachable bytecode for functions? See https://gist.github.com/4119799 |
| 12:16 | ambrosebs | I was also playing around with changing the `ana/specials` to stop macroexpansion. It's kinda useful, but you do have to make sure you analyze the children correctly |
| 12:16 | ambrosebs | I was excited to use `ana/specials`, but perhaps it isn't as useful as I thought. |
| 12:16 | ambrosebs | The wrapper macros were my second option. |
| 12:18 | tomoj | oh, I see what you meant by "use case" |
| 12:19 | ambrosebs | lol I didn't end up explaining cos you already knew. |
| 12:41 | ambrosebs | noidi: let me know how you go playing with Typed Clojure. Feedback has been sparse. |
| 12:42 | tomoj | I didn't take the time to understand it yet |
| 12:42 | maleghast | antares_: Hey there, how did you get on today.? |
| 12:42 | ambrosebs | Hopefully my conj talk will get ppl started |
| 12:42 | tomoj | but I just realized I'm struggling somewhat with the lack of a type system |
| 12:42 | tomoj | slides available? couldn't find them |
| 12:43 | maleghast | ambrosebs: can you paste a link to your github repo for this, please? |
| 12:43 | ambrosebs | https://github.com/downloads/frenchy64/papers/conj%20main%20talk.pdf |
| 12:43 | maleghast | ambrosebs: Thx :-) |
| 12:44 | ambrosebs | Typed Clojure is at https://github.com/frenchy64/typed-clojure |
| 12:44 | ambrosebs | There is an honours dissertation also if you're so inclined. |
| 12:45 | noidi | ambrosebs, will do |
| 12:45 | ambrosebs | noidi: cheers |
| 12:45 | tomoj | oh! I was playing with analyze. I wonder if it's easy to include the original :form like the cljs analyzer? |
| 12:45 | maleghast | ambrosebs: Possibly, but I'm struggling with limited time and brane-power at the moment, between my day-job and my 12 week old son and my 18 month old daughter… ;-) |
| 12:45 | tomoj | bbloom's cps on analyzer output is nice, but I'm in clojure right now so I'm writing an old-school macro :/ |
| 12:45 | ambrosebs | tomoj: I can't do anything past what the Clojure compiler does. |
| 12:46 | ambrosebs | so I'd have to reverse engineer analysis to emit a form |
| 12:46 | ambrosebs | too much work for me, but I'd accept a patch. |
| 12:46 | tomoj | I see |
| 12:47 | noidi | ambrosebs, typed clojure doesn't seem to like nrepl/counterclockwise. |
| 12:47 | noidi | => (require '[typed.core :refer [ann]]) |
| 12:47 | noidi | CompilerException java.lang.AssertionError: Assert failed: (FilterSet? %), compiling:(core.clj:1992:19) |
| 12:48 | tomoj | I hope it won't be all that long before we are somewhat liberated from Compiler.java |
| 12:48 | ambrosebs | noidi: thx, having a look |
| 12:48 | ambrosebs | tomoj: amen |
| 12:48 | noidi | doing the same in a plain repl seems to work fine |
| 12:48 | tomoj | we can make analysis better before doing full c-in-c maybe? |
| 12:48 | noidi | this is with typed 0.1.2 |
| 12:49 | ambrosebs | noidi: can you paste the stack trace? |
| 12:49 | ambrosebs | tomoj: But don't we all just want CLJS analysis? :-) |
| 12:51 | tomoj | really I do :). but I'm working in clojure for a bit because it's easier, and eventually I want to cross over |
| 12:51 | noidi | ambrosebs, https://www.refheap.com/paste/6921 |
| 12:51 | noidi | I'll upgrade to the latest CCW beta to see if it makes any difference |
| 12:55 | ambrosebs | noidi: I might cut a new SNAPSHOT, give me a few minutes |
| 12:56 | ambrosebs | I have no idea what's causing that error :) |
| 12:58 | ambrosebs | If it still happens, print a (clojure.repl/pst 1000) or equivalent |
| 12:58 | noidi | ambrosebs, it's probably a CCW issue |
| 12:59 | noidi | when I connect to an Nrepl started from Leiningen, it works |
| 12:59 | ambrosebs | interesting |
| 12:59 | noidi | but it fails when I try it in a REPL started from CCW |
| 13:01 | noidi | here's the output of (pst 1000) https://www.refheap.com/paste/6922 |
| 13:05 | ambrosebs | I really want the second exception, but I forget how to print it. |
| 13:05 | ambrosebs | or maybe that's it? |
| 13:07 | noidi | I think that's it |
| 13:08 | ambrosebs | Great. |
| 13:09 | ambrosebs | clojure.repl/root-cause was what I was thinking of. |
| 13:10 | ambrosebs | Could you add the first TC issue? :) https://github.com/frenchy64/typed-clojure/issues |
| 13:11 | antares_ | maleghast: quick question, so being able to control handling of down servers and core.cache implementation is all you need in Spyglass? |
| 13:11 | maleghast | Yeah |
| 13:11 | noidi | ambrosebs, sure |
| 13:12 | maleghast | sorry, antares_ Yeah that's what I am in need of |
| 13:12 | antares_ | maleghast: ok |
| 13:12 | maleghast | antares_: Thanks :-) |
| 13:16 | augustl | 2are there any XML parsers out there that parses to a hiccup like data structure? |
| 13:26 | ambrosebs | noidi: cheers |
| 13:27 | acagle | /flush |
| 13:31 | ambrosebs | time for sleep actually. |
| 13:31 | noidi | good night! |
| 13:33 | noidi | I'll post about the issue to the ccw-users mailing list |
| 13:34 | noidi | as it only appears in a CCW REPL |
| 13:51 | wink | hm, how do I create a lazy seq that repeats nil nil <arg>" or something? |
| 13:51 | gfredericks | wat |
| 13:51 | gfredericks | you want (nil nil arg nil nil arg nil nil arg ...)? |
| 13:51 | wink | yes |
| 13:52 | gfredericks | ,(take 20 (cycle [nil nil :arg])) |
| 13:52 | clojurebot | (nil nil :arg nil nil ...) |
| 13:52 | wink | cycle... doh. thanks :) |
| 13:52 | wink | was trying interleave and take |
| 13:55 | raek | ,(take 20 (interleave (repeat nil) (repeat nil) (repeat :arg))) ; you can of course do it with interleave too... |
| 13:55 | clojurebot | (nil nil :arg nil nil ...) |
| 13:56 | gfredericks | (apply interleave (map repeat [nil nil :arg])) |
| 14:23 | Sgeo_ | In Lamina, is there a way to have a callback get called when a channel is grounded? |
| 14:23 | Sgeo_ | As in, when something calls ground on the channel, I want to know about it |
| 14:24 | Sgeo_ | Not even entirely sure of the difference between ground and close |
| 14:32 | raek | Sgeo_: when you ground a channel you make sure that elements won't build up in it (presumably the elements are being processed in forks of the channel) |
| 14:34 | bbloom | tomoj: my cps transform isn't quite finished yet…. it was delayed while i got some changes into the cljs codebase, but now i need to get the energy back together to finish it |
| 14:35 | raek | (let [c (...)] (receive-all (fork c) processor-a) (receive-all (fork c) processor-b) (ground c)) |
| 14:35 | raek | here both processors can consume all the elements in their own pace |
| 14:35 | Sgeo_ | Wait, why can't you just ground c and do receive-all on c? |
| 14:36 | raek | if you only had one processor, you could just (let [c (...)] (receive-all c)) |
| 14:36 | raek | (receive-all c processor) |
| 14:36 | Sgeo_ | And the reason I want to know if a channel is grounded is because I want to disconnect from an underlying event-based SDK |
| 14:37 | raek | to me that sounds like something that you would do when it is closed |
| 14:37 | Sgeo_ | Ah, ok |
| 14:37 | raek | (i.e. no processors are interested in the values) |
| 14:38 | Sgeo_ | Can a processor in receive-all somehow decide it's not interested anymore? |
| 14:38 | raek | but I don't know how close and fork work together |
| 14:38 | raek | I assumed that that's what close does (you let it close its fork) |
| 14:38 | Sgeo_ | Ah |
| 14:38 | Sgeo_ | Ok |
| 14:39 | Raynes | Happy Thanksgiving USAians. |
| 14:39 | raek | 'seal' closes the producing end, 'close' closes the consuming end |
| 14:39 | raek | I think |
| 14:39 | Raynes | USA! USA! TURkEY! TURKEY! |
| 14:39 | gfredericks | Raynes: that's an odd pair of countries to cheer for |
| 14:39 | raek | I think the first example could have been written like (let [c (...)] (receive-all (fork c) processor-a) (receive-all c processor-b)) |
| 14:40 | danlarkin | Sgeo_: isn't there an on-grounded function? |
| 14:40 | danlarkin | I think there is |
| 14:40 | Sgeo_ | I should probably actually read the API docs |
| 14:40 | Sgeo_ | Rather than just the intro stuff |
| 14:40 | raek | Sgeo_: have you seen this? https://github.com/ztellman/lamina/wiki/Channels-new |
| 14:40 | Sgeo_ | raek, that's what I meant by intro docs |
| 14:40 | Sgeo_ | Admittedly, I sort of skimmed it |
| 14:41 | danlarkin | oh I think I was wrong |
| 14:41 | danlarkin | there's on-closed, on-error and on-drained |
| 14:42 | raek | hrm, I don't find any 'seal' function... |
| 14:42 | Sgeo_ | Hmm, a processor closing its channel might not be that helpful if there's still stuff remaining in that channel |
| 14:42 | raek | maybe I just imagined it |
| 14:42 | Sgeo_ | But I think I want on-closed |
| 14:42 | danlarkin | raek: seal was around in 0.2.x |
| 14:43 | raek | now there seems to be a 'drained?' predicate and a 'on-drain' function |
| 14:43 | Sgeo_ | I don't know if I should provide a more direct API and then just layer Lamina on top of that, or provide access only via Lamina. |
| 14:44 | danlarkin | Sgeo_: provide where? |
| 14:44 | Sgeo_ | danlarkin, to users of my wrapper |
| 14:44 | Sgeo_ | (Which will likely be only me, but whatever) |
| 14:44 | danlarkin | what is your wrapper |
| 14:45 | Sgeo_ | It's for bots for http://virtualparadise.org/ |
| 14:53 | thorwil | originally i had an "Could not locate tlog/test/data/account__init.class or tlog/test/data/account.clj on classpath" on "lein midje" |
| 14:53 | thorwil | fixed that with :test-path in my project.clj |
| 14:54 | thorwil | but now: All claimed facts (0) have been confirmed. |
| 14:54 | thorwil | i claimed 3 facts. or at least i'm attempting to!? |
| 14:59 | wink | ,(map (fn [coll] (drop 3 coll)) '(1 2 3 4 5 6)) |
| 14:59 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 14:59 | wink | why doesn't that work? |
| 14:59 | gfredericks | coll is a number |
| 14:59 | gfredericks | if you map over a list of numbers, your map function should expect a number as its argument |
| 15:00 | wink | doh. I think I should stop for today |
| 15:00 | wink | I actually have no clue how I managed ot work o_O |
| 15:08 | konr_trab | Is there a more elegant way to get the element where foo == 2 in [{:foo 1}{:foo 2}{:foo 3}] than (->> [{:foo 1}{:foo 2}{:foo 3}] (filter #(= (:foo %) 2)) first)? |
| 15:09 | gfredericks | not really; you can replace the anon fn with (comp #{2} :foo) if you like that better |
| 15:09 | gfredericks | but find-first is one of the more common not-in-core functions probably |
| 15:23 | gfredericks | I just noticed that in cljs (= (type "foo") (type :foo) (type 'foo)) |
| 15:30 | simard | how do you split the content of a string intro a list of its s-expressions ? something like clojure.string/split-lines but for s-expressions |
| 15:31 | gfredericks | ,(let [my-string "foo bar (some s-expression)"] (read-string (str "[" my-string "]"))) |
| 15:31 | clojurebot | [foo bar (some s-expression)] |
| 15:33 | Raynes | gfredericks: NaN |
| 15:34 | gfredericks | Raynes: I can't argue with that |
| 15:34 | simard | ok I meant, how do you split a string into a list of string representation of its s-expressions |
| 15:34 | gfredericks | oh hm. |
| 15:34 | simard | i.e.: ["foo" "bar" "(some s-expression)"] |
| 15:34 | gfredericks | well a hacky way is to map that back to pr-str |
| 15:35 | simard | that would also kindly eliminate comments and stuff. |
| 15:35 | gfredericks | that would take care of comments and things, but also (by default) lose metadata and reader macro stuff |
| 15:35 | simard | of btw Raynes, I'm using Clojail in my game project, so thank you for that |
| 15:36 | simard | oh* |
| 15:36 | gfredericks | which may be fine for your purposes |
| 15:36 | Raynes | o/ |
| 15:39 | xeqi | simard: what game? |
| 15:40 | simard | a little project of mine, it's not out yet.. it's a 3d game that happens in a space setting |
| 15:40 | simard | multiplayer and all that stuff. |
| 15:40 | simard | nothing really, I'm just having fun. |
| 15:45 | tomoj | hmm https://www.refheap.com/paste/0c2610aa6554fc7cfc91db9a4 |
| 16:01 | simard | what is the dual of merge for a map ? assoc and dissoc could work, but they expect a list and not a map, so I have to use apply and would like to avoid that. |
| 16:02 | danlarkin | simard: please give an example |
| 16:02 | gfredericks | +1 |
| 16:03 | brehaut | gfredericks: s/+1/inc/ |
| 16:03 | gfredericks | (dec brehaut) |
| 16:03 | lazybot | ⇒ 6 |
| 16:04 | simard | yeah, I understand why it wouldn't make much sense for a function like that to exist now. but here: (unmerge {:KEY_A 1, :KEY_B 2} {:KEY_B 2, KEY_C 5}) -> {:KEY_A 1} |
| 16:04 | simard | basically, a map is not needed, only keywords |
| 16:04 | simard | but.. I'm dealing with maps right now, and I want to do map A - map B |
| 16:04 | gfredericks | well it's easy enough to define it |
| 16:04 | gfredericks | (defn unmerge [m1 m2] (apply dissoc m1 (keys m2))) |
| 16:05 | simard | and so now I can use unmerge with (swap! unmerge B) |
| 16:07 | gfredericks | (swap! an-atom unmerge B) yes |
| 16:07 | simard | yes |
| 16:09 | bbloom | dnolen: was just tidying up my github "inbox" and since you had made me a contributor, you get to benefit from my OCD need to drive counts to zero :-) |
| 16:39 | alex_baranosky | anyone know where all of the print-method method definitions are? |
| 16:41 | alex_baranosky | the multi-method is defined in core here, https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3298, … I wanted to see the code for how maps get printed |
| 16:43 | gfredericks | ,(doc print-method) |
| 16:43 | clojurebot | "; " |
| 16:44 | gfredericks | what the heck are the args for print-method |
| 16:44 | alex_baranosky | found it: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_print.clj |
| 16:45 | alex_baranosky | gfredericks: args -> [x writer] |
| 17:24 | jodaro | clojure.core.memoize memo-ttl ftw |
| 17:35 | Sgeo_ | Lamina does not seem to be thoroughly documented |
| 17:44 | sporkball | This seems like a silly question, but how do you shut down the Netty server you've created when using aleph? |
| 17:47 | Sgeo_ | (namespace/import-macro namespace/import-macro) |
| 17:47 | mpenet | sporkball: the fn you used to lauch the server returns a shutdown fn |
| 17:47 | mpenet | launch* |
| 17:48 | Foxboron | Any Clojure conj vids up yet? |
| 17:48 | Bronsa | too early i think |
| 17:49 | sporkball | mpenet: Hm… I saw that in the unit tests, but then I swear yesterday I tried it and when I tried to restart it complained about the socket being in use… but today it seems like it works. Thanks! |
| 17:49 | tufflax | jodaro, i started reading about memo-ttl, but what is "unk"? "Unlike many of the other unk memoization functions..." |
| 17:49 | tufflax | Foxboron, some respectable person, i forgot who, said wait til june for conj vids |
| 17:49 | tufflax | :p |
| 17:50 | sporkball | mpenet: Must of have been doing something wrong yesterday (it was late, blah, etc.) |
| 17:50 | Foxboron | tufflax, june D:?! |
| 17:50 | mpenet | sporkball: possibly a bug, it was broken a couple of month, and it went through a major rewrite recently |
| 17:50 | tufflax | yeah :p I dunno why but, apparently it will take a long time :P |
| 17:50 | mpenet | sporkball: a couple of months *ago* |
| 17:51 | Bronsa | wtf. |
| 17:51 | Bronsa | 6 months? |
| 17:52 | tufflax | We can only hope that it was an hyperbole |
| 17:54 | tufflax | "Seriously it will take a long time" i can remember him saying |
| 17:55 | Foxboron | tufflax, for next Clojure Conj someone should just sneaky record everything and put it up asap. Then we don't have to wait ._. |
| 17:55 | tufflax | yeah :P |
| 17:55 | tufflax | I love me some clojure talks |
| 17:56 | wingy | i have been having these thoughts about testing all the time .. perhaps running the code in production is the best test? |
| 17:56 | sporkball | mpenet: more than likely it was me… I was having a pretty brain-free day yesterday. Love Aleph, though -- helluva lot nicer than working with raw sockets |
| 17:57 | wingy | ah nvm |
| 18:07 | mpenet | sporkball: I mostly use it as an http client/server and redis client, it's a lovely lib as you say |
| 18:08 | sporkball | mpenet: Was just looking at your Ash IRC bot… I'm working on creating an IRC server, and using aleph to power the TCP server. |
| 18:09 | mpenet | sporkball: sounds interesting |
| 18:10 | mpenet | sporkball: I didn't want to rewrite an irc client from scratch, I just use a fairly popular java client and build on it |
| 18:10 | mpenet | sporkball: and so far it has worked fine. It is really simple (not a lot of code) |
| 18:11 | sporkball | mpenet: Honestly I'm doing it as a "get up to speed in Clojure" project more than anything. I'm interested in actually using it for some projects, too, but I thought it would be a fun project to tackle. |
| 18:11 | mpenet | sporkball: yes I understand that |
| 18:11 | mpenet | sporkball: good way to learn gloss as well |
| 18:11 | mpenet | sorenmacbeth: if that's the route you chose to take |
| 18:12 | sporkball | mpenet: Indeed. Gloss seems pretty great. |
| 18:12 | mpenet | damn fingers |
| 18:12 | mpenet | sporkball: it is |
| 18:13 | mpenet | sporkball: ztellman has produced some amazing libs, Lamina is worth some interest as well, you probably know bits of it because of Aleph already |
| 18:38 | wingy | anyone having issues with "Unsupported escape character" errors |
| 18:40 | ucb | I'm guessing that there aren't still any tutorials/howtos on debugging with ritz? |
| 18:42 | alex_baranosky | anyone know how can I do fast batch updates using Korma or clojure.java.jdbc? |
| 18:47 | ucb | ugh, nrepl-ritz is megaslow for me, has anybody else found this? I'm on OS X 10.7.x |
| 18:47 | mammoth | I think I know now what was bothering me about parenthesis and have come to a solution that won't give you guys heart attack. |
| 18:48 | mammoth | for example if we have this |
| 18:48 | mammoth | (defn as-string [date] |
| 18:48 | mammoth | (let [y (year-from date) |
| 18:48 | mammoth | m (month-from date) |
| 18:48 | mammoth | d (day-from date)] |
| 18:48 | mammoth | (str-join "-" [y m d]))) |
| 18:49 | mammoth | i would format it as this |
| 18:49 | mammoth | |
| 18:49 | mammoth | (defn as-string [date] |
| 18:49 | mammoth | (let [ y (year-from date) |
| 18:49 | mammoth | m (month-from date) |
| 18:49 | mammoth | d (day-from date) ] |
| 18:49 | mammoth | (str-join "-" [y m d]) )) |
| 18:49 | p_l | ugly |
| 18:50 | mammoth | the idea is to add whitespace to closing parens that are not opened in the same line. That makes it a little easier to tell what's what without wasting more lines |
| 18:52 | Foxboron | that just gives the whole block of code a unatural look |
| 18:52 | Foxboron | atm, my eyes are grouping the str-join line together with the let. |
| 18:52 | Foxboron | which is not ideal |
| 18:52 | Foxboron | <- personal opinion |
| 18:53 | wingy | im getting: "java.lang.RuntimeException: Unsupported escape character: \g" has anyone else stumbled upon this error? |
| 18:53 | alex_baranosky | mammoth: please take this well, but… just get used to it. |
| 18:54 | alex_baranosky | maybe that didn't come out right… But I mean eventually none of that stuff matters, you'll just find it a non-issue eventually |
| 18:54 | p_l | mammoth: had it been CL, I'd tell you to just not look at parens, but at indentation, but I don't know how well it will fly with clojure's syntax sugar |
| 18:55 | mammoth | okay, bigger tab size |
| 18:55 | mammoth | |
| 18:55 | mammoth | (defn as-string [date] |
| 18:55 | mammoth | (let [ y (year-from date) |
| 18:55 | mammoth | m (month-from date) |
| 18:55 | mammoth | d (day-from date) ] |
| 18:55 | mammoth | (str-join "-" [y m d]) )) |
| 18:55 | mammoth | Ill get it right eventually. |
| 18:56 | mammoth | thanks for feedback, guys. |
| 18:59 | alex_baranosky | testing |
| 19:00 | Sgeo_ | I wonder if mammoth has done picolisp before, they have a similar convention |
| 19:01 | mammoth | Sgeo_: no |
| 19:01 | mammoth | I came up with this |
| 19:01 | mammoth | Sgeo_: EXTREMELY obsesive compulsive, thought. |
| 19:02 | tufflax | mammoth I'm sure you've heard this before, but focus on the indentation :P |
| 19:02 | mammoth | tufflax: I'll try. |
| 19:03 | tufflax | And learn to love the simplicity of the Lisp syntax |
| 19:03 | mammoth | tufflax: seven closing brackets is not my definition of simple. |
| 19:03 | tufflax | what's not simple about it? |
| 19:04 | tufflax | And why does it matter if there is seven closing parens? |
| 19:04 | Foxboron | Nothing? *points at Python* |
| 19:04 | nightfly_ | The book I learned common lisp with "The Elements of Artificial Intelligence Using Common LISP" advocated the same thing mammoth is suggesting. It really helped me when learning but I don't feel I need it anymore. |
| 19:05 | tufflax | When you get to the point of the closing backets, everthing is already done, and you don't need to care anymore |
| 19:05 | tufflax | :p |
| 19:05 | Foxboron | I'd argue that, if a syntax was simple, more people would be coding lisp :P |
| 19:05 | Foxboron | However, most people turn 180 degrees when they see tonstonsandmoretons of parens |
| 19:05 | tufflax | Foxboron, I don't know if that would be a strong arument |
| 19:06 | tufflax | Foxboron have you seen Rich's talk Simple Made Easy? |
| 19:06 | Foxboron | I believe i got it buffered up in the background, planning to see it the past hour :P |
| 19:07 | tufflax | Do it! |
| 19:07 | tufflax | Do it now |
| 19:07 | Foxboron | But i got a bed calling on me :/ |
| 19:07 | tufflax | It's more important than sleeping |
| 19:07 | Foxboron | More important then an important test :c? |
| 19:07 | tufflax | Way more |
| 19:07 | Foxboron | damn. |
| 19:08 | tufflax | And don't stop watching it until you agree with everything :D |
| 19:09 | tufflax | ...he says |
| 19:09 | yedi | what's the difference between a seq and a collection? |
| 19:10 | gfredericks | a seq implements ISeq |
| 19:10 | gfredericks | I can't remember if there's a formal definition of a collection |
| 19:10 | tufflax | seq is an abstraction that defines first and rest |
| 19:10 | Foxboron | ummm |
| 19:10 | Foxboron | think easy |
| 19:10 | yedi | tufflax: ah ok |
| 19:10 | Foxboron | What is a collection? a collection of numbers are: 350 43 100 |
| 19:10 | Foxboron | a sequence of numbers are: 1 2 3 4 5 6 |
| 19:11 | Foxboron | simple enough :3? |
| 19:11 | tufflax | as gfredericks says, I'm not sure if there is a definition of a collection, but in Java there is |
| 19:11 | tufflax | Foxboron, note that a seq and a sequence is NOT the same thing |
| 19:13 | wingy | regarding the error: "java.lang.RuntimeException: Unsupported escape character: \g" |
| 19:13 | wingy | i just escaped it : \\g |
| 19:13 | wingy | and it works |
| 19:13 | Foxboron | tufflax, like. Even if you would pick on the diff between seq and sequence...i am not sure if he actually wanted a indepth difference guide, but a basic one. |
| 19:14 | Foxboron | and if he wanted a basic one, i don't see any problem with the one i wrote <.< |
| 19:14 | gfredericks | Foxboron: well for starters it's not obvious what distinction you were trying to make |
| 19:14 | gfredericks | in both cases you listed some numbers separated by spaces |
| 19:14 | tufflax | Foxboron, 1 you did not explain any difference between a sequence and a collection 2 i think he asked specifically what a seq is |
| 19:15 | jodaro | tufflax: http://www.fogus.me/fun/unk/ |
| 19:15 | Foxboron | gfredericks, well. I maybe didn't think that far as if he would understand the difference. |
| 19:16 | Foxboron | tufflax, well he never really replyed anything after the question :P So i dunno rly. |
| 19:17 | yedi | Foxboron: it just seemed like you were seqs were lists of sequential items |
| 19:17 | yedi | im pretty sure that's not what the distinction in clojure is |
| 19:17 | gfredericks | a vector is not a seq, for instance |
| 19:18 | yedi | maps aren't seqs either right? |
| 19:18 | gfredericks | correct |
| 19:18 | gfredericks | ,(seq? {}) |
| 19:18 | clojurebot | false |
| 19:18 | Foxboron | yedi, i assumed you wanted the basic explenation ^^ I am not the right guy if you wanted the real difference ^^ |
| 19:18 | gfredericks | ,(map seq? [[] {} #{} () "foo" (range)]) |
| 19:18 | clojurebot | (false false false true false ...) |
| 19:19 | gfredericks | ,(doc sequential?) |
| 19:19 | clojurebot | "([coll]); Returns true if coll implements Sequential" |
| 19:19 | yedi | Foxboron: the basic explanation was what tufflax said. You instead said something incorrect, conflating seqs with a list of sequential items |
| 19:19 | gfredericks | ,(doc seq?) |
| 19:19 | clojurebot | "([x]); Return true if x implements ISeq" |
| 19:19 | Foxboron | yedi, then i was wrong :) Nothing more to it ^^ I am still human last time i checked |
| 19:20 | yedi | no biggie, thanks for tryna help |
| 19:20 | Foxboron | np :P |
| 19:20 | Foxboron | Rich said "You should never be afraid of being wrong." |
| 19:20 | yedi | gfredericks: thanks, so basically lists are the only seq structures in clojure? |
| 19:20 | gfredericks | Foxboron: I learn a lot in #clojure by responding with my best guess and getting corrected :) |
| 19:20 | Foxboron | gfredericks, thats how i learned programming ;P |
| 19:21 | gfredericks | yedi: no; there are lazy seqs, and there are seqs that are views over other collections |
| 19:21 | yedi | which you get by calling seq on one right? |
| 19:21 | gfredericks | ,((juxt identity type) (seq {:foo 43})) |
| 19:21 | clojurebot | [([:foo 43]) clojure.lang.PersistentArrayMap$Seq] |
| 19:21 | gfredericks | yedi: yep |
| 19:21 | tufflax | Actually, now I'm a bit unsure of what to call things that you can do first and rest on but that is not seqs |
| 19:21 | gfredericks | yedi: furthermore you can make a custom seq by implementing ISeq |
| 19:22 | yedi | tufflax: it's not? |
| 19:22 | gfredericks | tufflax: you mean things that clojure.core/{first,rest} accept? |
| 19:22 | yedi | what does ISeq give you/do? |
| 19:22 | tufflax | gfredericks, yes |
| 19:22 | gfredericks | tufflax: those are the seqable things :) |
| 19:22 | tufflax | yes, I mixed the two concepts |
| 19:23 | gfredericks | yedi: that's the interface that the seq functions use, so if you have a collection-thing and you implement ISeq, you can use the clojure functions with that collection-thing |
| 19:24 | yedi | what are the main clojure functions you would want to/typically use on a seq? |
| 19:25 | tufflax | Hm gfredericks help me out here. Does {} implement ISeq? And if not, what interface/protocol does make sure that one can do first and rest etc on it? |
| 19:27 | gfredericks | looks like there's a Seqable interface |
| 19:28 | gfredericks | just defines a seq function |
| 19:28 | gfredericks | so something that is seqable can provide a seq, which actually provides the first/rest |
| 19:29 | gfredericks | so you when call clojure.core/first with a map, it will first call seq on the map, then first on that sq |
| 19:29 | tufflax | yeah |
| 19:30 | gfredericks | but I don't understand ##(.seq {:foo 'bar}) |
| 19:30 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap |
| 19:30 | gfredericks | O_O |
| 19:32 | yedi | is the . how you run a java class method? |
| 19:32 | yedi | ,(doc .seq) |
| 19:32 | clojurebot | Cool story bro. |
| 19:33 | gfredericks | yedi: an instance method in this case |
| 19:33 | gfredericks | ,(class {2 3}) |
| 19:33 | clojurebot | clojure.lang.PersistentArrayMap |
| 19:34 | tufflax | yedi a class method is like Math/sqrt |
| 19:34 | yedi | yea my b, used wrong terminology |
| 19:34 | gfredericks | ,(. Math (sqrt 7)) |
| 19:34 | clojurebot | 2.6457513110645907 |
| 19:34 | gfredericks | also that |
| 19:35 | tufflax | then there is also this clojure.lang.RT that gets inbetween |
| 19:35 | gfredericks | yeah |
| 19:36 | tufflax | I mean like collections defines cons but then it's somehow called conj :p |
| 19:36 | gfredericks | I give up trying to make sense of ##(.seq {2 2}) |
| 19:36 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap |
| 19:36 | tufflax | define* |
| 19:36 | gfredericks | ,(.seq [2 2]) |
| 19:36 | clojurebot | (2 2) |
| 19:37 | gfredericks | ,(.seq #{2 3}) |
| 19:37 | clojurebot | (2 3) |
| 19:39 | gfredericks | found an unused line in clojure.core: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L495 |
| 19:40 | tufflax | :p |
| 19:41 | tufflax | I find that PersistentArrayMap business strange too |
| 19:42 | gfredericks | it's not obviously a bug since ##(seq {2 2}) still works |
| 19:42 | lazybot | ⇒ ([2 2]) |
| 19:43 | wingy | http://postbin.heroku.com/ is the shit for debugging |
| 19:51 | yedi | I keep getting a symbol not found error when trying to run a function in my nrepl repl. Does anyone know of some common pitfalls that could have led to this issue? |
| 19:52 | yedi | i've tried both loading the whole file C-c C-l and executing the function |
| 19:52 | yedi | and they don't error, so I'm not sure what the issue might be |
| 19:53 | tufflax | yedi maybe your repl is not in the right namespace |
| 19:54 | tufflax | e.g. your file is (ns myfile) but your repl says "user>" |
| 19:55 | yedi | yea |
| 19:55 | tufflax | was that it? :P |
| 19:55 | yedi | i think |
| 19:55 | yedi | how can I change namespace to the proper one? |
| 19:55 | tufflax | just do (ns the-right-one) |
| 19:55 | tufflax | i think that should work |
| 19:55 | tufflax | in the repl |
| 19:56 | yedi | is there a function to check what the current namespace is |
| 19:56 | tufflax | there is a var i think |
| 19:56 | tufflax | like *ns* |
| 19:56 | tufflax | or somthing |
| 19:59 | tufflax | yedi there are a lot of useful vars, like *command-line-args* *e (the last error) *1, *2 (the last, second to last, etc return value to the repl) *ns* |
| 19:59 | tufflax | and a few more |
| 20:07 | yedi | cool thanks |
| 20:09 | Sgeo_ | Does Lamina spawn any threads, or do I have to be careful of, say, taking a long time to do something in a receive-all if there are multiple things wanting to read from forks of the channel? |
| 20:16 | yedi | i have two functions that need to load the same thing from a file, but the functions do different things |
| 20:16 | yedi | sometimes i want to call the two functions in the same function |
| 20:17 | yedi | but i don't want to have to load something twice |
| 20:17 | yedi | is there a semantic way to only load it once and share it between the two files |
| 20:18 | tufflax | yedi well if you separate out the loading part, and instead let the functions take the string as input |
| 20:18 | tufflax | then it's pretty simple |
| 20:19 | tufflax | watch this: http://www.infoq.com/presentations/Simple-Made-Easy :) |
| 20:21 | yedi | so obvious, thanks tufflax |
| 20:22 | sporkball | Is there a way to have a test in clojure.test fail if an exception _is_ thrown? using (is (thrown? passes if the exception is thrown, but I want the test to pass in all cases unless a specific exception is thrown |
| 20:22 | ivan | yedi: http://blog.getprismatic.com/blog/2012/10/1/prismatics-graph-at-strange-loop.html is a much more general solution to the problem |
| 20:22 | ivan | anyone know when prismatic graph will get released? |
| 20:24 | yedi | yea i was thinkin that ivan |
| 20:24 | yedi | but i figured my systtem wasn't complex enough to need it |
| 20:25 | Sgeo_ | Is there a way to have a Lamina channel close if there are no references to it? |
| 20:28 | yedi | is there an last(inverse-first) and inverse-rest |
| 20:34 | bbloom | now I recall why I stopped writing blog posts… I'm as verbose as yegge…. i'll finish later…. it's turkey time. |
| 20:50 | TimMc | Oh man, it was such a pain to try to write a Clojure webapp while offline yesterday. |
| 20:52 | TimMc | `lein2 ring server` was a surprise source of pending dependencies; a lot of Clojure syntax isn't discoverable from the source; some important libs rely on online-only docs. |
| 20:56 | tufflax | TimMc, I'm sorry, what syntax are you talking about? |
| 21:08 | hakujin | is the volkmann tutorial the best place to start learning? |
| 21:09 | yedi | ,(doc when) |
| 21:09 | clojurebot | "([test & body]); Evaluates test. If logical true, evaluates body in an implicit do." |
| 21:11 | brehaut | hakujin: it claims to have been updated in the last few months, but it doesnt list a clojure version that i can see, so i guess its still current |
| 21:11 | hakujin | brehaut: thanks |
| 21:12 | moogatronic | hakujin: probably implement something easy, and ref that tut. |
| 21:12 | hakujin | should I just start with the repl? or dive in to leiningen |
| 21:12 | moogatronic | (among others) |
| 21:12 | moogatronic | hakujin: leiningen will let you just use the repl, and make the class path stuff easier when you want to experiment with various libs. |
| 21:13 | hakujin | moogatronic: thanks |
| 21:13 | moogatronic | if you install leiningen, you can do 'lein new fooproject', and then in the fooproject directory, type 'lein repl' and it will use the class path libs specified in the project.clj |
| 21:13 | brehaut | hakujin: lein is the front end to the language so yeah, use it |
| 21:14 | moogatronic | hakujin: I suggest lein2, which i believe is the default now on the github page. |
| 21:14 | moogatronic | hakujin: do you use emacs? |
| 21:16 | brehaut | it is not recommended that anyone learn a new editor while learning clojure |
| 21:17 | moogatronic | brehaut: yeah, but if he already uses emacs, emacs+nrepl.el / etc is significantly more awesome than just lein repl |
| 21:17 | brehaut | agreed |
| 21:18 | moogatronic | I'm not sure what the 'state of the art' is with regards to sublime text 2 and nrepl integration. Anyone use that combo? |
| 21:20 | muhoo | TimMc: i've had that problem. you almost have to do all your lein check stuff ahead of time, make sure all the libs are loaded, and hope you don't need new ones. |
| 21:21 | muhoo | i also git clone all libraries i might need, so the README.md file is local |
| 21:22 | TimMc | tufflax: Destructuring, mostly. |
| 21:22 | muhoo | source is in the actual jar files, which is nice. it'd be nice if lein included the readme and docs in jars though. then you could have offline docs |
| 21:23 | hakujin | moogatronic: I use vim |
| 21:25 | jyu | need i load file by shortcut when I make change using emacs and nrepl.el, the book programming clojure says some change have to load again, is it? |
| 21:31 | yedi | tufflax: the namespace thing wasn;t the problem |
| 21:33 | yedi | because I set the namespace to my file and nrepl's repl still can't resolve any symbols |
| 21:35 | moogatronic | yedi: what is your issue? this sounds similar to something I'm hitting |
| 21:37 | yedi | i can't run any functions in my repl because i keep getting the unable to resolve symbol error |
| 21:37 | moogatronic | is this after you've re-started nrepl? |
| 21:38 | moogatronic | i could be reading into your issue… =) I have trouble with nrepl.el and symbol errors unless i switch into an arbitrary namespace in my project and recompile. (only after killing the server and restarting it though) |
| 21:38 | yedi | ill try restarting the server |
| 21:39 | yedi | im new to both nrepl and emacs, so things are lil bit confusing |
| 21:40 | moogatronic | yedi: yeah, it's sadly still a bit confusing. Once you figure it all out though, it seems easy. =) |
| 21:42 | moogatronic | yedi: are you running nrepl-jack-in or connecting to some other nrepl server that you started from cmd line? |
| 21:42 | yedi | jack-in |
| 21:44 | moogatronic | it *should* work if you kill the nrepl-server buffer, and run jack-in again. I still have some weirdness where i have to run (in-ns 'arbitrary.namespace.in.project) before C-c C-k or C-x C-e will work |
| 21:49 | Frozenlock | Clojure/java interop: Is there a way to get all the fields from a class, as usually seen in "Field summary" in a javadoc? I tried .getFields and .getDeclaredFields, but some things returned aren't in the class Field summary. |
| 22:01 | john__ | greetings |
| 22:01 | john__ | lisp newb here |
| 22:01 | moogatronic | hi john__ |
| 22:01 | john__ | i'm trying to write a simple blackjack CLI app and (coming from ruby) not sure how to store the current value of the cards |
| 22:02 | john__ | its basically "while (n < 21) (add (rand-int 10) count)" |
| 22:02 | john__ | but i'm not sure how to store stuff in a variable, since theres no variables like in ruby |
| 22:02 | moogatronic | Well, you can use Atoms if you want some sort of mutable state |
| 22:03 | john__ | i don't think i need atoms since its not async or anything, i think i'm just missing 'the lisp way' on how to do this |
| 22:03 | john__ | like pass a number through a function repeatedly or something |
| 22:03 | moogatronic | ah. |
| 22:03 | john__ | i read somethin about recursive functions |
| 22:04 | john__ | where i could call the same function again but pass in the new number? |
| 22:04 | moogatronic | seems to always boil down to map and reduce. You can do loop / recur as well |
| 22:04 | john__ | ah recur is the one i think |
| 22:04 | moogatronic | john__: Loop recur matches what you're talking about. |
| 22:04 | john__ | is that where it calls the same function again? |
| 22:04 | brehaut | (let [cards (atom #{})] (while (< 21 (blackjack-sum @cards))) …)) |
| 22:05 | moogatronic | recur re-enters at the point where you set up your (loop [bindings] … (recur new-bindings)) |
| 22:05 | john__ | cool that looks like the one |
| 22:05 | john__ | so i'd bind [count] to 0 initially, and do (recur <new-count>) |
| 22:07 | moogatronic | that should work. there may be better idioms to employ here, but without seeing the entire code and all, I can't say. I always go with what works *now* and then revise later. =) Especially if you're learning. |
| 22:07 | john__ | sure i'm just starting out |
| 22:07 | john__ | i got intrigued by all the each'ing and map'ing in ruby ;) |
| 22:08 | moogatronic | this has some examples, and is generally useful. Perhaps you've seen it: http://clojuredocs.org/clojure_core/clojure.core/loop |
| 22:08 | john__ | yea i got there from the cheat sheet thx |
| 22:08 | moogatronic | ah ok |
| 22:08 | brehaut | (just btw, that while loop was not a serious suggestion) |
| 22:09 | john__ | brehaut: heh |
| 22:14 | zerokarmaleft | moogatronic: heyo, long time |
| 22:14 | moogatronic | zerokarmaleft: hey! no doubt. were you at the conj this year? |
| 22:14 | zerokarmaleft | i had a ticket, but i had to cancel my trip :( |
| 22:15 | zerokarmaleft | moogatronic: did you go? |
| 22:15 | TimMc | muhoo: Yeah, I updated my ring and compojure clones ahead of time. :-) |
| 22:15 | moogatronic | ah. yeah, I did. it was awesome. The presentations make much more sense after having had a year to implement things using clojure. =) |
| 22:17 | zerokarmaleft | indeed, looking forward to the talks getting posted on infoq or wherever |
| 22:18 | brehaut | TimMc: it is a pity compojures docs are mostly on the wiki |
| 22:19 | moogatronic | zerokarmaleft: I ended up staying at the Sheraton this year as well. That was nice. No 1.3 mile walk each morning and night. |
| 22:19 | john__ | haha nice almost there |
| 22:20 | moogatronic | Clojure west is in portland, which has me contemplating. Can't really justify another trip in march… but Portland is on my should-visit list... |
| 22:21 | john__ | is there a command to quit the program when i bust over 21? |
| 22:21 | john__ | or would i reverse engineer it in a way that the program only continues below 21 |
| 22:22 | yedi | moogatronic: thanks alot, in-ns worked |
| 22:22 | moogatronic | you could just (if (> val 21) (return value branch) (recur blah blah branch)) |
| 22:22 | moogatronic | yedi: yeah, i'm not sure why you have to do that. I recently switched from swank to nrepl, and discovered that issue. |
| 22:23 | zerokarmaleft | moogatronic: i'll have to convince my wife that portland in march is the ideal place for a second honeymoon |
| 22:23 | moogatronic | zerokarmaleft: Microbrew capital of the world? Gigantic second hand book store? Clojure? Bikes? Portlandia? |
| 22:24 | brehaut | the dream of the 90s is alive |
| 22:24 | john__ | moogatronic: i have a 'round' function determining if i win and a 'main' function with the loop. seems like i would have to have the test and the recur in the same function? |
| 22:24 | zerokarmaleft | she's allergic to gluten sadly, which severely limits the kinds of beer she can drink sadly |
| 22:25 | zerokarmaleft | plenty of wineries around though |
| 22:25 | john__ | zerokarmaleft: on the other hand, she'll always stay thin :) |
| 22:25 | moogatronic | john__ if you want to break out of the recur, yeah, you have to have some test in your loop. |
| 22:26 | moogatronic | zerokarmaleft: I think there are some micro-distilleries in portland as well. My wife has an issue with tyramine which is present in all fermented things, so distilled liquor is the only way to go for her. I'm not sure of residual gluten levels in whiskies though. |
| 22:30 | john__ | moogatronic: sweet, i did it with 'let' |
| 22:30 | john__ | returned the new value from round and only recur if it isn't nil |
| 22:30 | moogatronic | john__: sounds legit! =) |
| 22:31 | john__ | in general, do you guys write (function-name [args] ..) or do you put everything into its own line? |
| 22:31 | moogatronic | you mean when defn 'ing ? |
| 22:31 | john__ | both defn'ing and invoking |
| 22:32 | john__ | i currently do (defn welcome [] |
| 22:32 | brehaut | it depends |
| 22:32 | moogatronic | well, i like my docstrings… so i do |
| 22:32 | moogatronic | (defn \n "some docs" \n [the args] \n the other stuff) |
| 22:32 | moogatronic | but if the function is small and obvious and fits < 80 chars, then one line. |
| 22:32 | john__ | ok |
| 22:32 | john__ | next question: how do i comment out a line containing quotes? |
| 22:34 | moogatronic | not sure i understand. ;; / ; work for me. depending on your editor/mode |
| 22:35 | john__ | ah, i thought you commented stuff out using "" |
| 22:35 | john__ | thx for that |
| 22:35 | moogatronic | in emacs, sometimes you select the line and M-; it. |
| 22:35 | john__ | i use vim |
| 22:35 | john__ | but yea everybody who uses lisp seems to be loving emacs |
| 22:35 | john__ | maybe i'll look into that some time |
| 22:36 | john__ | the ; did it, thx |
| 22:36 | moogatronic | I saw some pretty impressive vim users at the conj. |
| 22:36 | moogatronic | presenters, etc. |
| 22:36 | john__ | vim is amazing if you know it |
| 22:36 | john__ | it doesn't seem to integrate witht he repl well |
| 22:36 | moogatronic | when my ergo-wrist-problem flares up, I switch to EViL mode in emacs. |
| 22:36 | john__ | as opposed to emacs, which IS a repl |
| 22:36 | moogatronic | modal editing seems to be more ergonomic for me at any rate. |
| 22:37 | john__ | yup that's wht i gather |
| 22:38 | moogatronic | john__: are you using the VimClojure stuff? |
| 22:38 | brehaut | moogatronic: travis rudd has voice controlled emacs |
| 22:38 | moogatronic | brehaut: !! |
| 22:39 | john__ | moogatronic: i have it installed, but haven't used any of it yet. this is my very first .clj file ;) |
| 22:39 | brehaut | i understand it is a bit ductape and twine, but nevertheless |
| 22:39 | moogatronic | brehaut: i'm already on a kinesis advantage, trackball, etc. but that sounds interesting. |
| 22:40 | brehaut | whoa, my bad, tavis rudd, no r |
| 22:41 | moogatronic | looks like he presented this setup at Strangeloop. I need to remember to watch that talk. |
| 22:41 | brehaut | yeah i believe so |
| 22:42 | brehaut | also, his emacs.d is on his github |
| 22:43 | moogatronic | it's an interesting concept. I wonder if switching between dictation and typing has any other side-effect benefits. |
| 22:44 | john__ | at the end of a 'do', i want to return either a number or nil. can i do this using (if (stuff) (println "should return nil) number) ? |
| 22:44 | brehaut | huh, emacs itunes binding. thats handy |
| 22:45 | john__ | or does the else branch of an if have to be a function? |
| 22:45 | moogatronic | you can return anything at th end of an else branch |
| 22:45 | john__ | k |
| 22:46 | flying_rhino | just to check something: appart from let, there are no local vars? |
| 22:48 | john__ | wooo :) it works! |
| 22:50 | john__ | http://pastebin.com/mTKTjRKa |
| 22:50 | john__ | if you wnt to see the code |
| 22:52 | moogatronic | john__: you don't need most of those explicit (do …) statements |
| 22:52 | john__ | oh? |
| 22:52 | john__ | can i just jam a bunch of functions? |
| 22:52 | moogatronic | yeah, you can just jam all the functions in the defn |
| 22:53 | moogatronic | you need it for your if branches tho |
| 22:53 | john__ | ok |
| 22:53 | john__ | but not in defn? |
| 22:54 | moogatronic | yeah |
| 22:58 | john__ | i still sometimes get a nullpointer exception at the end |
| 22:58 | john__ | when it tries to add up nil and the number in add-card |
| 23:02 | moogatronic | john__: you could return 0 instead of (println …) (do (println "blah") 0) |
| 23:05 | john__ | feels like i should move the busted? test from the round function into the main function |
| 23:05 | john__ | now i'm having to test twice essentially |
| 23:06 | john__ | but it did fix the NPE, thx |
| 23:06 | moogatronic | yeah, i think it fits better there. |
| 23:12 | john__ | cool |
| 23:12 | john__ | thx for your help guys, especially moogatronic |
| 23:12 | john__ | i like the way you have to think differently in clojure |
| 23:12 | john__ | see you later! |
| 23:12 | moogatronic | No prob. Later, and good luck. The FN thinking re-boot is quite nice. |
| 23:13 | moogatronic | recovering j2ee guy here… =) |
| 23:13 | john__ | hehe see you |
| 23:23 | atom_ | Happy Thanksgiving clojurites |
| 23:23 | atom_ | and if you're not in the US, hi. |
| 23:25 | wingy | woohoo |
| 23:26 | sporkball | atom_, what if you're an American, but not in the US #edgecase :) |
| 23:27 | atom_ | sporkball: It would apply then. You're included! |
| 23:27 | sporkball | atom_: hooray! Happy Thanksgiving to you, too |
| 23:28 | atom_ | sporkball: Thanks! Nothing like ending a feeding frenzy day like letting Clojure kick you around for awhile. :D |
| 23:30 | sporkball | atom_: It's a quick cure for a tryptophan hangover, for sure. |
| 23:30 | sporkball | atom_: whole turkeys are ridiculously expensive here in China, though, so we had chicken and duck instead -- delicious, but not quite the same. A turducken missing it's most important layer. |
| 23:31 | atom_ | sporkball: Well, it is the most important part. However, duck is an adequate substitution! Especially with the crispy skin. |
| 23:32 | sporkball | atom_: it was respectable, especially considering that I cooked it and well… I don't really _do_ that sort of thing. |
| 23:33 | atom_ | sporkball: I hear you. I leave the cooking to grandma and mom. Although I did venture out into baking and did a gluten free pumpkin pie. |
| 23:34 | sporkball | atom_: nice! |
| 23:34 | akhudek | Has anyone written a sorted bag data structure for clojure? |
| 23:58 | flying_rhino | what begginer's IDE would you recommend for me? (Right now I mostly use clojure vie repl via leiningen) |
| 23:58 | flying_rhino | *via |