2011-09-15
| 00:08 | srid | amalloy_: why doesn't 4clojure accept `def`? |
| 01:19 | nickmbailey | why would '(type (int 1))' return java.lang.Long? |
| 01:29 | nickmbailey | seems like a bug |
| 01:32 | quotemstr | Why doesn't ClojureScript have refs? |
| 01:35 | brehaut | quotemstr: because there is no shared state concurrency in javascript |
| 01:37 | brehaut | nickmbailey: in clj 1.2, type either returns the :type meta data for its argument, or the class. if in returns a primative its not going to have meta, so it will be boxed into an object (in this case a long apparently) for class |
| 01:38 | nickmbailey | brehaut: its actually a 1.3 thing |
| 01:38 | nickmbailey | it returns java.lang.Integer on 1.2 |
| 01:38 | brehaut | nickmbailey: then i have no idea |
| 01:38 | nickmbailey | but java.lang.Long on 1.3rc0 |
| 01:39 | nickmbailey | i assume its due to the fact that function arguments are auto boxed into actual objects so you can't really pass primitives |
| 01:39 | nickmbailey | but it seems like an int primitive should be boxed into Integer |
| 01:39 | brehaut | in 1.2 that would be the case |
| 01:40 | nickmbailey | i think its the case in 1.3 if you don't add primitive type hints |
| 01:41 | nickmbailey | oh you can only type hint longs and doubles |
| 01:42 | nickmbailey | i wonder if int even returns an integer primitive in 1.3 |
| 02:20 | nickmbailey | yeah looks like in 1.3 all primitives are boxed to either long or float, i guess that makes sense |
| 03:59 | tsdh | Hi |
| 04:01 | tsdh | I've just read something (book, blog, whatever) that demonstrated clojure's java interop by creating some AWT frame that translated a given function's value to RGB and printed it in some canvas. But I can't remember where I've read that. Do you? |
| 05:09 | fliebel | Next month I'm going to live code a web app in 15 minutes. I'm thinking about a simple wiki with Ring, Moustache and Hiccup, or something like that. Any input? |
| 05:10 | fliebel | It's for the Amsterdam Clojurians meetup, Uncle Bob is also going to present that month. |
| 05:12 | TheBusby | tsdh: Joy of Clojure? |
| 05:14 | scottj | fliebel: simple multiplayer version of http://strategerygame.com/ including cljs :) |
| 05:14 | tsdh | tsdh: Already looked there, but couldn't find it... |
| 05:15 | TheBusby | Page 87 |
| 05:15 | tsdh | TheBusby: Ah, found it. |
| 05:15 | tsdh | :-) |
| 05:16 | tsdh | I've only checked the Java.next chapter... |
| 05:17 | bsteuber | scottj: looks really nice - how much cljs does it involve? |
| 05:17 | scottj | fliebel: http://canvas.opalang.org/ would also be cool, especially if the audience could use functionality as you add it |
| 05:17 | fliebel | Whoa, write a game in 15 minutes? |
| 05:17 | scottj | fliebel: tic tac toe? |
| 05:17 | TheBusby | fliebel: minesweeper? |
| 05:18 | bsteuber | oh I misunderstood it, nevermind :) |
| 05:18 | Fossi | i dislike such talks for being "lazy", because you can't really show off the hard parts |
| 05:18 | Fossi | i'd maybe concentrate on corners that aren't so easy to get right |
| 05:19 | Fossi | or mistakes that are prone to happen if somebody would try without knowing the frameworks/domain much |
| 05:21 | robermann | fliebel: a music live coding? http://mad.emotionull.com/ |
| 05:22 | fliebel | Hm, fair point. What are hard parts in your opinion? |
| 05:22 | Fossi | don't know moustache or hiccup very well |
| 05:22 | Fossi | serving static resources with the right mime types and headers |
| 05:22 | fliebel | robermann: We had Jeff Rose show off Overtone a while back. |
| 05:22 | Fossi | getting authorization to work |
| 05:23 | Fossi | little things like that |
| 05:23 | robermann | (fliebel: ok ) |
| 05:23 | thorwil | fliebel: not sure for a wiki, but for a blog, nested comments and role-depending variations in the views can make things complicated |
| 05:23 | fliebel | Auth might be nice. |
| 05:23 | Fossi | how to work in session data and keeping your site functional |
| 05:23 | Fossi | how to connect some backend |
| 05:23 | Fossi | (ie, get data first, then render) |
| 05:23 | Fossi | switching renderers from html to json maybe |
| 05:25 | clgv | fliebel: +1 for authorization |
| 05:25 | thorwil | handling cases where the same html fragments need to be generated server-side first, then on client-side for updates |
| 05:28 | fliebel | I think the game is nice, But not sure it fits in 15 minutes. Because things like Ruby on Rail can generate a lot of the CRUD for you. Doing non-standard stuff is more powerful I think. |
| 05:32 | fliebel | Thanks for the input everyone :) |
| 05:33 | Fossi | we've been hacking a meetup replacement in the clojure hamburg group for a while :) |
| 05:33 | Fossi | so we've had quite a few of those talks :) |
| 06:19 | tsdh | If a java class has both a field foo as well as a method foo without args, what will (.foo obj) access? And how can I access the other? |
| 06:20 | clgv | tsdh: is that possible? |
| 06:20 | tsdh | clgv: Yes |
| 06:21 | tsdh | clgv: For java, it's easy to distinguish obj.foo from obj.foo(). |
| 06:22 | clgv | tsdh: it calls the method in my example. |
| 06:22 | opqdonut | tsdh: that will call the method |
| 06:22 | clgv | tsdh: maybe you can use the more verbose java interop where it might be distinguished |
| 06:23 | tsdh | clgv: (. foo obj) has the same semantics, doesn't it? |
| 06:24 | opqdonut | yes |
| 06:24 | clgv | tsdh: well it cant access the property it seems ; |
| 06:24 | tsdh | clgv: If you already have an example, could you check if (set! (.foo obj) 42) works? |
| 06:24 | opqdonut | ISTR that obj/foo works for the field, but is undocumented |
| 06:25 | opqdonut | no |
| 06:26 | clgv | tsdh: it pretends to do something by returning the number |
| 06:26 | tsdh | clgv: Thanks |
| 06:26 | clgv | but I cant read the value back as it is now ;) |
| 06:27 | clgv | tsdh: yes it works |
| 06:27 | tsdh | Great |
| 06:28 | mcstar | hi |
| 06:28 | mcstar | im in trouble with swank-clojure |
| 06:28 | tsdh | Well, the foo/foo() is a basically a non-issue. usually it's foo/getFoo()... |
| 06:28 | mcstar | what is the preffered way nowadays to get slime working with clojure? |
| 06:29 | clgv | mcstar: technomancys guide? |
| 06:31 | mcstar | lein plugin install swank-clojure 1.3.2 |
| 06:31 | mcstar | thats what he says |
| 06:31 | mcstar | however it seems when i lein swank and then slime-connect that the swank clojure is from 20100404 |
| 06:31 | mcstar | or some like that |
| 06:32 | clgv | didnt he have a detailed guide up? I thought I remember him posting a link sometime... |
| 06:32 | mcstar | the slime prompt accepts numbers, but not expressions like (+ 3 4) |
| 06:32 | tsdh | mcstar: I use only clojure-mode and did the lein plugin recipe. From inside emacs, I simply do M-x clojure-jack-in. Works fine... |
| 06:32 | mcstar | clgv: ive only found the github readme of his |
| 06:32 | mcstar | tsdh: do you start lein before? |
| 06:33 | mcstar | sorry guys im new to java/maven/ant/leiningen |
| 06:34 | joshnz | mcstar: I went thru your pain a few weeks back. I added my notes on to the wiki: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs |
| 06:34 | mcstar | aham, clojure-jack-in starts the swank itself |
| 06:35 | mcstar | thx |
| 06:35 | tsdh | mcstar: No |
| 06:35 | tsdh | mcstar: I just open some clojure file in a project that contains a project.clj. |
| 06:36 | joshnz | I particular, the bottom paragraph where I attempt to explain how the process works. Clojure-jack-in will actually grab the slime.el file from swank-clojure 1.3.2 so it's a recent, working version of slime, independent of any other slime version you may have installed. I think.... lol |
| 06:36 | joshnz | I do what tsdh does. Open a file within a lein project and run clojure-jack-in |
| 06:37 | mcstar | i did just that |
| 06:37 | mcstar | than jacked in |
| 06:38 | mcstar | than swank started |
| 06:38 | mcstar | than it notified me of the version mismatch |
| 06:38 | joshnz | mcstar: I should add, I'm running clojure-mode 1.10.0 and swank-clojure 1.3.2. If you have different versions thing might not work. You also need to ensure you don't have older versions of swank-clojure around as that can cause issues |
| 06:38 | mcstar | than i can enter single expressions, but not anything other than a symbol |
| 06:38 | tsdh | I use clojure 1.3, clojure-mode 1.10.0 and lein-swank 1.4.0-SNAPSHOT. |
| 06:39 | mcstar | anyway, where does lein store its stuff? |
| 06:39 | tsdh | mcstar: Somewhere in ~/.lein/ |
| 06:39 | joshnz | ~/..lein |
| 06:39 | clojurebot | Titim gan éirí ort. |
| 06:39 | joshnz | the swank files are in the plugins dir |
| 06:40 | mcstar | ive got 1.3.2 |
| 06:40 | joshnz | me too. I have no idea about clojure 1.3 with swank 1.4 snapshot sorry. |
| 06:41 | tsdh | mcstar: I think I had troubles once when in ~/.lein/self-installs/ there were multiple leiningen jars of different versions. |
| 06:41 | mcstar | emacs-clojure-mode-git 20110914-1 |
| 06:41 | mcstar | leiningen-1.6.1.1-standalone.jar only |
| 06:42 | joshnz | mcstar: do you reference swank-clojure at all in the project.clj file? Do you have any swank jars anywhere within your project tree at all? You should remove all of these if you do, I don't believe they're needed and can cause issues |
| 06:42 | tsdh | Ah, good point. |
| 06:42 | scottj | cemerick: what's the name of the "open source generalized Bayesian network modeling library" in your abstract? |
| 06:42 | mcstar | :dependencies [[org.clojure/clojure "1.2.1"]] |
| 06:43 | cemerick | scottj: I'm in the process of extracting it from a larger project :-) |
| 06:44 | scottj | cemerick: ok do you have an expected release timeframe? |
| 06:44 | cemerick | I'm hoping to get a first rev of it on github next month |
| 06:46 | scottj | cool I'm looking forward to it |
| 07:01 | clgv | Bayesian networks seem pretty popular nowadays |
| 07:11 | opqdonut | irc networks on the other hand are declining in popularity |
| 07:14 | clgv | lol |
| 07:25 | mcstar | whoa |
| 07:25 | mcstar | it seems to work |
| 07:25 | mcstar | with the old swank though |
| 07:25 | mcstar | i cleaned up my .emacs, and commented all the slime related things that i use with sbcl |
| 07:26 | mcstar | commented out* |
| 07:27 | mcstar | but i seem to lost my slime buffer? |
| 07:29 | mcstar | hm, maybe i just accidentaly closed it |
| 07:30 | mcstar | before i start hacking my way through clojure, i want to ask this |
| 07:30 | mcstar | is any of you familiar with AI Agent Systems? |
| 07:31 | mcstar | do you think that the clojure concurrenty agent model is a god candidate to implement such a system/model: |
| 07:31 | mcstar | ? |
| 07:31 | mcstar | (pls get over my typos :)) |
| 07:34 | companion_cube | agents can be in separate processes |
| 07:34 | companion_cube | (or computers, for that matter) |
| 07:35 | mcstar | (i forgot to tell that i added 1.3.0-master-SNAPSHOT to the project dependencies) |
| 07:36 | mcstar | companion_cube: i dont care about that right now, it could be single-threaded (in the end it WILL be) |
| 07:36 | companion_cube | wait, you were talking about clojure's concurrency model |
| 07:36 | companion_cube | but it's a general-purpose concurrency model anyway, so i guess the answer is "yes" |
| 07:38 | mcstar | companion_cube: i guess i was hoping for some comparison, idk,for example erlang has a similar actor-based message passing concurrency model, so an agent system could be implemented in it "naturally" too |
| 07:39 | companion_cube | message passing can be done with queues |
| 07:39 | mcstar | companion_cube: i guess, clojure doesnt NEED multiple threads to do its agent-thing, right? it can serialize it |
| 07:39 | companion_cube | even if the actor model probably fits more naturally to AI's agents |
| 07:39 | companion_cube | oh, "agent" in clojure has a special meaning |
| 07:40 | mcstar | isnt it something that can initiate a transaction? |
| 07:40 | companion_cube | see http://clojure.org/agents |
| 07:41 | companion_cube | you give actions to the agent and it applies them to its state, sequentially |
| 07:41 | fliebel | I thought Moustache was super easy and intuitive? It just sits there staring at me, pretending it doesn't know what I mean. |
| 07:42 | manutter | It's thursday, moustache always takes extra breaks on thursday |
| 07:42 | mcstar | im halfway through rich hickey's presentation to the Western Mass or similar, thats how far my clojure understanding goes |
| 07:43 | mcstar | companion_cube: how do you pronounce rich? |
| 07:43 | mcstar | rik or rich? |
| 07:43 | companion_cube | no idea |
| 07:43 | mcstar | i guess the second one |
| 07:43 | companion_cube | i'm not an english native speaker |
| 07:43 | fliebel | manutter: I have a helper that looks like this: [title] {:get title} requesting /foo gives me java.lang.String cannot be cast to clojure.lang.IFn. |
| 07:44 | mcstar | companion_cube: i didnt think so, i thought you were a nice cube with a heart on it |
| 07:45 | mcstar | i was surprised you could write |
| 07:45 | manutter | fliebel: gist? |
| 07:45 | companion_cube | you're not supposed to read what i type 0:-) |
| 07:45 | mcstar | whats the tendency? do people usually come from the lisp world to clojure or not? |
| 07:46 | fliebel | manutter: That's all there is to it. If I make it a literal string, it works, so It's macro trickery. |
| 07:46 | fliebel | The thing is, if I pass it a handler, I don't get to acces title at all. |
| 07:48 | thorwil | mcstar: seems to be a wild mix of prior experience often including java, common lisp. sometimes python, ruby. |
| 07:50 | clgv | mcstar: I cam from java, c#, c, c++, pascal/delphi ;) |
| 07:50 | thorwil | fliebel: without more context, that looks like a complete misunderstanding of how moustache works |
| 07:50 | manutter | fliebel: I'm not really a moustache user, but from looking at the docs, I'd expect your app to look more like (def my-app (app ["foo" title] {:get title} title)) |
| 07:51 | mcstar | i guess why im asking, is because i wasnt half as interested in clojure if it didnt have lisp fundamentals |
| 07:51 | manutter | no, I'm wrong |
| 07:51 | mcstar | wasnt->wouldnt be |
| 07:52 | manutter | fliebel: how about (app ["foo" title] {:get title})? That's still slightly different from what you posted, but if I'm reading the docs right it should work |
| 07:52 | thorwil | fliebel: how about [title] {:get (-> title constantly response)}? |
| 07:52 | fliebel | Let me see |
| 07:53 | manutter | no, I'm still wrong, I think. I'll just shut up and try drinking some coffee until I wake up. |
| 07:54 | thorwil | fliebel: that was implying [ring.util.response :only [response redirect]] |
| 07:54 | fliebel | thorwil: What is the constantly for? |
| 07:55 | thorwil | fliebel: makes it callable, as a fn is expected, as far as i understand it |
| 07:56 | fliebel | thorwil: That seemed to work... but it's silly. Oh, I think I know. |
| 07:57 | manutter | cgrand's example is (def my-app (app ["hi" name] (:get ["hello " name]})) |
| 07:58 | manutter | that should imply that fliebel's original code ought to work |
| 07:58 | manutter | it's the same without the "hi", and with title instead of name |
| 07:58 | fliebel | manutter: He's using s seq everywhere for some reason. |
| 07:59 | manutter | the example before that is (def my-app (app ["hi"] {:get "hello world only for GET!"})), which seems to return only a string |
| 07:59 | manutter | Meh, I'm sticking with noir :) |
| 08:01 | fliebel | ["foo" title] {:get [title]} breaks, ["foo" title] {:get ["" title]} works |
| 08:02 | thorwil | fliebel: i'm all ears if you figured out why/when the response and constantly is necessary / how to do away with it |
| 08:03 | fliebel | thorwil: I'm about to just switch to Noir or DIY. I'm just looking for a sweet router without magic. |
| 08:03 | gtrak` | mcstar, i think a bunch of people came from java |
| 08:04 | thorwil | fliebel: moustache is very small, not much room for magic. but the allowed variations can be confusing |
| 08:04 | gtrak` | mcstar, like me, I always wanted to learn a lisp... and concurrency, so clojure was a good next step |
| 08:04 | thorwil | fliebel: with noir, routing becomes a bit less explicit, even |
| 08:05 | manutter | fleibel: Ok, I studied the syntax diagram a bit more, I understand why {:get title} doesn't work |
| 08:05 | fliebel | manutter: Yay! Whats it? |
| 08:05 | manutter | fliebel: after the {:get part, it's expecting a handler body, a method dispatch, a string, a symbol, or (some clojure code) |
| 08:06 | manutter | title by itself is a symbol, but there's a not that says, if it's a symbol, it must evaluate to a handler body |
| 08:06 | manutter | which it doesn't, because it's been mapped to just a param |
| 08:07 | manutter | if you say ["" title] then that invokes moustache's built-in handler that contatenates vectors as strings |
| 08:07 | manutter | eh, *but there's a NOTE that says... |
| 08:08 | fliebel | So, what about ["foo" title] {:get (response title)}, That is some clojure code. |
| 08:08 | fliebel | Just gives 404! No error, same request as before. |
| 08:09 | bhenry | fliebel: what does response do? |
| 08:09 | manutter | does (response x) return a handler function, or just response data? |
| 08:09 | manutter | I'm guessing that it returns a map, not an actual handler |
| 08:09 | fliebel | a response map, like {:status 200 :body "hwhatever"} |
| 08:09 | manutter | Ah, forgot to mention, another note says (some clojure code) has to return a handler |
| 08:10 | bhenry | fliebel: have you looked at delegate? |
| 08:10 | fliebel | ah, so its literal string or map, a handler or something that evaluates to a handler. |
| 08:10 | manutter | Looks that way to me |
| 08:10 | fliebel | bhenry: delegate? |
| 08:11 | mcstar | gtrak`: lisp is quite a lot in itself, i would imagine clojure is not that easy without prior lisp experience, but sure its ok if you give it enough time, or you are very determined |
| 08:12 | gtrak` | I had a scheme class 8 years ago :-), too bad they dropped it for python |
| 08:13 | mcstar | gtrak`: you know computers were getting faster, so they needed python to slow the execution, so that everyone can follow in the class :D |
| 08:15 | gtrak` | haha, I think GT just does whatever MIT wants to do, still annoyed about it. What's an intro to computing without SICP or HTDP? |
| 08:16 | bhenry | fliebel: ["clients" "edit" id] (delegate views/edit-client id) |
| 08:16 | mcstar | i wouldnt know i dont have a CS background(but i watched quite a bit of sicp) |
| 08:16 | bhenry | gives id to the edit-client handler |
| 08:16 | bhenry | fliebel: you had said if you pass a handler you don't have access to the title anymore |
| 08:17 | clgv | mcstar: didnt have huge problem despite I didnt know any lisp before |
| 08:18 | mcstar | good, than i might stand a chance to understand clojure |
| 08:18 | manutter | Heh, I'm coming from PHP |
| 08:18 | manutter | This is my first *successful* attempt at learning a LISP or LISP-like language |
| 08:19 | mcstar | i dont understand youre use of a special variable in a lexical context |
| 08:19 | mcstar | :D |
| 08:21 | gtrak` | manutter, are you still a fan of php? |
| 08:22 | manutter | was I ever? |
| 08:22 | gtrak` | haha, good answer |
| 08:22 | manutter | php's ok, pays the bills and stuff |
| 08:22 | manutter | I'd love to port our app to clojure tho |
| 08:47 | kzar | Is using java.io.File the best way to list files? Also what's the base path assumed for relative paths? Is it the root of my project? |
| 08:48 | bhenry | kzar, i think it's where you launch from |
| 08:50 | kzar | Oh, just managed to get it listing files and I think it's the root of the project - at least when I eval it interatively |
| 08:55 | clgv | kzar: with leiningen and lein repl it's where your project.clj is |
| 08:55 | khaliG | i'm looking for web hosting, is there any particular feature to keep an eye out for if I intend to run some sort of java/clojure webapps in future? |
| 08:56 | clgv | khaliG: vserver? |
| 08:57 | khaliG | clgv, okay |
| 08:57 | clgv | or are there specialized tomcat hosting offers? |
| 08:58 | khaliG | clgv, i should say i'm completely new to all of this :P |
| 08:59 | clgv | yeah well, you'll need some "java server" like tomcat or jetty where your clojure app is hosted. |
| 08:59 | khaliG | clgv, noted |
| 09:24 | ladicha | I'm having trouble using a third party closure library in my cljs project. I jar'd up the lib and put it in $CLOJURESCRIPT_HOME/lib, but I still get a compile error: required namespace never provided |
| 09:24 | ladicha | any tips on where I'm going wrong? |
| 09:26 | clgv | ladicha: checking if the namespace exists? |
| 09:27 | tsdh | If I want to release a jar at clojars, is it mandatory to use a groupId of org.clojars.tsdh? |
| 09:27 | joegallo | nope, pretty sure you can use whatever group id you want |
| 09:28 | tsdh | Ok, then I guess de.uni_koblenz is more appropriate for *our*, not mine lib. |
| 09:29 | ladicha | clgv: the js files in the jar do provide the namespace |
| 09:29 | tsdh | And what's the difference between artifactId and name? |
| 09:30 | clgv | tsdh: you are claiming that group-id with it, so maybe you could add your department as well in case someone else in your uni might develop clojure as well in the future ;) |
| 09:31 | ladicha | I get this specifically: ERROR - required "scottlogic.chart.Chart" namespace never provided |
| 09:31 | tsdh | clgv: Ok. |
| 09:31 | joegallo | for that matter, you should probably put the current department head's name in there, too. in case a new one comes in later and the policy changes. |
| 09:31 | ladicha | in my project I have a [scottlogic.chart.Chart :as SLChart] |
| 09:31 | joegallo | couldn't hurt to add the year, too. |
| 09:32 | joegallo | in stardate form. |
| 09:32 | ladicha | in my namespace require |
| 09:33 | ladicha | the scottlogic/chart/chart.js file in the jar contains: goog.provide('scottlogic.chart.Chart'); |
| 09:34 | clgv | joegallo: lol then he could simply add his own name^^ |
| 09:35 | tsdh | clgv: What do I specify for a non-released version? 5.0.0-SNAPSHOT? |
| 09:35 | tsdh | joegallo: Ups, I've meant clgv. :-) |
| 09:36 | ladicha | clgv: are there any special directives I need to compile against a third-party lib? Am I putting the jar in the right place? |
| 09:43 | clgv | ladicha: I don't know. I just did a smal example with it yet |
| 09:50 | fliebel | Does Ring pass the query string as a plain string?? |
| 09:50 | lazybot | fliebel: Definitely not. |
| 09:50 | fliebel | Oh, okay lazybot. |
| 09:51 | ladicha | clgv: I just cloned the bitbucket, jar'd up the closure-charts/closure-charts/src/main/webapp/js/scottlogic directory as scottlogic |
| 09:51 | ladicha | scottlogic.jar |
| 09:52 | ladicha | and put the jar in $CLOJURESCRIPT_HOME/lib |
| 09:53 | bhenry | fliebel: it puts the items in :params in the request map. {:params {"key" "val" "key2" "val2"}} |
| 09:53 | bhenry | actually, that's wrap-params middleware that does that. |
| 09:53 | fliebel | bhenry: AH, I just found a middleware that claims to do that, but it already does that by default? |
| 09:53 | fliebel | ah |
| 09:54 | bhenry | fliebel: yeah sorry. i use that middle ware. |
| 09:54 | fliebel | ok, I'll add it as well |
| 09:55 | Fossi | fliebel: see, funky things like that ;) |
| 09:56 | Fossi | middlewares are a good topic on it's own |
| 09:56 | fliebel | hmhm |
| 09:57 | khaliG | is there a particular license preferred by the community? |
| 09:59 | clgv | the license clojure has itself? |
| 10:00 | m0wfo | https://github.com/clojure/clojure/blob/master/epl-v10.html |
| 10:01 | khaliG | clgv, Eclipse one? i'm considering that one vs MIT |
| 10:04 | fliebel | How do I destructure nested maps? Like... {:params {body "body"}} |
| 10:05 | fliebel | AH, the other way around of course... |
| 10:05 | fliebel | I always get map destructuring the wrong way around. |
| 10:09 | clgv | fliebel: how does the resulting destructuring look like for your example? |
| 10:09 | fliebel | {{body "body" rev "rev"} :params} |
| 10:10 | raek | {{:strs [body rev]} :params} works too |
| 10:10 | bhenry | raek: whoa. is :strs like using :keys? |
| 10:11 | bhenry | but for string keys? |
| 10:12 | raek | exactly so. |
| 10:12 | bhenry | neato |
| 10:12 | TimMc | nice |
| 10:12 | raek | there is syms too for symbol keys |
| 10:12 | TimMc | But no nums, I hope. |
| 10:13 | TimMc | ...considering how badly they behave as keys. |
| 10:14 | TimMc | Ha! I'm an idiot, that wouldn't make sense anyway. |
| 10:14 | raek | :nums doesn't make much sense since there is no symbol "with the same name" as a number |
| 10:14 | TimMc | (let [1 2] ...) |
| 10:31 | manutter | ,(let [+ -] (+ 2 2)) |
| 10:31 | clojurebot | 0 |
| 10:31 | manutter | muahaha |
| 10:32 | companion_cube | ,(let [let +] (let 2 2)) |
| 10:32 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding> |
| 10:32 | companion_cube | oops |
| 10:32 | opqdonut | let is a built-in |
| 10:33 | mcstar | ,(let [s] (dance)) |
| 10:33 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires an even number of forms in binding vector> |
| 10:34 | llasram | Oh, geez. Just now realized that slime lets you drill down to the source of the actual error when you throw an exception during lazy list evaluation |
| 10:52 | kzar | I'm trying to use the noir.options module to check which mode the server's running in. Problem is when I use noir.options/get or noir.options/dev-mode? I always get "Var noir.options/*options* is unbound.". The server's running and I've required noir.options as options, not sure what else to try. |
| 10:53 | bhenry | kzar: i forgot how i got around that. let me check in a minute. |
| 10:55 | manutter | kzar: *options* is set by a wrap-options middleware, maybe you need to put that in? |
| 10:56 | manutter | hmm, looks like it's setting that by default tho |
| 10:59 | manutter | kzar: try (server/start 8080 {}) |
| 11:01 | kzar | manutter: That address was already in use so I did (noir.server/start 8081 {}), then (noir.options/dev-mode?) and got te same error |
| 11:01 | duncanm | haha, "Haskell is lazier than Ruby, but Rubyists are lazier than Haskeller." |
| 11:01 | manutter | hrm |
| 11:03 | manutter | kzar: you got the "Server started on port [8081]" message? |
| 11:04 | manutter | my next try would be (server/stop) (server/start 8081 {:mode :dev}) |
| 11:07 | bhenry | kzar are you trying to evaluate (dev-mode?) in the repl? |
| 11:07 | manutter | ah, good question |
| 11:07 | manutter | server's going to be off running in a different thread with different bindings, yeah? |
| 11:08 | bhenry | yep |
| 11:08 | kzar | manutter: I was trying to eval it interactively in the source file and I tried typing it at the repl |
| 11:09 | manutter | yeah, I think bhenry has hit it then, you're having thread problems |
| 11:11 | manutter | I believe I've worked around that sort of issue by (1) def an atom in the main thread (2) have the other thread push a debugging message into the atom and (3) deref the atom from the main thread. |
| 11:11 | manutter | clumsy but quick-n-dirty |
| 11:13 | kzar | Hmm so I'm starting the server normally by doing (my-project-name/-main) and I need to access the options from repl + my other code. |
| 11:13 | kzar | Would that mean messing with server.clj or actually changing noir do you think? |
| 11:15 | manutter | Me being an irresponsible SOB I might try having my server-side code push the *options* var into some atom I def'ed from the REPL |
| 11:15 | mdeboard | you son of a bitch |
| 11:15 | mdeboard | how *dare* you |
| 11:15 | manutter | dunno if that would let you view/modify the *options* directly, but I'd try it |
| 11:15 | manutter | :) |
| 11:15 | manutter | Yeah, I've picked up a lot of bad habits writing PHP |
| 11:16 | mdeboard | :O |
| 11:17 | kzar | Is noir quite new? |
| 11:17 | srid | I think, yes. |
| 11:17 | manutter | yeah, relatively |
| 11:18 | srid | what other web 'frameworks' are there? |
| 11:18 | mdeboard | Compojure |
| 11:18 | mdeboard | is one |
| 11:18 | manutter | <plug>http://www.clojure-toolbox.com/</plug> |
| 11:19 | mdeboard | er |
| 11:19 | mdeboard | wow, django attack |
| 11:19 | mdeboard | html tag |
| 11:24 | KirinDave | mdeboard: Wanna change that to clojure at both? :) |
| 11:24 | KirinDave | mdeboard: Just start suggesting features that python is way to slow to provide. :D |
| 11:25 | mdeboard | KirinDave: We already have a few processes that could benefit from transitioning to a JVM FPL |
| 11:26 | mdeboard | massive XML processing for example |
| 11:26 | KirinDave | mdeboard: I'm working at a giant monolithic merb shop. |
| 11:26 | mdeboard | daily |
| 11:26 | mdeboard | merb? |
| 11:26 | mdeboard | something-ruby? |
| 11:26 | KirinDave | mdeboard: All I had to do was show that ONE box running a jvm version of the software is the equivalent of THREE boxes running ruby versions of the process. :D |
| 11:26 | KirinDave | Yeah |
| 11:26 | mdeboard | what's the `me` part? |
| 11:28 | mdeboard | Yeah I have entertained the thought of setting up a test bed to handle our XML processing with Clojure, esp. since I just took a huge employment offer with these guys. But I'm bogged down in some customer-facing feature implementations atm |
| 11:28 | mdeboard | fliebel: Yeah, agreed, was thinking the same |
| 11:30 | mattmitchell | Is it possible to inspect a namespace so I can see what vars/functions it contains? |
| 11:30 | KirinDave | I kinda miss working in clojure. |
| 11:30 | KirinDave | For some reason scala is an easier sell to my shop. :( |
| 11:30 | KirinDave | Haven't done much in clj recently. |
| 11:32 | mdeboard | KirinDave: "Scala has fewer parens" |
| 11:32 | clojurebot | the scala compiler | is | <reply> see: http://harrah.github.com/browse/samples/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala.html#65760 |
| 11:32 | mdeboard | also Scala's older and certainly more widely used |
| 11:32 | mdeboard | prob why |
| 11:33 | KirinDave | mdeboard: Probably |
| 11:33 | mdeboard | ya |
| 11:33 | mdeboard | I need to conspire more on getting clojure into play :P |
| 11:33 | mdeboard | you're right on that |
| 11:33 | KirinDave | mdeboard: Although I do confess that my time with haskell has made me like static typing more. As I work with scala more I think I feel like I fight its type system way too much. |
| 11:33 | KirinDave | Makes me pine for clojure. |
| 11:34 | mdeboard | haskell hurt my brain, I gave up |
| 11:34 | bhenry | mattmitchell: ##(doc ns-publics) |
| 11:34 | lazybot | java.lang.SecurityException: You tripped the alarm! ns-publics is bad! |
| 11:34 | mdeboard | that was a while ago though, first FPL I'd ever touched |
| 11:34 | mattmitchell | bhenry: cool thank you |
| 11:38 | gtrak | KirinDave, you like static typing, but scala's is so bad that you prefer dynamic typing? |
| 11:40 | kzar | So I'm still a bit bamboozled as to how I can look at the noir server's options. Been poking around noir's code but I don't even really understand the explanation to do with threads that you guys described to be honest |
| 11:40 | kzar | It seems to me that there must be a reasnoble way to check the options, otherwise what's the point of setting them? |
| 11:41 | KirinDave | gtrak: Scala isn't bad. Scala's schizo three-way culture clash is bad. |
| 11:41 | KirinDave | gtrak: You have the scalaz guys, the typesafe/akka guys, and the java purists. |
| 11:41 | KirinDave | You literally cannot write code that 2/3 of the scala community will not roll their eyes at. It's a very demoralizing code culture. |
| 11:45 | kzar | And the "Var noir.options/*options* is unbound." message confuses me, I don't see the distinction between that error and an "Unable to resolve symbol" one |
| 11:46 | clgv | kzar: the var is defined but has no value |
| 11:47 | bhenry | kzar: https://github.com/ibdknox/noir/blob/master/src/noir/options.clj#L5 |
| 11:48 | kzar | bhenry: aha, gotya |
| 11:48 | kzar | (declare frebob) fredbob -> "Var fredbob is unbound." |
| 11:58 | manutter | kzar: what options do you need to look at? The options are just whatever you pass as the 3rd arg to server/start (as I understand it), so you control what they are. |
| 11:59 | manutter | sorry, 2nd arg, not 3rd |
| 11:59 | manutter | (server/start <port> <map-of-options>) |
| 12:13 | kzar | manutter: I need to see the mode variable so I know if it's production or not. I'm launching the app with foreman because I'm putting it up on heroku for now, not sure how it works |
| 12:14 | kzar | manutter: oh could I def a ref at the top of the server.clj and then have the -main function update that to contain the options so I can check them later? |
| 12:15 | manutter | kzar: I'd def an atom (ref would be overkill) but yeah, I think that would work |
| 12:15 | kzar | manutter: Gotya, OK I'll do it that way |
| 12:15 | kzar | Brill thanks, was stuck there |
| 12:16 | manutter | :) |
| 12:47 | belun | hi |
| 12:47 | belun | could anyone help with this error |
| 12:47 | belun | user=> (use 'midje.sweet) |
| 12:47 | belun | CompilerException java.lang.RuntimeException: Unable to resolve symbol: print-doc in this context, compiling:(clojure/contrib/ns_utils.clj:67) |
| 12:47 | manutter | belun: missing use/require? |
| 12:48 | belun | this is the actual settings |
| 12:48 | belun | (defproject play-with-midje "1.0" |
| 12:48 | belun | :description "Playground for messing around with Midje" |
| 12:48 | belun | :dependencies [[org.clojure/clojure "1.3.0-beta3"] |
| 12:48 | belun | [org.clojure/clojure-contrib "1.1.0"]] |
| 12:48 | belun | :dev-dependencies [[midje "1.3-alpha1"] |
| 12:48 | belun | [lein-midje "1.0.0"]]) |
| 12:48 | manutter | ,(doc print-doc) |
| 12:48 | clojurebot | excusez-moi |
| 12:48 | manutter | eh |
| 12:48 | belun | what do you mean? like i dont have the jars u mean ? |
| 12:48 | technomancy | belun: get rid of that ancient contrib version |
| 12:49 | manutter | no, you might be missing a (:require [something :as something]) in your (ns) declaration |
| 12:49 | technomancy | belun: also: use gisthub.com next time |
| 12:49 | belun | what is latest contrib |
| 12:49 | belun | use it for what u mean ? |
| 12:49 | belun | contrib ? |
| 12:50 | technomancy | use gist instead of pasting into the channel |
| 12:51 | bhenry | how can i turn an epoch time to a date with minimal imports? |
| 12:51 | bhenry | err scratch that. date to epoch |
| 12:51 | technomancy | clojurebot: where did contrib go is <reply>well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 12:51 | clojurebot | 'Sea, mhuise. |
| 12:51 | technomancy | belun: ^ |
| 12:52 | technomancy | belun: depends on which specific parts you need |
| 12:52 | belun | like i know... |
| 12:52 | belun | let me just drop it :P |
| 12:54 | naeu | is there a way of determining whether a number is a long |
| 12:55 | naeu | long? doesn't seem to be available |
| 12:55 | belun | so i got same error without contrib |
| 12:56 | belun | git://gist.github.com/1219793.git |
| 12:56 | belun | might it be the beta version of midje ? |
| 12:56 | manutter | bhenry: clj-time ? https://github.com/getwoven/clj-time |
| 12:57 | belun | um...maybe i need the utils part of contrib |
| 12:57 | kjeldahl` | Anybody have any recent example of using clojure.java.jdbc; let's start simple - getting a connection. The usual "(def db {.... params}) ... (with-connection db (create-table :somename))" does not seem to actually connect to the database. Anybody? |
| 12:57 | kjeldahl` | .. with postgresql I should add. |
| 12:57 | technomancy | belun: do you need clojure 1.3? if you drop back to clojure 1.2.1 you can add back in contrib version 1.2.0 |
| 12:57 | technomancy | that's going to be the path of least resistance |
| 12:57 | bhenry | manutter: thanks. turns out i'm just a dummy (.getTime date) |
| 12:58 | belun | that path i like |
| 12:59 | technomancy | belun: but try to avoid adding any additional usages of contrib so that it will be easier to upgrade in the future. |
| 13:00 | belun | wohoo |
| 13:01 | belun | worked to run a midje fact |
| 13:01 | belun | luv u |
| 13:01 | seancorfield | kjeldahl`: that should work fine - postgresql is one of the base test cases for that library |
| 13:01 | seancorfield | do you get any exceptions? |
| 13:02 | kjeldahl` | seancorfield: I get "no current database connection" when doing it. |
| 13:02 | kjeldahl` | seancorfield: None that I can see, but I'm not "try"'ing either, if I have to do that... |
| 13:04 | seancorfield | are you following a particular article / blog post? |
| 13:04 | hiredman | kjeldahl`: make sure you force your lazy-seq before leaving the scope of the connection |
| 13:04 | kjeldahl` | I've looked at several. They all simply use the hash/map and "with-connection"... |
| 13:04 | kjeldahl` | hireman: Ah, good idea. |
| 13:04 | seancorfield | ah, good point... that often gives a no connection exception! |
| 13:05 | seancorfield | having said that, for create-table it should "just work" |
| 13:08 | choffstein | Hey all. Is there a way to initialize a vector to be a certain size filled with a given initial value? |
| 13:09 | choffstein | For example, I have a non-deterministic input that I bind to the variable n. I then need to create a vector of length n with all 1s. |
| 13:10 | manutter | ,(repeat 3 1) |
| 13:10 | clojurebot | (1 1 1) |
| 13:11 | choffstein | sweeeet. thanks |
| 13:11 | seancorfield | kjeldahl`: any success? |
| 13:28 | dnolen | erg, anybody encounter the problem where cljcs/build doesn't pull in the goog deps into the out dir ? |
| 13:28 | gtrak | ,(vec (repeat 3 1)) |
| 13:28 | clojurebot | [1 1 1] |
| 13:29 | gtrak | ,(vec ( take 3 (cycle 1))) |
| 13:29 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 13:29 | gtrak | ,(vec ( take (cycle 1) 3)) |
| 13:29 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Number> |
| 13:30 | manutter | ,(vec (take 3 (cycle constantly 1))) |
| 13:30 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$cycle> |
| 13:30 | manutter | :P |
| 13:30 | amalloy | omg guys, ##(take 3 (cycle [1])) |
| 13:30 | bhenry | ,(vec (take 3 (cycle [1]))) |
| 13:30 | lazybot | ⇒ (1 1 1) |
| 13:30 | clojurebot | [1 1 1] |
| 13:30 | gtrak | lol, how many ways are there to eff that up? |
| 13:30 | amalloy | or ##(take 3 (repeat 1)) |
| 13:30 | manutter | ,(vec (take 3 (cycle (repeatedly 1)))) |
| 13:30 | lazybot | ⇒ (1 1 1) |
| 13:30 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 13:30 | manutter | hrug |
| 13:31 | amalloy | manutter: ##(vec (take 3 (repeatedly (constantly 1)))) is a bit silly but looks like what you meant |
| 13:31 | lazybot | ⇒ [1 1 1] |
| 13:31 | manutter | doh |
| 13:31 | manutter | ,(vec (take 3 (cycle (constantly 1))) |
| 13:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 13:31 | manutter | ,(vec (take 3 (cycle (constantly 1)))) |
| 13:31 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__3684> |
| 13:31 | gtrak | like monkeys banging on pots |
| 13:32 | manutter | honestly, kids these days |
| 13:43 | kjeldahl` | Sorry, got pulled away. Yes, I now get an exception, which I think I can handle. Thank you for the pointers! |
| 13:47 | zerokarmaleft | new to swank here; is there a better way to reload changes to a source file to a slime repl than 1) C-x C-s 2) C-c C-l 3) C-c C-z? |
| 13:47 | amalloy | zerokarmaleft: C-c C-k does (1+2) |
| 13:49 | Vinzent | zerokarmaleft, I have save-and-compile bound to C-s |
| 13:50 | technomancy | C-c C-l forces a reload of all deps; C-c C-k just does the current file |
| 13:50 | amalloy | technomancy: no shit, really? i need to start using C-c C-l sometimes, then |
| 13:50 | zerokarmaleft | that's good to know |
| 13:50 | amalloy | that suddenly explains weird behavior |
| 13:51 | technomancy | amalloy: C-c C-, also invokes the reload behaviour |
| 13:54 | zerokarmaleft | guess i should dive into elisp and make a command for what i want |
| 13:55 | zerokarmaleft | basically save, don't prompt me, reload all deps, switch back to repl, gtfo my way i'm testing my small change |
| 14:08 | choffstein | Optimization question for everyone: I have a huge bottle neck in parsing a couple thousand strings to date objects using a SimpleDateFormat. There is no reason that all the parsing can't be done in parallel, but I it would seem that SimpleDateFormat is not thread safe -- and creating a new object for each parse seems like an allocation nightmare. Any ideas? |
| 14:09 | amalloy | split into chunks, create a parser for each chunk, and then pmap? |
| 14:09 | choffstein | that was my next thought |
| 14:10 | hiredman | depending on the format you could just write your own parser |
| 14:13 | choffstein | seems like overkill hiredman |
| 14:14 | Chousuke | (map send some-agents (make-enough-parser-functions) (partition data (/ data-size number-of-agents))) wonder if that would work :P |
| 14:14 | Chousuke | with a do-all of course |
| 14:28 | khaliG | choffstein, would it help to use clj-time (jodatime)? |
| 14:28 | srid | i'm not *very* familiar with github contrib workflow, so here's a question: must each pull request happen on a separate branch? i sent one the 4clojure repo under 'playground' branch. now if I want to work on another bug/feature, I must create a new branch? |
| 14:28 | choffstein | I don't know about clj-time. I'll check it out. Thanks for the suggestion. |
| 14:29 | amalloy | srid: no, but you should make sure your new commits are based on the upstream develop |
| 14:30 | joegallo | srid: yes, you really should |
| 14:30 | srid | amalloy: I noticed that when I make commits to the 'playground' branch, they automatically gets added to the pull request. |
| 14:30 | joegallo | correct |
| 14:30 | joegallo | pull requests are about branches, not commits |
| 14:30 | srid | this is why I refrain from making irrelevant commits (addressing a different bug) to this branch |
| 14:30 | khaliG | choffstein, its a nice library, i rely on it a lot. it wraps jodatime, which is a well designed java library that's written in a functional style (as well as these things can be) |
| 14:30 | amalloy | joegallo: i see what you mean. his pull request has been merged already, so he could reuse the same branch if he wanted |
| 14:30 | choffstein | looks very clean. |
| 14:30 | joegallo | ah, yes, true enough |
| 14:31 | joegallo | in that case, though, i would fetch the remote and base my work on the newly updated master |
| 14:31 | amalloy | but, srid, you should do something like $ git merge --ff-only dbyrne/4develop |
| 14:31 | joegallo | to have the remote merge commit and everything |
| 14:31 | amalloy | right |
| 14:32 | amalloy | s/4// |
| 14:49 | srid | amalloy: i should do that on my 'develop' branch, and then merge that to 'playground' right? |
| 14:49 | srid | or directly do it on playground? |
| 14:50 | amalloy | doesn't matter, i think |
| 14:50 | amalloy | i think it's easier to understand if you keep your develop up to date with ours, but that's more of your problem than mine :P |
| 14:51 | srid | i guess, i'll just keep my 'develop' clean (and merge from upstream often) and always work on branches made from it. |
| 14:52 | amalloy | that's a common pattern |
| 14:52 | icey | is there a version of contains? that tests for multiple keys? |
| 14:53 | icey | or should i just wrap multiple contains? with an and? |
| 14:53 | amalloy | (fn [m ks] (every? #(contains? m) ks)) |
| 14:53 | amalloy | (fn [m ks] (every? #(contains? m %) ks)) |
| 14:53 | sdbo | Can you define a default implementation of a protocol method, similar to a default implementation of a typeclass function in Haskell? |
| 14:54 | amalloy | (extend-protocol Foo Object (method [args] impl)) |
| 14:54 | icey | amalloy: thanks.. that was fast - does that question get asked a lot? |
| 14:54 | amalloy | not as far as i'm aware, Icey |
| 14:55 | sdbo | amalloy: I tried that, but it's not working. It says there's no implementation. Let me make a simplest replication of the situation. |
| 14:56 | icey | amalloy: it does exactly what i need, thanks again :) |
| 15:01 | sdbo | This is the situation that I'd like to use, but throws errors |
| 15:01 | sdbo | amalloy: https://gist.github.com/1220157 |
| 15:01 | amalloy | you can't partially extend a protocol - all or nothing |
| 15:02 | amalloy | if you want to be able to plug in different impls for different functions within a protocol, you need different protocols instead |
| 15:03 | amalloy | ie, Place implements AProtocol/say-hello by throwing an exception, rather than not implementing it at all |
| 15:03 | ordnungswidrig | …or when you implement only single function you can stick to multimethods |
| 15:04 | sdbo | Okay, that's how I thought it might work. I'm just used to Haskell typeclasses. I suppose it can be implemented by using multimethods, but that would involve a lot more complexity than I need. Thanks! |
| 15:06 | sdbo | Actually, what would be the Clojure idiom for a situation like this: |
| 15:06 | sdbo | I want to implement a protocol of probability distributions. The primary method is (prob [this obj]) |
| 15:07 | sdbo | Knowing only that, I can implement conditional distributions by constricting the object space and renormalizing. |
| 15:07 | dnolen | man being able to print DOM localStorage as a Clojure map is pretty awesome. having access to the reader so stored Clojure data types print properly even more awesome |
| 15:08 | sdbo | But if the distribution is implemented underneath as a particular functional form, it might be much faster to return the answer directly. |
| 15:08 | sdbo | So there is a way to implement conditional-prob knowing only that an object implements DistributionProtocol |
| 15:08 | amalloy | sdbo: i'm solving the same problem (not for probability distributions, though) myself at the moment |
| 15:09 | amalloy | i'm writing protocols for "things i could do for you but maybe you can do faster" and extending those protocols to Object with default impls |
| 15:09 | sdbo | With type classes you can just define a default method (depending only on other protocol methods) which is overridden at extension time. |
| 15:09 | amalloy | it's more complicated than i'd like, but seems cleanest |
| 15:09 | sdbo | And there's a minimal complete definition of a protocol |
| 15:10 | sdbo | Yeah— that's what I thought the solution might be, but it seems a little heavy-handed |
| 15:10 | amalloy | agreed. call me back if you find something better :P |
| 15:11 | sdbo | Probably not without resorting to serious multimethod dispatching, haha |
| 15:11 | sdbo | but will do ;D |
| 15:12 | dnolen | sdbo: you can add default implementations by extending your protocol to Object. |
| 15:12 | amalloy | dnolen: right, but that extends the whole protocol. see his gist at https://gist.github.com/1220157 |
| 15:12 | sdbo | dnolen: see https://gist.github.com/1220157 for where that fails. |
| 15:14 | sdbo | The idea is that a protocol could have a "minimal complete definition" (or multiple ones) and that anything outside of that definition is optional and can have defaults defined only on that minimal complete set. |
| 15:18 | sdbo | amalloy: so far the best thing I can think of is to create a defprotocol* and extend-protocol* which wrap the original macros, store default methods if they exist, and patches them in if they don't get defined. That doesn't seem so bad on the user end… |
| 15:19 | amalloy | sdbo: don't forget to write deftype*, defrecord*, and reify* :P |
| 15:19 | sdbo | Yeah, exactly… which is why I'm not even going to consider doing that until I need this functionality in at least 3 different places |
| 15:20 | sdbo | Right now it's just 2 ;P |
| 15:21 | dnolen | sdbo: I see, yeah protocols just weren't intended for this, and I don't think they ever will be. |
| 15:21 | dnolen | converting it multimethods is pretty simple tho, certainly not any more code. |
| 15:24 | sdbo | dnolen: I just assumed protocols mapped nicely to typeclasses, but it's not quite 1-1. Multimethods would work, but to be a general solution I'd really want to write a whole macrology to restrict the generality. I really like the idea of protocols/typeclasses and don't want to abandon it to the full generality of multi methods. |
| 15:24 | dnolen | sdbo: I'm not following, what generality of multimethod is problematic here? |
| 15:29 | sdbo | dnolen: Full control over the dispatch means there's more ways to do it. I don't need full generality, so I hazard to invoke it. It's not something specific, really. |
| 15:29 | dnolen | sdbo: just limit your dispatch to type, no one can change that later. |
| 15:30 | dnolen | sdbo: https://gist.github.com/1220237 |
| 15:31 | sdbo | dnolen: I understand *how* to do it. I just don't think the complexity tradeoff is worth it yet. |
| 15:31 | dnolen | sdbo: ok, I just don't see where the "complexity" is here. |
| 15:32 | sdbo | dnolen: The gist is just a toy example, the real code is much different |
| 15:32 | dnolen | and by trying to make it work with protocols will just create complexity. |
| 15:32 | dnolen | since they don't map to the behavior you want |
| 15:32 | sdbo | dnolen: that's exactly it. I'm not going to anymore. |
| 15:33 | dnolen | gotcha |
| 15:34 | sdbo | dnolen: I implemented this before in Haskell. Typeclasses are ubiquitous and so it's natural to think and communicate using them, and they're powerful enough to easily unify counted frequency distributions and parametric probability distributions. |
| 15:34 | sdbo | But outside of math, those are actually two very different objects. I'm happy enough just treating them differently |
| 15:38 | robermann | hi was trying the amazing debug stuff from the JoY book on emacs + swank |
| 15:39 | robermann | but when I insert the (break) breakpoint call, |
| 15:39 | robermann | the REPL swank does not eval the variables |
| 15:40 | robermann | when running the same code in a plain REPL (lein repl) it works |
| 15:41 | robermann | Is there something peculiar on emacs/swank/slime when parsing a sub-repl? (I'm referring to pag 309ss of JoY book) |
| 15:49 | amalloy | srid: out of curiosity, what's the next thing you're working on? |
| 15:53 | cwb | How do I "re-export" vars imported into a namespace? That is, I want to put a/myvar into b so that I can then do b/myvar from c. I thought refer (use) would achieve this but no luck.. |
| 15:53 | hiredman | don't do that |
| 15:53 | cwb | All right, what should I do instead? |
| 15:54 | joegallo | defalias or https://github.com/ztellman/potemkin |
| 15:54 | joegallo | but yeah, reconsider whether that's as great an idea as it appears at first |
| 15:56 | joegallo | i guess the argument would be that you should just define things where they are supposed to end up |
| 15:56 | joegallo | and that big namespaces aren't that bad |
| 15:56 | joegallo | or something along those lines |
| 15:56 | naeu | out of interest, is anyone aware of any macro changes between 1.2 and 1.3? |
| 15:56 | hiredman | cwb: write tiers namespace a provides functionality that b relies on, and namespace b provides functionality c relies on |
| 15:59 | cwb | joegallo, hiredman: I'm defining a protocol and multimethods in b, extending them in d,e, etc. All of b,d,e, etc. are required by a, so that I can import a from c and ensure the multimethod has been loaded with all methods. Is there a neater way of doing that (keeping related logic in the same module). |
| 15:59 | hiredman | if c requires b and a it should require both |
| 16:00 | hiredman | (ns a (:require b d e)) |
| 16:15 | srid | clojure regex supports named groups? just wondering how to concisely get these matches into an array map. |
| 16:15 | srid | https://gist.github.com/1220343 |
| 16:22 | nickmbailey | any clojure contrib committers around |
| 16:30 | cwb | hiredman: The problem is that I'd like c to only know about a, not b,d,e. |
| 16:43 | cemerick | nickmbailey: what's up? |
| 16:45 | nickmbailey | so i created a couple jira tickets for the jmx contrib library in the main clojure-contrib jira project, seems like maybe each contrib project is getting its own jira project though? |
| 16:45 | nickmbailey | cemerick: ^ |
| 16:45 | nickmbailey | should i ping someone for making a java.jmx jira project or something? |
| 16:46 | cemerick | nickmbailey: Yes, send a mail to the clojure list (or the clojure-dev list if you can). |
| 16:46 | nickmbailey | k, will do |
| 16:46 | cemerick | nickmbailey: I'd just delete those tickets you added to the legacy clojure-contrib JIRA tho. |
| 16:47 | cemerick | I'd create the jmx project in JIRA for you, but I don't own it :-) |
| 16:48 | nickmbailey | well if i get someone to create it i can just move the tickets which would be nicer than recreating them |
| 16:48 | cemerick | true |
| 16:49 | jli | Clojure doesn't use this for hotswapping code, does it? http://download.oracle.com/javase/1.4.2/docs/guide/jpda/enhancements.html |
| 16:49 | cemerick | no |
| 16:50 | cemerick | Clojure just generates and loads bytecode corresponding to new implementing classes. |
| 16:58 | amalloy | srid: zipmap would be my choice, though you might also see if https://github.com/cgrand/regex/ has the features you want |
| 16:58 | amalloy | (from the wiki, it looks like it does) |
| 17:01 | amalloy | naeu: i don't think so |
| 17:02 | naeu | amalloy: it might not be macros per se, but with 1.3 one of my macros is doing bad things which it doesn't do with 1.2 |
| 17:02 | naeu | i'm finding it very hard to track down what's going wrong |
| 17:02 | dnolen | naeu: what error are you getting? |
| 17:03 | naeu | something lame: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector |
| 17:04 | naeu | I'm not entirely sure how to reduce the problem to something communicable |
| 17:04 | naeu | it could very well just be me doing something abusively bad with macros which somehow managed to work with 1.2 but 1.3 is complaining about |
| 17:04 | raek | probably a word too much or too less next to a parameter list |
| 17:05 | raek | ,(let foo [x 1] x) |
| 17:05 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding> |
| 17:05 | naeu | raek: how would you guess that? |
| 17:05 | raek | ,(fn foo foo [x 1] x) |
| 17:05 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol> |
| 17:05 | TimMc | ,(let 'foo [x 1] x) |
| 17:05 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: let requires a vector for its binding> |
| 17:06 | TimMc | naeu: Is it occurring at macro expansion time or at call time? |
| 17:06 | raek | naeu: well, I have seen such exceptions before from the compiler |
| 17:06 | naeu | TimMc: call time |
| 17:06 | dnolen | naeu: should be pretty easy to isolate then, you should have a precise line number. |
| 17:07 | naeu | dnolen: how would I find that line number? |
| 17:07 | dnolen | naeu: the stacktrace. |
| 17:08 | dnolen | naeu: this sounds like a bug related to expanding to a fn, or protocol, deftype/record |
| 17:08 | naeu | dnolen: I just see: 18: overtone.sc.cgen$eval10533.invoke(NO_SOURCE_FILE) |
| 17:08 | dnolen | a symbol where there should be a vector |
| 17:09 | naeu | dnolen: I wonder why 1.3 would pick it up and not 1.2 |
| 17:09 | dnolen | naeu: hard to say. but I'm sure it will turn out to be something simple. |
| 17:09 | naeu | dnolen: that's usually the case with these things ;-) |
| 17:10 | naeu | dnolen: so how would you get the line number from the stacktrace |
| 17:10 | naeu | I'm getting that trace from an emacs buffer |
| 17:10 | naeu | would I be better off generating it through some other way? |
| 17:10 | dnolen | naeu: you said the error is at call time |
| 17:10 | amalloy | easiest way: gist the stacktrace and tell people you need help understanding it |
| 17:10 | naeu | dnolen: yep, emacs throws that buffer at call time |
| 17:11 | naeu | here's the stacktrace: https://gist.github.com/1220495 |
| 17:11 | naeu | "people, I need help understanding it!" :-) |
| 17:13 | dnolen | naeu: if this at call time then what is the smallest form that causes the problem. |
| 17:13 | dnolen | naeu: what is the macroexpansion? |
| 17:13 | naeu | dnolen: it's a bit of a beast, hold on... |
| 17:13 | dnolen | naeu: tho it's clear here its *not* a call time error, it's a compile time error |
| 17:14 | naeu | dnolen: ok, but emacs throws that buffer up when I try and 'call' the fn |
| 17:14 | naeu | and not when I use the macro to generate the fn |
| 17:19 | naeu | dnolen: I've updated the gist to include the macroexpansion (which I've simplified a little) |
| 17:20 | amalloy | naeu: 1.3 sees the exception sooner because it checks for primitive typehints on arglists, i suspect |
| 17:20 | naeu | amalloy: 1.2 never even complained... |
| 17:21 | amalloy | i'm just saying, i'm looking at the compiler, the line where the stacktrace tries to cast, and it's looking through the arglists to see if there's a primitive hint |
| 17:22 | naeu | amalloy: oh cool :-) |
| 17:23 | naeu | my java-fu is sadly weak - I really should start reading some one day |
| 17:24 | naeu | amalloy: how do you know where in the stacktrace to look? |
| 17:24 | amalloy | well, i just looked at the topmost line |
| 17:24 | amalloy | since that's the immediate cause |
| 17:25 | naeu | ah, yes, makes sense |
| 17:25 | hugod | that error normally comes from passing a symbol to something that is being destructured as a vector |
| 17:25 | naeu | I just tend to skip to the clojure bit - perhaps I should stop doing that |
| 17:25 | amalloy | hugod: then you usually get nth not supported |
| 17:25 | dnolen | naeu: your source looks strange are you def'ing inside a vector? |
| 17:26 | amalloy | looking at the stacktrace, it seems like the compiler is trying to parse something like (fn [foo] (bar ...)), and when it looks up the global variable bar it sees that its arglists are illegal in some way |
| 17:26 | naeu | dnolen: I'm looking at exactly that right now trying to figure out why I'm def'ing inside a vec |
| 17:31 | naeu | dnolen: it looks like I was tryign to create a list of defs to def, but never actually got round to unwrapping it |
| 17:31 | naeu | and yet it seemed to work with 1.2 like that |
| 17:31 | dnolen | naeu: so is it fixed now? |
| 17:31 | naeu | not yet |
| 17:32 | naeu | going to stick it in a do and see what happens |
| 17:37 | naeu | hmm, there seems to be an issue with my use of `(with-meta c-name metadata)` |
| 17:37 | naeu | where c-name is a symbol and metadata is a map |
| 17:37 | naeu | I'm using that in a macro |
| 17:38 | naeu | and binding it to default-c-name in a let statement |
| 17:38 | naeu | next, I do the following: `(def ~default-c-name ~default-cgen)` |
| 17:39 | naeu | ~default-c-name doesn't seem to resolve to a symbol |
| 17:39 | clojurebot | a symbol is just a variable name |
| 17:40 | amalloy | naeu: link to where your with-meta is? |
| 17:40 | naeu | amalloy: you mean the source code? |
| 17:40 | amalloy | yeah |
| 17:41 | naeu | https://github.com/overtone/overtone/blob/master/src/overtone/sc/cgen.clj#L176 |
| 17:45 | amalloy | naeu: sadly nothing stands out as crazy, as long as none of those cgens depend on each other |
| 17:45 | amalloy | i've had an issue before where a name's metadata gets eval'd more than i expected, but that doesn't seem to be your issue |
| 17:46 | raek | hrm, shouldn't there be a 'do' around all those defs? |
| 17:46 | naeu | when you say "cgens depend on each other" you mean the possibility that one def might invoke the other and visa versa? |
| 17:46 | amalloy | raek: well, he's putting them in a vector, which is silly but should work if they're not interdependent |
| 17:46 | naeu | raek: yup, there is now in my local source :-) |
| 17:46 | raek | to me it looks like the macro generates something like [(def ...) ((def ...) (def ...) (def ...))] |
| 17:47 | amalloy | raek: yeah, it does do that, which in fact is crazy :) |
| 17:47 | naeu | raek: yeah, it was, now it's (do (def..) (def …)) |
| 17:47 | raek | that looks better :) |
| 17:48 | naeu | but that doesn't fix the exception ;-) |
| 17:48 | naeu | just tidies things up |
| 17:48 | raek | well, a def is an expression, so it's valid syntax :) |
| 17:48 | amalloy | naeu: btw, (list* `do def1 (for ...)) is the easiest way to get that, imo. i guess `(do ~def1 ~@(for...)) works too, but it seems more confusing |
| 17:48 | raek | and a def returns a var, which implemets IFn |
| 17:50 | naeu | amalloy: good tip |
| 17:50 | naeu | thanks |
| 17:56 | Zolrath | I'm having an issue with Noir/CongoMongo in that I have a page which fetches entries from the MongoDB but it caches the values the first run. |
| 18:01 | Zolrath | In the defpage it calls a function that calls (fetch :jobs) and inserts html using the data but apparently that is not the right way to go about this. |
| 18:01 | naeu | amalloy: so it appears to be the with-meta lines which are blowing up |
| 18:01 | srid | is there a primitive to remove nil/false from a collection? |
| 18:02 | amalloy | filter |
| 18:02 | naeu | amalloy: everything works now after I removed those specific lines |
| 18:04 | srid | (filter #(%) (map f records)) |
| 18:04 | naeu | srid: (filter identity (map f records)) |
| 18:05 | srid | that's same as using #(not (nil? %)) as pred, I hope |
| 18:06 | amalloy | no; it's the same as using #(not (boolean %)) |
| 18:07 | amalloy | er...that's the opposite |
| 18:07 | amalloy | my point is just that it removes false as well as nil |
| 18:07 | naeu | amalloy: I think that's what srid wanted? |
| 18:08 | amalloy | yes, which is why i'm puzzled that he hopes it's the same as something that obviously isn't what he wanted |
| 18:11 | srid | checking for nil alone is fine. |
| 18:11 | srid | can `(println (filter ...))` ever raise NullPointerException? |
| 18:12 | srid | ... after printing a single ( |
| 18:12 | srid | yes, lazy seqs |
| 18:13 | srid | so the nullpointer must have happened inside the filter's pred, even though clojure traceback points to the println location. |
| 18:14 | amalloy | it doesn't even have to happen in the filter pred |
| 18:15 | amalloy | &(println (filter identity (map #(.size %) [nil nil]))) |
| 18:15 | lazybot | java.lang.NullPointerException |
| 18:16 | srid | the culprint was zipmap ignoring the last key because re-matches did not include the last group (for one log record). |
| 18:33 | srid | I need the result of a cond test expr in the result expr; is there a primitive function for that? or do I have to reimplement cond? |
| 18:34 | srid | the cond test expr in question doesn't always return true/false - they may return complex data structures too |
| 18:34 | srid | i want to bind the data structures for use in the result expr. |
| 18:36 | nickmbailey | perhaps you just want a few if-lets rather than cond? |
| 18:36 | nickmbailey | i don't think there is a cond-let |
| 18:37 | llasram | There is in clojure.contrib.cond, but it looks... odd. I'm having difficulty parsing what it does, other than "not what I'd think" |
| 18:40 | llasram | Oh, I see. Interesting. I think it might do what srid wants. |
| 18:40 | llasram | It just seems a little weird because you specify a single binding form to use for all the text/expr pairs |
| 18:41 | nickmbailey | yeah something like '(cond-let [x] false nil true x)' |
| 18:42 | srid | nickmbailey: if-let's are not exclusive, unless you nest them which is ugly. |
| 18:42 | nickmbailey | yeah but cond-let seems to do exactly what you need |
| 18:43 | srid | seems so; (cond-let [x] (+ 2 3) (* x 2)) |
| 18:44 | srid | the first I read the cond-let doc in clojuredocs.com it was confusing, then later I understood. |
| 18:45 | llasram | I think the example needs a little love... At the very least, the formatting doesn't intuitively express the relationship between the forms |
| 18:50 | srid | `map` is annoying. i can't easily debug errors in its predicate, because clojure's traceback doesn't include line number information for the stack after the call to predicate. |
| 18:50 | srid | that's because map returns lazyseq |
| 18:51 | nickmbailey | yeah its not exactly clear in that example that '[5 2 3]' is the test |
| 18:51 | llasram | nickmbailey: updated -- hopefully better now :-) |
| 18:51 | srid | and primitives like `(count a-lazy-seq)` fail without telling which line the error occured |
| 18:51 | llasram | srid: What dev env are you using? |
| 18:51 | srid | emacs - cake swank |
| 18:51 | srid | i type C-c C-k and then invoke my main function in REPL |
| 18:51 | llasram | srid: Cool! I literally just today learned that you can drill down when you get lazy seq errors |
| 18:52 | srid | how do you drill down? |
| 18:52 | llasram | Hit 1 in the exception buffer |
| 18:54 | llasram | I was so excited when I found that out, because debugging lazy seqs had been a pain in my ass too |
| 18:55 | llasram | anyway, I'm off -- gl |
| 19:21 | srid | hit 1 and? |
| 19:22 | srid | exception buffer now shows "0 1" to qui slime or abort slime. |
| 19:22 | amalloy | srid: but now it has a new stacktrace |
| 19:22 | srid | ah yes. |
| 19:24 | amalloy | gfredericks: meh. it's just showing the next "Caused By" exception you'd see in a real stacktrace |
| 19:24 | gfredericks | oh okay |
| 19:24 | gfredericks | good |
| 19:24 | gfredericks | that'll make it easier for me to keep sitting in my corner over here telling myself that emacs isn't all that cool |
| 19:30 | srid | in the 'caused by' exception, I see nullpointerexception at -- (if-let [attr (typ record)] |
| 19:30 | mdeboard | computers are hard |
| 19:30 | srid | what could have happened? if it the source was in the 'typ' function, then i'm surprised that the 'caused by' exception didn't show it (the line no) |
| 19:30 | mdeboard | for me* |
| 19:34 | srid | 'typ' was null. (last entry of loop) |
| 19:35 | amalloy | if-let is a macro - you can lose line metadata information when macros enter the picture |
| 20:49 | devn | hm, is there a way to have a clojurescript node repl? |
| 20:50 | devn | as in: once I require [cljs.nodejs :as node], I get access to node/require, etc. in script/repljs |
| 20:50 | devn | methinks I might need to start from script/repl instead |
| 20:52 | srid | amalloy: ok. still, pringin *which* variable was 'null' would have been more useful than a mere "nullpointerexception". then again, i don't know much of clojure/java internals to judge if that is doable. |
| 20:52 | srid | *printing |
| 20:52 | amalloy | not really, no |
| 20:53 | srid | no - to what? |
| 21:00 | alandipert | i think ataggart is around there, and i imagine he will be coming |
| 21:03 | srid | best to go to vancouver clojure group (sept 20) and find out http://www.meetup.com/Vancouver-Clojure/ |
| 21:12 | hiredman | ,(/ 128 8) |
| 21:12 | clojurebot | 16 |
| 21:13 | tomoj | I see that method annotations work with reify, but is there no way to give a class annotation? |
| 21:20 | cemerick | tomoj: I don't believe so; there's no class/type name to hang metadata off of in that case. |
| 21:24 | tomoj | shucks |
| 21:24 | cemerick | a deftype will bring you home |
| 21:24 | tomoj | got that working, but what I want is anonymous |
| 21:24 | tomoj | though |
| 21:25 | cemerick | I wouldn't put money on that happening. :-) |
| 21:25 | tomoj | I was going to replace them all with a single gen-class, can just replace them all with a single deftype |
| 21:28 | redinger | srid: Even better, go to the vancouver meet up and tell them all to attend the conj. :) |
| 21:49 | TheBusby | can you have multiple namespaces in a single file and have them reference each other? |
| 21:58 | alandipert | TheBusby: yes, but in a file like (ns a) (ns b) stuff in ns a doesn't know about ns b |
| 21:59 | TheBusby | alandipert: Would "ns b" be able to require/user from "ns a" ? |
| 21:59 | alandipert | TheBusby: yes |
| 22:02 | TheBusby | alandipert: Hmm, trying a simple example I get "java.io.FileNotFoundException: Could not locate foo/a__init.class or foo/a.clj on classpath" |
| 22:03 | alandipert | TheBusby: how are you compiling? |
| 22:03 | TheBusby | alandipert: via slime and the command line |
| 22:04 | TheBusby | alandipert: Here is the sample code I was using to test, http://pastie.org/2540810 |
| 22:04 | alandipert | oh, whoops - i was mistaken. 'require' needs a file |
| 22:05 | TheBusby | er, and 'use' ? |
| 22:05 | TheBusby | probably the same, is there another way to access it though? |
| 22:06 | alandipert | TheBusby: http://pastie.org/2540826 |
| 22:07 | TheBusby | alandipert: doh, much thanks! |
| 22:08 | alandipert | np, happy computing! |
| 22:13 | bpr | Using definterface, can you specify parameterized method parameters (ie. Map<String, String>)? |
| 22:15 | bpr | for example i'd like to do something like (definterface IAvailableResourcesCallback (onResources [^Map<String,String> m])) ; sorry for the horrid syntax... |
| 22:17 | amalloy | bpr: no |
| 22:17 | bpr | amalloy: that doesn't surpise. I had to ask though |
| 22:27 | srid | are their presentations/articles detailing why Heroku chose Clojure (over ruby/python) for implementing some of its components (eg: pulse)? |
| 22:35 | devn | srid: http://www.theregister.co.uk/2011/07/11/heroku_does_clojure_and_beyond/ |
| 22:37 | devn | srid: Also, it looks like Mark McGranaghan is going to be giving a talk at Clojure/conj 2011 about Pulse: http://lanyrd.com/2011/clojure-conj/shhfd/ |
| 22:37 | devn | srid: (There's an abstract there that might give a bit more insight) |
| 22:39 | srid | devn: mark's talk is how I came to know about pulse (in fact, i was just starting today at work to do some log analysis in clojure) |
| 22:41 | srid | devn: but as for the theregister article, the rationale behind choosing clojure for pulse is just intuition (gut sense, hip, feels right)? |
| 22:42 | srid | he says "Clojure is suited to building application components that must be eminently predictable" - i don't even know what that means. what is 'eminently predicable'? |
| 22:44 | dhm | srid: i'd read it as another way of saying "functional" |
| 22:45 | srid | that raises the question - how are clojure-based components 'eminently/more functional' than others (ruby/python). |
| 22:45 | zippy314 | are folks talking about clojurescript on this channel or is there a better place? |
| 22:45 | redinger | zippy314: This is the ClojureScript channel, too. |
| 22:46 | zippy314 | kewl. Just digging into now. Checking out the twitterbuzz example. Anybody know of any other good sample clojurescript/closure apps out there to learn from? |
| 22:48 | amalloy | srid: they don't mutate |
| 22:48 | amalloy | zippy314: pacman! |
| 22:48 | amalloy | $google github pacman clojure |
| 22:48 | lazybot | [Twitter / @btbytes/clojure] http://twitter.com/btbytes/clojure |
| 22:48 | amalloy | ... |
| 22:48 | srid | heh |
| 22:49 | amalloy | http://mjg123.github.com/pacman/pacman.html |
| 22:49 | srid | zippy314: https://github.com/heroku/leech is written in clojurescript |
| 23:02 | bpr`` | is there a way to declare abstract classes in clojure? I know it's *very* non-idiomatic, but I'm creating a Java-interop interface... |
| 23:05 | brehaut | bpr``: that sounds like the realm of AOT compilation |
| 23:07 | brehaut | bpr``: http://clojure.org/compilation |
| 23:08 | brehaut | no idea if it actually supports defining abstract classes specifically |
| 23:13 | bpr`` | this is my first major chunk of java-interop where I'm exposing clojure functionality to Java code. So I'm looking for all the advice I can get haha. This is especially true because I'm not really a Java dev. I come from the dynamic language world lol |
| 23:13 | bpr`` | dynamic type* |
| 23:13 | zippy314 | wow. That pacman link really fries safari! |
| 23:21 | icey | i am writing a small noir example app for practice and i've got a couple of functions that don't feel idiomatic to me. anyone feel like taking a peek? |
| 23:21 | icey | https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/utils/utils.clj |
| 23:22 | icey | the human-date function's let section looks gross to me |
| 23:22 | icey | the -> didn't really help much |
| 23:26 | brehaut | icey. where does 'markdown' come from? (in markdownify) |
| 23:26 | icey | brehaut: markdownj |
| 23:26 | brehaut | oh. im out of practise at reading that form of method call |
| 23:27 | icey | brehaut: ah, is there a preferred method? |
| 23:27 | icey | err, form |
| 23:27 | brehaut | (.markdown mdp …) |
| 23:27 | brehaut | i think |
| 23:28 | brehaut | http://clojure.org/java_interop |
| 23:28 | brehaut | yeah |
| 23:29 | icey | brehaut: sweet, thanks. i'll give it a whirl |
| 23:30 | alandipert | the naked dot form is handy in macros |
| 23:32 | brehaut | icey: contains-all is kinda funny |
| 23:32 | brehaut | icey: you only need it if your map might contain false or nil |
| 23:40 | brehaut | icey: human-date is ok. the only actual gross part is that its not pure functional… |
| 23:41 | icey | brehaut: i'm trying to recall the exact reason i went the contains-all route |
| 23:42 | brehaut | icey: well the alternative is just to use every? with the map as the function. your function is fine if you think there is a chance that the value of one of the key is nil or false |
| 23:43 | icey | brehaut: yeah, i'm using it on a page with 2 possible entry points and I may get different data between them |
| 23:44 | icey | brehaut: i'm using it here https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/views/post.clj around like 86 - |
| 23:44 | brehaut | icey: if you click the line numbers, gh updates the url |
| 23:44 | icey | err, line 86 |
| 23:45 | icey | sweet, i never knew that |
| 23:45 | icey | thanks |
| 23:47 | icey | i think every? will work here |
| 23:49 | alandipert | i'd probly do (clojure.set/subset? (set ks) m) there |
| 23:49 | brehaut | alandipert: thats nice |
| 23:50 | amalloy | that's not going to work, is it? it will seq m, and look at the k/v pairs |
| 23:50 | alandipert | sets are degenerate maps |
| 23:50 | amalloy | yes |
| 23:50 | brehaut | huh. subset? just uses every under the hood anyway |
| 23:51 | brehaut | (in 1.2 anyway) |
| 23:51 | amalloy | i see. i guess it works if you pass the args in that order |
| 23:51 | amalloy | i think i was thinking of intersection or something |
| 23:52 | alandipert | (subset? ks m) also works, but for reasons unknown to me |
| 23:52 | amalloy | alandipert: the first arg just gets seq'd |
| 23:53 | brehaut | alandipert: it doesnt treat keys as a set |
| 23:53 | amalloy | since you have to look at all of them anyway |
| 23:53 | alandipert | ah, cool |
| 23:55 | alandipert | well, i'm outs. looking forward to seeing peeps at strangeloop! |
| 23:55 | icey | alandipert: thanks for the advice - i'm reading up on subset right now |
| 23:56 | alandipert | np, happy clojuring |