2012-12-17
| 00:35 | metellus | um. |
| 01:07 | seangrove | cljs in chrome extensions is really pretty frustrating |
| 01:11 | seangrove | I have to do this for any object that's originated from the content-script: (js->clj (goog.json/parse (goog.json/serialize object-from-content-script)) :keywordize-keys true) |
| 01:15 | seangrove | I don't really understand this: http://dev.clojure.org/jira/browse/CLJS-439 |
| 01:16 | seangrove | Why not use goog.isObject instead of (identical? js/object .)? |
| 02:24 | amalloy | seangrove: tomoj probably knows |
| 02:25 | seangrove | amalloy: Using goog.isObject in that function seems to work fine. I've just copied/pasted it into a helper function I can use instead |
| 02:26 | amalloy | i'm the wrong person to tell |
| 02:26 | tomoj | so now try js->clj on some weird stuff |
| 02:26 | tomoj | like a function |
| 02:27 | tomoj | or any random object |
| 02:27 | tomoj | like a dom node or something |
| 02:27 | tomoj | that may cause havoc.. |
| 02:28 | seangrove | Ah, damn |
| 02:28 | seangrove | I suppose I can use it with some modifications for my needs of host<->CS communications though |
| 02:29 | tomoj | maybe just extend IEncodeClojure to your other frame's Object |
| 02:29 | tomoj | dunno if you can do that |
| 02:31 | seangrove | Yeah, not sure how to do that, or how to get a reference to the other frame's Object |
| 02:37 | tomoj | probably impossible I guess |
| 04:57 | mindbender1 | what are some undeniable benefit of typed clojure as against untyped clojure |
| 04:58 | HolyJak | mindbender1: https://github.com/frenchy64/typed-clojure#readme ? |
| 04:58 | clgv | mindbender1: compile time errors when you pass the wrong type to a function, I'd guess |
| 04:58 | mindbender1 | to me it looks more like beginner beenfits |
| 04:59 | mindbender1 | something to help novice programmers to be more type conscious |
| 04:59 | clgv | mindbender1: if you have your core source completely typed and you change functions signatures that is a really useful tool to find the places where you forgot to change a function invocation |
| 05:00 | clgv | this is the kind of error which annoyed me a lot during some refactoring |
| 05:00 | benedikt | there is a typed clojure? |
| 05:01 | HolyJak | benedikt: indeed; https://github.com/frenchy64/typed-clojure#readme |
| 05:01 | benedikt | cool! |
| 05:02 | mindbender1 | clgv: I think your case is a really good use case |
| 05:02 | mindbender1 | should be mentioned in thagt readme |
| 05:03 | mindbender1 | please guys if you have more use case let's share it |
| 05:03 | clgv | mindbender1: I like the idea of external optional typing. I dont know if it is yet so good that you can have the typestuff in completely different files. that would be awesome^^ |
| 05:11 | jballanc | I'd imagine that, eventually, typed clojure could implement certain optimizations that wouldn't be available to regular clojure |
| 05:12 | jballanc | although, that's probably all washed out by hotspot |
| 05:12 | clgv | jballanc: typed clojure only checks. you would need additions to clojure's compiler to apply optimizations |
| 05:15 | jballanc | right, that's what I mean...once type guarantees are in place, you could (in theory) utilize that information for optimization |
| 06:00 | mindbender1 | I thought there was a lein newnew template for lib skeleton |
| 06:00 | mindbender1 | lein new lib foo |
| 06:19 | tgoossens | the dereferencing to get a snapshot is a great idea! But! What in the following case: (def r1 (atom [])) (def r2 (atom [r1])) |
| 06:19 | tgoossens | @r2 |
| 06:20 | tgoossens | not really a stable value as promised |
| 06:21 | tgoossens | this could be a game board |
| 06:21 | tgoossens | with players on it |
| 06:21 | tgoossens | how to cope with this? |
| 06:32 | clgv | tgoossens: you want a consistent snapshot of both r1 and r2? |
| 06:33 | tgoossens | no, i'm just stating that @r2 doesn't really give you a snappshot of whats the situation was back then |
| 06:33 | tgoossens | because the nested atom r1 can still change |
| 06:33 | tgoossens | so its a weird situation |
| 06:34 | tgoossens | not sure what it does when you would go back in history of the persistent data structure |
| 06:34 | clgv | hm what? please make one or two complete setences to describe what you want |
| 06:34 | edlothiol | tgoossens: that's (one reason) why nesting atoms is a bad idea |
| 06:34 | clgv | oh they are nested ^^ |
| 06:34 | tgoossens | :) |
| 06:35 | tgoossens | nested atoms just break all the goodness that comes with immutability |
| 06:35 | clgv | yeah better do not do that if you need a consistent snapshot |
| 06:36 | tgoossens | i came up with it because i have the situation of |
| 06:36 | tgoossens | a game board, and pieces |
| 06:36 | clgv | you could have an immutable array with [r1 r2] though |
| 06:36 | tgoossens | hmmm |
| 06:37 | tgoossens | thats not such a stupid idea :p |
| 06:37 | clgv | you could put the whole thing in a map within an atom: (atom {:board [field1 field2 ...] :pieces [pieces1 piece2 ...]} |
| 06:37 | tgoossens | yes i was just thinking that |
| 06:37 | tgoossens | but how do i model the following: |
| 06:38 | clgv | if that doesnt work well, you can use refs for all mutable entities and get the consistent snapshot within a transaction |
| 06:38 | tgoossens | another (concurrent) user of the system wants to track movement of a certain piece over time |
| 06:38 | tgoossens | the easiest solutions is of couse to nest identities here. but then i'm back at my problem |
| 06:39 | clgv | tgoossens: the pieces have implicit ids within the vector I used in the example above, so (get-in @game [:pieces 1]) works |
| 06:39 | tgoossens | hmmm |
| 06:39 | tgoossens | mmyes |
| 06:41 | clgv | if you need to have change-handlers on every pieces you probably need to use refs instead |
| 06:42 | tgoossens | in my OO project (i'm rethinking it in clojure now) |
| 06:42 | tgoossens | i had a Board class & a Piece class |
| 06:43 | tgoossens | they were coupled: board.getPieces() , piece.getBoard() |
| 06:43 | tgoossens | maybe i'm trying too hard to get that functionality as well |
| 06:44 | mindbender1 | clojure is about looking at your problems from a different point of view as clgv is stressing |
| 06:45 | tgoossens | i'm trying ;) |
| 06:45 | clgv | just forget about those classes and use data representations instead |
| 06:46 | clgv | it helps to define the operations you need on that data to decide if it needs any special structure |
| 06:46 | mindbender1 | I can't stress enough how Rich Hickey talks hepled |
| 06:46 | mindbender1 | helped |
| 06:46 | tgoossens | i've seen a lot of them |
| 06:46 | mindbender1 | listen to it over and over and over and over again |
| 06:47 | tgoossens | maybe next semester, first exams :D |
| 06:49 | clgv | tgoossens: computer science? |
| 06:51 | tgoossens | yes |
| 06:51 | tgoossens | clgv: kuleuven belgium, 3th bachelor Computer Science |
| 06:52 | clgv | so more theoretical computer science now? |
| 06:52 | andrewmcveigh|wo | tgoossens: You must be the only other person in Belgium I've heard of using Clojure! |
| 06:52 | tgoossens | Where are you from then? |
| 06:52 | tgoossens | (in belgium) |
| 06:53 | andrewmcveigh|wo | I'm from the UK, but I'm in Brussels. |
| 06:53 | tgoossens | ah cool. Well in fact I discovered clojure via another belgium guy |
| 06:54 | tgoossens | i'm still pretty unexperienced, but i got tired of always having to think and work with java/OOP. So i went out on discovery to find something drastically different |
| 06:54 | tgoossens | and ended up with clojure |
| 06:55 | andrewmcveigh|wo | You're from Leuven, or just studying there? |
| 06:57 | t-goossens | I might be the only one at my univ that works with clojure |
| 06:57 | t-goossens | Who knows |
| 06:58 | andrewmcveigh|wo | I wouldn't be suprised, I think there were only a couple of people who did anything but java when I was at uni. Few years ago though now. |
| 06:59 | t-goossens | Here almost all courses are java OoP based |
| 07:00 | andrewmcveigh|wo | Yeah, it's a shame that. |
| 07:00 | t-goossens | Next semester I think im going to read |
| 07:00 | t-goossens | Seven program language s in seven weeks |
| 07:01 | t-goossens | Looks interesting |
| 07:01 | t-goossens | And broading |
| 07:02 | andrewmcveigh|wo | I just heard about that book the other day. Is it new? |
| 07:02 | Raynes | Not really. |
| 07:03 | andrewmcveigh|wo | Maybe someone mentioned it on here... |
| 07:11 | clgv | can I add an additional "jar" to the classpath leiningen uses for lein repl? just for a one-off test scenario |
| 07:12 | llasram | clgv: You can add the JAR file path to the project :resource-paths |
| 07:25 | tgoossens | andrewmcveigh: enjoy your stay in belgium. I'll be offline for the coming month (exams need a bit more focus ) So cya! |
| 07:25 | andrewmcveigh|wo | tgoossens: cheers. Study well! |
| 07:27 | clgv | llasram: ah thx |
| 07:30 | tomoj | what is the contract of IEditableCollection/ITransientCollection? |
| 08:32 | TimMc | llasram: I finally released lein-otf 2! |
| 08:41 | clgv | TimMc: ah the one with automatically generated main-function? |
| 08:41 | PudgePacket | Hey, I'm doing the clojure koans, and I'm upt o recursion. The questions are really weird, do you guys have any pointers ? |
| 08:42 | PudgePacket | Why would the function is-even? continually decrement ? how does that check if it's even or not at all ? |
| 08:42 | clgv | PudgePacket: if it changes the state of another boolean parameter it can |
| 08:42 | babilen | PudgePacket: You you mind sharing the function (e.g. on http://refheap.com) or give us a link to the particular question? (I, for one, haven't memorised all the koans) |
| 08:43 | PudgePacket | https://www.refheap.com/paste/7658 |
| 08:43 | clgv | PudgePacket: you can decrement and remember whether you decremented an odd or even number in total. if you reach zero you know whether the number was even or odd |
| 08:44 | babilen | clgv: How do you determine if the number of decrement steps (say k) is even or odd? |
| 08:45 | PudgePacket | Is there a function that can be called that will show how many times the function it's in has recursively called itself ? |
| 08:45 | clgv | babilen: 1. dec -> odd, 2. dec -> even, 3. dec -> odd ... |
| 08:46 | clgv | PudgePacket: do you want a spoiler there? |
| 08:46 | PudgePacket | then you would have to pass n, and another value to count how many times it has been called |
| 08:46 | PudgePacket | I don't really mind, i understand recursion and i've used it before, it's just this example is really confusing me, it's such a weird way to do it |
| 08:46 | clgv | PudgePacket: hint: is 0 even or odd? and what is n if n-1 is even? what in the case of odd? |
| 08:46 | clojurebot | No entiendo |
| 08:46 | babilen | clgv: Why do you have to count how often you decrement? You will decrement exactly k times if the number you are testing is k |
| 08:47 | clgv | babilen: it's not counting just switching the even and odd state |
| 08:48 | clgv | babilen: I'd check 0th bit if I really needed to implement it ;) |
| 08:48 | babilen | clgv: That would be a sensible way to implement that, but I haven't seen the function PudgePacket is asking about yet and can't say anything about /that/ implementation. |
| 08:48 | PudgePacket | https://www.refheap.com/paste/7658 |
| 08:48 | babilen | clgv: Do /you/ have a link ... ? Ah, thanks PudgePacket :) |
| 08:49 | clgv | babilien: I gave him a hint. theres nothing more left than the spoiler ^^ |
| 08:50 | babilen | clgv: Ah, forget it then. I thought the question was: "Why is is-even? implemented as NEVER-SEEN-THIS which /only/ decrements?" Not: "How could I implement is-even? in a way that decrements/increments a number?" |
| 08:52 | PudgePacket | ok I can't figure it out |
| 08:52 | PudgePacket | ......... |
| 08:52 | PudgePacket | without altering the structure of the function, i don't see how i would implement it |
| 08:53 | TimMc | clgv: It's the thing that makes uberjars non-AOT, yeah. |
| 08:55 | clgv | PudgePacket: spoiler in PM... |
| 09:20 | AWizzArd | I have a sequence s and three functions f1, f2 and f3. I would like to apply the three fns to s and concat their results. Is there a more readable way than (mapcat #(% s) [f1 f2 f3])? |
| 09:21 | AWizzArd | ,(mapcat #(% (range 9)) [identity #(partition 2 %) #(partition 3 %)]) |
| 09:21 | clojurebot | (0 1 2 3 4 ...) |
| 09:21 | AWizzArd | ==> (0 1 2 3 4 5 6 7 8 (0 1) (2 3) (4 5) (6 7) (0 1 2) (3 4 5) (6 7 8)) |
| 09:25 | sgeo | Using juxt maybe? |
| 09:25 | sgeo | ,((juxt identity #(partition 2 %) #(partition 3 %)) (range 9)) |
| 09:25 | clojurebot | [(0 1 2 3 4 ...) ((0 1) (2 3) (4 5) (6 7)) ((0 1 2) (3 4 5) (6 7 8))] |
| 09:26 | sgeo | ,(-> ((juxt identity #(partition 2 %) #(partition 3 %)) (range 9)) (apply concat)) |
| 09:26 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$concat> |
| 09:26 | sgeo | ,(->> ((juxt identity #(partition 2 %) #(partition 3 %)) (range 9)) (apply concat)) |
| 09:26 | clojurebot | (0 1 2 3 4 ...) |
| 09:26 | sgeo | I don't know if that's actually more readable :/ |
| 09:35 | jsabeaudry | Recommendations for a notification library from clojurescript? |
| 09:41 | mthvedt | are clojure core protocols standardized? that is, if i write something implementing clojure protocols--a new data structure, for example--is there a guarantee it'll work on clj/cljs/clj-clr/whatever going forward? |
| 09:49 | clgv | AWizzArd: what is not readable with the mapcat approach? |
| 09:52 | stuartsierra | mthvedt: no |
| 09:53 | stuartsierra | At the moment the protocols are different in Clojure/ClojureScript. |
| 09:54 | mthvedt | stuartsierra: thanks |
| 09:55 | stuartsierra | Maybe someday they can be brought into agreement. |
| 09:55 | mthvedt | yes, iirc host independence for the core lib was one of the reasons for protocols |
| 10:13 | bosie | i installed lein-midje via the plugin install mechanism and now i see this in my lein project: "leiningen.midje Problem loading: java.io.FileNotFoundException: Could not locate leiningen/core/eval__init.class or leiningen/core/eval.clj on classpath: (midje.clj:3)" |
| 10:14 | bosie | anyone know why? |
| 10:14 | duck1123 | which version of lein are you using? |
| 10:14 | bosie | fresh install |
| 10:14 | clojurebot | I don't understand. |
| 10:14 | bosie | lets see |
| 10:14 | bosie | omg |
| 10:15 | bosie | its not 2.0 |
| 10:15 | duck1123 | that'll do it |
| 10:16 | AWizzArd | sgeo: yes, juxt is a good idea. |
| 10:17 | bosie | guess i have to manually install leiningen |
| 10:17 | hyPiRion | manually? |
| 10:17 | hyPiRion | Are you running windows or linux? |
| 10:17 | bosie | osx |
| 10:17 | hyPiRion | oh |
| 10:18 | duck1123 | the manual process is still pretty automatic |
| 10:18 | bosie | thankfully |
| 10:19 | bosie | and voila |
| 10:19 | bosie | lein-midje is installed |
| 10:20 | bosie | thanks duck1123 |
| 10:20 | clgv | AWizzArd: but (apply concat ((juxt f1 f2 f3) s)) is even longer ;) |
| 10:21 | hyPiRion | (mapcat #(% s) [f1 f2 f3]) is short and sweet, no? |
| 10:25 | clgv | I'd say so ^^ |
| 10:28 | AWizzArd | It is short, yes. I just have the general concept to map over values. Of course, functions are the values here. But still, juxt is also not a bad candidate, because it directly brings the specific idea/mindset. |
| 10:29 | AWizzArd | Typically in 99% of my map calls the f in #(f …) is fix, while the varying stuff comes then. |
| 10:31 | AWizzArd | juxt is doing exactly that core task |
| 10:35 | clgv | but it is not concatenating the results for you |
| 10:37 | clgv | &(apropos "lazy") |
| 10:37 | lazybot | ⇒ (lazy-cat lazy-seq *lazybot-dir*) |
| 10:38 | clgv | humm interesting. repl-y in lein2-prev10 shows something called "lazy-clojuredocs"... |
| 10:52 | grc | Macro question: I'm trying to calculate a value in a macro and use that value in mygenerated code but I'm getting an error "can't use qualified name as a parameter" |
| 10:52 | grc | Example (defmacro foo [a] (let [bar (+ a 2) ] `(fn [bar] (* bar 3)) ) ) |
| 10:52 | gfredericks | ah ha |
| 10:52 | gfredericks | ,`(fn [bar] (* bar 3)) |
| 10:52 | clojurebot | (clojure.core/fn [sandbox/bar] (clojure.core/* sandbox/bar 3)) |
| 10:53 | gfredericks | ,(let [bar (+ 7 2)] `(fn [bar] (* bar 3))) |
| 10:53 | clojurebot | (clojure.core/fn [sandbox/bar] (clojure.core/* sandbox/bar 3)) |
| 10:53 | gfredericks | ,(let [bar (+ 7 2)] `(fn [~bar] (* ~bar 3))) |
| 10:53 | clojurebot | (clojure.core/fn [9] (clojure.core/* 9 3)) |
| 10:53 | gfredericks | ^ note this still doesn't make sense since 9 is not a valid function arg-name |
| 10:53 | gfredericks | ,(let [bar (+ 7 2)] `(fn [bar#] (* ~bar 3))) |
| 10:53 | clojurebot | (clojure.core/fn [bar__105__auto__] (clojure.core/* 9 3)) |
| 10:54 | gfredericks | it's not clear what you're actually trying to do from your example, so either of those tactics could be relevant |
| 10:55 | clgv | grc: you have to use gensyms for bindings within syntaxquote, e.g. `(fn [bar#] (* bar# 3)) |
| 10:56 | grc | gfredericks: I'm generating a function definition where the macro's argument is used (after modification) in the function so your final example looks right. What's the purpose of the trailing # |
| 10:56 | grc | ah - gemsyms |
| 10:56 | clgv | grc: that one would be: (defmacro foo [a] (let [bar (+ a 2) ] `(fn [] (* ~bar 3)) ) ) |
| 10:56 | clgv | the `bar` as fn param is superfluous I guess... |
| 10:57 | gfredericks | the fact that you had bar as a function argument made it unclear what you were doing, since bar was a number in the context |
| 10:57 | gfredericks | but debugging backquote is pretty easy since you can play with it outside of a defmacro |
| 10:58 | grc | Thanks for that and apologies for the ambiguous nature of the question. Off to play with backquotes and gensyms |
| 11:09 | clgv | do I need to stop an agent to get it garbage collected? or does not referencing it suffice? |
| 11:11 | jsabeaudry | Can I nest (context in compojure? i.e. (context "/foo" [] (context "/bar" [] foobar-routes)) |
| 11:12 | clgv | jsabeaudry: according to the docs yes |
| 11:12 | weavejester | jsabeaudry: Yep |
| 11:13 | S11001001 | clgv: they'll gc, they aren't rooted in any thread |
| 11:16 | TimMc | S11001001: That doesn't make sense to me. |
| 11:16 | clgv | S11001001: good :) |
| 11:17 | TimMc | clgv: Is this some local agent, or what? |
| 11:17 | S11001001 | TimMc: threads are rooted, so you have to kill them before they go away |
| 11:17 | clgv | TimMc: yeah. it's going into a closure. |
| 11:18 | TimMc | Ah, OK. I'm used to seeing them in vars. |
| 11:29 | jsabeaudry | clgv, weavejester: great, thank you! |
| 11:30 | clgv | TimMc: need them in a closure to coordinate data serialization within a callback |
| 11:33 | cark | now that javafx is provided with the jre, and considering it's not automatically in the classpath : what would be the lein project.clj incantation to make it available to the repl ? |
| 11:36 | clgv | cark: there is probably no way to do that, since you need to know the install directory... |
| 11:36 | cark | but but but ... |
| 11:37 | cark | in a pdf from oracle : |
| 11:37 | clgv | I'd make my life easy and keep it as dependency^^ |
| 11:37 | cark | Starting with JRE 7 Update 6, JavaFX Runtime is part of JRE installation |
| 11:37 | cark | No separate installation is needed for JavaFX, and there is no need to |
| 11:37 | cark | write custom code to detect where JavaFX is installed. |
| 11:38 | clgv | well then it must be on the classpath, right? |
| 11:38 | cark | it isn't =/ |
| 11:38 | cark | hum well |
| 11:38 | clgv | system classpath? |
| 11:38 | cark | how would i check that from the repl ? |
| 11:38 | clgv | do you have a profiler which lists such environment configurations? |
| 11:39 | cark | err nope =) |
| 11:39 | clgv | you could simply try an `import` with a known javafx class |
| 11:39 | cark | i tried that |
| 11:39 | clgv | and it did not work? |
| 11:40 | cark | nope didn't work, i wouldn't be pestering you about it if it did =) |
| 11:40 | cark | it's a pain to find documentation on the web about all this |
| 11:40 | cark | much is about older versions |
| 11:40 | clgv | right. hmm then you have to ask oracle about how the magic of the second sentence you quoted shall work^^ |
| 11:40 | cark | hehe i guess you're right =) |
| 11:41 | cark | how about the part where you said "i'd keep it as a dependency" |
| 11:41 | clgv | is it still available as single artifact via maven? |
| 11:42 | cark | just add it to the local repository and refer to it as a normal dependency ? |
| 11:42 | clgv | then use that one as dependency like before jre inclusion^^ |
| 11:42 | clgv | how did you include it until now? |
| 11:42 | cark | i never included it, i'm only now investigating it for a new project |
| 11:43 | cark | i'd love to have that web view thingie as gui instead of |@#@ swing |
| 12:05 | clgv | cark: depending on how strong you are sold to javafx - vaadin might be an option as well |
| 12:28 | technomancy | http://www.bonkersworld.net/object-world/ |
| 12:30 | hyPiRion | I suppose "object-oriented" => "java-enterprisey" |
| 12:31 | gtrak | yegge's kingdom of nouns is my fave |
| 12:32 | egghead | for want of a horse shoe nail |
| 12:32 | egghead | good reference |
| 12:52 | samrat | how would I send a file's contents using the PUT method? here's my current attempt which returns `ClassCastException [trace missing]`: https://www.refheap.com/paste/7668 |
| 12:52 | samrat | I'm trying to use dropbox's api, btw |
| 12:53 | TimMc | Without a stack trace, that's pretty hard to debug. |
| 12:53 | TimMc | ...but I'd check whether local-path is the value you think it is. |
| 13:06 | hyPiRion | Blech, Travis seems to fail authentication with GitHub |
| 13:08 | gfredericks | does != work well with the finite domain code? |
| 13:12 | gfredericks | oh I see there is a !=fd |
| 13:12 | dnolen | gfredericks: I commented on your ticket, and yes I would !=fd until the interaction between != and other constraints becomes more well understood. |
| 13:12 | samrat | TimMc: it should be something like "~/tmp/foo.bar" right? |
| 13:13 | gfredericks | dnolen: I saw the comment, thanks for the prompt response :) are you actively working on it or is it up for contributions? |
| 13:14 | dnolen | gfredericks: it's pretty low in the system - I'm working on it. |
| 13:15 | gfredericks | okay cool |
| 13:16 | TimMc | samrat: I can only guess wildly. |
| 13:21 | irctc712 | stuck in a macro problem |
| 13:22 | irctc712 | (defmacro init-db [params] `(doseq [[db-name host db] params] (defdb ~db-name (cfg/build-db-spec ~host ~db)))) |
| 13:22 | irctc712 | (defmacro init-db [params] `(doseq [[db-name# host# db#] ~params] (defdb db-name# (cfg/build-db-spec host# db#)))) |
| 13:22 | irctc712 | both don't work |
| 13:23 | hyPiRion | Well, what are the input parameters? |
| 13:23 | hyPiRion | The last one looks reasonable |
| 13:24 | hyPiRion | Though I'm not sure whether defdb is a macro or not. If it is, then it's attaching a gensym as name. |
| 13:24 | irctc712 | yeah defdb is a macro |
| 13:25 | irctc712 | the problem of second version is that db-name# should eval to real value, not just db-name# |
| 13:25 | irctc712 | no idea how to do that |
| 13:25 | hyPiRion | Yeah, here's the issue: ##`(def db-name# :foo) |
| 13:25 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 13:25 | hyPiRion | meanie, lazybot. |
| 13:25 | hyPiRion | ,`(def db-name# :foo) |
| 13:25 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 13:25 | llasram | irctc712: You need to iterate over `params` during macro-expansion |
| 13:26 | hyPiRion | or eval at runtime. |
| 13:26 | llasram | Or KILL BABIES |
| 13:26 | hyPiRion | clojurebot: eval |
| 13:26 | clojurebot | eval is evil |
| 13:27 | irctc712 | hyPiRion: could you elaborate |
| 13:27 | ohpauleez | technomancy: Do you have a document of tips for Code Swarming? PDX is about to do our first one this week. |
| 13:28 | irctc712 | is there a solution without using eval |
| 13:29 | llasram | irctc712: Yes. Your macro just needs to iterate over the groups in `params` itself, producing an expansion which contains `defdb` forms for every group |
| 13:29 | technomancy | ohpauleez: scripts and technical setup are in https://github.com/nuclearsandwich/swarming but the best general overview might be the clojure/west video here: http://www.infoq.com/presentations/Swarm-Coding |
| 13:30 | ohpauleez | technomancy: Thanks! |
| 13:31 | llasram | irctc712: something like (defmacro init-db [params] `(do ~@(for [[db-name host db] params] `(defdb ~db-name (cfg/build-db-spec ~host ~db))))) |
| 13:31 | technomancy | ohpauleez: np; hope it goes well |
| 13:31 | irctc712 | llasram: thanks, i'll have a try |
| 13:31 | hyPiRion | irctc712: llasram's solution is the "best" one in this case. |
| 13:42 | jweiss | what's the best way to avoid having to recompile multiple namespaces, when you change a var in one ns, that is referred to in several others? Let's say there are several levels of such references. seems like you would have to make them functions (maybe memoized)? |
| 13:43 | jweiss | (when i say referred to, i mean in a def) |
| 13:43 | S11001001 | jweiss: you'd have to make the referring points into functions |
| 13:44 | jweiss | S11001001: yeah, i can get away with rebuilding the data each call at runtime but generally that is bad. |
| 13:46 | llasram | jweiss: Anything which actually references the var (normal Clojure function calls included) doesn't need to be re-compiled |
| 13:46 | jweiss | llasram: yeah, i mean compile-time values eg, (def x (inc other.ns/y)) |
| 13:46 | jweiss | when i change y, i have to reeval that def |
| 13:48 | jweiss | i guess i'd change it to (defn x [] (inc other.ns/y)) |
| 13:49 | duck1123 | if y is a reference type, you could have a watcher update x when y changes, but that's probably not the best solution |
| 13:52 | auser | hola all |
| 14:03 | TimMc | jweiss: You could build a memoize variant that watches a single atom somewhere. Frob that atom, and all the "memos" are deleted. |
| 14:16 | dimovcih | hello people |
| 14:17 | dimovcih | can someone plz help me with some code... |
| 14:17 | TimMc | dimovcih: Just go ahead and ask your question; if someone can help they will answer. |
| 14:17 | dimovcih | why does (run a) cause the agent to fail with a null pointer error |
| 14:17 | dimovcih | https://www.refheap.com/paste/7669 |
| 14:20 | TimMc | I have no idea what that code is supposed to be doing... |
| 14:21 | dimovcih | increase the value held in agent a by 1 each time process is sent |
| 14:21 | dimovcih | the same principle as the crawler example from Clojure Programming book |
| 14:22 | TimMc | Page? |
| 14:22 | dimovcih | 222 |
| 14:23 | gfredericks | it looks like it will bounce back and forth at least until the agent is at 10? |
| 14:23 | borkdude | dimovcih I also don't understand the code, but it works in my repl: #<Agent@31eeeaed: 10> |
| 14:23 | dimovcih | gfredericks: yes |
| 14:23 | dimovcih | borkdude: strange... |
| 14:24 | gfredericks | yeah I can't see why it wouldn't work |
| 14:24 | borkdude | dimovcih clojure 1.4.0 here |
| 14:24 | dimovcih | jeezzz... now it works for me too... wtf... |
| 14:25 | TimMc | dimovcih: Did you have old versions of those defns in your REPL, perhaps? |
| 14:25 | dimovcih | TimMC: maybe |
| 14:25 | TimMc | I'm not up to speed on how redefinitions happen, but I'm wondering if process referred to an old version of run. |
| 14:26 | dimovcih | I tested it a couple of times with restarting the repl and got the same error ... |
| 14:26 | dimovcih | well, good to know it was a repl issue, and not code |
| 14:27 | dimovcih | lol, thanks |
| 14:27 | TimMc | So frustrating when that happens. |
| 14:39 | ohpauleez | $findfn [[1 2 3][1 2][1]] [1 2 3] |
| 14:39 | lazybot | [clojure.core/first] |
| 14:41 | gfredericks | $findfn [1 2 3] [[1 2 3][1 2][1]] |
| 14:41 | lazybot | [] |
| 14:42 | gfredericks | $findfn [1 2 3] [[1 2 3][1 2][1][]] |
| 14:42 | lazybot | [] |
| 14:42 | AimHere | $findfn [true] [true] |
| 14:42 | lazybot | [clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/list* clojure.core/time clojure.core/dosync clojure.core/distinct clojure.core/lazy-cat clojure.core/sequence clojure.core/rseq clojure.core/vec clojure.core/concat clojure.core/sequ... https://www.refheap.com/paste/7670 |
| 14:42 | gtrak | ha |
| 14:43 | gtrak | $findfn [0] [1] |
| 14:43 | lazybot | [] |
| 14:43 | gtrak | $findfn [1] [0] |
| 14:43 | lazybot | [] |
| 14:44 | AimHere | $findfn [* [1 2 3 4 5 6]] [720] |
| 14:44 | lazybot | [] |
| 14:44 | ohpauleez | gfredericks: Thanks, that's the I messed up the arg order |
| 14:45 | ohpauleez | I swear I've seen and written a comp to do what I'm looking for, but I can think of it right now |
| 14:45 | AimHere | $findfn [[[1 2 3][1 2][1]] [1 2 3]] [[clojure.core/first]] |
| 14:45 | cark | what is this findfn thing ? |
| 14:45 | lazybot | [] |
| 14:45 | TimMc | cark: A lazybot plugin. It tests a bunch of fns against your args and output. |
| 14:45 | ohpauleez | it finds functions that give you the result, given some args |
| 14:46 | AimHere | You feed it arguments and outputs, and it finds the core function that gives the result |
| 14:46 | cark | mhh |
| 14:46 | ohpauleez | you can also use it locally, though I've never successfully done it |
| 14:46 | cark | $findfn 1 [1 2 3] |
| 14:46 | cark | what's the syntax ? |
| 14:46 | lazybot | [] |
| 14:46 | cark | $findfn [1 2 3] 1 |
| 14:46 | AimHere | $findfn [5] [0 1 2 3 4] |
| 14:46 | lazybot | [clojure.core/first clojure.core/rand-nth] |
| 14:46 | AimHere | Hah, you got lucky there! |
| 14:47 | lazybot | [] |
| 14:47 | cark | haha |
| 14:47 | cark | nice one =) |
| 14:47 | cark | so last argument is the return value |
| 14:47 | AimHere | $findfn [5] (0 1 2 3 4) |
| 14:47 | lazybot | java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn |
| 14:47 | AimHere | $findfn [5] '(0 1 2 3 4) |
| 14:47 | lazybot | [] |
| 14:48 | amalloy | ohpauleez: ##(take-while seq (iterate next [1 2 3]))? |
| 14:48 | lazybot | ⇒ ([1 2 3] (2 3) (3)) |
| 14:48 | cark | $findfn 5 '(0 1 2 3 4) |
| 14:48 | lazybot | [clojure.core/range] |
| 14:48 | cark | yay |
| 14:48 | cark | that's almost like a little game |
| 14:48 | ohpauleez | amalloy: That's basically what I have written now |
| 14:48 | cark | test your clojure knowledge ! |
| 14:49 | ohpauleez | I felt like I had seen something more succinct before |
| 14:49 | amalloy | i don't think there's a very good way to build it with comp and builtins |
| 14:49 | AimHere | I remember some conj talk or something where the miniKanren guys wrote a program to generate all the scheme programs that evaluated to 6. findfn should go that route! |
| 14:50 | amalloy | if you want heads instead of tails, you can write ##(reductions conj [] [1 2 3]) |
| 14:50 | lazybot | ⇒ ([] [1] [1 2] [1 2 3]) |
| 14:50 | cark | AimHere: exactly what i was pondering |
| 14:50 | AimHere | If there's no function in core that gives the answer, it should start making them up |
| 14:50 | cark | AimHere: the generated functions were mostly garbage tho =) |
| 14:51 | cark | (defn do-it [] 6) and the like |
| 14:51 | amalloy | &((fn [] ((fn [] ((fn [] 6)))))) |
| 14:51 | lazybot | ⇒ 6 |
| 14:51 | cark | right =) |
| 14:51 | ohpauleez | amalloy: Ahh that totally works in my case |
| 14:51 | AimHere | I don't care. My mind boggles at the idea anyways |
| 14:51 | ohpauleez | thank you |
| 14:52 | amalloy | hah, really? asked the wrong question, then :) |
| 14:52 | technomancy | AimHere: it only works on the toy language they defined, not on actual scheme |
| 14:52 | ohpauleez | I did indeed |
| 14:52 | cark | technomancy: nothing prevents you from defining a more complete language, maybe a subset of clojure |
| 14:52 | ohpauleez | (I just have to change the sort for something I'm working with) |
| 14:53 | sgeo | Apparently there's no such thing as a language good enough that I will stick with it for a year |
| 14:53 | sgeo | Although there are some I keep coming back to again and again |
| 14:53 | cark | man i've been sticking to clojure for years now |
| 14:53 | cark | since before 1.0 |
| 14:54 | cark | how long has that been ? |
| 14:54 | technomancy | cark: sure; in theory. I suspect it would be incredibly difficult to do it in a way that maintained compatibility with Clojure though. |
| 14:54 | sgeo | I think 1.0 was 2009? |
| 14:54 | cark | technomancy: if that was easy there would be much more generative programming around |
| 14:54 | sgeo | Or was that when Clojure was first created? |
| 14:55 | cark | technomancy: the idea is so exciting |
| 14:55 | dnolen | cark: technomancy: I think it would be quite challenging - still I think there may be utility in modeling very specific parts of a Clojure / Scheme program w/ their approach. |
| 14:55 | dnolen | challenging to model an entire language I mean, whether Scheme or Clojure |
| 14:56 | cark | maybe some hybrid mix of logic and evolutionary programming would help |
| 14:57 | amalloy | sgeo: 2009 seems kinda late. i know i picked it up in 2010, and 1.2 was released not long after that |
| 14:58 | sgeo | Wikipedia says 2007 |
| 14:58 | sgeo | Doesn't say if that's 1.0 or an earlier release |
| 14:58 | technomancy | 2009 is correct for 1.0; it was April or so |
| 14:58 | cark | once 1.0 came out, versions seemed to come faster than i could upgrade my existing projects. So could have been that fast |
| 14:58 | technomancy | same time as the first book |
| 14:59 | amalloy | technomancy: july 2009 apparently |
| 14:59 | amalloy | http://build.clojure.org/releases/org/clojure/clojure/1.0.0/ |
| 14:59 | amalloy | presuming that the timestamps weren't later mucked with |
| 15:00 | technomancy | what the heck; changes.md only covers 1.4? |
| 15:03 | amalloy | who would ever care about any other version, am i right |
| 15:06 | technomancy | well, true of 1.4 specifically |
| 15:10 | amalloy | the git logs for clojure are interesting. apparently rich started work in march 2006, fiddled around a little until october, and then left it alone until june 2007 |
| 15:11 | matthavener | amalloy: hickey was literally laying in a hammock from oct 06 to june 07 ;P |
| 15:11 | matthavener | sort of a software design coma |
| 15:32 | cark | I asked this earlier but want to ask again just in case. javafx is now distributed with the jre. The only trouble is that it is not in the classpath. It is a single jar file jfxrt.jar in the lib directory of the jre. what would be the project.clj incantation to add this classpath to lein in a portable manner ? |
| 15:34 | technomancy | cark: "exists somewhere in the JRE directory" and "portable" are mutually exclusive |
| 15:34 | cark | right; but it's included now on linux solaris and windows jre distributions, so there hsould be a way to access it ? |
| 15:35 | cark | i managed to add it to my local repo and use it this way, but I don't like this, as my version might not be compatible with future version of the jre |
| 15:36 | technomancy | you can hack it into :resource-paths, but like I said, you can't do it portably |
| 15:36 | llasram | cark: Is there an official way Oracle expects it to end up on the class path? |
| 15:36 | cark | i think they expect you to use netbeans =P |
| 15:36 | llasram | hah |
| 15:37 | cark | my poor emacs is just not to par ='( |
| 15:40 | ynniv | lazybot handles mail now? |
| 15:41 | Raynes | Yeah, it's pretty recently. Only like 2 years. |
| 15:41 | Raynes | ;) |
| 15:43 | ynniv | guess I don't get a lot of mail |
| 15:43 | ynniv | is there a clojure validation library that's introspective? |
| 15:44 | amalloy | introspective sounds more like an implementation concern than a feature |
| 15:45 | ynniv | I have records that will be validated and want to show contextual UI elements for them |
| 15:46 | duck1123 | are you doing this client or server side? |
| 15:47 | ynniv | yes |
| 15:48 | ynniv | I've grown a system that validates in clojure, exports descriptions as json, and creates the UI clientside |
| 15:48 | duck1123 | I've been going between validateur and clj-schema for validating server side. I'm not sure which I like better |
| 15:52 | duck1123 | with either one it should be simple to transform the error report into something you can use client side. I've been using backbone for my client-side models, but haven't hooked in validation yet |
| 15:53 | devinus | what's the binary number reader format? |
| 15:54 | amalloy | ,101b |
| 15:54 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 101b> |
| 15:54 | amalloy | aw |
| 15:54 | amalloy | ,101r2 |
| 15:54 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 101r2> |
| 15:54 | hyPiRion | ,2r100 |
| 15:54 | clojurebot | 4 |
| 15:54 | amalloy | evidence, i suppose, that knowledge is more efficient than random guessing |
| 15:54 | llasram | I do like that it lets you express numbers in base 7 when relevant |
| 15:55 | borkdude | is there an example of a small simple imperative language built with clojure? |
| 15:55 | amalloy | it should automatically interpret 755 as octal; i can't think of any other reason to use that number in code |
| 15:55 | hyPiRion | Is there an example of a language built with clojure in the first place? |
| 15:56 | hyPiRion | I've not seen one, but would love to have a look at it. |
| 15:56 | llasram | I guess it depends on what one means by "language" |
| 15:56 | borkdude | llasram a language not represented as clojure sexps |
| 15:56 | llasram | Ah |
| 15:57 | ynniv | that's a different syntax, not a different language |
| 15:57 | ynniv | IIRC clojure doesn't have the extensible reader that common lisp has |
| 15:58 | hyPiRion | you have reader literals though |
| 15:58 | borkdude | ynniv an example of a small language with a simpe grammar, parsed and interpreted or compiled by clojure |
| 15:58 | borkdude | ynniv imperative |
| 15:59 | dnolen | borkdude: akhudek works on a logic programming language, here's another based on Inform7 targeted at kids http://github.com/maryrosecook/islaclj |
| 15:59 | ynniv | duck1123: I don't want to round trip and report errors, but use the validation schema to display a range for input, like a bounded slider |
| 16:00 | AimHere | You can fake an inline language with some use of macros |
| 16:00 | borkdude | dnolen tnx |
| 16:00 | duck1123 | ynniv: Yeah. I don't know anything like that. |
| 16:02 | dnolen | borkdude: I'm sure I've seen some forths and I feel like I heard about a Java compiler. |
| 16:03 | borkdude | dnolen a Java compiler in Clojure….? ;) |
| 16:03 | dnolen | borkdude: yes, that using core.logic to do type checking and byte code verification |
| 16:03 | dnolen | uses |
| 16:03 | hyPiRion | heh, sounds like we're talking about unicorns or dinosaurs |
| 16:03 | hyPiRion | "I've sure I've seen some" |
| 16:03 | callen | I was wondering about a potential use-case for core.logic/match (not sure where it would live) and if it would produce pathological behavior or not. Specifically, if one could build up a rules-based / expert system efficiently out of matching rules ala predicate logic and if doing so would be reasonably efficient or not |
| 16:03 | hyPiRion | "I think I heard of" |
| 16:04 | callen | I realize my question is vague, but I can get more specific if anybody gets down to brass-tacks. |
| 16:04 | dnolen | hyPiRion: well I haven't seen it, but I got patches to core.logic, was a student project by one of the Storm devs |
| 16:04 | callen | Storm uses core.logic? |
| 16:04 | dnolen | callen: no |
| 16:04 | dnolen | the Java compiler project that was a term assignment |
| 16:05 | callen | dnolen: do you have any thoughts regarding my expert system question? |
| 16:06 | dnolen | callen: seems in the realm of possibility yes - but I've never looked very closely at expert systems nor how they are put together |
| 16:06 | callen | dnolen: the reason I'm envisioning this is that I'm trying to avoid hacking up a custom AI model or abusing a database. |
| 16:06 | dnolen | callen: well you probably end up hacking core.logic - so work will have to be done somewhere ;) |
| 16:06 | callen | dnolen: well, just imagine something like a very large collection of "if statements/predicates", and you want to explore that space and get a list of "yeses" efficiently. |
| 16:07 | callen | dnolen: taking for granted that some hacking will be necessary, does that sound like an efficient/appropriate use-case? |
| 16:07 | callen | dnolen: in particular, something that will help is being able to detect related spaces of predicates so that you can treat it like "20 questions" |
| 16:07 | dnolen | callen: yes I think it would be interesting to use core.match for large decision tree optimization, but we'd probably need to patch core.match for that use case since there are code size limits on the JVM. |
| 16:07 | callen | dnolen: where you narrow down the problem/question space as quickly as possible by matching against meta-rules that invalidate as many possibilities at once at a time. |
| 16:08 | callen | this is simultaneously an interest of mine and a potential "business problem" to be solved at my startup. |
| 16:08 | callen | the "MVP" version is just if-statements, but I'd rather do it more intelligently if we've proven that it's a useful bit of functionality. |
| 16:09 | callen | dnolen: part of the problem is compiling and pre-preparing a tree that can efficiently eliminate as many possibilities at time as possible. |
| 16:09 | dnolen | callen: well that's what core.match does |
| 16:09 | dnolen | with the specific goal of pattern matching in mind of course. |
| 16:09 | callen | dnolen: that sounds like it could work, I'm just wondering how flexible it would be |
| 16:10 | callen | because it might mean projecting our data model into a big tuple of pre-prepared predicates. Another issue is that I don't want to match a single case, but rather, get a list of possibilities. |
| 16:10 | dnolen | callen: patterns are not first class - and it generate Clojure code - so the obvious limitations there |
| 16:12 | callen | I get that they're not first-class, I'm just not sure if my modeling of it as, "give everything that's true without testing redundant possibilities" is sensible for core.match. I thought of it as being more comparable to erlang/haskell type pattern matching. |
| 16:13 | dnolen | callen: yes, it's pretty much erlang/haskell style pattern matching. |
| 16:13 | callen | right, which leads to my aforementioned concern that it's a mis-matched use-case. |
| 16:13 | callen | my impression was that it was designed to narrow down into a single test-case efficiently |
| 16:14 | callen | not explore a multi-faceted search space, avoiding redundant test-cases, efficiently. |
| 16:14 | dnolen | callen: right. |
| 16:14 | callen | let me propose an alternative, and maybe this will better articulate what I'm thinking of. |
| 16:14 | dnolen | callen: in some distant future, core.logic ideally would have it's own version of the pattern matching optimizations. |
| 16:15 | callen | you have a user, for which things could be true or not. You have rules you want to match the user against, thereby creating a list of possibilities. |
| 16:15 | callen | a hypothetical model is treating the rules as a literal collection of "documents" in an indexed search engine and using a constraint solver of sorts to generate a pre-prepared query to search that space based on the content of the user's data. |
| 16:16 | callen | then returning all the "matching" documents which happen to be "things that are possibly relevant to this user" |
| 16:16 | callen | alternately, treating each document/rule as a matching rule in a predicate logic/pattern matcher type system. |
| 16:16 | callen | One is the inversion of the other, hypothetically. |
| 16:17 | callen | dnolen: I'm sorry if I'm being opaque or wasting your time. Thanks for your consideration so far. |
| 16:19 | dnolen | callen: sounds like something worth modeling in core.logic - not sure if it can deliver the desired performance you want. though I could imagine some wacky cool solution that perhaps tries to leverage both. sorry I can't be more helpful. |
| 16:19 | callen | dnolen: it's quite alright. the reason for the search engine thing is predictable soft real-time performance. |
| 16:21 | dnolen | callen: yeah if something already solves the problem and won't create a mountain of headache - little reason to try to cobble something crazy together from alpha quality open source libs |
| 16:26 | devinus | are regex's compiled during the compile stage or when the program is run? |
| 16:26 | egghead | runtime i'd imagine |
| 16:26 | egghead | though I don't know for sure either way |
| 16:27 | amalloy | read time |
| 16:27 | TimMc | I thought regex literals were interned at compile time, but I couldn't produce any evidence of it. |
| 16:28 | TimMc | &(read-string "#\"[\"") |
| 16:28 | lazybot | java.util.regex.PatternSyntaxException: Unclosed character class near index 0[^ |
| 16:28 | TimMc | ^ amalloy is right about it being read time |
| 16:28 | devinus | i wonder why |
| 16:29 | m0smith | hi |
| 16:29 | egghead | does java even support regex at compile time? It doesn't have regex literals |
| 16:29 | m0smith | I have a Lein question |
| 16:30 | devinus | egghead: i know java doesn't, but i wonder if there would be a way to just store the compiled representation in the class file |
| 16:30 | m0smith | which is: In Maven I can filter resources so that the contents of the file is changed to include build info like artifactId and the like |
| 16:30 | m0smith | Does Lein support the same thing/ |
| 16:30 | m0smith | ? |
| 16:30 | TimMc | It seems like you ought to be able to write a plugin to do that. |
| 16:31 | m0smith | egghead: no, regexs in Java are simply strings that are compiled |
| 16:32 | m0smith | egghead: the Pattern object can be serialized |
| 16:32 | devinus | m0smith: if it can be serialized you'd imagine it could be compiled at compile-time |
| 16:33 | m0smith | devinus: I imagine an annotation could be written to do that |
| 16:33 | amalloy | the serialized form of a j.u.regex.Pattern is just a string. it doesn't store any of the interesting stuff |
| 16:34 | devinus | ah |
| 16:35 | amalloy | (i recommend having a local copy of the jdk source; it makes answering this sorts of questions so much easier) |
| 16:35 | devinus | Erlang's re module returns the compiled regex as a binary, allowing Elixir to embed the compiled regex during compilation |
| 16:40 | devinus | is there anybody doing interesting SOAP work in Clojure? |
| 16:40 | devinus | (well, as interesting as possible given that it's SOAP) |
| 16:41 | brehaut | devinus: no offense, but thats the stupidest thing ive heard in a while |
| 16:41 | m0smith | I was just pondering a JAX-WS client in Clojure |
| 16:41 | devinus | brehaut: which comment? |
| 16:41 | brehaut | devinus: SOAP in clojure |
| 16:41 | devinus | brehaut: why's that? |
| 16:41 | brehaut | well because its soap |
| 16:41 | technomancy | or the phrase "interesting SOAP work" |
| 16:41 | devinus | so? |
| 16:42 | brehaut | SOAP is the current pinnicle of design by committee meta type systems for RMI |
| 16:42 | brehaut | over XML |
| 16:42 | brehaut | its the cross product of 4 types of crazy |
| 16:43 | devinus | hah |
| 16:43 | TimMc | brehaut: That's impressive. I though you could only take the cross product of *two* vectors. |
| 16:43 | m0smith | So how hard would it be to throw a WSDL at clojure? |
| 16:43 | devinus | considering i've had to work with SOAP in: PHP, Python, Scala, and most recently Erlang I'm aware of SOAP's crazy |
| 16:43 | devinus | but the fact is, people still have to work with soap, regardless of what language they're using |
| 16:44 | devinus | so i thought seeing Clojure's answer to it would be interesting |
| 16:44 | brehaut | devinus: i think clojures answer is: cry, and then just use Java. |
| 16:44 | llasram | brehaut: +1 |
| 16:45 | llasram | I've been doing some UPnP stuff helping a friend with a personal project, and just counting on the existing Java libraries to insulate me |
| 16:48 | devinus | amalloy: regarding binary numbers, I swear i just read in JoC that there was a literal binary syntax |
| 16:48 | brehaut | devinus: having implemented one stupid RPC mechanism in clojure, i can understand the motivation. but learn from my fail, and dont take on something as insane as soap |
| 16:48 | technomancy | you have to draw the line somewhere |
| 16:50 | gtrak | ,(Integer/parseInt "0110" 2) |
| 16:50 | clojurebot | 6 |
| 16:51 | amalloy | devinus: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L64 is all the integer patterns, and there's clearly no binary pattern (aside from the r2 suffix, of course) |
| 16:53 | egghead | on demand dynamic scoping is really nifty, thanks clojure! |
| 16:55 | TimMc | "clearly", he says, pointing devinus at a big ol' regex |
| 16:57 | solussd | is it possible to type hint using a Protocol name? e.g. (defn blah [^SomeProto obj] (proto-func obj)) ? |
| 16:57 | TimMc | It also clearly allows 99rf00. :-P |
| 16:58 | amalloy | TimMc: if you're a regex pansy, you can look at https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L362 instead |
| 16:58 | hyPiRion | ,99rf00 |
| 16:58 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Radix out of range> |
| 16:58 | hyPiRion | for the masses. |
| 16:58 | amalloy | solussd: that would not be a useful typehint: it cannot improve performance |
| 16:59 | solussd | amalloy: maybe not, but would I get a reflection warning if I passed something else? |
| 16:59 | amalloy | you don't get that with typehints anyway |
| 16:59 | amalloy | &((fn [^String x] x) 10) |
| 16:59 | lazybot | ⇒ 10 |
| 17:00 | amalloy | typehints are performance optimizations, not a static type checker |
| 17:00 | devinus | i didn't realize rich was fond of Whitesmiths style indentation |
| 17:02 | solussd | amalloy: yeah, but I thought they helped the compiler avoid reflection |
| 17:02 | solussd | err, runtime |
| 17:02 | technomancy | I always assumed the indentation style used in Clojure's Java implementation was a nameless horror. |
| 17:02 | technomancy | kind of disturbing to learn there's a name for it as that implies other people use it |
| 17:02 | amalloy | yes, that is a performance optimization that has no impact on what warnings you get at compile time |
| 17:02 | callen | technomancy: the horror isn't nameless...Cthulhu ftagn! |
| 17:03 | dnolen | solussd: type hints are only about interop, primitive arrays & unboxed arithmetic. anywhere else they have no effect. |
| 17:03 | gtrak | technomancy: it's popular for C |
| 17:03 | amalloy | dnolen: primitive deftype fields! |
| 17:03 | devinus | technomancy: lol |
| 17:03 | dnolen | amalloy: oops, right |
| 17:03 | solussd | dnolen: any point in type hinting for record types? |
| 17:03 | callen | I'm a fan of this indent style: if (blah) { |
| 17:03 | dnolen | solussd: primitive fields as amalloy pointed out |
| 17:04 | solussd | dnolen: how about for functions I write that take a record type? |
| 17:04 | dnolen | solussd: if you want static type checking - help ambrosebs type the rest of clojure.core |
| 17:04 | amalloy | solussd: just for performance of looking up the fields |
| 17:04 | dnolen | solussd: the 4 cases above is it. |
| 17:04 | solussd | dnolen: amalloy: thanks |
| 17:05 | brehaut | callen: clojure's java source is the gate and the key, and the guardian of the gate. past, present and future, all are one. |
| 17:05 | solussd | dnolen: watched your techmesh core.logic talk thismorning- awesome stuff. |
| 17:05 | dnolen | solussd: thx! |
| 17:06 | callen | (inc brehaut) |
| 17:06 | lazybot | ⇒ 8 |
| 17:06 | devinus | what's a super tight clojure data structure i can use for packed values |
| 17:06 | dnolen | solussd: btw to be clear, type hints on protocols wouldn't make anything go any faster - protocol dispatch if the implementation was inline delivers host dispatch perf on the JVM. |
| 17:06 | solussd | I think I'll use pre-conditions where I feel I need to. I hate static typign. :D |
| 17:06 | solussd | good to know |
| 17:06 | hyPiRion | Humm |
| 17:06 | dnolen | solussd: I'm still pondering on how we can deliver close to same guarantee on CLJS ... |
| 17:07 | aperiodic | devinus: primitive byte arrays? |
| 17:07 | gtrak | devinus: bytebuffer? |
| 17:07 | devinus | bytebuffer looks promising |
| 17:08 | amalloy | naw, solussd, you just hate badly-implemented static typing. static typing in, eg, haskell is pretty nice. choosing between good static typing and dynamic typing is a matter of taste; choosing java's static typing instead is worth hating |
| 17:08 | callen | amalloy: careful what you say re: Haskell and "nice" |
| 17:09 | callen | amalloy: that's only true when you're not using a library that has incredibly invasive monads that you keep having to ditch. |
| 17:09 | solussd | amalloy: you're right- I like haskell static typing- I hate it when static typing feels like it's getting in my way. |
| 17:09 | callen | this is the same community that looks for excuses to turn every problem into parser combinators. |
| 17:11 | solussd | the things I most frequently want a statically typed version of are records |
| 17:12 | gtrak | why? |
| 17:12 | clojurebot | http://clojure.org/rationale |
| 17:12 | duck1123 | I want static typing whenever I'm looking at docs and all it says is that it takes a function. |
| 17:13 | brehaut | duck1123: totally |
| 17:13 | solussd | yeah, that too- or better documentation. :D |
| 17:13 | technomancy | duck1123: so you wish everyone else used it but you didn't have to? =) |
| 17:13 | brehaut | technomancy: how great would that be :) |
| 17:13 | technomancy | like public transit or being carbon-neutral |
| 17:14 | gtrak | I thought we make the tradeoff that the code is so minimal, reading it is practical |
| 17:14 | technomancy | I would be happy with non-nullable Object |
| 17:14 | technomancy | thrilled, in fact |
| 17:14 | brehaut | likewise |
| 17:15 | technomancy | ◔ <- a pie chart of how many type errors I make that aren't NPEs |
| 17:15 | amalloy | technomancy: i would like static typing when writing documentation, so that i *can* say what the dang function takes. it's so wordy to write junk like "returns a function f which takes a collection coll and a function g, and maps g over coll" |
| 17:15 | technomancy | amalloy: meh; "takes a collection coll" is redundant |
| 17:15 | duck1123 | I was interested in typed clojure till I saw the video where clojure.set was being typed. That scared me away slightly |
| 17:16 | brehaut | duck1123: im still interested, but i dont think i'd use it till it has an inferencer |
| 17:16 | amalloy | whatever, i just made that example up as fast as my fingers could type. the point is that i have written functions where the doc is difficult to write clearly |
| 17:16 | technomancy | amalloy: IME this is most likely to lead to mistakes when a concept has multiple representations in the code and there's no consistency in local names |
| 17:17 | technomancy | for instance, user-id vs user; is bare "user" a map or was someone lazy? |
| 17:18 | technomancy | duck1123: yeah, without inference I'm certainly not going to take the time to annotate things |
| 17:18 | egghead | clojure partials with multi arity fns are such a fine magic |
| 17:18 | gtrak | I have an example: "Accepts n-args of thunks that either return an error (value of some sort) or falsy, reduces over them and accumulates any errors. Returns nil if none." |
| 17:19 | gtrak | the doc is 5 times as long as the function: (->> (map #(%) checks) (filter identity) seq)) |
| 17:20 | devinus | you would think that so would change his username |
| 17:20 | amalloy | "Returns only the truthy results of invoking the supplied thunks", gtrak |
| 17:21 | llasram | devinus: I know, right? It's been driving me crazy |
| 17:21 | gtrak | amalloy: I suppose that's better :-) |
| 17:21 | amalloy | the implementation is easier too: (seq (keep #(%) checks)) |
| 17:21 | gtrak | ah, keep, I never use that one, thanks! |
| 17:21 | amalloy | although i guess that changes the meaning such that false now counts as an error |
| 17:22 | hyPiRion | yeah |
| 17:22 | gtrak | ah, that's probably why I never use keep, I rarely need to differentiate between false and nil |
| 17:22 | hyPiRion | ,(keep identity [true false nil :foo]) |
| 17:22 | clojurebot | (true false :foo) |
| 17:26 | devinus | is there a function for (keep identity coll) ? |
| 17:27 | devinus | (keepident coll) |
| 17:27 | hyPiRion | A function for removing nils? |
| 17:27 | hyPiRion | (remove nil? coll) is probably more evident |
| 17:27 | technomancy | functions that are a trivial partial application of two existing functions generally don't get top-level definitions |
| 17:28 | devinus | technomancy: probably a good philosophy to have |
| 17:29 | brehaut | oh metaWeblog, no. base64 encoded media uploads‽ how is that ever going to be a good idea |
| 17:29 | S11001001 | doesn't prevent occasional if-not, though |
| 17:29 | technomancy | S11001001: yeah, IMO that's kind of silly |
| 17:30 | technomancy | if-let is nicer, but only because macros aren't as composable as functions |
| 17:30 | tgoossens | if have a vector [1 2 1] and some collection. i want to sequentially "take&drop the given amount in the vector. Example coll [a b c d] ,vector [1 2 1] it should return [[a] [b c] [d]] |
| 17:30 | technomancy | S11001001: if someone proposed adding if-not today it would get shot down with prejudice before you could blink |
| 17:30 | tgoossens | any ideas? |
| 17:31 | AimHere | tgoossens, I'd knock up something using loop and recur and take |
| 17:31 | amalloy | technomancy: really? |
| 17:31 | S11001001 | tgoossens: you need a reduction |
| 17:31 | tgoossens | i was thinking that as well |
| 17:31 | tgoossens | (recur) |
| 17:31 | tgoossens | i'll go with that for now |
| 17:31 | S11001001 | technomancy: I would hope so |
| 17:31 | gtrak | a case of 'programmer-convenience thinking' :-) |
| 17:33 | dnolen | \me likes if-not when-not just fine |
| 17:34 | gtrak | I really don't like '(if (seq .. |
| 17:34 | hyPiRion | gtrak: I tend to use (if (empty? .. instead |
| 17:34 | dnolen | also they leave the door open for some clever optimization by CLJ implementations like CLJS if the host language has effed up notions of truthy falsey like JS |
| 17:35 | gtrak | hyPiRion: yea... seq is supposed to be idiomatic according to the docs |
| 17:35 | gtrak | empty? is more intuitive, but (not (empty? is discouraged |
| 17:35 | hyPiRion | Call me stupid, but I think it reads better |
| 17:35 | hyPiRion | why is that? |
| 17:35 | hyPiRion | better to use not-empty ? |
| 17:36 | technomancy | yeah, seq is not an english word |
| 17:36 | gtrak | ,(doc empty?) |
| 17:36 | clojurebot | "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))" |
| 17:36 | technomancy | even its clojure definition makes no sense in a conditional |
| 17:37 | gtrak | so now I just call seq on my returns values of things... for the convenience of client ifs... I guess that might be bad. |
| 17:37 | amalloy | gtrak: that's not really very nice, because it forces evaluation of a seq that might never get consumed at all, and which might be expensive |
| 17:38 | gtrak | just the head, I thought |
| 17:38 | hyPiRion | ,(take 4 (seq (range))) |
| 17:38 | clojurebot | (0 1 2 3) |
| 17:38 | technomancy | gtrak: depends on chunking |
| 17:38 | gtrak | yea, in this use-case, error checks on a web-service input, there will always be a conditional realizing it |
| 17:39 | gtrak | otherwise there's no need to do it in the first place |
| 17:40 | AimHere | Isn't seq bad for testing of empty, since it evals the first element? |
| 17:41 | gtrak | AimHere: there's no other way |
| 17:41 | gtrak | I think this notion of falsity should have matching conditionals though... it's common for me at least |
| 17:41 | AimHere | Hmm, (not (empty? [])) also evaluates it, fair enough |
| 17:42 | gtrak | I guess you could implement an 'empty' protocol, or something equivalent |
| 17:43 | AimHere | Trap compiler exceptions and if they're unresolved symbols of the form foo-not, turn them into (not (foo ...)) |
| 17:45 | gtrak | huh, what the heck does #! do? |
| 17:46 | gtrak | ah, 'CommentReader' |
| 17:46 | gtrak | that's new to me |
| 17:46 | gtrak | ,#! WTF MATE |
| 17:46 | amalloy | gtrak: it's a trick to make shebang work |
| 17:46 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 17:46 | hyPiRion | heh |
| 17:46 | gtrak | ah |
| 17:47 | amalloy | #! is strictly identical to ; |
| 17:49 | matthavener | does anyone use shebang? is there a nice workaround to the jvm startup? |
| 17:49 | hyPiRion | I use it for scripts |
| 17:50 | hyPiRion | and for the jvm startup time, there's always Drip |
| 17:51 | matthavener | wow, drip is awesome, thanks hyPiRion |
| 17:51 | gtrak | for the clojure startup time, you can lazyload libs by using (require..) and resolve at runtime |
| 17:51 | TimMc | gtrak: And don't forget &| (+ 2 3) |&, of course. |
| 17:51 | lazybot | ⇒ 5 |
| 17:51 | gtrak | wha? |
| 17:51 | TimMc | Yeah man, &| |
| 17:52 | TimMc | (Kidding, it's some random lazybot eval delimiter.) |
| 17:52 | gtrak | haha |
| 17:53 | TimMc | ,'(&|5|&) |
| 17:53 | clojurebot | (&|5|&) |
| 17:53 | TimMc | Mmm, it's just like ## |
| 17:54 | hyPiRion | ,'( &| 42 |& ) |
| 17:54 | clojurebot | (&| 42 |&) |
| 17:54 | hyPiRion | boo |
| 17:54 | TimMc | ,'(&|(+ 2 3)|&) |
| 17:54 | clojurebot | (&| (+ 2 3) |&) |
| 17:54 | lazybot | ⇒ 5 |
| 17:54 | lazybot | ⇒ 5 |
| 17:55 | TimMc | hyPiRion: THe inline eval feature demands parens, or maybe one other leading char. |
| 17:55 | ynniv | hmm, what's wrong with (not (empty? x)) |
| 17:55 | ynniv | i usually use (comp not nil?) to filter my collections |
| 17:55 | hyPiRion | &| (+ 1 2) (+ 3 4) ; |& |
| 17:55 | lazybot | ⇒ 3 |
| 17:56 | hyPiRion | &| (+ 1 2) ##(+ 3 4) ; |& |
| 17:56 | lazybot | ⇒ 7 |
| 17:56 | TimMc | ynniv: Golfers will get annoyed because you could usually just write (seq x). |
| 17:56 | TimMc | hyPiRion: It only takes the first form anyhow. |
| 17:56 | TimMc | Oh, I see. nvm |
| 17:56 | hyPiRion | Unless you inject some ##'s within there |
| 17:56 | lazybot | ⇒ s |
| 17:57 | brehaut | TimMc: ive always wonder what running maven backwards would do. |
| 17:57 | brehaut | would it restore sanitiy? |
| 17:57 | ynniv | TimMc: umm, what if I have non-collections in my list? |
| 17:58 | wingy | I have a HTML form that makes a POST go a POST route .. should a POST route redirect to a GET route or is it okay for it to return a HTML response with a body? |
| 17:58 | ynniv | ,(filter (comp not nil?) '(a b c nil d)) |
| 17:58 | clojurebot | (a b c d) |
| 17:58 | brehaut | wingy: if you redirect a post to a get it stops accidental double-submits |
| 17:58 | ynniv | ,(filter seq '(a b c nil d)) |
| 17:58 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol> |
| 17:59 | wingy | brehaut: what do you mean? |
| 17:59 | gtrak | ynniv: that's a lot like identity |
| 18:00 | auser | hey all |
| 18:00 | gtrak | ynniv: err, wait... just use (remove nil? ...) |
| 18:00 | TimMc | wingy: https://en.wikipedia.org/wiki/Post/Redirect/Get |
| 18:00 | brehaut | wingy: say your post creates a DB item. (eg, posting a comment on a blog). a double submit will result in the same comment appearing in the DB (and thus on the page) twice. If you just return HTML from the POST route, then double submits are possible, but if you redirect to the GET instead, then the interaction error that causes double submits is avoided |
| 18:00 | ynniv | gtrak: depends on whether falsey means false or no return value |
| 18:00 | brehaut | (inc TimMc) |
| 18:00 | lazybot | ⇒ 22 |
| 18:01 | ynniv | remove nil? expands into (comp not nil?) anyway. 6 of one? |
| 18:02 | amalloy | TimMc: inline eval demands a collection of any sort |
| 18:02 | gtrak | ynniv: I usually go for minimal surface area and maximum display of intent.. |
| 18:02 | gtrak | (remove nil? ... ) reads easily |
| 18:02 | karbak | Trying to understand how the following works - (if (#{:a :b :c} foo) (then-clause) (else-clause)) - specifically the syntax around (#{..} foo) |
| 18:03 | gtrak | karbak: using a set as a function checks for containment |
| 18:03 | bbloom | ,(#{:a :b :c} 1) |
| 18:03 | clojurebot | nil |
| 18:03 | bbloom | ,(#{:a :b :c} :b) |
| 18:03 | clojurebot | :b |
| 18:03 | bbloom | ,(boolean nil) |
| 18:03 | clojurebot | false |
| 18:03 | bbloom | ,(boolean :b) |
| 18:03 | clojurebot | true |
| 18:04 | hyPiRion | If you don't have false or nil in the map, then it's the same as the following |
| 18:04 | ynniv | thats fair, but you don't always get to specify filter vs remove |
| 18:04 | hyPiRion | (if (contains? #{:a :b :c} foo) (then) (else)) |
| 18:04 | wingy | brehaut: i c .. so PRG is a good thing |
| 18:04 | brehaut | wingy: yes |
| 18:05 | gtrak | ,(contains #{nil} nil) |
| 18:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: contains in this context, compiling:(NO_SOURCE_PATH:0)> |
| 18:05 | gtrak | ,(contains? #{nil} nil) |
| 18:05 | clojurebot | true |
| 18:05 | gtrak | ,(contains? #{} nil) |
| 18:05 | clojurebot | false |
| 18:06 | gtrak | nil is a silly thing to have in a set |
| 18:06 | karbak | gtrak: thanks, forgot that worked both ways. What kind of object is #{...} - a sequence of some kind? |
| 18:06 | metellus | it's a set |
| 18:06 | gtrak | ,(class #{}) |
| 18:06 | clojurebot | clojure.lang.PersistentHashSet |
| 18:07 | ynniv | gtrak: why? could be a set of valid inputs |
| 18:07 | gtrak | I'm writing a function that only takes nil or 4... 2 is right out! |
| 18:08 | ynniv | you laugh... |
| 18:08 | gtrak | nah, I'm kidding, it's practical I guess.. but strange if you try to think about it too hard |
| 18:08 | wingy | if i have a ring session and wants to keep it then i shouldn't return a new :session key-value/pair? |
| 18:09 | ynniv | that's why I never got into haskell |
| 18:09 | ynniv | it always feels like they're thinking too hard |
| 18:09 | gtrak | wingy: the session middleware will do it for you unless you explicitly clear the session with ':session nil' |
| 18:09 | wingy | gtrak: great |
| 18:10 | gtrak | I also found myself writing a function to copy a session from a request into a response, in case I want to modify something and I don't want to use the sandbar approach |
| 18:11 | gtrak | but an empty :session key on a response doesn't alter anything |
| 18:12 | wingy | I get "java.lang.NullPointerException" in Ring response but i can't get what causes it |
| 18:12 | wingy | there is no stack trace as well |
| 18:13 | gtrak | is *e bound? |
| 18:15 | gtrak | ,*e |
| 18:15 | clojurebot | #<Unbound Unbound: #'clojure.core/*e> |
| 18:15 | gtrak | hmm, I bet that only works at the repl |
| 18:15 | gtrak | &*e |
| 18:15 | lazybot | ⇒ #<Unbound Unbound: #'clojure.core/*e> |
| 18:17 | wingy | gtrak: *e was great to get an error message |
| 18:19 | octagon | hi, is there a way to accomplish the same as the javascript "a instanceof B" in clojurescript? |
| 18:19 | dnolen | octagon: instance? |
| 18:20 | octagon | awesome, thanks dnolen |
| 18:20 | dnolen | (instance? String "foo") |
| 18:20 | dnolen | for example |
| 18:21 | octagon | dnolen: thanks, that looks like what i need. there is nothing in any of the refcards about it, by the way |
| 18:22 | dnolen | octagon: yeah I'm not in charge of those - might be worth bringing up on the ML or contacting the people that keep them up-to-date |
| 18:23 | devinus | i wonder why apropos returns a list |
| 18:23 | devinus | instead of a vector |
| 18:24 | amalloy | it surely returns a lazy sequence |
| 18:24 | bbloom | ,(class (apropos "do")) |
| 18:24 | clojurebot | clojure.lang.LazySeq |
| 18:25 | devinus | amalloy: ah, curse me getting ahead of myself |
| 18:26 | devinus | i just started the chapter on laziness in JoC |
| 18:26 | devinus | to me it just looked like a list |
| 18:28 | amalloy | that's the idea |
| 18:33 | wingy | i've got a design issue .. so im using datomic where the attributes have a certain data type eg. float, string etc. the form returning the fields (attributes) are all in strings .. so i should convert the form params to appropriate data type manually? |
| 18:34 | gtrak | yes? that should be a function of a serialization/deserialization lib, or you should validate your inputs |
| 18:36 | gtrak | generally, you should have the front layer of your app responsible for validating user input, and persistence code should never have to deal with that |
| 18:36 | wingy | gtrak: yeah |
| 18:37 | wingy | i wonder how i could know what data type each form field is |
| 18:42 | gtrak | you mean.. .like a schema? |
| 19:02 | wingy | gtrak: lucky me datomic's attributes are just saved as data so i can query them to get what type they are |
| 19:02 | gtrak | ah, that's neat |
| 19:04 | wingy | yepp … made my day |
| 19:05 | samflores | hey, where did seq-utils go? |
| 19:06 | technomancy | samflores: various places; looking for a specific function? |
| 19:07 | samflores | find-first |
| 19:07 | technomancy | is that the same as (first (filter ...))? |
| 19:08 | samflores | yeah, I know. I'm using it. justo wondering if I'm reinventing something that's already implemented :) |
| 19:08 | samflores | s/justo/just/ |
| 19:08 | technomancy | functions that are a trivial partial application of two existing functions generally don't get top-level definitions |
| 19:08 | technomancy | |
| 19:08 | samflores | ok, then. thanks |
| 19:10 | technomancy | s/partial application/composition/ |
| 19:10 | technomancy | np |
| 19:10 | gtrak | didn't you just say that 30 minutes ago? |
| 19:10 | technomancy | yep =) |
| 19:11 | technomancy | IRC is easy when you can just pound M-p |
| 19:11 | gtrak | ha |
| 19:11 | gtrak | careful, you might fail the turing test |
| 19:12 | callen | given what I've heard about technomancy being tall and having an evil goatee, he'd be the tallest, most evil markov chain that ever was. |
| 19:12 | AimHere | Well that's because Mark V Chaney was a midget |
| 19:13 | callen | AimHere: Shaney |
| 19:13 | AimHere | Actually it's Markoff I was thinking of |
| 19:13 | AimHere | Mark V Shaney was a bot. Markoff Chaney was the midget |
| 19:14 | callen | AimHere: you don't run into many people that read that series these days. |
| 19:15 | AimHere | Yeah, seems to have fallen out of fashion |
| 19:15 | callen | AimHere: I think the general sub-culture died with the 90s |
| 19:15 | gtrak | hm, I'm guessing it's generally a bad idea to capture a handle to a ring request map and send it off to an async thread |
| 19:16 | callen | gtrak: nothing is a bad idea as long as you set your expectations very low. |
| 19:16 | callen | "this could explode in my face. Okay then." |
| 19:16 | gtrak | ha, it's rare that I worry about a memory leak these days.. but it might bring me to it |
| 19:17 | gtrak | closures just make it so easy! |
| 19:18 | samflores | is there a way to define a function in a ns other than the current one? |
| 19:19 | egghead | what are you doing that makes you want to do that samflores |
| 19:19 | gtrak | samflores: yes, you can switch ns mid-stride |
| 19:19 | technomancy | it's possible but not wise |
| 19:19 | egghead | changing ns and then deffing something inside a fn, makes my skin crawl! |
| 19:19 | brehaut | gtrak: I would be curious what the lifespan of a ring :body is on the request. It may well not live beyond the lifespan of the request / response cycle |
| 19:20 | brehaut | (and may be adapter / server dependant) |
| 19:20 | gtrak | well, it *shouldn't*, but that means there has to be some indirection in the input/outputstreams, I guess that's what they're for, after all |
| 19:21 | brehaut | gtrak: shouldnt might be a flexible notion in context of keepalive |
| 19:21 | samflores | I'm making a macro (yeah, I know I probably shouldn't) that defines some functions in it's own ns |
| 19:21 | gtrak | it seems like one of those clojure-java value chasms |
| 19:22 | gtrak | what's a 'value' in the presence of mutability? |
| 19:22 | technomancy | an integer? =) |
| 19:24 | hyPiRion | uh, that's news to me |
| 19:25 | hyPiRion | ,(meta (with-meta '(1 2) {:foo 1})) |
| 19:25 | clojurebot | {:foo 1} |
| 19:26 | hyPiRion | ,(meta ^{:foo 1} '(1 2)) |
| 19:26 | clojurebot | nil |
| 19:26 | hyPiRion | ,(meta ^{:foo 10} (list 1 2)) |
| 19:26 | clojurebot | nil |
| 19:28 | hyPiRion | Anyone with experience with metadata |
| 19:28 | hyPiRion | that could explain the results above for me? I get the (quote (1 2)), but the (list 1 2)? |
| 19:29 | hyPiRion | In addition, elaborating why quoted lists automatically has {:line lineno} attached would be a great addition. |
| 19:33 | brehaut | hyPiRion: i know next to nothing about metadata but reader metadata (such as is attached with ^) is intended for clojure the language, whereas if you want meta data in your program you want with-meta i believe. |
| 19:34 | brehaut | hyPiRion: from memory reader metadata is attached to forms that are read, not the functions that are evaluated |
| 19:34 | brehaut | hyPiRion: thus ^{:foo 1} (list 1 2 3) is attaching the metadata map to the list '(list 1 2 3) not the list created by evaluating that expression '(1 2 3) |
| 19:35 | brehaut | hyPiRion: i suspect that lists that you get back from the reader have metadata annotating textual information because thats useful for error reporting |
| 19:36 | hyPiRion | Well, that's consistent with what I'm seeing here. Thanks |
| 19:36 | hyPiRion | (inc brehaut) |
| 19:36 | lazybot | ⇒ 9 |
| 19:36 | hyPiRion | I learned something today too. |
| 19:36 | brehaut | hyPiRion: it might also be wrong ;) |
| 19:36 | bosie | https://gist.github.com/6c7b342124669300d461 |
| 19:36 | brehaut | hyPiRion: thats based entirely what ive read, not what i know from looking at the implementation or experience |
| 19:37 | bosie | why does this result in: Actual: java.lang.IllegalArgumentException: No matching field found: length for class [Ljava.io.File; |
| 19:37 | ddima | does anybody have a good source/or collection handy for an explanation or something why TCO is not done? The argument in the doc is that clj uses java calling conventions, which seem to prevent it. Thought I wasnt able to find anything obvious looking thorugh http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf and some smilar sources. |
| 19:37 | bosie | clearly length is not executed as an instance method, right? |
| 19:37 | ddima | I guess a thread from the ML could do too ;) |
| 19:37 | hyPiRion | ,(. length (into-array [1 2 3])) |
| 19:37 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: length in this context, compiling:(NO_SOURCE_PATH:0)> |
| 19:38 | brehaut | ddima: its not done for interop reasons. |
| 19:38 | arohner | ddima: the JVM can't tail call across function boundaries, in the general case |
| 19:38 | arohner | or more specifically, can't goto across fn boundaries, because of security restrictions that may be in place |
| 19:38 | ddima | ok, and within functions? (why do we need recur for simple and no co-recursion?) |
| 19:38 | bosie | hyPiRion: i guess i should have an epiphany now but... ;) |
| 19:39 | hyPiRion | bosie: I just wanted to confirm my suspicion |
| 19:39 | ddima | I mean, I really do not know the jvm too well, what would be a good read and could shed light on how its done and what it can do (and obviously not do) |
| 19:39 | bosie | hyPiRion: hm |
| 19:39 | arohner | ddima: recur asserts that you're in a tail call spot, so it's mostly a safety/asthetic thing |
| 19:39 | p_l | search for bytecode reference |
| 19:40 | brehaut | ,(source alength) |
| 19:40 | clojurebot | Source not found |
| 19:40 | ddima | p_l: I actually thought that the pdf linked above would be an authoritative source, but there literally not a single mention of calling conventions |
| 19:40 | brehaut | (source alength) |
| 19:40 | brehaut | bah |
| 19:41 | brehaut | bosie: i think you want alength anyway |
| 19:41 | ddima | arohner: hm, ok, so it would actually be possible to omit recur within one function. Im just curious and looking to dig deeper because I had a lengthy discussion with a passionate non-clojurist and he really had a problem with recur. |
| 19:41 | p_l | ddima: the calling convention of java is very straightforward - put arguments on stack, call, then take return value from stack |
| 19:41 | bosie | hyPiRion: brehaut heh, thats what i am trying |
| 19:41 | bosie | now |
| 19:41 | bosie | alength works |
| 19:41 | p_l | it is, after all, a stack machine |
| 19:41 | ddima | arohner: his argument was that any good compiler sould detect it (true), and that an explicit recur should not be needed. I only was able to cite interop reasons from memory but couldnt back up with hard jvm facts ;) |
| 19:42 | brehaut | ddima: its entirely possible to do so. scala does TCO i believe |
| 19:42 | brehaut | ddima: its an explicit choice to come down on this side of the tradeoff, not due to some compiler implementation deficiency in the clojure community |
| 19:42 | arohner | ddima: yes, it shouldn't be necessary, but I do like the tail-call checking |
| 19:42 | arohner | it's helped me several times |
| 19:43 | arohner | I'd like to see an optional (assert-tail-call (foo)) in scheme |
| 19:43 | arohner | if I ever wrote scheme again, that is |
| 19:43 | ddima | arohner: personally I dont have a problem with it either, it just was a 'hangup' for the guy, as it seemed as a less 'real tco', since explicit |
| 19:44 | ddima | p_l: thanks for the pointer, thats what i assumed but somehow wasnt able to grasp from the doc. |
| 19:44 | wingy | noob question: how do i for loop a map? |
| 19:44 | p_l | ddima: I think the docs for jvm tend to assume that, because "stack machine" is pretty common stuff |
| 19:44 | brehaut | wingy: seq on a map results in a seq of pairs (vectors) |
| 19:45 | brehaut | ,(map identity {:a 1 :b 2}) |
| 19:45 | clojurebot | ([:a 1] [:b 2]) |
| 19:45 | wingy | my intention is to convert the map to another one .. so maybe i should use a map |
| 19:45 | gtrak | ddima: there's work on some macros implementing TCO via CPS transform : https://github.com/cjfrisz/clojure-tco |
| 19:45 | ddima | p_l: hehe, maybe. but assumptions are bad. i mean, they have funny 'complex' opcodes like iconst_5 and iload_2... |
| 19:45 | brehaut | ,(for [[k v] {1 2 3 4}] (+ k v)) |
| 19:45 | clojurebot | (3 7) |
| 19:45 | brehaut | wingy ^ |
| 19:45 | AimHere | There's various ways of doing that sort of thing, wingy |
| 19:45 | ddima | p_l: or maybe im an idiot, who knows. |
| 19:46 | wingy | cool |
| 19:46 | brehaut | wingy: you might be wanting to (into {} (map … )) |
| 19:46 | wingy | yeah |
| 19:46 | p_l | ddima: those are iirc specialized forms for generic iconst and iload instructions that load certain common stuff |
| 19:46 | brehaut | wingy: return a vector pair from your map function |
| 19:46 | hyPiRion | ,(. (into-array ["foo"]) length) |
| 19:46 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: length for class [Ljava.lang.String;> |
| 19:46 | hyPiRion | hm. |
| 19:46 | wingy | i should know what i wanna get out of it first and then use the correct fn .. since its fp style |
| 19:46 | ddima | p_l: yes, true. still interesting and unusual, at least to me. |
| 19:46 | p_l | ddima: so you call them without argument(s) |
| 19:46 | wingy | brehaut: oh yeah i forgot map is only working for arrays right? |
| 19:47 | brehaut | wingy: i have no idea what you mean |
| 19:47 | AimHere | Map works on collections |
| 19:47 | brehaut | wingy: map works on anything seqable |
| 19:47 | ddima | gtrak: thanks, will take a look at that. |
| 19:47 | p_l | for example, 0 and 1 are common values in integers (all those compaisons with 0 etc.), so there's special opcode to loading it |
| 19:47 | AimHere | map works on maps, but it treats a map as a sequence of pair vectors |
| 19:47 | p_l | instead of doing 0 iconst (two codes) |
| 19:48 | gtrak | wingy: you can try reduce-kv as well |
| 19:48 | ddima | p_l: its not that i dont get how that works or why, it still seemed pretty unusual to put that into an own opcode, even for the sake of saving one byte. but thats just my impression. |
| 19:49 | hyPiRion | ,(.size (Arrays/asList (into-array [1 2 3]))) |
| 19:49 | clojurebot | 3 |
| 19:49 | ddima | so thats why i actually thought that a spec as above would explicitly mention that arguments are pushed to stack in order and blabla, because there might be some other funny ways the jvm does it, even if its a stack machine. doesnt prevent funny optimizations ;) |
| 19:49 | wingy | so here is the deal . i need a fn that checks each key/value pair in a map .. the value will be converted depending on what key it is .. so the fn has to take a key/value pair |
| 19:50 | wingy | it seems that the map fn just takes one value from the sequence at a time |
| 19:50 | wingy | and it should return a formatted map structure |
| 19:51 | AimHere | ,(let [foo {:a 1 :b 2 :c 3}] (zipmap (keys foo) (map inc (vals foo)))) |
| 19:51 | clojurebot | {:b 3, :c 4, :a 2} |
| 19:52 | AimHere | ^ that's one suggestion, though I'm faintly worried that keys ... and vals .. might not pull their values out in the same order |
| 19:52 | gfredericks | they do |
| 19:52 | gtrak | ,(reduce-kv (fn [acc k v] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0}) |
| 19:52 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: reduce-kv in this context, compiling:(NO_SOURCE_PATH:0)> |
| 19:52 | gtrak | &(reduce-kv (fn [acc k v] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0}) |
| 19:52 | lazybot | ⇒ {9 1, 7 9, 5 7, 3 5, 1 3} |
| 19:52 | wingy | ah you misunderstood .. let me give you an example |
| 19:53 | bosie | anybody can give me pointers as to how i can connect "lein midje" to a nailgun server? |
| 19:53 | gtrak | equivalent to: ##(reduce (fn [acc [k v]] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0}) |
| 19:53 | lazybot | ⇒ {9 1, 7 9, 5 7, 3 5, 1 3} |
| 19:53 | gfredericks | AimHere: I think that's undocumented though :/ |
| 19:53 | AimHere | ,(into {} (map #(if (even? %1) (inc %2)) {1 2 2 3 3 4 5 6 7 8}) |
| 19:53 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 19:53 | AimHere | ,(into {} (map #(if (even? %1) (inc %2)) {1 2 2 3 3 4 5 6 7 8})) |
| 19:53 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval547$fn> |
| 19:53 | ddima | wingy: I think you'd just want something like (map (fn [a b] ...) (seq youdict)) |
| 19:53 | AimHere | ,(into {} (map #(if (even? (first %)) (inc (second %))) {1 2 2 3 3 4 5 6 7 8})) |
| 19:53 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 19:53 | AimHere | Bah |
| 19:54 | wingy | ddima: yeah but map takes only one value from the seq |
| 19:54 | hyPiRion | /msg clojurebot guys |
| 19:54 | ddima | wingy: seq will give you a seq of kv 'tuples', which you can use to do your checks |
| 19:54 | wingy | ddima: i c |
| 19:54 | ddima | , (map (fn [[a b]] [b a]) (seq kv)) |
| 19:54 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: kv in this context, compiling:(NO_SOURCE_PATH:0)> |
| 19:54 | gtrak | ddima: you don't need seq... map does the same |
| 19:54 | ddima | err, mom |
| 19:54 | gtrak | ,(map identity {1 2 3 4 5 6}) |
| 19:54 | clojurebot | ([1 2] [3 4] [5 6]) |
| 19:55 | hyPiRion | ,(map class {1 2}) |
| 19:55 | clojurebot | (clojure.lang.MapEntry) |
| 19:55 | hyPiRion | et voila. |
| 19:55 | ddima | ,(map (fn [[a b]] [b a]) (seq {:a "a" :b "b"})) |
| 19:55 | clojurebot | (["a" :a] ["b" :b]) |
| 19:55 | ddima | wingy: should do, right? |
| 19:55 | hyPiRion | but reduce-kv is potentially faster, so may use that one. |
| 19:55 | ddima | gtrak: oh, really? hm :) |
| 19:55 | hyPiRion | and it's well, as far as I know what you want. |
| 19:56 | ddima | yep. true |
| 19:56 | ddima | nevermind. beers and stuff. |
| 19:56 | gtrak | more beer! onwards. |
| 19:56 | mehwork | why does this give me clojure.set not found: (clojure.set/union #{:foo} #{bar}) |
| 19:57 | gfredericks | did you require clojure.set yet? |
| 19:57 | mehwork | no, the book didn't tell me too ah |
| 19:57 | AimHere | Which book? |
| 19:57 | gfredericks | burn it! |
| 19:57 | mehwork | "seven languages in seven weeks" |
| 19:57 | mehwork | it's a good book overall |
| 19:57 | wingy | ddima: excellent..but how do i convert the sequence with key/value pairs back to a map? |
| 19:57 | gfredericks | wingy: (into {} ...) |
| 19:58 | wingy | wiii |
| 19:58 | wingy | thx all |
| 19:58 | AimHere | mehwork, shame. I was rather hoping to chastise the author in here, since most of the writers of Clojure-specific books show up in here at some point |
| 19:59 | gfredericks | shame on all of you clojure-specific-book-writers |
| 19:59 | technomancy | in 1.2 you didn't have to require clojure.set |
| 19:59 | gfredericks | technomancy: it was used somewhere in core? |
| 19:59 | technomancy | gfredericks: not sure if it was that or convenience |
| 20:00 | mehwork | AimHere: well maybe they thought that clojure.set would be auto loaded, as stackoverflow is saying anyway |
| 20:00 | mehwork | it's not for me in the lein repl in ubuntu |
| 20:00 | ddima | wingy: or (apply hash-map [[:key val] [:key val]]) if you feel funny ;) |
| 20:00 | arohner | right, in 1.3 or so, clojure.set stopped being autoloaded |
| 20:01 | technomancy | all the breaking changes, all the time |
| 20:01 | gfredericks | ddima: I'd bet two quarters that doesn't work |
| 20:01 | gfredericks | ,(let [val 42] (apply hash-map [[:key val] [:key val]])) |
| 20:01 | clojurebot | {[:key 42] [:key 42]} |
| 20:01 | ddima | damn, true again |
| 20:01 | ddima | why dont i check first |
| 20:01 | ddima | sorry, retreating to the batcave |
| 20:02 | ddima | nesting too deep! |
| 20:03 | wingy | ddima: both gave the same value: https://www.refheap.com/paste/7684 |
| 20:03 | wingy | i didn't have to use seq |
| 20:03 | ddima | wingy: yes, thats what somebody noted before |
| 20:03 | wingy | weird |
| 20:03 | ddima | I was wrong, he was right. its not needed. |
| 20:03 | wingy | maybe because of the destructuring clause? |
| 20:04 | wingy | or maybe not |
| 20:04 | hyPiRion | to the source |
| 20:04 | hyPiRion | &(source map) |
| 20:04 | lazybot | ⇒ Source not found nil |
| 20:04 | hyPiRion | $source map |
| 20:04 | lazybot | map is http://is.gd/47nOpc |
| 20:05 | hyPiRion | yeah, it uses seq on its arguments |
| 20:05 | ddima | wingy: i think its more because thats the way maps are seq'ed ;) |
| 20:06 | mehwork | it's kinda weird how def creates a variable |
| 20:06 | technomancy | you mean a var? |
| 20:07 | mehwork | there's a diff? |
| 20:07 | ddima | gfredericks: but on a serious note, was into really the only way to build a dict from nested 'tuples'? could have sworn there either was a function or similar. thats why i thought that was an apply thing. |
| 20:07 | ddima | just curious. |
| 20:07 | technomancy | clojure doesn't have variables |
| 20:07 | mehwork | maybe you should chastize the author of this book then :> |
| 20:07 | AimHere | merely 'vars' |
| 20:08 | gfredericks | technomancy: what does variable mean such that clojure doesn't have them? |
| 20:08 | technomancy | gfredericks: locals that change |
| 20:08 | gfredericks | technomancy: okay. clojure doesn't have variables. |
| 20:09 | AimHere | doesn't that make 'global variables' an oxymoron? |
| 20:09 | gfredericks | ddima: I don't know of an easier way. the hash-map function expects pairs of arguments, so you could #(apply hash-map (apply concat [[:foo 3] [:bar "MRHRAH"] [:baz "Lots of money"]])) |
| 20:09 | technomancy | AimHere: depends on the language. usually globals are a completely different mechanism that kind of look like locals if you aren't paying attention. |
| 20:10 | gfredericks | while everybody else was busy demonizing global variables clojure kept the globals and just eliminated the locals. |
| 20:10 | technomancy | anyway, a var isn't what most languages call global variables either; it's a storage location |
| 20:10 | ddima | gfredericks: uh, i was pretty close to the real deal, just lacking the concat ;) |
| 20:10 | ddima | ok, then i just dreamed something up i guess. |
| 20:11 | mehwork | so a var is more like an immutable pointer? |
| 20:11 | gfredericks | ddima: whoops I forgot to add the extra # so lazybot would eval it |
| 20:11 | gfredericks | mehwork: yes except mutable |
| 20:11 | technomancy | mehwork: you can change vars, but unless you're crazy you only do it during development time |
| 20:12 | mehwork | will it dump core |
| 20:12 | technomancy | no, it'll just make your colleagues hate you |
| 20:12 | mehwork | too late |
| 20:13 | gfredericks | apparently it is also okay to wrap vars at compile-time. |
| 20:13 | technomancy | well yeah you can push thread-local bindings |
| 20:13 | gfredericks | no I mean alter-var-root |
| 20:14 | technomancy | don't do that |
| 20:14 | technomancy | I mean it's OK for dev tools |
| 20:14 | brehaut | technomancy means its ok for his code, but not yours. |
| 20:14 | brehaut | talk about your double standards |
| 20:15 | brehaut | :P |
| 20:15 | technomancy | brehaut: I only write dev tools! |
| 20:15 | technomancy | so I'm in the clear =D |
| 20:15 | brehaut | :) |
| 20:15 | gfredericks | https://github.com/clojure/core.contracts/blob/master/src/main/clojure/clojure/core/contracts.clj#L65 |
| 20:15 | joevandyk | is there anything like vcr for clojure? https://www.relishapp.com/vcr/vcr/docs |
| 20:15 | ddima | btw, has anybody had fun with decompiling clojure just to see what happens? |
| 20:15 | gfredericks | joevandyk: I started one |
| 20:15 | gfredericks | and so did some other guy. |
| 20:15 | gfredericks | I don't know which one is better. |
| 20:15 | gfredericks | mine is pretty minimal |
| 20:15 | joevandyk | i sometimes have to work closely with a lot of 3rd party http services and would like to test against their responses |
| 20:16 | technomancy | gfredericks: blurgh |
| 20:16 | technomancy | do not want |
| 20:16 | gfredericks | technomancy: vcr or alter-var-root? |
| 20:16 | technomancy | gfredericks: this crazy provide function |
| 20:16 | joevandyk | technomancy: do you guys still have the seattle clojure meetups? |
| 20:16 | technomancy | joevandyk: yeah totally |
| 20:16 | technomancy | first thursday of the month |
| 20:16 | joevandyk | i should stop by. getting sick of ruby |
| 20:17 | gfredericks | technomancy: I also added a var-reddefer in some code recently for wrapping a function with logging; would you use a defn-macro or something? |
| 20:17 | wingy | how do i convert a string into a double? |
| 20:17 | wingy | "12.12" -> 12.12 |
| 20:17 | gfredericks | Double/parseDouble |
| 20:17 | gfredericks | or read-string if you want to be sloppy |
| 20:17 | gfredericks | it's shorter! |
| 20:17 | wingy | maybe the former is better for security? |
| 20:17 | gfredericks | yeps |
| 20:17 | wingy | and you cannot execute any code |
| 20:17 | wingy | :) |
| 20:17 | AimHere | The latter is a proper clojure function |
| 20:17 | joevandyk | gfredericks: is your clojure vcd code somewhere? |
| 20:18 | gfredericks | $google fredericksgary vcr-clj |
| 20:18 | technomancy | gfredericks: hmmm... that might be permissible because it doesn't change the behaviour |
| 20:18 | lazybot | [fredericksgary/vcr-clj · GitHub] https://github.com/fredericksgary/vcr-clj |
| 20:18 | gfredericks | technomancy: yeah I always had the impression that orthogonal concerns _might_ be justifiable |
| 20:18 | gfredericks | never business stuff |
| 20:18 | technomancy | gfredericks: I wonder what tools.trace does |
| 20:18 | ddima | yeah, read string will deceive you horribly in situations with 0 prefixed number etc.pp - great fun ;) |
| 20:19 | ddima | "works till 7, hmmm. close enough!" |
| 20:19 | joevandyk | the thing i have in mind is retrieving tracking numbers against a bunch of different shipping services (dhl, upsmi, ups, sups, fedex, etc) and have a unified api to figure if they have shipped, the best tracking url, etc |
| 20:19 | technomancy | gfredericks: in any case I think a blanket "never use alter-var-root" is a good idea because the people who are capable of understanding when it's a good idea are generally confident enough to know when to ignore what they hear on IRC =) |
| 20:19 | ddima | thought, deception is the wrong word. it actually does what its supposed to do. |
| 20:20 | turbofail | is there some way to configure the size of the thread pool used to run futures? |
| 20:20 | turbofail | it seems to be maxing out at 30 |
| 20:20 | gfredericks | technomancy: never use clojure |
| 20:21 | technomancy | gfredericks: brb porting lein to clojurescript |
| 20:21 | mehwork | never use use |
| 20:21 | brehaut | never use :use |
| 20:21 | brehaut | use is sometimes useful |
| 20:21 | brehaut | (at the repl) |
| 20:22 | gfredericks | technomancy: I feel like you just defended a big pile of parenting techniques :) |
| 20:23 | technomancy | turbofail: I think there's an open issue for that but no patch yet |
| 20:23 | CoverSlide | ok so don't use (ns (:use and don't use (use ok so what do i use? |
| 20:23 | turbofail | ah |
| 20:24 | brehaut | CoverSlide: (:require ns.foo :refer [baz bop]) |
| 20:24 | CoverSlide | hmm |
| 20:24 | ddima | frighteningly funny channel, actually. |
| 20:25 | gfredericks | (:require [ns.foo :as foo]) |
| 20:25 | mehwork | lol |
| 20:25 | brehaut | gfredericks: that too |
| 20:25 | gfredericks | brehaut: (:require [jayq.core :as $ :refer [$]]) |
| 20:26 | brehaut | gfredericks: thats all great except for the use of jquery |
| 20:26 | gfredericks | Jayq Weary? |
| 20:27 | akhudek | I expected deftype to support = |
| 20:27 | gfredericks | I think deftype is intentionally pretty bare |
| 20:28 | technomancy | akhudek: deftype supports mutability, and equality can't be meaningfully defined on mutable objects |
| 20:28 | gfredericks | that's a much gooder explanation |
| 20:28 | brehaut | gfredericks: jquery, like all big arse-libraries (xkcd'd for you already), is a giant collection of average implementations of everything |
| 20:28 | joevandyk | what's the best way of interfacing with postgresql? while using all the nice datatypes, like ranges, intervals, json, etc? |
| 20:29 | akhudek | That makes sense. Do I need to implement hashcode too? These types are in fact immutable. |
| 20:29 | technomancy | joevandyk: there's not a great story right now. you have low-level access through clojure.java.jdbc and high-level access with some baked in bad assumptions with korma. pick the lesser of two evils. |
| 20:30 | seangrove | brehaut: That's a slightly strange stance given the scope of the google closure library |
| 20:30 | joevandyk | technomancy: bad assumptions? |
| 20:31 | brehaut | seangrove: who said i like google closure either :P |
| 20:31 | seangrove | You did |
| 20:31 | seangrove | All throughout the internet |
| 20:31 | brehaut | seangrove: i never! |
| 20:31 | brehaut | lol |
| 20:32 | seangrove | But, it is pretty closely tied to cljs, for better or worse |
| 20:32 | seangrove | At least for now, I suppose |
| 20:32 | brehaut | indeed |
| 20:32 | ddima | is there a good writeup on 'gc pressure' exercised by clojure though the pretty large number of function objects etc.pp? just curious. |
| 20:32 | technomancy | joevandyk: it doesn't allow for you to control the scope of your DB connections and IIRC messes up laziness for cursor queries among a few other things I can't remember right now |
| 20:32 | technomancy | I don't use it much, but it comes up every so often in the channel |
| 20:32 | brehaut | seangrove: although closure can optimize out the usage of a lot of it if you dont actually use it |
| 20:32 | brehaut | (except where clojurescript.core doe) |
| 20:33 | brehaut | seangrove: i don't actually clojurescript at the present time anyhow |
| 20:33 | seangrove | brehaut: Yeah, but that's really possible with just the compiler |
| 20:33 | seangrove | I could see a future where cljs-in-cljs eventually leads to less of a reliance on the closure library and more on pure cljs libraries |
| 20:34 | gfredericks | as soon as somebody implements format |
| 20:34 | seangrove | CL's format? |
| 20:34 | gfredericks | clojure.core/format |
| 20:34 | gfredericks | or maybe cljs.core/format in this case |
| 20:34 | seangrove | bah, I was excited to see CL's format |
| 20:35 | seangrove | One of the most baffling and powerful things I've ever used |
| 20:42 | hyPiRion | (require '[clojure.pprint :refer [cl-format]]) |
| 20:42 | hyPiRion | ,(require '[clojure.pprint :refer [cl-format]]) |
| 20:42 | clojurebot | nil |
| 20:42 | hyPiRion | ,(cl-format true "~{~A~^, ~}" [1 2 3 4]) ; 'tis powerful |
| 20:42 | clojurebot | 1, 2, 3, 4 |
| 20:43 | technomancy | does our version have roman numeral support? |
| 20:43 | hyPiRion | ,(cl-format true "~{~R~^, ~}" [1 2 3 400]) ; 'tis powerful |
| 20:43 | clojurebot | one, two, three, four hundred |
| 20:43 | technomancy | geez |
| 20:43 | hyPiRion | ,(cl-format true "~{~:R~^, ~}" [1 2 3 400]) ; 'tis powerful |
| 20:43 | clojurebot | first, second, third, four hundredth |
| 20:43 | ddima | nice |
| 20:43 | seangrove | hahaha |
| 20:43 | hyPiRion | I think it has everything cl's format has, except function calls. |
| 20:43 | seangrove | technomancy: Curious to see the discussion that said it should ship with clojure...? |
| 20:44 | brehaut | next thing you know, well have brainfuck shipping as standard |
| 20:44 | brehaut | and someone will have a brainfuck / cl-format polyglot |
| 20:44 | technomancy | seangrove: I think it snuck in as part of pprint |
| 20:44 | technomancy | kinda like how clojure.walk snuck in as part of clojure.test |
| 20:44 | hyPiRion | technomancy: You forgot the roman numbers. |
| 20:44 | hyPiRion | ,(cl-format true "~{~@R~^, ~}" [1 2 3 400]) ; 'tis powerful |
| 20:44 | clojurebot | I, II, III, CD |
| 20:45 | hyPiRion | In case anyone needs it. |
| 20:45 | technomancy | [17:35] <technomancy> does our version have roman numeral support? |
| 20:45 | technomancy | =){ |
| 20:45 | hyPiRion | Oh, I read that as written numeral support |
| 20:45 | hyPiRion | sorry |
| 20:46 | seangrove | Iterating over vectors, maps, etc. is pretty cool though |
| 20:46 | technomancy | heh; it's cool |
| 20:46 | gfredericks | hyPiRion: man that'd be cool if it could write numerals as well |
| 20:46 | seangrove | I've only used it a handful of times and haven't missed it terribly when in languages that didn't have cl-format, but I do like it overall |
| 20:46 | cark | ,(cl-format true "file~p" 1) |
| 20:46 | clojurebot | file |
| 20:46 | cark | ,(cl-format true "file~p" 10) |
| 20:46 | clojurebot | files |
| 20:46 | cark | darn |
| 20:46 | cark | it's all in there |
| 20:47 | seangrove | ,(cl-format true "ox~p" 10) |
| 20:47 | clojurebot | oxs |
| 20:47 | cark | CL's plural thingie isn't that good either =) |
| 20:47 | seangrove | Yeah, I ported the rails inflection system to CL as an early project, was fun |
| 20:47 | brehaut | please tell me its not locale aware |
| 20:47 | cark | brehaut: haha that would be awesome |
| 20:47 | hyPiRion | cark: it's good if you know the plural form |
| 20:48 | seangrove | I posted it to hn and got a good response, and some people asked that I port a perl system over, wonder if I can find it... |
| 20:49 | seangrove | Oh, wow, my project was forked and improved on, had no idea |
| 20:50 | cark | ,(cl-format true "~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~}" [1 2 3 400]) |
| 20:50 | clojurebot | 1, 2, 3, and 400 |
| 20:50 | hyPiRion | ,(cl-format true "~r ox~:*~[en~;~:;en~]" 10) |
| 20:50 | clojurebot | ten oxen |
| 20:50 | hyPiRion | ,(cl-format true "~r ox~:*~[en~;~:;en~]" 1) |
| 20:50 | clojurebot | one ox |
| 20:50 | cark | hyPiRion: nice one =) |
| 20:51 | cark | now you pass the resource file to your translators =) |
| 20:52 | seangrove | Ah, yes, here it is: http://search.cpan.org/~dconway/Lingua-EN-Inflect-1.895/lib/Lingua/EN/Inflect.pm |
| 20:53 | seangrove | I ported rails' inflector as a learner-project, and the top comment included "Damian Conway (Lingua::EN::Inflect's author) also wrote a paper about algorithmic English pluralization that actually takes a linguistic approach to all of this" |
| 20:54 | seangrove | "Oh, I see you have a toy project - have you considered going through all of the academic research and writing a professional-grade system instead?" |
| 20:54 | cark | we need to bindle that with clojure ! |
| 20:54 | cark | bundle* |
| 20:56 | n_b | annnnd one more paper gets added to the list |
| 20:56 | seangrove | Reading list, or burn list? |
| 20:56 | n_b | Reading |
| 20:57 | n_b | English Lit major, so anything that has CS<->Degree crossover piques my interest |
| 20:57 | seangrove | Ah, very cool |
| 20:57 | seangrove | You could do some good in the world |
| 20:57 | seangrove | Things like Lingua-EN do actually help quite a bit |
| 20:58 | seangrove | Even if a simple table of regexes gets you ~80% of the way there |
| 20:58 | n_b | I started to dissect the Rails inflector once when I had less experience, wouldn't mind giving it another go |
| 20:59 | seangrove | It's pretty tiny, super easy |
| 20:59 | n_b | Which leads to all sorts of hilarious outcomes in Rails projects for those unaware of its corner cases |
| 21:00 | seangrove | Here's (I believe) a full recreation in CL: http://trapm.posterous.com/vana-inflector-an-english-inflector-in-common |
| 21:03 | n_b | That is indeed simpler than I remember |
| 21:03 | seangrove | Looking at it, I don't think it handles camelCase things, which I believe the rails inflector also does |
| 21:03 | n_b | Experience counts for a lot |
| 21:03 | seangrove | So maybe it's not actually a full port. Owell. |
| 21:05 | n_b | and utf-8? Not sure of the status of that in CL |
| 21:06 | mattmoss | If I'm wrapping a (proprietary) java lib with pre-built classes (no src avail), I can't extend-protocol IPersistentMap to it, can I? |
| 21:06 | mattmoss | That is, I know I can't do it directly... since IPersistentMap isn't a protocol. Wondering if there are workarounds... |
| 21:09 | gfredericks | line repple |
| 21:11 | seangrove | heh, what is "The new alternative to `lein repl`" |
| 21:11 | n_b | Doesn't everything hook into lein repl? |
| 21:11 | seangrove | line repple => lein repl |
| 21:11 | craigbro | lime apple |
| 21:12 | n_b | ahh |
| 21:13 | gfredericks | how to install line again |
| 21:13 | gfredericks | should I use line again too or line again won? |
| 21:14 | seangrove | gfredericks: that's really technomancy's fault for choosing an impossible to spell name |
| 21:14 | brehaut | SERD ERPTGERT ERNSTERL LERNERGERN |
| 21:15 | hyPiRion | lien rpel is usually what I manage to type. |
| 21:16 | seangrove | heh, lein repel! |
| 21:16 | seangrove | To be used when you find foreign jars in your project |
| 21:16 | n_b | echo 'alias lr="lein repl"'>>~/.profile |
| 21:16 | lazybot | 'alias lr="lein repl"'>>~/.profile |
| 21:16 | hyPiRion | echo $HOME |
| 21:16 | lazybot | $HOME |
| 21:16 | hyPiRion | meh. |
| 21:16 | gfredericks | echo echo echo |
| 21:16 | lazybot | echo echo |
| 21:16 | gfredericks | ,(println "echo echo") |
| 21:16 | clojurebot | echo echo |
| 21:16 | lazybot | echo |
| 21:16 | hyPiRion | you beat me. |
| 21:17 | gfredericks | clojurebot: echo is foxtrot |
| 21:17 | clojurebot | Ack. Ack. |
| 21:36 | hyPiRion | ,(println "echo ,(println echo echo)") |
| 21:36 | clojurebot | echo ,(println echo echo) |
| 21:36 | lazybot | ,(println echo echo) |
| 21:36 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: echo in this context, compiling:(NO_SOURCE_PATH:0)> |
| 21:36 | nsxt | what's the name of the editor that LightTable builds on? |
| 21:36 | brehaut | codemirror |
| 21:36 | nsxt | brehaut: Thanks! |
| 21:37 | hyPiRion | ,(println "echo ,(println \"echo foo\")") |
| 21:37 | clojurebot | echo ,(println "echo foo") |
| 21:37 | lazybot | ,(println "echo foo") |
| 21:37 | clojurebot | echo foo |
| 21:37 | lazybot | foo |
| 21:37 | hyPiRion | woo, two levels |
| 21:37 | hyPiRion | the next step is obviously to make an iterating quine out of this. |
| 21:39 | seangrove | Ugh, just read through a thread on comp.lang.lisp, incredibly painful to read. So much ego and snark. |
| 21:40 | gfredericks | wait wait |
| 21:40 | gfredericks | you actually can make a bot trampoline out of that can't you |
| 21:41 | hyPiRion | &((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x))))) |
| 21:41 | lazybot | ⇒ ((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x))))) |
| 21:41 | hyPiRion | sure thing. |
| 21:41 | hyPiRion | Just need a bit of massage |
| 21:41 | gfredericks | well you need it to alternate forms |
| 21:42 | hyPiRion | yeah |
| 21:42 | gfredericks | well sorta |
| 21:42 | gfredericks | lazybot won't do any evaling I guess |
| 21:42 | gfredericks | so it's not a twine |
| 22:06 | hyPiRion | gfredericks: Dangit, it's actually working too. |
| 22:22 | wingy | how can i convert a "123.0" to Long? |
| 22:23 | wingy | Long/parseLong says it's bad input |
| 22:24 | hyPiRion | Parse it to a double first, then cast it to a long |
| 22:25 | hyPiRion | ,(long (Double/parseDouble "123.0")) |
| 22:25 | clojurebot | 123 |
| 22:25 | bbloom | hyPiRion: that's probably not a great idea, since long and double don't have the same domain |
| 22:25 | bbloom | wingy: just split at . and parse the first part |
| 22:25 | bbloom | assuming you don't mind truncating instead of rounding |
| 22:25 | wingy | bbloom: good idea |
| 22:26 | brehaut | bbloom: can you explain 'domain' in that context? |
| 22:26 | hyPiRion | a long can represent something a double cannot, and vice versa. |
| 22:26 | bbloom | domain, as in function domain, range, co-domain, etc |
| 22:27 | brehaut | right |
| 22:30 | hyPiRion | ,(let [a [[36 116 105 109 [101 114 32 49 [54 58 48 58 [48 32 44 40 [108 101 116 32 [91 119 104 97 [116 39 115 32 [39 116 104 105 [115 63 32 97 32]]]]]]]]] "] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))"]] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1)))) |
| 22:30 | clojurebot | $timer 16:0:0 ,(let [what's 'this? a [[36 116 105 109 [101 114 32 49 [54 58 48 58 [48 32 44 40 [108 101 116 32 [91 119 104 97 [116 39 115 32 [39 116 104 105 [115 63 32 97 32]]]]]]]]] "] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))"]] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1)))) |
| 22:30 | lazybot | Timer added. |
| 22:37 | erewhon | if you're wanting to convert it to a long, why does the input have .0? |
| 22:38 | amalloy | hah, well done hyPiRion. many have tried for the multi-bot quine, and you've finally found a clever hack involving a spot where lazybot doesn't prepend his output |
| 22:38 | amalloy | Raynes: ^ |
| 22:41 | Raynes | Pretty sure I have a list of people to ignore somewhere that is broken. I'll just have to fix it and add clojurebot. |
| 22:42 | Raynes | Then your evil plans will be foiled once and for all. |
| 22:44 | Raynes | hyPiRion: Good work. |
| 22:44 | Raynes | I have a fresh cookie that I'll mail to you promptly, sir. |
| 22:50 | hyPiRion | Raynes: To be fair, if I were evil, I would just do echo instead. $timer removes colons, so I had to use that vector-with-ints hack which isn't needed for echo. |
| 22:51 | Raynes | hyPiRion: Echo? |
| 22:51 | Raynes | echo hi |
| 22:51 | lazybot | hi |
| 22:51 | Raynes | That? |
| 22:51 | clojurebot | that is dumb |
| 22:51 | Raynes | It is, I agree. |
| 22:51 | hyPiRion | yeah |
| 22:52 | Raynes | Well, if you did that everybody would probably have hated you. |
| 22:52 | Raynes | :p |
| 22:52 | hyPiRion | exactly, heh. |
| 22:52 | Raynes | But yeah, that's why I had the user blacklist thingy. It used to ignore clojurebot but somewhere along the line I broke it. |
| 22:53 | hyPiRion | hm, better fix it before i make them hold a conversation through timers and Thread/sleeps |
| 22:53 | gfredericks | ~botstack |
| 22:53 | clojurebot | Pardon? |
| 22:53 | Raynes | hyPiRion: Feel powerful, don't you? |
| 22:54 | Raynes | hyPiRion: How would you feel if I forced you to talk to gfredericks all day like a broken record? |
| 22:54 | Raynes | :p |
| 22:55 | hyPiRion | Raynes: :( |
| 22:55 | gfredericks | &((apply comp (repeat 10000 identity)) 42) |
| 22:55 | lazybot | ⇒ 42 |
| 22:55 | gfredericks | I wonder how that computation feels |
| 22:57 | hyPiRion | ,(recur) |
| 22:57 | clojurebot | Execution Timed Out |
| 22:57 | hyPiRion | That is also painful. Poor bots. |
| 23:00 | gfredericks | ,(recur 5) |
| 23:00 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1, compiling:(NO_SOURCE_PATH:0)> |
| 23:00 | hyPiRion | ,@(promise) |
| 23:01 | clojurebot | Execution Timed Out |
| 23:03 | ldh | \tproject |
| 23:03 | ldh | oops |
| 23:04 | ldh | if i i'm in a repl ("lein repl") and i change a source file, why wouldn't (require … :reload) pick up the change? is there something else i'm missing? i swear this used to work... |
| 23:07 | brehaut | ldh: it should do |
| 23:08 | brehaut | ldh: there are some gotchas though, around things like multimethods and anything with defonce semantics |
| 23:08 | brehaut | (not new gotchas however) |
| 23:13 | ldh | brehaut: i'm tweaking the implementation of a protocol in a defrecord. i do have a couple of instances of defonce data being passed around, maybe that's related. thanks for the tip |