2011-11-21
| 00:11 | alex_baranosky | do you all think colorization of Midje console output should be togglable, or would it be ok to just have colorization be the only option? |
| 00:11 | ibdknox_ | alex_baranosky: I added that stuff to colorize btw |
| 00:12 | alex_baranosky | if you think the former, what do you think is a good way to specify not desiring colorization? |
| 00:12 | amalloy | alex_baranosky: it needs to be togglable so that you can (eg) write it to text files or devices that don't support ansi color, right? |
| 00:12 | alex_baranosky | ibdknox: thanks! |
| 00:12 | ibdknox_ | amalloy: those extra bytes won't hurt anyone, right? ;) |
| 00:13 | alex_baranosky | amalloy: makes sense, so then the question moves onto the second step of what is the best medium for togglability |
| 00:13 | amalloy | ibdknox_: i sure enjoy reading ^[[67A in my logfiles :P |
| 00:14 | ibdknox_ | is midje used outside of the context of lein? |
| 00:14 | alex_baranosky | as far as I know it is only used from cake and lein... |
| 00:14 | amalloy | ibdknox_: there's a midje-mode for emacs that at least marick uses; dunno who else does |
| 00:14 | ibdknox_ | project file |
| 00:14 | ibdknox_ | hm |
| 00:15 | ibdknox_ | Project file still probably makes the most sense as a default place |
| 00:15 | devn | seancorfield: the pprint issue was damned simple -- just a rename from earmuffed *code-dispatch* to code-dispatch |
| 00:15 | devn | seancorfield: it looked worse on the surface -- now I'm onto a new issue, (recur) within a (try ...) |
| 00:15 | devn | some hairy code, taboot :| |
| 00:15 | amalloy | devn: whattttt? surely that should be setting *code-dispatch* to be dynamic |
| 00:16 | amalloy | well, i guess i don't actually know that |
| 00:16 | amalloy | but it sounds like the sort of thing that wants to be dynamic |
| 00:16 | devn | amalloy: I moved from clojure.contrib.pprint where it was earmuffed |
| 00:16 | devn | clojure.pprint => no earmuffs |
| 00:16 | devn | yes, it is ^:dynamic |
| 00:16 | ibdknox_ | if it's dynamic it should have earmuffs :p |
| 00:16 | alex_baranosky | ibdknox_: maybe set a midje-colorize property based on what's in the project file? |
| 00:17 | ibdknox_ | alex_baranosky: yep |
| 00:17 | devn | ibdknox_: that's not a thing anymore |
| 00:17 | ibdknox_ | devn: oh? The convention itself is not endorsed anymore? |
| 00:17 | amalloy | alex_baranosky: ideally you would query the output pipe/console and ask if it supports color - that's what grep does. but that's probably a lot of work and might not be possible in java anyway |
| 00:17 | devn | ibdknox_: i dont think it was ever endorsed TBH |
| 00:17 | devn | ibdknox_: i did it though :) |
| 00:17 | amalloy | ibdknox_: fairly sure devn is talking nonsense here |
| 00:17 | alex_baranosky | I might have to roll my own colorization code then to bake the property check into the function/macro calls |
| 00:17 | devn | amalloy: wha? |
| 00:18 | amalloy | dynamic vars and earmuffed vars probably don't correspond 1:1, but they're closely tied |
| 00:18 | ibdknox_ | devn: http://dev.clojure.org/display/design/Library+Coding+Standards |
| 00:18 | amalloy | and you should usually have one iff you have the other |
| 00:18 | ibdknox_ | devn: that seems endorsed to me :p |
| 00:18 | devn | err, yeah, you can say I'm talking nonsense |
| 00:19 | devn | that's what I was saying |
| 00:19 | devn | the code I'm fixing is using *earmuffs* for constants |
| 00:19 | hiredman | pre-1.3's release there was a trnasition period where earmuffed vars were automatically made dynamic, which is no longer the case |
| 00:19 | amalloy | alex_baranosky: project.clj isn't very flexible though, right? maybe i usually want color but this time i'm writing to a log file |
| 00:19 | devn | and yes, that. |
| 00:19 | amalloy | you might take a hint from lein and use an environment variable |
| 00:19 | ibdknox_ | actually |
| 00:19 | amalloy | MIDJE_COLOR=false lein midje |
| 00:19 | ibdknox_ | an env var makes sense |
| 00:19 | ibdknox_ | you can then have the lein plugin set it |
| 00:20 | ibdknox_ | based on the project var if it exists |
| 00:20 | ibdknox_ | otherwise, amalloy can write his log files by setting it explicitly at the start of the command :p |
| 00:22 | devn | ibdknox_: to your original point, I'm wrong again. code-dispatch used to be earmuffed, it's not anymore, but the whole structure of pprint is quite different, code-dispatch is now a multimethod |
| 00:22 | ibdknox_ | devn: haha |
| 00:23 | ibdknox_ | no one knows what's going on anymore! :D |
| 00:23 | ibdknox_ | it's a mad house |
| 00:23 | devn | I've been a bit out of the loop. |
| 00:25 | devn | now...need to figure out how to refactor this code to not use a (recur) inside (try) |
| 00:25 | alex_baranosky | ibdknox_: amalloy: thanks for the great ideas, I've jotted down some notes and will think about it tomorrow. It's getting later here. |
| 00:26 | amalloy | devn: it's a bit gross that that doesn't work anymore |
| 00:26 | ibdknox_ | wait |
| 00:26 | hiredman | devn: letfn |
| 00:26 | ibdknox_ | that doesn't work at all? |
| 00:26 | amalloy | you can probably fix it by turning (loop [] (recur)) into ((fn [] (recur))) |
| 00:26 | hiredman | it doesn't work to recur across a try |
| 00:27 | ibdknox_ | ah |
| 00:27 | amalloy | hiredman: there was a bug about this a while ago where it wasn't possible to recur even entirely-inside of a catch clause. is that still an issue? |
| 00:27 | hiredman | amalloy: I believe the issue is still open |
| 00:27 | hiredman | e.g. for (catch E e (loop [] (recur))) |
| 00:28 | amalloy | right |
| 00:28 | ibdknox_ | if it's in a function it's fine though? |
| 00:28 | hiredman | I think so, I forget |
| 00:31 | devn | https://gist.github.com/1381725 |
| 00:32 | devn | That's what I'm looking at^ |
| 00:36 | scottj | is there a pretty dates lib ("2 hours ago", "yesterday") |
| 00:39 | hiredman | devn: seems like you can just hoist the try/catch outside of the loop/recur |
| 00:41 | devn | hiredman: ill give it a try -- clojure-refactoring is not light reading |
| 00:41 | hiredman | loop recur seems kind of disgusting there |
| 00:41 | hiredman | looks like a reduce |
| 00:42 | hiredman | report is some horrible macro that lexically captures report-fn? |
| 00:47 | devn | hiredman: i think it was from clojure.test |
| 00:47 | amalloy | clojure.test is nothing but horrible macros |
| 00:47 | hiredman | inc |
| 00:48 | devn | the ns was (when (= (class clojure.test/report) clojure.lang.MultiFn) (eval '(do (require 'clojure.test) (ns clojure.test) (def old-report clojure.test/report)))) |
| 00:48 | devn | wtf? |
| 00:48 | hiredman | :( |
| 00:49 | hiredman | monkey patching the reporting for clojure.test |
| 00:49 | amalloy | that's a really bad way to monkey-patch, even |
| 00:49 | devn | I'll give Tom the benefit of the doubt -- I think he wrote this back in 1.0 |
| 00:49 | devn | but yeah, agree |
| 00:49 | amalloy | i helped marick replace some code in midje that looked exactly like this. the result is still bad but at least doesn't use eval |
| 00:50 | hiredman | the reporting stuff for clojure.test get's monkey patched a lot |
| 00:50 | devn | I really like midje |
| 00:50 | hiredman | makes you wonder if someone should just provide a nice extension mechanism for it |
| 00:52 | hiredman | it's kind of a shame clojure.test went it to clojure proper, then no further developement |
| 00:54 | hiredman | I guess there have been some commits in 2010 |
| 00:56 | devn | I haven't used clojure.test a whole lot |
| 00:57 | devn | I'm going to go ahead and take your word for it |
| 00:58 | hiredman | clojure.test is what we use at work actually |
| 00:58 | devn | oh right, you're one of those lucky assholes who gets to write clojure all the time at work |
| 00:58 | devn | ;) |
| 00:58 | hiredman | and it is mostly fine, we had some trouble here and there with conflicting monkey patching of the reporting function |
| 00:59 | hiredman | different lein plugins that format test output in different ways |
| 00:59 | hiredman | the few, the proud, etc |
| 01:00 | devn | hiredman: yeah, that sounds nasty |
| 01:01 | hiredman | I've gone all avant garde recently, and used 'are' in a test or two instead of 'is' |
| 01:01 | devn | hhahahaha, that's so postmodern |
| 01:02 | devn | we need to fuse the two worlds: iares |
| 01:02 | hiredman | be |
| 01:02 | devn | not-to-be |
| 01:02 | technomancy | clojure-test-mode had a truly awful monkey patch |
| 01:02 | technomancy | for clojure.test/report |
| 01:02 | technomancy | but I wrote that like three months after I started with clojure |
| 01:02 | hiredman | maybe that is what I was thinking of |
| 01:03 | technomancy | anyway, it's much better now |
| 01:04 | devn | I wish I could claim all of the clojure I write was created three months after I started |
| 01:05 | devn | we've been talking about starting a clojure practice-- i'm in the process right now of rewriting an app we did that should have been done in clojure to show off what clojure is good at |
| 01:06 | devn | it's hard for me to explain clojure, i think. "it's different than what you're used to" doesn't seem to be getting the message across. ;) |
| 01:06 | ibdknox_ | devn: we're hiring ;) |
| 01:07 | devn | ibdknox_: meetup? |
| 01:07 | ibdknox_ | you do :p |
| 01:07 | ibdknox_ | https://www.readyforzero.com |
| 01:08 | devn | where are you guys located? |
| 01:08 | ibdknox_ | San Francisco |
| 01:08 | ibdknox_ | downtown |
| 01:08 | devn | if it's san francisco the whole debt thing should work out well for me as a service |
| 01:08 | amalloy | hahaha |
| 01:08 | ibdknox_ | haha |
| 01:08 | ibdknox_ | it's true |
| 01:08 | ibdknox_ | :) |
| 01:09 | devn | they always say to eat your own dog food |
| 01:09 | devn | but this is ridiculous |
| 01:09 | devn | ibdknox_: all kidding aside, looks cool |
| 01:15 | slyphon | there's gotta be a better way to do this: |
| 01:15 | slyphon | (let [s {:a 1 :b 2}] (and (contains? s :a) (contains? s :b))) |
| 01:16 | amalloy | &(every? {:a 1 :b 2} [:a :b]) |
| 01:16 | lazybot | ⇒ true |
| 01:16 | amalloy | fails iff you have nil/false values in the map |
| 01:17 | slyphon | hrm |
| 01:17 | slyphon | ok, bad example then |
| 01:17 | slyphon | i have a list that can contain :a or :b and optionally :c |
| 01:17 | slyphon | :a and :b is an error |
| 01:18 | hiredman | ,(every? true? (map (partial contains? {:a 1 :b 2}) [:a :b])) |
| 01:18 | slyphon | (which is what i'm trying to detect) |
| 01:18 | clojurebot | true |
| 01:18 | amalloy | slyphon: a list? |
| 01:18 | slyphon | let's say, yes |
| 01:18 | slyphon | a seq |
| 01:18 | slyphon | i'm not sure what the caller is going to provide, so i'd coerce into what i need |
| 01:21 | hiredman | (constantly promise) |
| 01:22 | slyphon | :D |
| 01:22 | technomancy | (do (not deliver)) |
| 01:23 | slyphon | hah |
| 01:24 | slyphon | (require shorts) |
| 01:24 | slyphon | too bad no "shoes" |
| 01:24 | devn | (deliver us "from evil") |
| 01:24 | technomancy | "There is no try" actually works semantically since try is a special form that doesn't exist as a var. |
| 01:24 | slyphon | hah |
| 01:27 | amalloy | i have to confess, after that bizarre ML post asking people to stop saying "idiomatic", i'm noticing that word used in some pretty absurd places |
| 01:28 | slyphon | (complement shorts) |
| 01:28 | hiredman | amalloy: the solution to that is to stop reading the normal ml, and just read -dev |
| 01:28 | amalloy | a comment on an old SO answerR: "I don't like reimplementing core functions, it's not idiomatic." |
| 01:30 | hiredman | so :( |
| 01:30 | amalloy | hiredman: -dev is not terribly fun reading most of the time |
| 01:30 | hiredman | the regular list is mostly junk |
| 01:31 | hiredman | at least there haven't been any blog posts to the list recently |
| 01:34 | R4p70r | I was reading this http://stackoverflow.com/q/8199046 and was wondering.. Why does Clojure have an "update-in" for nested associative structures but no plain "update" for updating "flat" associative structures? |
| 01:35 | hiredman | what would update do? |
| 01:35 | hiredman | (and how would it differ from update-in?) |
| 01:39 | Raynes | &(update-in {:foo 0} [:foo] inc) |
| 01:39 | lazybot | ⇒ {:foo 1} |
| 01:39 | Raynes | R4p70r: The only thing you'd gain from 'update' is two less square brackets. |
| 01:42 | devn | I have a buy order out for square brackets. |
| 01:43 | devn | It's like Cash4Gold, but for syntax |
| 01:43 | slyphon | hah |
| 01:44 | devn | ming slyphon? |
| 01:44 | slyphon | at one point |
| 01:44 | devn | slyphon: cool to see you in here -- I think you were the first nice guy I met on IRC |
| 01:44 | slyphon | hah |
| 01:44 | devn | seriously. :) |
| 01:44 | slyphon | well, i try :) |
| 01:45 | devn | slyphon: still hacking the rubies? |
| 01:45 | slyphon | yeah, mostly |
| 01:45 | R4p70r | Raynes I can see that... But why is it like that in the first place? Is it more common to use this on nested structures somehow? I guess it's just more inconvenient than (assoc (get (get coll 3) 4) (f (get (get coll 3) 4))) |
| 01:45 | slyphon | i try other things, but i keep coming back |
| 01:46 | devn | slyphon: clojure might turn you! :D |
| 01:46 | Raynes | What do you mean 'why is it like that'? What other way could it be? |
| 01:46 | amalloy | there are support groups for that |
| 01:46 | slyphon | hah! |
| 01:46 | devn | I don't need a support group. I came out to my coworkers a year or two ago. |
| 01:46 | amalloy | R4p70r: that is not equivalent |
| 01:46 | slyphon | my friend just said about ClojureScript "that's so fucking nerd-trendy that somewhere a cobol programmer just died" |
| 01:47 | devn | I never want to go back. This is who I am now, and everyone will need to learn to accept it. :) |
| 01:47 | amalloy | because of immutability; it looks equivalent if you imagine this is python, but it aint |
| 01:47 | slyphon | devn: hahahah |
| 01:47 | devn | slyphon: only a hipster would say something like that |
| 01:48 | devn | or a nerd with an axe to grind |
| 01:48 | slyphon | devn: he's actually a crusty sysadmin type |
| 01:48 | slyphon | "haggard" |
| 01:48 | devn | a filthy neckbeard is he? |
| 01:48 | amalloy | (update-in m [3 4] f) is roughly (assoc m 3 (let [m2 (get m 3)] (assoc m2 4 (f (get m2 4))))) |
| 01:48 | slyphon | hahaha |
| 01:48 | slyphon | indeed |
| 01:48 | devn | well then, lisp should be right up his alley |
| 01:48 | devn | :) |
| 01:48 | slyphon | kind of guy you want there when shit goes down |
| 01:48 | slyphon | in production, on a friday |
| 01:48 | devn | so he carries a gun? |
| 01:49 | devn | "have gun, will admin" |
| 01:49 | slyphon | indeed |
| 01:49 | zakwilson | Never know when you might need to headshot a zombie process. |
| 01:49 | devn | "kill all the children |
| 01:49 | slyphon | sometimes you need to be a little more persuasive than normal |
| 01:50 | devn | haha. i think for a lot of the heavy-duty neckbeards the beard does most of the talking |
| 01:50 | devn | like: "Hello I resemble PLATO. Ever heard of him?" |
| 01:50 | R4p70r | amalloy, Well ok. My point was it's more way concise. And that's probably why clojure has update-in in core. |
| 01:51 | devn | slyphon: there's a large overlap. "philosopher beard" and "unix beard" |
| 01:52 | R4p70r | amalloy, But you're right my version was bogus. |
| 01:52 | amalloy | yes. it's more concise, but also much easier to manage/understand. basically the same reason any function gets written |
| 01:52 | daaku | anyone familiar with clj-time/joda time? i can't seem to figure out why the 'T in this doesn't work: (parse (formatter "yyyy-mm-dd'Thh:mm'Z") "2011-11-21T05:51Z") |
| 01:52 | amalloy | i imagine it got into core because it's an operation that frequently needs to be done, given clojure's emphasis on immutable hashmaps |
| 01:56 | devn | daaku: what are you trying to get with T |
| 01:57 | daaku | devn: i want to define a formatter that has a literal T in it |
| 01:57 | R4p70r | And since updating a non-nested structure take less code we don't really need an "update" I guess. But I see how update-in can be used with only one key... Anyways I was just a bit curious about the choice of built-in. |
| 01:57 | amalloy | daaku: you're using mm in two places. that sounds wrong |
| 01:58 | devn | daaku: what is the output? |
| 01:59 | daaku | amalloy: ah, that was definitely wrong |
| 01:59 | daaku | but fixing that didn't help: (parse (formatter "yyyy-MM-dd'Thh:mm'Z") "2011-11-21T05:51Z") |
| 01:59 | daaku | gives: IllegalArgumentException Invalid format: "2011-11-21T05:51Z" is malformed at "T05:51Z" org.joda.time.format.DateTimeFormatter.parseDateTime |
| 02:00 | hiredman | 'T' is most likely what you need |
| 02:02 | daaku | hiredman: ah, i didn't realize it was not just a escape prefix |
| 02:02 | daaku | thanks |
| 02:05 | slyphon | why is it that (vector :a) returns [:a] but (seq :a) and (set :a) throw exceptions? |
| 02:05 | hiredman | because that is what they do |
| 02:06 | amalloy | vector creates vectors from items; seq and set create seqs and sets out of seqs |
| 02:06 | slyphon | hrm |
| 02:07 | slyphon | i kind of want (flatten (vector arg)) |
| 02:07 | amalloy | nooooo, you don't |
| 02:07 | hiredman | uh |
| 02:07 | slyphon | right, i know that |
| 02:07 | hiredman | why would you possibly want that? |
| 02:07 | hiredman | what do you think that does? |
| 02:08 | brehaut | ~flatten |
| 02:08 | clojurebot | flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with. |
| 02:08 | brehaut | wow. thats larger than i remember |
| 02:08 | amalloy | brehaut: dangit, i always forget i taught him that |
| 02:08 | hiredman | clojurebot: mapcat is useful |
| 02:08 | clojurebot | Roger. |
| 02:09 | slyphon | so, i have a function that will take a map, one key is :flags, which I want to treat as a set, but someone may hand me a single value |
| 02:09 | slyphon | :flags [:a :b] or :flags :a |
| 02:09 | hiredman | (if (coll? ...) (set ...) #{...}) |
| 02:10 | slyphon | ah |
| 02:10 | slyphon | yeah, or, that |
| 02:10 | slyphon | :) |
| 02:10 | slyphon | thanks |
| 02:12 | R4p70r | slyphon, the closest equivalent to set and seq in your example would be "vec" not vector |
| 02:12 | slyphon | ah |
| 02:13 | scottj | slyphon: hash-set is the equiv of vector |
| 02:13 | slyphon | ah |
| 02:13 | slyphon | ok |
| 02:14 | slyphon | (again) |
| 02:27 | georgek | hi, I'm using emacs, lein, and swank-clojure, and up to now when I add something to the project.clj I have to M-x clojure-jack-in again to get the changes to take effect. Is there an easier way? Trying C-c C-k in project.clj just says that it can't resolve the symbol defproject |
| 02:28 | seancorfield | according to technomancy no, there's no easier way at present |
| 02:28 | hiredman | that is how you do it |
| 02:28 | georgek | OK thanks, good to know |
| 02:28 | amalloy | clojurebot: classpath is <reply> You can't add things (libraries, dependencies) to a running JVM process. Java doesn't like it, and we just have to live with that. |
| 02:28 | clojurebot | In Ordnung |
| 02:29 | seancorfield | if you have :checksum-deps true in project.clj you don't have to run lein deps which is one less step |
| 02:29 | seancorfield | make sure you have clojure-mode 1.11.4 tho' - earlier versions barf on lein output when it fetches deps |
| 02:30 | hiredman | cemmerick has a project that is supposed to save us all from it |
| 02:30 | seancorfield | i look forward to that :) |
| 02:31 | georgek | cool, that'll be nice, thanks for the tips in the meanwhile |
| 02:31 | hiredman | well, we'll see if it does |
| 02:31 | seancorfield | now if i can just persuade my team mates to switch to emacs... |
| 02:31 | georgek | I'm just happy I have a remote emacs, Ring and nginx finally working :) |
| 02:32 | hiredman | https://gist.github.com/a1f737bfe0d70a385d4c |
| 02:32 | seancorfield | yeah, i need to try this whole remote emacs thing... i only found out about the client / server aspect recently... |
| 02:34 | seancorfield | gah, are there any good examples out there of how to use clojure.test.junit? |
| 02:36 | seancorfield | "locate-dominating-file" - really? *boggle* |
| 02:36 | hiredman | elisp, it's fun |
| 02:37 | amalloy | hiredman: i didn't know about locate-dominating-file. very handy |
| 02:38 | hiredman | me neither, cribbed from clojure-mode |
| 02:38 | devn | I wonder: Does github have a limit on the number of times you can clone/pull repos? |
| 02:39 | amalloy | devn: planning to strike it rich by running git-backed rapidshare site? |
| 02:39 | devn | hahahha |
| 02:39 | devn | No just trying to pull down every single recognized clojure repo |
| 02:40 | devn | so I can start parsing ns macros 3:) |
| 02:52 | slyphon | <cartman> I hate you java </cartman> |
| 03:00 | scottj | devn: do you have a list of all clojure repos? |
| 03:05 | amalloy | scottj: i'm pretty sure github's api will give you that |
| 03:20 | scottj | amalloy: was only able to find repositories matching a search term in the api, no equivalent of https://github.com/languages/Clojure/created that would filter out forks |
| 03:22 | amalloy | sorry, i guess by "pretty sure" i mostly meant "random guessing" |
| 03:23 | scottj | devn: did you run slamhound on clojure-refactoring? |
| 06:57 | babilen | Hi all. I am looking for a project that exemplifies good midje practices and welcome any pointers. (Or is adopting midje a bad idea?) |
| 07:00 | babilen | The most obvious answer seems to be: "Take a look at midje itself!" :) *sigh* |
| 08:29 | babilen | What is a good way to write tests that read/write external files? How do I read them in a portable way? |
| 08:34 | michael_campbell | what kind of portable; across different OS's, or different environments (production, dev, beta, ...), or something else? |
| 08:35 | babilen | michael_campbell: I was merely thinking about different OS's and absolute paths |
| 08:36 | michael_campbell | ugh, yeah. always a pita. I don't know enough clojure to give you solid advice here, but there are generally os-level "create a temp name for me" calls somewhere that you can use to make a temp directory and put stuff in there. |
| 08:36 | babilen | michael_campbell: The first is not hard at all, but I am unsure how to actually find the files. I've seen plenty of examples of .clj files being read which relies on setting the CLASSPATH correctly. |
| 08:37 | michael_campbell | or the cheesy way out, which is what I'm all about, is to "mkdir c:\tmp" on any windows box I have, then use /tmp for most everything, since it'll damn sure be on any *nix boxen. (Well, rather, I've never seen one that doesn't have /tmp) |
| 08:37 | babilen | michael_campbell: I have a bunch of files that contain data that I need for testing. As I would also like to test the actual reading of the files I don't want to define their content in a variable. |
| 08:38 | michael_campbell | <nod> Were it me, I'd just put them in /tmp. But I may be misunderstanding your needs here, and as I said I'm way, way too new at clojure to be depended on for anything =) |
| 08:41 | babilen | michael_campbell: Sure. I could put them in /tmp, but that would require that I still keep their content in a variable. I would much rather use a PROJECT/resources/test directory that contains all the files. Just not sure how to actually figure out the PROJECT path. |
| 08:43 | mdeboard | Is Josh out sick today |
| 08:43 | mdeboard | wrong window |
| 08:47 | jkkramer | babilen: (clojure.java.io/resource "test/data.txt"), which returns a file URL, which can be passed to io/reader, etc |
| 08:49 | babilen | jkkramer: Wonderful, that sounds as if it is exactly what I was looking for. Lets test it |
| 08:57 | raek | babilen: also, 'resource' always uses forward slash as the path separator |
| 08:58 | raek | to join non-classpath paths in an OS-independent way, use c.j.io/file |
| 08:59 | raek | you can also use the java.io.File class directly to create temp files, among other things |
| 09:00 | babilen | raek: I'll do that, thanks. |
| 09:01 | raek | babilen: 'resource' will look for files on the classpath (a good fit for resource files bundled with the application), so (io/resource "foo/bar.txt") can resolve to src/foo/bar.txt or resources/foo/bar.txt etc |
| 09:01 | raek | resources/ is generally preferred for non-code files |
| 09:09 | samaaron | things are a little quiet in here :-) |
| 09:12 | TimMc | samaaron: East coast of US is just getting to work. |
| 09:12 | TimMc | or just finished settling in |
| 09:13 | ejackson | bzzzzzzzzzzzzzzz |
| 09:13 | samaaron | hahaha |
| 09:13 | samaaron | ejackson: when are we grabbing that lunch? |
| 09:14 | ejackson | how's your tomorrow looking ? |
| 09:14 | TimMc | ejackson: "Are We There Yet?" was great. |
| 09:14 | ejackson | TimMc: Yeah, it blew me away, |
| 09:14 | ejackson | Glad you liked it |
| 09:14 | TimMc | I sent a few notes to my work mail address. :-) |
| 09:14 | samaaron | ejackson: tomorrow is grand |
| 09:15 | ejackson | samaaron: sorted, we're on :) |
| 09:19 | ejackson | TimMc: the other videos that I really enjoyed were these http://vimeo.com/seandevlin |
| 09:22 | TimMc | ah, those |
| 09:23 | TimMc | Thanks for reminding me -- I'll download some to watch at the airport. :-) |
| 09:54 | zerokarmaleft | yeesh, someone implemented a jvm in js |
| 09:55 | chouser | ooh, so now we can compile ClojureScript in the browser? |
| 09:56 | zerokarmaleft | theoretically? heh |
| 09:58 | joegallo | can you run rhino in it? |
| 09:58 | apgwoz | zerokarmaleft: was it just compiling the openjdk via emscripten? |
| 09:58 | apgwoz | or actually wrote a jvm in javascript? |
| 09:59 | zerokarmaleft | https://github.com/notmasteryet/jvm-js <= actually wrote a jvm |
| 10:02 | zerokarmaleft | joegallo: ouroboros! |
| 10:03 | apgwoz | woah. this is awesome |
| 10:04 | zerokarmaleft | https://github.com/nurv/BicaVM <= also this |
| 10:05 | apgwoz | pretty crazy |
| 10:06 | apgwoz | someone should implement a JVM in clojure... |
| 10:12 | michael_campbell | and run clojure in it? |
| 10:15 | fbru02_ | hi all |
| 10:17 | Saturnation | pretty disappointed in the "Clojure in Action" index thus far... :( |
| 10:21 | Saturnation | correction, I'm pretty disappointed in MY ability to remember what I'm looking for... :) |
| 10:34 | fliebel | How does meta data work with macros? (a-macro ^:foo argument) |
| 10:37 | TimMc | zerokarmaleft: Pretty cool! The JVM isn't perfect yet, but it basically works. |
| 10:38 | fliebel | I half expected to get an expanded with-meta form, but not so. |
| 10:55 | AWizzArd|work | fliebel: because you used a reader macro. As soon Clojure read it, it's gone. |
| 10:56 | AWizzArd|work | reads |
| 10:57 | fliebel | AWizzArd|work: oh, okay, so I just get a symbol with meta on it, nice. :) |
| 11:03 | raek | hrm. a bit off topic: I think I saw a presentation (probably FP-related) where it was mentioned that a certain language had "reactors"... anyone heard about such a language? |
| 11:03 | raek | is it a widely known concept? |
| 11:09 | fliebel | Is a workoing version of this in core? ie like partition-by, but taking parts up to a predicate returns false: (defn partition-with [f s] (lazy-seq (cons (take-while f s) (partition-with f (drop-while f s))))) |
| 11:18 | R4p70r | raek, Isn't a reactor pattern something the direct I/O events to various callbacks? |
| 11:20 | R4p70r | s/a reactor pattern/the reactor pattern/ |
| 11:22 | duck1123 | doesn't scala web dev make use of reactors? I seem to remember the words 'scala' and 'reactor' used in the same sentence multiple times |
| 11:25 | klauern | I think you guys are talking about this paper: http://lamp.epfl.ch/~imaier/pub/DeprecatingObserversTR2010.pdf |
| 11:42 | fliebel | This is impossible. 2 projects, both have the same core.match in lib, entering the same command on the repl, I get a different result. |
| 11:44 | tcj | I'm using clojure 1.3.0 and want to use some contrib.string (http://richhickey.github.com/clojure-contrib/string-api.html) stuff. How do I add this to a leiningen project? |
| 11:44 | lazybot | Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/string-api.html) and try to stop linking to rich's repo. |
| 11:45 | apgwoz | ... why doesn't rich just remove his repos if they're so out of date? |
| 11:45 | duck1123 | also. all the string stuff is in clojure.string now |
| 11:45 | cemerick | amalloy_: well done :-) |
| 11:45 | tcj | Will have a look, lazybot :) |
| 11:45 | cemerick | apgwoz: Unknown. |
| 11:45 | apgwoz | cemerick: ok. :) |
| 11:46 | cemerick | a message to clojure-dev would probably be worthwhile |
| 11:46 | duck1123 | tcj: So here are the new clojure.string stuff http://clojuredocs.org/clojure_core/clojure.string you don't need to add anything for them, just require (not use) clojure.string |
| 11:46 | apgwoz | i'm sure if someone asked him nicely to remove the repos, or put a big warning in the readme with instructions on where to go, he'd comply |
| 11:47 | tcj | duck1123: Thanks |
| 11:47 | dnolen | fliebel: sounds strange, what command? |
| 11:48 | dnolen | fliebel: if it seems like a bug, it would nice to have a very small set of instruction to reproduce. |
| 11:48 | fliebel | dnolen: something without a vector, so one throws an exception, while the other does not. |
| 11:48 | fliebel | dnolen: No, certainly a environment issue :( |
| 11:48 | hugod | dnolen: I am trying to match a map with a constrained set of keys, some of which are optional. I can't see a way of doing this with the current :only. Also :guards can not be or'd (I wanted a guard that matches if a key was not found or a predicate matches). |
| 11:50 | fliebel | dnolen: When was the vector-less binding introduced? |
| 11:51 | dnolen | hugod: ok, enhancement tickets please to at least get the discussions started. |
| 11:51 | hugod | dnolen: will do |
| 11:51 | fliebel | Both have 0.2.0-alpha6 in lib. |
| 11:52 | dnolen | fliebel: hmm, I think that landed in alpha5. |
| 12:01 | R4p70r | I've just seen this headline on Hacker News "GCC 4.7 adds transactional memory extensions for C/C++" http://goo.gl/kvUee Haven't read the article yet but I'm kind of curious about it. |
| 12:05 | R4p70r | That page doesn't say much. |
| 12:11 | fliebel | dnolen: http://pastebin.com/CKdhBgud http://pastebin.com/WGg1QGyb |
| 12:11 | tcj | I'm using compojure. Is there a way to assign a default value to a parameter using the compojure destructuring syntax. I read this page https://github.com/weavejester/compojure/wiki/Destructuring-Syntax and didn't see anything. I like to do something like |
| 12:11 | tcj | (defrouts name (GET [p1 (or p2 "none")] "My response here")) |
| 12:12 | dnolen | fliebel: is that the same jar, did you try replacing w/ the jar that works? |
| 12:13 | TimMc | R4p70r: Looks less powerful than Clojure's STM, |
| 12:14 | TimMc | since it probably locks pessimistically. |
| 12:16 | fliebel | dnolen: hm, will try... |
| 12:16 | fliebel | dnolen: match does not include a version number in the source, does it? |
| 12:17 | fliebel | dnolen: Are you sure it landed in alpha5? because I figured out I still had a copy hanging around in checkouts. |
| 12:18 | fliebel | *doh* |
| 12:20 | fliebel | ah, now it is at least consistently broken :) |
| 12:23 | fliebel | dnolen: Is there any way to get something more recent than 0.2.0-alpha6 via maven? |
| 12:25 | dnolen | fliebel: ah sorry, the fix is in HEAD, but release for that yet |
| 12:25 | dnolen | fliebel: I was hoping to get some bigger tickets in before cutting another alpha, but who am I kidding? :) I'll cut alpha7 tonight. |
| 12:46 | hugod | dnolen: is this expected? (let [x [:a 1 :b 1]] (clojure.core.match/match [x] [{:a _ :b _}] true)) => true |
| 12:54 | dnolen | ,(bases (type [])) |
| 12:54 | clojurebot | (clojure.lang.APersistentVector clojure.lang.IObj clojure.lang.IEditableCollection) |
| 12:54 | dnolen | ,(supers (type [])) |
| 12:54 | clojurebot | #{clojure.lang.Seqable clojure.lang.IPersistentCollection clojure.lang.ILookup java.lang.Comparable clojure.lang.Sequential ...} |
| 12:55 | dnolen | hugod: the interface I test for is clojure.lang.ILookup, not sure if there's a better one. |
| 12:56 | gfredericks | the weirdest thing about that is that [:a 1 :b 1] is not a list of pairs |
| 12:56 | dnolen | gfredericks: that has nothing to do with it, Vectors support ILookup |
| 12:56 | gfredericks | dnolen: I know, I mean from a user-expectations perspective |
| 12:57 | dnolen | those map pattern keys are wildcards, so they aren't even tested |
| 12:57 | gfredericks | oh hm |
| 12:57 | gfredericks | so (match [x] [{:a 1 :b 1}] true) would not match? |
| 12:57 | dnolen | gfredericks: it would not |
| 12:58 | gfredericks | kay that's good |
| 12:58 | gfredericks | dnolen: I used match seriously for the first time yesterday, it went quite well. |
| 13:01 | dnolen | hugod: I suppose I could add an additional type constraint - java.util.Map. But seems odd since hardly anyone would go through the hassle to implement that. |
| 13:02 | hugod | dnolen: java.util.Map? |
| 13:02 | dnolen | hugod: but I don't like that idea. You might for example want to match a vector with map pattern syntax! |
| 13:03 | dnolen | (match v [{0 3 13 :Foo}] ...) |
| 13:03 | dnolen | is kinda nice |
| 13:03 | dnolen | instead of [3 _ _ _ _ _ _ _ _ _ _ _ _ :Foo] |
| 13:04 | dnolen | hugod: I just mean check for some other thing to ensure map-like-ness, but I'm not convinced it's much of an issue. |
| 13:05 | dnolen | ,(let [{a 0 b 5} [:a :b :c :d :e :f :g :h]] [a b]) |
| 13:05 | clojurebot | [:a :f] |
| 13:05 | fliebel | dnolen: yay for release :) |
| 13:05 | dnolen | I rest my case |
| 13:06 | hugod | I can always use a guard, but just wanted to check that it was expected behaviour - I found it surprising. |
| 13:07 | dnolen | hugod: was kidding about "I rest my case". If you got better ideas - I'm listening. |
| 13:11 | TimMc | dnolen: So {:a _} means "lookup on key :a and confirm that any value is returned"? |
| 13:11 | TimMc | as opposed to (contains? :a) |
| 13:13 | fliebel | Is nil a value? |
| 13:13 | hiredman | what else would it be? |
| 13:14 | dnolen | TimMc: no, wildcards might not be tested. |
| 13:15 | dnolen | {:a _} is next to useless |
| 13:15 | dnolen | {:a a} at least will force extraction of the value. |
| 13:17 | tcj | I'm trying to create a jar from clojure code to use in a Java application. I've done ~10min of googling and see a few different solutions (Clojure.RT, and :gen-class). Is there a "preferred" way to go? I tried the gen-class method, but couldn't get it going (only spent ~5min... for some reason lein jar does not seem to create .class files in my output jar). |
| 13:20 | raek | tcj: you need to either add a ahead of time compilation entry for the namespace to the project.clj like ":aot [the.ns]" or declare the namespace as main like ":main the.ns". in both cases you need to add :gen-class to the ns form like (ns the.ns (:gen-class)) |
| 13:20 | raek | tcj: the clojure.lang.RT way is a bit simpler |
| 13:21 | tcj | raek: Thanks! |
| 13:22 | dnolen | hugod: as far required keys, got something shorter than :required ? |
| 13:26 | hugod | dnolen: :mandatory, :at-least or :enforce are the only things that spring to mind |
| 13:27 | gfredericks | :has |
| 13:27 | dnolen | gfredericks: nice |
| 13:28 | hugod | dnolen: so in the meantime, to enforce the presence of a key requires a guard expression on it's value, checking for c.c.match/not-found? |
| 13:28 | dnolen | hugod: hmm, have you tried that? |
| 13:29 | gfredericks | dnolen: also :contains would be consistent with the core function name |
| 13:29 | hugod | dnolen: nope |
| 13:30 | dnolen | gfredericks: good suggestions ticket updated. |
| 13:30 | dnolen | hugod: I don't think that will work. |
| 13:30 | dnolen | hugod: I think I feed c.c.match/not-found only for :only |
| 13:31 | gfredericks | dnolen: has it been suggested to have a similar modifier without an argument that requires all the keys listed in the pattern? e.g., :has-all |
| 13:32 | gfredericks | ({:a 1 :b 2} :has [:a :b]) <==> ({:a 1 :b 2} :has-all) |
| 13:33 | dnolen | gfredericks: not a bad idea though sugary stuff I hope other people will send patches for, I really need to tackle the remaining big things :) |
| 13:34 | gfredericks | dnolen: I just took a glance at the jira issue, did you mean to include the :has/:contains inside the map? |
| 13:36 | dnolen | gfredericks: oops thx fixed |
| 13:36 | dnolen | gfredericks: sadly we can't put things in the map since we can't reverse keys like destructuring does. |
| 13:36 | tcj | I'm trying to use Clojure from Scala (just using the Scala repl to test using Clojure from Java). One problem I've run into is that clojure.lang.RT.var conflicts with Scala's var keyword. Am I just out of luck here? |
| 13:36 | hugod | dnolen: :has/:contains still doesn't allow the restriction of which keys are present without enforcing their presence, iiuc. |
| 13:37 | dnolen | hugod: you want not-contains? |
| 13:37 | gfredericks | I suppose that's because destructuring has the luxury of requiring that keys be symbols for normal usage, whereas match allows arbitrary keys? |
| 13:38 | robbrit | is there a good clojure "package manager" like cpan or rubygems? |
| 13:38 | dnolen | gfredericks: arbitrary anything, which might mean duplicate keys |
| 13:38 | tcj | Here's what I'm seeing: |
| 13:38 | tcj | scala> RT.var("clojure.core", "require").invoke(Symbol.intern("cfr.web.core")) |
| 13:38 | tcj | <console>:1: error: identifier expected but 'var' found. |
| 13:38 | tcj | RT.var("clojure.core", "require").invoke(Symbol.intern("cfr.web.core")) |
| 13:38 | gfredericks | dnolen: the reader will allow duplicate keys? |
| 13:38 | raek | robbrit: Leiningen (which uses Maven for dependency resolution and fetching) |
| 13:39 | dnolen | gfredericks: it won't that's why we can't reverse keys like destructuring does |
| 13:39 | hugod | dnolen: more like :may-contain-only |
| 13:39 | tcj | Sorry, should have googled first. I found the solution: http://www.scala-lang.org/node/8471 |
| 13:40 | gfredericks | :may-not-contain-any-keys-other-than-these |
| 13:40 | robbrit | raek: great, thanks! |
| 13:40 | hugod | gfredericks: :) |
| 13:40 | dnolen | hugod: oh, that whatever keys are there, below to a specific set |
| 13:40 | dnolen | belong |
| 13:40 | hugod | dnolen: yes |
| 13:40 | raek | robbrit: https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md |
| 13:42 | dnolen | hugod: ok, noted on the ticket |
| 13:43 | ajsharp | i don't understand why i'm getting a tail recursion error here -- I think I'm misunderstanding something about recur |
| 13:43 | ajsharp | https://gist.github.com/1383464 |
| 13:44 | hugod | dnolen: thanks - though :has/:contains certainly looks useful too :) |
| 13:46 | gfredericks | ajsharp: your recur isn't in tail position |
| 13:46 | gfredericks | you can't use recur that way |
| 13:46 | raek | ajsharp: tail position is basically the "top level" of a function or a branch of an 'if' |
| 13:47 | ajsharp | raek: gfredericks so i can't use recur inside an if? |
| 13:47 | gfredericks | ajsharp: it has to be such that the recursive call is the last thing the function does |
| 13:47 | ajsharp | ah |
| 13:47 | ajsharp | right |
| 13:47 | raek | ajsharp: in your example 'recur' is not in tail position since the call to (:created_at ...) remains to be evaluated after the "recur" would have returned |
| 13:47 | gfredericks | you can inside an if, the issue is you have it inside a vector |
| 13:47 | gfredericks | and the :created_at that raek just mentioned |
| 13:48 | raek | ajsharp: so the important thing is that whatever (recur ...) returns should be the result of the function |
| 13:48 | raek | then it's a tail call |
| 13:48 | ajsharp | raek: gfredericks: got it, thanks much |
| 13:49 | TimMc | dnolen: Interesting. So matching against x with {:a _} where (:a x) would produce an error... might not throw an exception? |
| 13:49 | TimMc | because match might not even bother asking? |
| 13:50 | gfredericks | TimMc: why would (:a x) produce an error when x passes the type requirements? |
| 13:50 | gfredericks | a funky implementation that throws exceptions? |
| 13:50 | TimMc | Because x might be a bastard lying piece of reified fraud. |
| 13:50 | TimMc | right |
| 13:50 | dnolen | TimMc: what I mean is {:a _} without some qualifier is non-information. this could be changed, but I haven't heard anything convincing. |
| 13:50 | gfredericks | TimMc: oh those darn BLPORFs |
| 13:50 | TimMc | dnolen: Oh, I think it makes sense. I'm just curious. :-) |
| 13:51 | TimMc | GIGO |
| 13:51 | TimMc | or "Ask a stupid question..." |
| 13:54 | gfredericks | Yesterday I had a collection of objects that were either {:foo x} or {:bar y :baz z} and wanted to differentiate them with pattern matching, but ended up changing them to [:foo x] and [:bar y z] |
| 13:54 | gfredericks | since it seemed to fit core.match better |
| 13:55 | gfredericks | may have been a better representation of the data anyhow |
| 13:56 | dnolen | gfredericks: hugod: all this is good feedback, stuff to ponder ... |
| 14:06 | TimMc | gfredericks: So you needed to find out if they had a certain key? |
| 14:06 | TimMc | Or you could have an additional field :type -> :foo |
| 14:11 | gfredericks | TimMc: yeah, a :type field would have worked. Certainly I could have done it with guards, but that was more verbose than I wanted. |
| 14:12 | gfredericks | doing the vector thing ended up being a lot more syntactically distinct, and it wasn't important enough code to care how readable it is next week |
| 14:12 | gfredericks | s/distinct/succinct |
| 14:13 | duck1123 | I find that lazybot actually doing that replacement is usually a bit much |
| 14:14 | duck1123 | I'm perfectly capable of doing a simple word replacement in my head |
| 14:16 | amalloy | duck1123: yeah, that's why we turned it off |
| 14:18 | hiredman | technomancy: google wave, it's the future |
| 14:19 | srid | no more clojure; need to rewrite my project in python (thinking of using gevent - to replace lamina-based code) |
| 14:20 | technomancy | hiredman: I'm all for retro-futurism |
| 14:20 | hiredman | technomancy: you've seen http://www.paleofuture.com/ ? |
| 14:20 | hiredman | well, I guess they moved |
| 14:20 | hiredman | http://blogs.smithsonianmag.com/paleofuture/ |
| 14:21 | technomancy | yeah, a while ago, but I had forgotten it; thanks |
| 14:21 | TimMc | amalloy: I just got in the habit of putting a space in front of my s/.../.../ |
| 14:23 | Raynes | amalloy: No, we turned it off because people whined like baby pigs. I'm not going to sugarcoat it. |
| 14:23 | licenser | cemerick: I finished the translation :) |
| 14:24 | cemerick | licenser: nice, send a pull req :-) |
| 14:24 | Raynes | cemerick: I demand that my conversation be posted immediately. |
| 14:24 | licenser | aye aye :) |
| 14:24 | Raynes | Or I withdraw your rights to my beautiful voice. |
| 14:24 | Raynes | Your rights? Some legal thing. |
| 14:25 | cemerick | Raynes: are you having a conversation with yourself now? ;-) |
| 14:25 | Raynes | I hope not. |
| 14:25 | cemerick | I was going to combine yours and Chris' into one, since they were on the shorter side. |
| 14:25 | Raynes | That sounds good. |
| 14:25 | cemerick | Wasn't planning on it until next week. |
| 14:26 | Raynes | I was kidding about immediately. |
| 14:26 | Raynes | You can have a week. ;) |
| 14:26 | cemerick | That's good, 'cause it wasn't gonna happen this week. ;-) |
| 14:26 | Raynes | You would have given in. |
| 14:27 | licenser | also Raynes clj-highlight is updated to clojure 1.3.0 |
| 14:28 | Raynes | Neat |
| 14:28 | devn | How would one implement "method_missing" using multimethods? |
| 14:28 | Raynes | devn: :default |
| 14:28 | hugod | dnolen: c.c.match/not-found seems to be getting passed to the guard quite happily. I'm finding (defn key-found? [x] (not= x :clojure.core.match/not-found)) to be useful. |
| 14:28 | hugod | |
| 14:28 | devn | Raynes: ah yes, thanks |
| 14:28 | cemerick | Raynes: most other times, probably. :-) |
| 14:28 | devn | also, fastest way to take {:a 1 :b [2 3 4]} and get (:a 1 :b [2 3 4]) |
| 14:29 | devn | I'm doing something silly |
| 14:29 | TimMc | &(apply concat {:a 1 :b [2 3 4]}) |
| 14:29 | lazybot | ⇒ (:a 1 :b [2 3 4]) |
| 14:29 | devn | duh. I was even using concat |
| 14:31 | dnolen | hugod: ok, good to know :) |
| 14:31 | TimMc | devn: I'm probably complecting some things there. :-P |
| 14:32 | gfredericks | TimMc: the simple way to do it is (constantly '(:a 1 :b [2 3 4])) |
| 14:32 | TimMc | haha |
| 14:32 | TimMc | You've been doing too much 4clojure. |
| 14:32 | gfredericks | no reason to complect output with input |
| 14:33 | TimMc | nice |
| 14:47 | gfredericks | I'm thinking about writing tests for an existing java web app. Is the simplest method to deploy it to a server (tomcat?) and test it as a black-box HTTP server? |
| 14:48 | gfredericks | and if I go that route, do I want to use enlive? |
| 14:48 | gfredericks | (not very familiar with it) |
| 14:48 | TimMc | I'm finding enlive's documentation problematic. |
| 14:48 | TimMc | The lack of it, you see. |
| 14:48 | tcj | I'm trying to run a some Clojure code from Java. I ran 'lein uberjar' to create a jar file (all my files are .clj files in the resulting jar). I can then us this using clojure.lang.RT in a Scala REPL. Now I'm trying to use this in Tomcat and getting a FileNotFoundException saying it can't find a .clj file on my classpath. I'm stuck... The jar is in the correct place for Tomcat to see it. Any... |
| 14:48 | tcj | ...idea why Tomcat doesn't fine my .clj file? |
| 14:49 | gfredericks | TimMc: I don't imagine you have an alternative in mind? |
| 14:50 | TimMc | gfredericks: Not yet. :-( |
| 14:50 | TimMc | tcj: I thought uberjar AOT'd all the clj. |
| 14:50 | ibdknox | hah korma ended up on HN again.. For those wanting to hear more about why I wrote it despite ClojureQL's existence: http://news.ycombinator.com/item?id=3261479 |
| 14:51 | tcj | TimMc: There are .class files for everything except for my files |
| 14:51 | tcj | I'm still confused why this works in a Scala REPL, but not in Tomcat |
| 14:53 | hiredman | tcj: tomcat != scala repl |
| 14:53 | hiredman | the environments are different (the most likely do different kinds of classloader tricks) |
| 14:54 | tcj | hiredman: Thanks. Understood. I guess I'm looking for somebody that has experience running Clojure from Tomcat using clojure.lang.RT |
| 14:54 | hiredman | the fact that code behaves differently in different environments should not be surprising |
| 14:55 | tcj | I feel like I have a pretty good grasp of Tomcat's classloading... Anything in WEB-INF/lib should be in the app's classpath |
| 14:56 | tcj | I guess i'll dig into the RT code to see how it uses the CP to load files |
| 14:56 | hiredman | tcj: what makes you say that? (about WEB-INF/lib) |
| 14:56 | tcj | ibdknox: You wrote korma? Thanks! I've been using and like it. |
| 14:57 | ibdknox | tcj: you're quite welcome :) |
| 14:57 | tcj | hiredman: the docs at tomcat.apache.org |
| 14:57 | hiredman | tcj: WEB-INF is a war thing, you mentioned jars |
| 14:58 | devn | ibdknox: extra korma love from me |
| 14:59 | tcj | hiredman: thanks. |
| 15:07 | mefesto | tcj: i've used tomcat to load some clojure code from java ... been a while though. |
| 15:08 | mefesto | tcj: have an example of how you are working with the clj files? |
| 15:09 | Raynes | devn: So, is pair.io awesome? |
| 15:09 | Raynes | I bet it's awesome. |
| 15:10 | tcj | mefesto: RT.var("clojure.core", "require").invoke(Symbol.intern("cfr.web.core")); return RT.var(ns, function); |
| 15:10 | devn | Raynes: It's pretty great. |
| 15:10 | devn | I could show it to you later if you'd like to pair |
| 15:11 | Raynes | I don't have an account. |
| 15:11 | tcj | mefesto: it blows up with this message: java.io.FileNotFoundException: Could not locate cfr/web/core__init.class or cfr/web/core.clj on classpath: |
| 15:11 | devn | You don't need one Raynes. You wont be able to administer the instance, but I could invite you to pair |
| 15:11 | Raynes | Oh. Awesome! |
| 15:11 | Raynes | Sure then, ping me. |
| 15:11 | devn | will do |
| 15:11 | devn | back to work for now :) |
| 15:12 | Raynes | Likewise. |
| 15:12 | mefesto | tcj: and that file is definitely bundled in your war? either in WEB-INF/classes or in a jar under WEB-INF/lib ? |
| 15:12 | tcj | mefesto: Yes |
| 15:12 | tcj | I've triple checked it |
| 15:12 | tcj | inspected the jar |
| 15:14 | mefesto | tcj: just for debugging to make sure that resource is available, in your java code can you log the result of something like: Thread.getCurrentThread().getContextClassLoader().getResource("path/to/clj/file"); |
| 15:16 | tcj | mefesto: I think this may be something wrong on my end (surprise! :) The (uber) jar has clojure.lang.RT.class in it, but that class it not found. I discovered this after I removed clojure.jar from my classpath (it should be redundant with the uber jar, I think). |
| 15:17 | mefesto | tcj: so you have the clojure.jar in tomcat's shared lib dir? |
| 15:18 | tcj | mefesto: No, it was in my app's WEB-INF/lib dir |
| 15:18 | mefesto | the error message you pasted earlier doesn't complain about RT not being there ... instead it's specifically complaining about the clj file you are trying to load: cfr/web/core.clj |
| 15:19 | tcj | mefesto: I found the problem |
| 15:19 | tcj | INFO: validateJarFile(/home/ian/work/cfr/target/cfr-0.0.36/WEB-INF/lib/cfr-1.0.0-standalone.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class |
| 15:19 | tcj | I'm using compojure, which I'll be included the Servlet.class |
| 15:19 | tcj | Teach me to look at my logs :) |
| 15:20 | tcj | mefesto: Thanks for the help debugging! |
| 15:20 | mefesto | you shouldn't be bundling the servlet api classes with your war files ... is that what you think is happening? |
| 15:20 | ibdknox | tcj: you should try out Noir ;) |
| 15:20 | technomancy | that's twice in an hour I've wished for :when-let inside a for call |
| 15:20 | technomancy | wonder what that means |
| 15:20 | tcj | mefesto: I agree. I didn't realize I was.. |
| 15:21 | gfredericks | given I have a generic java web-app which I've been able to deploy to tomcat easily, should it also be straightforward for me to use jetty to test it? |
| 15:21 | gfredericks | (instead of tomcat, which I imagine would be a lot more sluggish) |
| 15:21 | mefesto | tcj: maybe you have the servlet api listed under :dependencies instead of :dev-dependencies ? |
| 15:21 | mefesto | tcj: if you're using leiningen ... not sure if that's the case |
| 15:22 | amalloy | technomancy: i want it fairly often. it'd be nice to have but probably not worth the syntax pollution |
| 15:22 | mefesto | tcj: i think you said you were using lein uberwar so maybe so :) |
| 15:22 | technomancy | amalloy: pollution is more onerous when it results in new top-level vars |
| 15:23 | tcj | mefesto: No servlet API, just compojure and some other stuff. I'm pretty sure it's compojure. I'll just do a normal jar and include the necessary jars in my Tomcat app |
| 15:24 | ibdknox | does anyone know of a simple way to format currency? (add commas and such) |
| 15:24 | amalloy | technomancy: i agree, but it's still more complexity/load to remember and document inside of for |
| 15:24 | tcj | ibdknox: I'll prolly eventually go to noir, but I want to start from the beginning. From what I understand, Noir builds on ring and compojure? |
| 15:24 | ibdknox | tcj: it does indeed |
| 15:24 | technomancy | amalloy: I agree enough to just gripe about it on IRC and not open a jira ticket |
| 15:24 | mefesto | gfredericks: it should be. you might find jetty to be nicer :) |
| 15:24 | brehaut | ibdknox: i *think* format should be able to do that with the right gibberish |
| 15:24 | ibdknox | brehaut: I see... *goes to read more about format* |
| 15:25 | amalloy | good, good. we're on the same side then. as you were |
| 15:25 | gfredericks | mefesto: kay, cool. Also I was making sure I wasn't ignoring any easier option. |
| 15:26 | ibdknox | or there's also java.text.NumberFormat :D |
| 15:27 | mefesto | is clj-http top of the heap as far as clojure http clients go? |
| 15:27 | amalloy | ibdknox: yeah, java has a built-in currency formatter somewhere |
| 15:28 | hiredman | mfoemmel: yes |
| 15:28 | ibdknox | yep, for future reference: (.format (NumberFormat/getCurrencyInstance) 32049852) |
| 15:29 | brehaut | i wonder if format should be extended to take a string or a java.text.Format instance? |
| 15:32 | scottj | does clj-http support just downloading the headers, not the actual content? (idk, does http support that?) |
| 15:33 | mefesto | scottj: that would be an http HEAD request |
| 15:33 | brehaut | scottj: although HEAD is only a GET without the content; theres no provision for a POST without content beside what the server implements itself |
| 15:34 | brehaut | (because that would be meaningless) |
| 15:34 | scottj | ahh so clj-http.client/head |
| 15:42 | brehaut | ibdknox: i think the gibberish for format i was thinking of was (format "%,(.2f" (double 32049852)) and its not workable because if the number is negative, then you cant get the $ sign inside the parens as best i can tell |
| 15:53 | oreills | Hi all |
| 15:55 | gfredericks | ,(println "oreills: hi.") |
| 15:55 | clojurebot | oreills: hi. |
| 15:56 | oreills | Haha, very nice! |
| 15:56 | oreills | ,(println "Hello, world") |
| 15:56 | clojurebot | Hello, world |
| 16:01 | ibdknox | dsantiago: Got a stencil question for you |
| 16:01 | oreills | Has anyone had any luck setting up http://clojars.org/org.clojars.ibdknox/lein-nailgun with Clojure 1.3? |
| 16:03 | ibdknox | oreills: I haven't had any issues |
| 16:03 | oreills | Heh, seems like I asked that at a good moment. =P |
| 16:04 | oreills | When I install it as a leiningen plugin, lein starts kicking up errors and refuses to work until I delete the plugin from .lein/plugins/ |
| 16:04 | ibdknox | what version of lein? |
| 16:05 | oreills | Installed from bootstrap: Leiningen 1.6.2 on Java 1.6.0_22 OpenJDK 64-Bit Server VM |
| 16:06 | ibdknox | oreills: and what are the errors you're getting? |
| 16:06 | oreills | Hangon, I'll stick it in pastebin |
| 16:06 | devn | Anyone here running the new Java release for OSX? |
| 16:07 | devn | I thought I'd hold off for a bit until I knew it didn't break muh clojures. |
| 16:07 | hiredman | the beta? |
| 16:07 | hiredman | runs fine |
| 16:07 | devn | hiredman: iyes |
| 16:07 | devn | hiredman: cool, thanks |
| 16:07 | hiredman | haven't tried any ui stuff |
| 16:09 | chouser | technomancy: emacs starter-kit is fantastic. That plus evil and about one week of usage and I'm pretty productive in emacs. |
| 16:10 | oreills | ibdknox: http://pastebin.com/cncs0Gvv |
| 16:11 | ibdknox | likely due to the JVM mismatch |
| 16:12 | ibdknox | try to clone the repo and install it, then plugin install |
| 16:12 | oreills | Ok, thanks very much, will give it a try. =) |
| 16:15 | scgilardi | ah, specific evil. cool. |
| 16:16 | technomancy | chouser: sweet; glad to hear it |
| 16:16 | gfredericks | is enlive not appropriate for http testing? Glancing through the code suggests it just does GETs? |
| 16:18 | TimMc | devn: What is pair.io? |
| 16:18 | brehaut | gfredericks: (enlive/html-snippet (:content (request something))) i think ? |
| 16:18 | TimMc | gfredericks: Use something else to get the data; feed the string to enlive. |
| 16:19 | devn | TimMc: Pure unadulterated awesome? |
| 16:19 | brehaut | enlive just uses the (not particular sophisticated) java url plumbing to fetch remote resources |
| 16:19 | technomancy | TimMc: http://pair.io has a video that explains it pretty well |
| 16:19 | gfredericks | TimMc: okay, so clj-http for the http part and enlive for the assertions? |
| 16:19 | devn | TimMc: heh, it's zkim's (clojuredocs) setup for spawning AWS instances with default templates |
| 16:20 | devn | TimMc: on top of that you can invite github users to your repo, it imports their pubkey into the instance |
| 16:20 | devn | TimMc: finally, you can save off an image for use later, or save the full current state of the image so you can resume where you left off |
| 16:20 | TimMc | technomancy: Call me old fashioned, but I prefer to skim over several paragraphs of text rather than subject myself to a forced audio/video linearization of a topic. |
| 16:21 | TimMc | devn: So, um... what does it *do*? |
| 16:21 | TimMc | Run websites? |
| 16:22 | TimMc | technomancy: Also, no headphones. |
| 16:22 | gfredericks | like heroku for tmux? |
| 16:23 | TimMc | or vice versa |
| 16:23 | gfredericks | or something |
| 16:27 | gfredericks | I just realized this app is a client-heavy javascript app :| |
| 16:29 | gfredericks | dangit I need some kind of crazy browser simulator. There's nothing clojure-oriented in that arena is there? |
| 16:29 | ajsharp | is there a way to see in the docs or otherwise all the functions available to say, a hash map? |
| 16:30 | gfredericks | ajsharp: there's that whatsit-doohicky what cemerick made |
| 16:30 | gfredericks | ajsharp: http://www.clojureatlas.com/ |
| 16:30 | cemerick | gfredericks: that's what I should've called it from the start |
| 16:30 | ajsharp | haha |
| 16:30 | ajsharp | whatsit-doohickey |
| 16:30 | brehaut | cemerick: was the domain already taken? |
| 16:31 | cemerick | brehaut: that's *always* the problem |
| 16:31 | cemerick | brehaut: saw you released. Congrats, looks nice. :-) |
| 16:31 | brehaut | cemerick: thanks :) |
| 16:31 | gfredericks | cemerick: I had the complementary problem. I snagged lolwaffle.com but had not a clue how to make a million dollars with it. |
| 16:31 | brehaut | i feel the need to make a better CSS file for it now ;) |
| 16:32 | gfredericks | ajsharp: the clojure cheatsheet can be helpful too |
| 16:33 | ajsharp | gfredericks: aren't there ways to introspect on types in clojure? |
| 16:33 | cemerick | gfredericks: I have about a dozen domains like that :-) |
| 16:33 | brehaut | cemerick: id like to have a few people bash on it in the wild before trying to get it onto wordpress |
| 16:34 | cemerick | brehaut: understood. |
| 16:34 | brehaut | the domain registration industry would collapse if nerds stopped speculating on random fun domains |
| 16:34 | gfredericks | I think becausetheluckystiff.com might be still available |
| 16:34 | cemerick | brehaut: I'd help, but I can't let my yak-shaving descend into running a blog myself, etc. |
| 16:35 | gfredericks | ajsharp: the functions that you'd typically use to handle maps are not instance methods of the map type |
| 16:35 | brehaut | cemerick: thats no problem |
| 16:35 | gfredericks | ajsharp: so it depends on what exactly you're after |
| 16:35 | brehaut | i send a pull request to marginalia; no idea if they will accept it |
| 16:35 | ajsharp | gfredericks: right, but like, for ruby, i'll often look at the docs for the Enumerable module |
| 16:36 | brehaut | and seancorfield has expressed interest in getting it going himself |
| 16:36 | cemerick | brehaut: fixed that for you: https://twitter.com/#!/cemerick/statuses/138730619369816064 |
| 16:36 | brehaut | cemerick: awesome :) |
| 16:37 | gfredericks | ajsharp: I guess things aren't really organized that way. There are the two resources I mentioned, and also lazybot's findfn feature can be quite useful |
| 16:37 | ajsharp | i see |
| 16:37 | gfredericks | $findfn {:foo "bar"} :baz :bang :bang |
| 16:37 | lazybot | [clojure.core/if-not clojure.core/dosync clojure.core/sync clojure.core/with-loading-context clojure.core/with-redefs clojure.core/condp clojure.core/get clojure.core/and clojure.core/locking clojure.core/io! clojure.core/when clojure.core/trampoline] |
| 16:37 | ajsharp | cemerick: i presume this is why you're building clojureatlas?? |
| 16:37 | lazybot | ajsharp: Definitely not. |
| 16:37 | gfredericks | haha weird |
| 16:38 | ajsharp | hrm |
| 16:38 | wilkes | ajsharp: you can also checkout http://clojure.org/sequences and http://clojure.org/data_structures |
| 16:38 | cemerick | ajsharp: this, being? |
| 16:38 | cemerick | The project's rationale is below the fold. |
| 16:38 | cemerick | Sadly falling behind at the moment. seancorfield is going to whack me one if I don't get 1.3 up there, pronto. |
| 16:39 | ajsharp | yea, so far what i see looks interesting |
| 16:39 | ajsharp | i'm definitely finding myself missing the introspection of ruby as a way to discover what i can do with an object / type |
| 16:40 | gfredericks | ajsharp: also I believe basic questions are welcome in #clojure. Especially hairy questions about manipulating data structures people seem to have fun with. |
| 16:42 | cemerick | ajsharp: the operations available for a particular type of value in Clojure are an open set. The tradeoff is that you have very, very few base types, and tons of operations that work with them, so composition is natural and *expected* in Clojure, rather than something you need to design for explicitly. |
| 16:42 | gfredericks | (inc cemerick) |
| 16:42 | lazybot | ⇒ 8 |
| 16:42 | cemerick | That's not actually a tradeoff, more like just one way that Clojure is OP. :-P |
| 16:42 | gfredericks | ^ I knew there was something to say along those lines, but didn't know what it was :) |
| 16:43 | cemerick | The actual tradeoff is that you can't just do (dir some-value), and instantly know what operations can be used with values of that type. |
| 16:43 | hiredman | ~#9 |
| 16:43 | clojurebot | 9. It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures. |
| 16:43 | ajsharp | cemerick: awesome, thanks, that's very helpful |
| 16:44 | wilkes | ajsharp: it's a big part of the learning curve. It's disorienting at first but a fair tradeoff in the long run |
| 16:44 | cemerick | hiredman: you should have clojurebot emit "— Perlis, http://www.cs.yale.edu/quotes.html" at the end of each quote. |
| 16:45 | cemerick | That may be the most useful bot command ever, though. |
| 16:45 | cemerick | ~#119 |
| 16:45 | clojurebot | 119. Programming is an unnatural act. |
| 16:45 | cemerick | That takes care of a lot of the others. |
| 16:49 | oreills | ibdknox: Still no luck, am I meant to plugin install ibdknox/lein-nailgun or scott/lein-nailgun? The lein install creates a file in ~/.m2 called scott/lein-nailgun : http://pastebin.com/C4nh3tJz |
| 16:49 | TimMc | ~#55 |
| 16:49 | clojurebot | 55. A LISP programmer knows the value of everything, but the cost of nothing. |
| 16:50 | nickik | cemerick: Have you seen the Standford-Class on Probabilistic Graphical Models. I have read your conj slides and I hope this class will help me understand them :) |
| 16:52 | TimMc | (inc hiredman) |
| 16:52 | lazybot | ⇒ 6 |
| 17:01 | mebaran151 | I'd like to teach lein to use a 32 bit jvm. I have both Java 1.6 and Java 1.7 installed. What's the best way to set up a project to use the 32 bit jvm (have to interact with an old school ODBC database...) |
| 17:02 | cemerick | nickik: I did. Her book is very good. |
| 17:02 | TimMc | mebaran151: It can't do 32-bit by default? |
| 17:02 | technomancy | mebaran151: set the JAVA_CMD environment variable |
| 17:02 | cemerick | Or, I should say, very good from my thumbing through it. I happened to choose the Darwiche, but either will likely do just fine. |
| 17:02 | technomancy | or use update-java-alternatives if you use a debian-based system |
| 17:02 | TimMc | Oh I see, you just want to select a JVM. |
| 17:09 | nickik | cemerick: Have you been to Standford? I will have to stuide up on math befor I can take the class. I will do the algorithems class for sure (im only self taught and lack some basics) and I hope I will have time for one other class. Either ML or PGM (or AI but thats not jet offered). Not sure witch one is preferable. |
| 17:10 | cemerick | nickik: nope, never been to Stanford |
| 17:11 | cemerick | I'm self-taught too. |
| 17:11 | cemerick | Though, I hope people take that as a cautionary tale and not a recommendation. :-) |
| 17:15 | nickik | cemerick: I wanted to go to collage next year but the will trie to get me to programm everything in java or c++. So maybe Ill to an Experiment on my self and embrace chances offered by standford. |
| 17:16 | gfredericks | is there a way with leiningen to do "provided" dependencies? |
| 17:16 | nickik | Thats more of a creazy idea then a plan. |
| 17:16 | cemerick | nickik: learning how Java works isn't the worst thing in the world if you really want to understand Clojure top to bottom. |
| 17:18 | mebaran151 | technomancy: thanks! anyway to tell that directly to the lein project? |
| 17:19 | mebaran151 | rather than polute the environment (I'm running off of Windows Powershell) |
| 17:20 | gfredericks | maybe that's not really what I want anyhow |
| 17:20 | gfredericks | or maybe it is |
| 17:20 | technomancy | no, it can't be checked into the project |
| 17:20 | gfredericks | if I want to avoid (Class/forName ...) everywhere |
| 17:20 | technomancy | usually JAVA_CMD is specific to the machine you're on anyway |
| 17:23 | gtrak | gfredericks, you could do the eval approach |
| 17:24 | gfredericks | gtrak: eval! dang thing is so shunned I forgot it existed. |
| 17:25 | gtrak | they do that trick in clojure.tools.logging to compile at runtime, with a class that might not exist in the classpath |
| 17:26 | gtrak | gfredericks, https://github.com/clojure/tools.logging/blob/7694fd2067e3366b63b50dc698c32da17488ea10/src/main/clojure/clojure/tools/logging/impl.clj#L82 |
| 17:26 | oreills | How do I install a lein plugin after cloning the repo? I've tried lein install and it's created a folder in ~/.m2/repositories, but how do I now point lein plugin install at that location rather than the central repos? |
| 17:27 | mebaran151 | technomancy: thanks, yeah this project is weird; I have to interface with an old 32 bit odbc sybase db, so I'm little bit pickier with regard to my jvm than I usually would be |
| 17:28 | technomancy | yeah, leiningen doesn't really attempt to manage system-level dependencies |
| 17:28 | technomancy | it's outside the scope |
| 17:29 | gfredericks | gtrak: looks right |
| 17:29 | gtrak | oreills, when you do a lein plugin install, it copies it to a folder whose name escapes me |
| 17:29 | duck1123 | ~/.lein/plugins |
| 17:29 | clojurebot | Excuse me? |
| 17:29 | gtrak | oreills, ~/.lein/plugins$ ls |
| 17:29 | gtrak | lein-eclipse-1.0.0.jar ritz-0.1.7.jar swank-clojure-1.3.2.jar |
| 17:30 | oreills | lein plugin install seems to fetch from clojars/maven repos and copy to ~/.lein/plugins |
| 17:30 | oreills | I've tried copying the jar generated from lein install there manually |
| 17:30 | oreills | But it's giving me lein errors still |
| 17:30 | technomancy | oreills: you should be able to do "lein plugin install" if you've done the regular "lein install" |
| 17:31 | R4p70r | Does anyone have an idea for a simple Clojure project that can benefit the community? Look into some bug or develop a simple lib maybe. |
| 17:32 | oreills | technomancy: Using the original url? e.g. lein plugin install org.clojars.ibdknox/lein-nailgun "1.1.1" |
| 17:32 | technomancy | it's not a URL, but yeah |
| 17:33 | mebaran151 | ah technomancy, I found a cleverer hack: I just launch lein from a 32 bit version of powershell and Windows handles the rest |
| 17:33 | technomancy | just match whatever's in project.clj |
| 17:34 | oreills | Yeah, it seems to install, but then it makes lein throw "java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>" errors for every task after that |
| 17:34 | oreills | I guess I haven't got the right environment for the plugin |
| 17:35 | technomancy | sounds like the plugin is broken |
| 17:35 | oreills | ibdknox said I should clone the repo, install it and then install plugin because of a JVM mismatch |
| 17:36 | oreills | Am I causing problems using openjdk? |
| 17:36 | oreills | Should update-java-alternatives to sun and then reinstall lein? |
| 17:36 | technomancy | nah, openjdk works fine |
| 17:37 | oreills | Hm. =/ Could it be a 64bit thing then? |
| 17:37 | technomancy | I don't think so |
| 17:38 | oreills | Hm, ok, I'll just submit a bug report on github, then, unless you have any other advice? |
| 17:41 | technomancy | you'll have to run it by him |
| 17:41 | oreills | Ok, thanks very much for your time. |
| 17:42 | oreills | Also, thanks very much for leiningen, it's brilliant. I was dreading getting clojure set up on another laptop and the bootstrapping made it take about 5 mins. =) |
| 17:44 | technomancy | heh; great |
| 17:45 | gfredericks | if I do (eval '(new foo.bar.Baz)) and nobody has loaded Baz yet, will it still work? |
| 17:45 | oreills | Am off, see you later |
| 17:45 | oreills | Thanks again |
| 17:47 | gfredericks | hm, eval doesn't see locals :/ |
| 17:48 | hiredman | clojure doesn't have reified environments |
| 17:48 | hiredman | (at runtime) |
| 17:49 | gfredericks | Guess I can pass something in with a dynamic var? |
| 17:49 | hiredman | best to think on it |
| 17:49 | hiredman | you most likely don't need eval |
| 17:50 | gfredericks | hiredman: I'm using classes not available at compile time |
| 17:50 | gfredericks | so else I could do Class/forName |
| 17:50 | hiredman | and? |
| 17:50 | gfredericks | which I mentioned earlier and it was suggested I do eval instead |
| 17:50 | hiredman | right, you could just use reflection |
| 17:50 | gfredericks | so I suppose you're saying eval is worse instead of better |
| 17:51 | hiredman | well, I dunno, possible whoever it was the suggested it have more information available |
| 17:51 | hiredman | you could also consider using clojure.lang.Reflector directly |
| 17:51 | hiredman | basically you are using eval as a wrapper for it |
| 17:53 | gtrak | hiredman, I suggested it, I pulled it out of my ass :-) |
| 17:53 | gfredericks | Reflector/invokeConstructor I suppose is what I need |
| 17:53 | gfredericks | still will be doing Class/forName, but oh well |
| 17:53 | gfredericks | the var trick didn't even work for some reason |
| 17:53 | hiredman | var trick? |
| 17:54 | gfredericks | (def ^:dynamic eval-arg) |
| 17:54 | gfredericks | then (binding [eval-arg ...] (eval '(new Foo eval-arg))) |
| 17:55 | gtrak | gfredericks, i think what you want there is a macro |
| 17:55 | gfredericks | maybe it has to be fully qualified? |
| 17:55 | gfredericks | gtrak: eh? |
| 17:55 | gtrak | ah, that might work |
| 17:56 | amalloy | gfredericks: ` is way better than ' here |
| 17:56 | amalloy | if you're going to be eval-ing |
| 17:56 | gfredericks | amalloy: good tip |
| 17:57 | gfredericks | amalloy: wait will that not trip up on the non-existent class? |
| 17:57 | gfredericks | if the class isn't available and my method is never called then nothing should break |
| 17:57 | amalloy | well Foo wouldn't work anyway |
| 17:58 | amalloy | but com.bar.Foo would probably be unaffected by whether you use ' or ` |
| 17:59 | gfredericks | ah right |
| 17:59 | gfredericks | of course |
| 17:59 | mebaran151 | I'm having a little bit of swank trouble; installed the lein swank plugin but clojure-jack-in fails with an invalid unicode escape |
| 17:59 | mebaran151 | maybe my emacs is out of date? |
| 18:00 | mebaran151 | I just resurrected my Clojure environment for this new project, so the toolkit got a little rusty |
| 18:00 | gfredericks | dang. Creating a jruby array doesn't seem to be as simple as you'd expect |
| 18:02 | headius | gfredericks: how so? |
| 18:02 | mebaran151 | exact error is non-hex digit used for unicode escape |
| 18:02 | gfredericks | headius: I'm looking at http://www.docjar.com/docs/api/org/jruby/RubyArray.html |
| 18:02 | gfredericks | headius: can't do anything without acquiring one of them Ruby objects |
| 18:02 | headius | that's correct; because we have a lot of runtime state, you need to associate it with some jruby runtime |
| 18:03 | gfredericks | headius: isn't there only one Ruby though? |
| 18:03 | headius | certainly not |
| 18:03 | headius | there can be arbitrarily many with their own classes, etc |
| 18:03 | headius | or just one |
| 18:04 | hiredman | how else would you get fast forking on the jvm? |
| 18:04 | headius | hah |
| 18:04 | gfredericks | oh I should have read through the second sentence in the docs there |
| 18:04 | headius | well, we can certainly spin up isolated ruby environments :) |
| 18:04 | mebaran151 | also when I use slime-connect |
| 18:04 | mebaran151 | it fails unexpectedly, without any error, as though it connected, but the slime buffer doesn't pop up |
| 18:04 | hiredman | clojure, sort of painfully, makes you fiddle with classpaths |
| 18:05 | gfredericks | headius: so is there a method here for getting the "default"? Do I even know what I'm talking about? |
| 18:05 | gfredericks | ah, I see a getDefaultInstance method :) |
| 18:06 | gfredericks | or maybe getCurrentInstance |
| 18:13 | hiredman | ~#68 |
| 18:13 | clojurebot | 68. If we believe in data structures, we must believe in independent (hence simultaneous) processing. For why else would we collect items within a structure? Why do we tolerate languages that give us the one without the other? -- Alan J. Perlis |
| 18:35 | Raynes | dakrone: ping |
| 18:35 | dakrone | Raynes: pong |
| 18:37 | Raynes | dakrone: https://github.com/Raynes/tentacles/blob/master/src/tentacles/repos.clj#L214 is the stuff I was working on that requires multipart (I didn't know it at the time). Just something you can work with to test, if you so desire. |
| 18:38 | dakrone | okay, I'll take a look and see if I can get the multipart uploads working |
| 18:45 | Raynes | dakrone: In other news, thanks for the awesome work maintaining clj-http. It has been a total breeze to use. |
| 18:46 | dakrone | Raynes: glad to hear it, thanks for the feedback |
| 19:01 | patchwork | what repository can I get algo.generic from? it is not on clojars.org |
| 19:01 | hiredman | clojure.org stuff is all in the sonatype oss repos |
| 19:02 | patchwork | Hmm… this one? |
| 19:02 | hiredman | if it doesn't have a release it is in the snapshot repo, otherwise release |
| 19:02 | patchwork | :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"} |
| 19:02 | hiredman | https://oss.sonatype.org/content/repositories/snapshots/ is the snapshot repo |
| 19:02 | patchwork | Aha |
| 19:04 | patchwork | Hmm, lein still fails to find it: |
| 19:04 | patchwork | [INFO] Unable to find resource 'org.clojure:algo.generic:jar:0.1.0-SNAPSHOT' in repository sonatype-oss-snapshots (https://oss.sonatype.org/content/repositories/snapshots/) |
| 19:04 | hiredman | is that a good version for algo.generic? |
| 19:05 | patchwork | Aha, it is at 1.1 |
| 19:05 | patchwork | I am trying to use a project that is including it |
| 19:05 | patchwork | *requiring it |
| 19:05 | patchwork | and apparently they have the wrong version in there |
| 19:05 | patchwork | : ( |
| 19:07 | patchwork | So I can just override this in my local project |
| 19:07 | patchwork | and it will figure it out |
| 19:12 | brehaut | how do i get emacs to recompile and reload elisp ? |
| 19:23 | moogatronic | I'm trying to perform an operation on each line of a file with (with-open … (doseq [line]) … but I also need to aggregate counts of things I find inside of each line I have a (reduce f {} col) going on in there. I'm a FN noob and am having trouble reasoning about how to "save" my map from line to line… |
| 19:26 | alex_baranosky | moogatronic: reductions, maybe? |
| 19:28 | moogatronic | in my mind I need to somehow preserve the map I generate in my reduce and pass it back into the next "iteration" of the doseq, but i don't know how to do that. |
| 19:28 | moogatronic | or if that's what i should really be doing. heh. |
| 19:29 | bhenry | moogatronic: is the file too big to hold the seq in memory? |
| 19:29 | hiredman | sounds like you want reduce |
| 19:30 | hiredman | why do you have doseq? |
| 19:30 | moogatronic | (with-open [rdr (io/reader in)] (doseq [line (line-seq rdr)] …) |
| 19:31 | moogatronic | well, i guess i'm not really producing any output this time.. |
| 19:31 | moogatronic | maybe i don't need doseq |
| 19:31 | hiredman | why do you have a doseq? |
| 19:31 | moogatronic | I have some more code in the body that is reducing maps that I create from the values in the Input file's line. |
| 19:32 | hiredman | why do you have a doseq? |
| 19:32 | moogatronic | hiredman: my answer is that i"m a noob and I found an example that had doseq and copied it. |
| 19:32 | moogatronic | because another part of my program had to produce output from simple text processing as well. |
| 19:32 | hiredman | unless you know why you are using something, stop using it |
| 19:32 | moogatronic | bhenry: yeah, way too big. |
| 19:33 | bhenry | moogatronic: (reduce your-fn-here {} (line-seq rdr)) |
| 19:33 | moogatronic | hiredman: obviously, but I can't magically generate knowledge without trying thigns. |
| 19:33 | moogatronic | and reading, and trying and googling and asking ,etc. |
| 19:34 | moogatronic | bheary: yeah, i think that is probably what i need to do. |
| 19:34 | hiredman | moogatronic: yes, but unless you have a theory, you are just flailing around, you aren't learning |
| 19:35 | moogatronic | hiredman: I had an incorrect theory based on prior success at another task earlier in the day. that is all. |
| 19:35 | hiredman | ok, so you just didn't want to share your theory? |
| 19:36 | moogatronic | hiredman: dude, i'm not sure what your issue is? I pretty much described to the best of my ability what I was trying to do… Anyway, bhenry has assisted, no more discussion from you necessary. |
| 19:37 | hiredman | I mean, I asked, and I think the closest thing to a "I am using doseq because" was "y answer is that i"m a noob and I found an example that had doseq and copied it." |
| 19:38 | moogatronic | The expanded version is I used doseq to iterate over some lines to produce some sideeffects in code earlier, was adapting this code, and am a noob and don't fully understand every aspect of clojure AND/OR functional programming as I hail from imperative roots. |
| 19:38 | hiredman | so you were looking for an imperative for loop? |
| 19:39 | moogatronic | zomg. |
| 19:40 | hiredman | how am I trolling? |
| 19:41 | hiredman | ~fire |
| 19:41 | clojurebot | fire is “Give a man fire and he's warm for a day; set a man on fire and he's warm for the rest of his life” |
| 19:41 | bhenry | maybe if you answer the questions and receive the responses openly you will learn what is necessary to know which tool to use next time. |
| 19:41 | hiredman | you have a specific problem, which is a sympton of a general lack of understanding |
| 19:42 | hiredman | in this case it seems like you were looking for a for loop |
| 19:42 | hiredman | which in clojure you almost never want |
| 19:42 | hiredman | you want sequence processing, map/reduce/filter |
| 19:43 | hiredman | so now you know more about clojrue then you did from just "use reduce" |
| 19:43 | hiredman | which was my first response |
| 19:47 | moogatronic | hiredman: I think what was happening was "the chicken and the egg problem" -- I'm not articulate enough currently to even undersand how to translate my deficiencies in undestanding. |
| 19:48 | moogatronic | But thanks for the continued explaination. |
| 19:50 | devn | man, mutlimethods are a blast |
| 19:50 | devn | technomancy: is the new lein templating stuff getting into lein today? |
| 19:50 | technomancy | devn: yeah, as of ~4 hours ago? |
| 19:51 | devn | technomancy: cool, looking forward to using them |
| 19:51 | devn | technomancy: I was imagining something sort of akin to gemsets like in rvm |
| 19:51 | tolstoy | Is there a discussion somewhere for using "hidden" name spaces? my.lib.internal, or something like that? |
| 19:51 | technomancy | devn: that's profiles, which is actually a completely different discussion |
| 19:51 | devn | technomancy: a skeleton project with a default gemset sort of thing |
| 19:52 | devn | technomancy: interesting, didn't know that was on the table |
| 19:52 | technomancy | devn: not sure how much of that has made it to documentation beyond channel logs, but it's definitely in the planning stages |
| 19:52 | technomancy | probably deserves its own wiki page at this point |
| 19:52 | devn | technomancy: I think a really great combination would be clojars.org/templates or something along those lines |
| 19:53 | devn | an easy way to share templates |
| 19:53 | technomancy | devn: yep, templates are just mvn artifacts |
| 19:53 | technomancy | lein plugin install lein-newnew 0.1.0 # <- to use it in lein 1.x |
| 19:53 | devn | technomancy: sorry I keep bringing this up whenever I talk to you, but what is the status on clojars being dev'able in a local env? |
| 19:54 | devn | technomancy: should I remove lein-newnew if I'm upgrading? |
| 19:54 | technomancy | upgrading to master? |
| 19:54 | technomancy | basically: you shouldn't upgrade to master right now |
| 19:54 | devn | ah, okay -- i was under the impression there was a full release ~4 hours ago |
| 19:54 | technomancy | oh, that was just the merge |
| 19:54 | devn | gotcha, nevermind! :) |
| 19:55 | technomancy | no progress on clojars, sorry |
| 19:55 | devn | technomancy: no need to apologize. is there anything I can do to push it forward? Is a rewrite worth considering? |
| 19:56 | technomancy | you can hack on it from my "heroku" branch, but it's likely that won't be merged into master, we'll probably just be taking code from that bit by bit over to master |
| 19:57 | devn | the primary force right now is "pull" from build tools -- would be nice to see clojars.org get some life of its own to push new capabilities back down |
| 19:57 | technomancy | if you want to get hacking, it would be great to investigate the viability of deploying to s3 |
| 19:57 | technomancy | actually you should be fine to do that off my heroku branch; the odds of conflict are low |
| 19:58 | technomancy | once lein settles down a bit I'll try to put together a plan of action for clojars |
| 19:58 | technomancy | step-by-step for getting my new features into master |
| 19:58 | technomancy | devn: would be good to look into github's pledgie integration for prior art |
| 19:58 | devn | technomancy: sounds good -- ill give it a look this evening |
| 19:58 | technomancy | which ISTR got disabled |
| 19:58 | technomancy | devn: glad to have help with that, thanks |
| 19:58 | devn | Intl Society for Third-Sector Research? |
| 19:59 | devn | Never heard of 'em. Seriously. |
| 19:59 | technomancy | ~istr |
| 19:59 | clojurebot | Gabh mo leithscéal? |
| 19:59 | technomancy | ~istr is I seem to recall |
| 19:59 | clojurebot | c'est bon! |
| 19:59 | devn | ahhh |
| 19:59 | devn | sorry, I'm not up on the hip new lingo. |
| 20:00 | technomancy | that's why we have a bot |
| 20:00 | devn | technomancy: anyway, I'm going to get back to toying around with a REPL-driven documentation swiss army knife |
| 20:00 | devn | but clojars is next. |
| 20:00 | technomancy | sweet |
| 20:01 | devn | cheers |
| 20:02 | technomancy | are there any lisps in existence whose readers allow preservation of comments? |
| 20:12 | TimMc | technomancy: Hmm. The reader would need to look ahead to know it was done. |
| 20:12 | technomancy | TimMc: already has to; you can't read off a reader unless it's a pushbackreader |
| 20:12 | TimMc | I guess that's needed for some literals. |
| 20:16 | amalloy | technomancy: so you'd want some kind of modal reader? like, (read-string :with-comments "(foo ;; is awesome\nbar)") => '(foo #<comment is aweomse> bar)? |
| 20:17 | technomancy | yeah, what good is code-as-data if you can't round-trip it through a file? |
| 20:17 | hiredman | yeah, I don't think metadata is a good a idea, just have comments as an object in the stream of objects |
| 20:17 | technomancy | just seems like things like marginalia and clojure-refactoring have to do a lot of extra work because the reader is missing this functionality |
| 20:18 | amalloy | technomancy: you'd want to keep whitespace as well |
| 20:18 | technomancy | amalloy: not as important as comments, but yes, you'd need it if you couldn't agree on a pretty-printer. |
| 20:19 | amalloy | technomancy: if you're round-tripping source code, you need to keep newlines., i don't trust any pretty-printer to decide where the newlines go in my function calls |
| 20:19 | technomancy | well, that's a personal matter. =) |
| 20:20 | brehaut | i think the rules for good lisp style are concrete enough that if there was a tool like this, the pretty printer could achieve that style consistently |
| 20:21 | brehaut | (ie if everyones pretty printing efforts were focused on one project rather than 3) |
| 20:22 | amalloy | brehaut: i welcome emacs's indenter into my heart, but it can't have my newlines |
| 20:22 | TimMc | technomancy: What brings this up? |
| 20:22 | technomancy | TimMc: just fooling around with marginalia |
| 20:23 | TimMc | Ah. |
| 20:23 | TimMc | That's an interesting point. |
| 20:23 | brehaut | technomancy: would a round tripping reader need to preserve map and set ordering? |
| 20:23 | gfredericks | kids these days and their newfangled drugs |
| 20:23 | technomancy | brehaut: interesting! probably. |
| 20:24 | technomancy | well, maybe only for array-maps? |
| 20:24 | gfredericks | and metadata tag ordering |
| 20:25 | gfredericks | and reader macro info |
| 20:25 | brehaut | gfredericks: yes true. i made a prefix node type in my brush to handle that case |
| 20:26 | gfredericks | (let [s (slurp "source.clj")] (with-meta (read (str "(" s ")")) {:source s})) |
| 20:26 | gfredericks | ^ round tripping reader :) |
| 20:27 | gfredericks | oh and reader-eval? |
| 20:27 | technomancy | perhaps we've discovered the reason(s) why no other lisps do this! |
| 20:28 | gfredericks | are there any issues with back-quote? |
| 20:28 | brehaut | is this something that should be jumped on while the reader is only moderately complex though ? |
| 20:30 | gfredericks | number radices |
| 20:30 | brehaut | huh. the code that ` generates caught me by surprise |
| 20:30 | gfredericks | float forms |
| 20:30 | technomancy | brehaut: it does seem to jive with Rich's "knobs to turn down *and* up the dynamicity/richness level" talk. |
| 20:30 | brehaut | ,(read-string "`(1 2 ~@(map inc [1 2]))") |
| 20:30 | clojurebot | (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (map inc [1 2]))) |
| 20:31 | gfredericks | brehaut: ##(read-string "````````a") |
| 20:31 | lazybot | java.lang.StackOverflowError |
| 20:31 | hiredman | https://github.com/hiredman/syntax-quote *cough* *cough* |
| 20:31 | brehaut | technomancy: sadly, i havent seen that yet, so i'll take your word for it |
| 20:31 | gfredericks | hiredman: I like the word "smacros" |
| 20:32 | hiredman | it's fun |
| 20:32 | gfredericks | I would use a library by that name regardless of what it did |
| 20:32 | technomancy | more like smackros, am I right? |
| 20:32 | brehaut | gfredericks: i still havent managed to wrap my head around the nested concats stack overflow |
| 20:32 | TimMc | OK, so it would be interesting to have a surface-form reader. |
| 20:33 | gfredericks | brehaut: in this case I think it's just because the forms generated by nested backquotes grow exponentially, and I suppose the reader ties the stack to the nesting of the forms it generates |
| 20:33 | amalloy | technomancy: how would you do it, though? comments can't be actual "source code forms" in ordinary programs. if they were, then macros would get passed them, and would have to explicitly ignore them. so if your turned on a special comment-preserving reader, it would be returning objects that aren't "really" code |
| 20:34 | hiredman | well, concat eats the stack |
| 20:34 | TimMc | ```foo becomes (#<squo> (#<squo> (#<squo> (#<sym> "foo")))) |
| 20:35 | hiredman | adding layers of lazy seqs without realizing them means you have to call at least N methods on the stack for N layers of lazy seqs to realize a single item in the seq |
| 20:35 | hiredman | amalloy: actually the compiler could discard them when doing macro expansion |
| 20:36 | TimMc | hiredman: I think I understand, but what's an example? |
| 20:36 | hiredman | but meh, yeah, sounds like an AnnotatedLispReader |
| 20:36 | brehaut | hiredman: ah right. for some reason in my head i had some magic trampolining in the realisation of lazy-seqs. clearly not matching with reality |
| 20:39 | gfredericks | ,(for [i (range 1 7)] (count (flatten (read-string (str (apply str (repeat i "`")) "a"))))) |
| 20:39 | clojurebot | (2 8 41 221 1202 ...) |
| 20:39 | brehaut | ,(count (flatten (read-string "{:a 1 :b {1 2 3 4}}"))) |
| 20:39 | clojurebot | 0 |
| 20:40 | brehaut | ,(flatten (read-string "{:a 1 :b {1 2 3 4}}")) |
| 20:40 | clojurebot | () |
| 20:40 | gfredericks | o_o |
| 20:40 | gfredericks | brehaut: maybe clojure is broken |
| 20:40 | brehaut | gfredericks: nah, flatten and maps dont mix |
| 20:40 | gfredericks | oh |
| 20:40 | brehaut | amalloy has a treeseq trick for it |
| 20:41 | hiredman | flatten just means you failed to use ->> and mapcat correctly |
| 20:41 | brehaut | ~flatten |just means| you failed to use ->> and mapcat correctly |
| 20:41 | clojurebot | Alles klar |
| 20:41 | gfredericks | ~shrimp |
| 20:41 | clojurebot | shrimp must be #=(str "super" "awesome") |
| 20:42 | fbru02 | hi all, how do you use proxy ? my understanding is that you have to do : (proxy [ClassToReify] (at-least-one-method-to-override ... )) |
| 20:42 | amalloy | brehaut: well, not much of a trick, since i just copied the source of flatten and then made it behave more like i want |
| 20:42 | alex_baranosky | does anyone know of a way to set an environment variable from Clojure? |
| 20:42 | moogatronic | hiredman: crap. =) I have lots of flatten in my code too. =) |
| 20:42 | brehaut | amalloy: lol :) |
| 20:42 | fbru02 | ? |
| 20:42 | hiredman | infered because shrimp are endofunctors, endofunctors are monads, and monads are #=(str "super" "awesome") |
| 20:42 | amalloy | &(count (remove coll? (tree-seq coll? seq {:a 1 :b {1 2 3 4}}))) |
| 20:42 | lazybot | ⇒ 7 |
| 20:42 | brehaut | the difference between flatten and mapcat is why coffeescript is a dead end ;) |
| 20:43 | hiredman | so says that guy who that blog post that one time |
| 20:43 | hiredman | wrote |
| 20:43 | brehaut | indeed :P |
| 20:43 | technomancy | alex_baranosky: that would require the JVM not completely failing at unix |
| 20:43 | brehaut | and went and pissed off a bunch of coffee script fans apparently |
| 20:43 | alex_baranosky | technomancy: I'm working on adding colorization to Midje console output, and thought about using an environment variable for it |
| 20:44 | gfredericks | hiredman: holy crap. It was simpler for me to just misremember that amalloy had set shrimp to #=(str "super" "awesome") directly. |
| 20:44 | hiredman | I know, inference is sweet |
| 20:44 | technomancy | alex_baranosky: there's a heinous hack you can do with reflection, but it's probably better to think of another way |
| 20:44 | hiredman | the problem is all these complicated verbs, adjectives, and adverbs |
| 20:45 | TimMc | fbru02: Looks about right. What are you asking? |
| 20:45 | hiredman | and part of speech tagging slows everything down too much |
| 20:45 | alex_baranosky | I could just make people set the envirnoment variable manually if they want to turn colorization *off* |
| 20:46 | ajsharp | so i'm getting an OutOfMemory error from the jvm, but I thought I had written this pretty efficiently (not holding on to head position) |
| 20:46 | ajsharp | https://gist.github.com/1384628 |
| 20:46 | fbru02 | TimMc: actually i was asking for advice ... so if i override one method in my proxy then the other methods still call the superclass method ? |
| 20:46 | ajsharp | i'm passing the function a lazy seq of about 50,000 items |
| 20:46 | brehaut | ajsharp: puppies are injured whenever closing parens get their own line |
| 20:47 | TimMc | fbru02: Yes, it is basically like "extends" in Java. |
| 20:47 | ajsharp | brehaut: nice, good to know |
| 20:47 | fbru02 | TimMc: thanks |
| 20:47 | fbru02 | amalloy: was awesome meeting in the conj |
| 20:47 | ajsharp | brehaut: still trying to figure out all the style rules and idioms |
| 20:47 | brehaut | ~style |
| 20:47 | clojurebot | style is http://mumble.net/~campbell/scheme/style.txt |
| 20:47 | TimMc | That's a decent guide. |
| 20:48 | ajsharp | brehaut: fixed ;) |
| 20:48 | amalloy | ajsharp: looks like you're rewriting merge-with |
| 20:49 | brehaut | ajsharp: ##(update-in {} [:a] (fnil inc 0)) |
| 20:49 | lazybot | ⇒ {:a 1} |
| 20:49 | ajsharp | amalloy: looks like merge-with actually merges the values in the two maps, no? |
| 20:49 | TimMc | brehaut: fnil! |
| 20:49 | amalloy | (apply merge-with + (for [obj coll] {(str (year obj) "/" (month obj)) 1})) |
| 20:49 | brehaut | ajsharp: also, you still have one injured puppy |
| 20:50 | amalloy | fbru02: thanks, nice to meet you as well |
| 20:50 | ajsharp | brehaut: heh, you're right, fixed again |
| 20:50 | amalloy | oh, and of course this merge-with is actually just frequencies |
| 20:50 | alex_baranosky | technomancy: what do you think about simply making people set the environment variable manually if they want to turn colorization *off* |
| 20:51 | amalloy | &(doc frequencies) ; ajsharp |
| 20:51 | lazybot | ⇒ ------------------------- clojure.core/frequencies ([coll]) Returns a map from distinct items in coll to the number of times they appear. nil |
| 20:51 | technomancy | alex_baranosky: I did something like that with lein-difftest; worked out fine |
| 20:51 | brehaut | ajsharp: did that update-in make sense above? (even though amalloy is showing you a generally better approach, that if pattern you used is generalised with update-in) |
| 20:52 | amalloy | Raynes: why is doc so ugly today? |
| 20:52 | ajsharp | brehaut: i'm trying it now, but i understand what it does |
| 20:52 | Raynes | amalloy: Dunno. It shouldn't be. |
| 20:52 | ajsharp | looks like it's often more concise than reduce |
| 20:52 | alex_baranosky | technomancy: its the most straightforward, which I can tweak if need be |
| 20:53 | Raynes | &(doc frequencies) |
| 20:53 | lazybot | ⇒ "([coll]); Returns a map from distinct items in coll to the number of times they appear." |
| 20:53 | brehaut | ,(frequencies "Hello, world!") |
| 20:53 | clojurebot | {\space 1, \! 1, \d 1, \e 1, \H 1, ...} |
| 20:54 | ajsharp | brehaut: or would i use the update-in inside the reduce? |
| 20:54 | bhenry | &(doc frequencies) ;with comment??? |
| 20:54 | lazybot | bhenry: How could that be wrong? |
| 20:54 | lazybot | ⇒ "([coll]); Returns a map from distinct items in coll to the number of times they appear." |
| 20:54 | brehaut | ajsharp: update-in is just a replacement for that (if (get …) (assoc … (get …)) …) soup you have |
| 20:54 | ajsharp | ah ok |
| 20:54 | brehaut | err you were using merge not assoc |
| 20:55 | ajsharp | yea, to continually build the accumulated map |
| 20:56 | brehaut | ajsharp: update-in lets you update a nested associated structure given a path through the structure (as a sequence of keys) and a function to apply to the value at the end. |
| 20:56 | brehaut | ajsharp: fnil lets you wrap up a function that doesnt accept a nil argument so that it has a default if a nil is passed |
| 20:57 | brehaut | ,(for [f [inc (fnil inc 0)], a [nil 10]] (f a)) |
| 20:57 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NullPointerException> |
| 20:57 | brehaut | haha fail |
| 20:57 | brehaut | ((fnil inc 0) nil) |
| 20:58 | brehaut | ,((fnil inc 0) nil) |
| 20:58 | clojurebot | 1 |
| 20:58 | brehaut | ,(inc nil) |
| 20:58 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 20:58 | technomancy | ,(into {} (map #(.split % "=") ["one=1" "two=2"])) |
| 20:58 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map$Entry> |
| 20:58 | amalloy | ajsharp: https://gist.github.com/1384650 for what it's worth |
| 20:58 | technomancy | what's going on there? |
| 20:58 | TimMc | &(map (fnil inc 1) [2 nil 0]) |
| 20:58 | lazybot | ⇒ (3 2 1) |
| 20:58 | TimMc | erm |
| 20:58 | TimMc | &(map (fnil inc 0) [2 nil 0]) |
| 20:58 | lazybot | ⇒ (3 1 1) |
| 20:58 | TimMc | much better |
| 20:59 | amalloy | technomancy: split returns a String[], which isn't a MapEntry? |
| 20:59 | technomancy | yeah, but it doesn't really require a mapentry |
| 20:59 | ajsharp | brehaut: wow, fnil is so simple but a really nice tool to have around |
| 21:00 | TimMc | ,(into {} [1 2]) |
| 21:00 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 21:00 | TimMc | ,(into {} [[1 2]]) |
| 21:00 | clojurebot | {1 2} |
| 21:00 | technomancy | ,(into {} ['(1 2)]) |
| 21:00 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry> |
| 21:00 | TimMc | ,(into {} '[(1 2)]) |
| 21:00 | brehaut | ajsharp: theres lots of great little funs like that in the core lib. juxt is another #clojure favorite |
| 21:00 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry> |
| 21:00 | amalloy | technomancy: no, but it doesn't do what you hope |
| 21:00 | TimMc | $source into |
| 21:00 | lazybot | into is http://is.gd/7toqQd |
| 21:00 | technomancy | just seems odd that it's so particular |
| 21:00 | technomancy | the root is trying to conj on a tranisent hashmap |
| 21:01 | TimMc | ugh lazybot why 1.2.x? |
| 21:01 | technomancy | *root cause |
| 21:01 | amalloy | if the input to conj is seqable, then it assumes it's a seq of MapEntries |
| 21:01 | technomancy | ,(instance? clojure.lang.MapEntry [1 2]) |
| 21:01 | clojurebot | false |
| 21:01 | amalloy | &(conj {} '([1 2])) |
| 21:01 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry |
| 21:02 | amalloy | the exception for vectors is only if they're pairs at the top level |
| 21:02 | TimMc | Irritating. |
| 21:03 | TimMc | ,(into {} [[1 2 3]]) |
| 21:03 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair> |
| 21:03 | TimMc | Ah, *very* specific. |
| 21:03 | amalloy | eg, if you got a seq of pairs you could conj them all sequentially (as into does), but you can't just conj the whole thing (like you could if they were a seq of MapEntry) |
| 21:03 | TimMc | ,(into {} [[1 2] [4 5 6]]) |
| 21:03 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair> |
| 21:04 | technomancy | it just seems odd to make an exception for 2-element vectors and not 2-element lists |
| 21:04 | amalloy | technomancy: "the root is trying to conj on a tranisent hashmap" - i don't understand this. it's calling conj! on the transient, which works fine if it's passed a correctly-typed arg |
| 21:04 | technomancy | I'm just disputing the narrow definition of "correctly-typed" |
| 21:04 | amalloy | i agree about the silliness of the exception for two-element vectors, but i think it's probably practical |
| 21:05 | TimMc | Would there be anything wrong with accepting anything it can call first and second on? |
| 21:06 | amalloy | TimMc: i think it would break the *other* crazy exception conj makes |
| 21:06 | TimMc | What's that? |
| 21:07 | amalloy | that you can conj a seq of MapEntries instead of conjing them each individually |
| 21:07 | TimMc | ew |
| 21:07 | amalloy | it would make (conj x (list (MapEntry...) (MapEntry...))) ambiguous - is it a pair of objects, or two entries? |
| 21:07 | TimMc | This is in PersistentMap or whatever? |
| 21:08 | amalloy | APersistentMap.cons |
| 21:08 | TimMc | Sounds like a pretty bad idea in the first place. |
| 21:08 | amalloy | agreed |
| 21:08 | TimMc | Well, there's always 1.4... :-) |
| 21:08 | hiredman | APersistentMap.cons is sloppy with the case analysis |
| 21:09 | amalloy | yeah, rich was really enthusiastic about making sure that every future release has some breaking changes like 1.3 |
| 21:09 | amalloy | hiredman: i'm sure you're right, but what in particular are you referring to? |
| 21:09 | hiredman | do people really use conj that much? |
| 21:09 | brehaut | amalloy: poes law has just bitten me. i cant tell if you are joking |
| 21:09 | hiredman | I have seqs of maps, seqs use cons, maps use assoc or merge |
| 21:10 | amalloy | hiredman: i think conj mostly gets used "transitively" by into |
| 21:10 | amalloy | brehaut: hah. well you'll just have to wait till the video comes out |
| 21:11 | amalloy | (no. he said they want to avoid more breaking releases) |
| 21:11 | hiredman | amalloy: well, you can pass a pair (2 element vector) but not a vector of pairs, but you can pass a seq of pairs |
| 21:11 | brehaut | amalloy: thanks :) |
| 21:12 | hiredman | the utility of the last for loop there just seems questionable |
| 21:12 | TimMc | (into {} [[1 2] [3 4]]) |
| 21:12 | TimMc | ,(into {} [[1 2] [3 4]]) |
| 21:12 | clojurebot | {1 2, 3 4} |
| 21:12 | amalloy | well, the whole thing is crazy, but it looks vaguely like it was designed to be crazy, so i'm not inclined to call it sloppy |
| 21:12 | hiredman | utility vs. errors from accepting to large a variety of input arguments |
| 21:12 | hiredman | too |
| 21:13 | TimMc | ,(into {} [1 2] [3 4]) |
| 21:13 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$into> |
| 21:13 | amalloy | TimMc: you're looking for ##(conj {} [[1 2] [3 4]]) |
| 21:13 | lazybot | ⇒ {[1 2] [3 4]} |
| 21:13 | TimMc | right |
| 21:13 | amalloy | vs ##(conj {} '([1 2] [3 4])) |
| 21:13 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry |
| 21:13 | amalloy | er, except those would have to be map entries |
| 21:13 | hiredman | also, into only take one thing to into is meh |
| 21:13 | amalloy | (inc hiredman) |
| 21:13 | lazybot | ⇒ 7 |
| 21:14 | amalloy | that's one that actually impacts me sometimes, unlike the crazy options for conj |
| 21:14 | bobhope | If I'm writing a compiler in clojure, if I want to do typechecking, should I learn core.logic, or just implement the checks/unification/etc myself with zippers? |
| 21:15 | hiredman | the pain |
| 21:15 | TimMc | amalloy: Are there two distinct inputs to conj that give the same result, just using vectors? |
| 21:16 | amalloy | TimMc: that's trivially true with something like (conj {:a 1} [:b 2]) vs (conj {:b 2} [:a 1]) |
| 21:17 | amalloy | but no, if the input map is originally empty, and the argument is a vector, no two vectors would yield the same map |
| 21:18 | gfredericks | would a clojure->jruby data converter be useful as a public lib? does it already exist somewhere? |
| 21:19 | hiredman | does it give you something beyond what you get via java interop? |
| 21:19 | gfredericks | hiredman: calling a clojure function from jruby just gives me a bunch of native-seeming objects |
| 21:19 | gfredericks | if there's an easy way to rubyize them I couldn't figure it out at the console |
| 21:20 | gfredericks | e.g. keywords don't become ruby symbols |
| 21:21 | gfredericks | so the point is that the jruby consumer does not have to do interop |
| 21:21 | hiredman | oh, I was just thinking, jruby can deal with java.util.Map maps |
| 21:21 | hiredman | which clojure maps are |
| 21:21 | gfredericks | right |
| 21:21 | gfredericks | I'm writing this for ruby-coworkers who do not want to have to think about the jvm |
| 21:22 | hiredman | their loss |
| 21:22 | gfredericks | hiredman: indeed. but my question still stands. |
| 21:25 | headius | in general, utilities for the JRuby side to make Java types feel more like Ruby types would be preferable to anything language or library-specific |
| 21:25 | headius | i.e. if the lists and maps you get back from clojure don't feel ruby enough, help us make them feel better |
| 21:25 | headius | it will apply to any lists and maps coming in from java |
| 21:26 | gfredericks | headius: that's an interesting point |
| 21:26 | TimMc | Wow, that's annoying: Occurrences of ".cons" in the Java side of Clojure are really conj operations. |
| 21:26 | gfredericks | headius: keywords are kind of clojure-specific though |
| 21:27 | TimMc | Not confusing at all! |
| 21:27 | gfredericks | TimMc: you betcha! |
| 21:27 | headius | what exactly are keywords |
| 21:27 | TimMc | headius: interned thingies |
| 21:27 | gfredericks | headius: equivalent to ruby symbols |
| 21:27 | gfredericks | so ideally when the rubyist calls the clojure function the clojure keywords become ruby symbols |
| 21:27 | TimMc | headius: Globally interned no-namespace character sequences. |
| 21:27 | headius | mmm |
| 21:28 | headius | if they're backed by interned strings in clojure, it wouldn't be too bad a conversion to do |
| 21:28 | headius | but we'd never know going the other way if we should turn something into a clojure symbol or just a string |
| 21:28 | brehaut | (namespace :no.namespace.on/keywords) ; TimMc: really? |
| 21:28 | gfredericks | the basic use cases for both are the same |
| 21:28 | headius | RubySymbol just wraps an interned java.lang.String |
| 21:28 | brehaut | ,(namespace :no.namespace.on/keywords) |
| 21:28 | clojurebot | "no.namespace.on" |
| 21:29 | gfredericks | headius: the conversation is confused by the fact that clojure also has "symbols" which are different |
| 21:29 | headius | I wish other language implementers were more interested in interop...we could come up with a common set of interfaces we all implement for some of these "atoms" of the language |
| 21:30 | gfredericks | that'd be cool |
| 21:30 | gfredericks | are erlang atoms more like clojure symbols or keywords? |
| 21:30 | TimMc | brehaut: New in 1.3, right? |
| 21:30 | brehaut | nope |
| 21:30 | TimMc | hrmph |
| 21:30 | gfredericks | TimMc: ##::whats-this |
| 21:31 | gfredericks | dammit lazybot |
| 21:31 | gfredericks | &::foo-bar |
| 21:31 | lazybot | ⇒ :clojure.core/foo-bar |
| 21:31 | TimMc | gfredericks: I thought that was just a convenient shorthand for putting the namespace on. |
| 21:31 | TimMc | *current namespace |
| 21:31 | gfredericks | TimMc: the point is that the keyword then has a namespace |
| 21:31 | TimMc | Right, but it's not as supported as Symbol. |
| 21:31 | TimMc | I just don't remember how. |
| 21:32 | amalloy | "not as supported as"? |
| 21:32 | brehaut | ,(symbol "imagination!" "foo") |
| 21:32 | clojurebot | imagination!/foo |
| 21:32 | gfredericks | amalloy: I had no idea what he meant either but assumed it was my fault |
| 21:32 | TimMc | Argh, there was something about them that did not have parity re: namespaces. |
| 21:33 | brehaut | TimMc: it appears that keywords are actually interned symbols |
| 21:33 | brehaut | (https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java) |
| 21:33 | TimMc | Gonna have to go log-diving now. |
| 21:35 | TimMc | headius: Anyway, yeah... they can have namespaces. -.- |
| 21:35 | gfredericks | which could just map to ruby symbols with slashes, if that happens to come up |
| 21:36 | brehaut | headius: the main difference between symbols and keywords in clojure is that symbols are often used to reference something else (ie, locals and vars), and keywords reference themselves |
| 21:37 | TimMc | I think the conversation that misled me was in the context of (derive) and the use of ::foo. |
| 21:37 | TimMc | ,*ns* |
| 21:37 | clojurebot | #<Namespace sandbox> |
| 21:37 | TimMc | &*ns* |
| 21:37 | lazybot | ⇒ #<Namespace sandbox17060> |
| 21:38 | headius | keywords references themselves... |
| 21:38 | headius | what a useful concept |
| 21:38 | headius | :) |
| 21:38 | brehaut | headius: modulo poor wording on my part ;) |
| 21:38 | gfredericks | brehaut: I liked it |
| 21:38 | headius | sounds like symbols are probably closer to what we think of ruby symbols as being |
| 21:38 | headius | they're generally used for symbolic lookup of variables, methods, etc |
| 21:39 | gfredericks | headius: I think clojure keywords are much closer to ruby symbols |
| 21:39 | brehaut | headius: keywords in clojure implement the IFn interface and are used as accessor functions on maps and records (just to muddy the waters) |
| 21:39 | headius | I guess I don't understand either |
| 21:40 | brehaut | ,(:foo {:foo 1}) |
| 21:40 | clojurebot | 1 |
| 21:40 | headius | geh |
| 21:40 | gfredericks | headius: half the reason symbols exist is the code/data thing. "Variables" in clojure are represented by symbols from the data perspective |
| 21:40 | gfredericks | class names are symbols |
| 21:40 | gfredericks | function names are symbols |
| 21:40 | gfredericks | etc. |
| 21:40 | TimMc | headius: Ruby's symbols probably complect named fields and binding. |
| 21:40 | TimMc | :-P |
| 21:41 | TimMc | *named lookup |
| 21:41 | TimMc | Scheme languages also just have symbols, I think. |
| 21:41 | gfredericks | (foo bar baz) is a list of three symbols as data, but as code it is calling the foo function with arguments named bar and baz |
| 21:43 | brehaut | headius: i should have said 'evaluate to' instead of 'reference' above. http://clojure.org/data_structures#Data%20Structures-Keywords |
| 21:43 | headius | in Ruby, it's never really exposed how method names or classes are represented, but they're usually accessed by symbols |
| 21:43 | headius | so whether they "are" symbols or not isn't relevant |
| 21:43 | clojurebot | symbols are kind of fun |
| 21:43 | gfredericks | headius: yeah, I think that's the most clojure-symbol-like use of ruby-symbols |
| 21:43 | headius | symbols are little more than a unique identifier |
| 21:44 | devn | technomancy: I fixed clojure-refactoring to work with 1.3 FWIW |
| 21:44 | gfredericks | headius: unlike ruby-symbols and clojure-keywords, clojure-symbols are not often used with data |
| 21:44 | gfredericks | unless the data is code, of course |
| 21:45 | headius | mmm yeah...in ruby symbols are often used to reflect named keys in data structures |
| 21:45 | headius | [:foo, [:bar, 1]] |
| 21:45 | TimMc | headius: Clojure uses keywords for that (idiomatically). |
| 21:45 | headius | symbols can also be lifted to functions in a way that sounds like keywords |
| 21:46 | headius | :foo.to_proc[1] == 1.foo |
| 21:47 | gfredericks | clojure keywords aren't really used that way, but neither are symbols. I think that usage is kind of specific to instance methods, so doesn't apply much in clojure |
| 21:47 | gfredericks | symbols name things the same way ruby variables do |
| 21:47 | amalloy | gfredericks: disagree, i think it's fairly symmetric |
| 21:48 | gfredericks | amalloy: to clj-kws or clj-syms? |
| 21:49 | amalloy | keywords |
| 21:49 | gfredericks | what usage of keywords corresponds to instance-method-reification? |
| 21:49 | gfredericks | there's even a clojure.core function for that isn't there? |
| 21:50 | gfredericks | $findfn will not help me here :/ |
| 21:50 | amalloy | gfredericks: getting keys out of a map. in ruby there are (as i understand it) often objects which have a .foo method returning the value of their internal @foo variable |
| 21:50 | amalloy | gfredericks: memfn? |
| 21:50 | gfredericks | amalloy: yep that's it |
| 21:51 | gfredericks | amalloy: I can see how you might make an argument out of that, but I don't think the typical use cases overlap much |
| 21:51 | gfredericks | every such instance I've seen in ruby is calling real methods, not just accessing data |
| 21:52 | gfredericks | I often do (apply concat ...) by .inject(:+), for instance |
| 21:52 | gfredericks | brehaut: I hesitated before I used it |
| 22:14 | R4p70r | blip.tv always displays totally irrelevant ads on the side when I’m watching Clojure videos. |
| 22:15 | R4p70r | How-To Cook a Turkey With Kat... |
| 22:31 | TimMc | I get "hot babe photoshoot" stuff. |
| 22:31 | gfredericks | TimMc: well at least that's related to clojure |
| 22:31 | TimMc | indeed |
| 22:31 | amalloy | based on prior internet activity, eh? |
| 22:31 | TimMc | amalloy: haha! |
| 22:31 | amalloy | cross-site cookies |
| 22:31 | TimMc | I doubt it. |
| 22:33 | TimMc | amalloy: No, I'm getting the turkey ads now, in both browsers. |
| 22:34 | Raynes | In both browsers? |
| 22:34 | Raynes | How many do you use at any given time? |
| 22:35 | gfredericks | I bet he has a meta-browser with tabs for each of his active browsers |
| 22:35 | gfredericks | that sounds like some kind of fantasy web developer's tool |
| 22:36 | brehaut | gfredericks: a fantasy web developers tool removes internet explorer and ffx 3.5 from the world |
| 22:36 | TimMc | Raynes: I have about 5 Firefox profiles, 2 of which I use frequently. The main one has Flash disabled. |
| 22:36 | Raynes | You're insane. |
| 22:36 | gfredericks | brehaut: that already exists |
| 22:36 | Raynes | First the password stuff and now this. |
| 22:36 | gfredericks | Raynes: what's he do with his passwords? |
| 22:37 | brehaut | gfredericks: your world is a better place than mine |
| 22:37 | TimMc | Raynes: I do web dev sometimes, and it's important to test sites *without* all my extensions interfering. |
| 22:37 | Raynes | TimMc: P.S. I accidentally gave amalloy my password last night while demonstrating new tentacles features. |
| 22:37 | TimMc | haha |
| 22:37 | Raynes | It was fun. |
| 22:37 | Raynes | I was due for a new one anyway. |
| 22:37 | TimMc | gfredericks: I don't hand them out, that's what. :-P |
| 22:37 | gfredericks | (str "hunter" (swap! pw-int inc)) |
| 22:39 | TimMc | Raynes: Actually, a big part of the pain is that my passwords are mostly random ASCII, so it's annoying to retrieve them from Firefox's password manager. I either have to use Firebug to nab one from a login page (which may require logout) or I can do a "search" in the password box and type in the password incrementally until I can copy it. |
| 22:39 | TimMc | A different password manager might help. |
| 22:39 | Raynes | I don't do password managers. |
| 22:40 | TimMc | amalloy is your password manager amirite |
| 22:40 | brehaut | my password manager is M-x butterfly |
| 22:54 | amalloy | brehaut: my password is M-x butterfly |
| 23:08 | aamar | Huh, M-x butterfly actually does something. |
| 23:08 | brehaut | http://xkcd.com/378/ |
| 23:16 | amalloy | $learn some-key some-value |
| 23:16 | lazybot | My memory is more powerful than M-x butterfly. I won't forget it. |
| 23:17 | brehaut | amalloy: ?? |
| 23:17 | lazybot | brehaut: Uh, no. Why would you even ask? |
| 23:17 | amalloy | just pointing out some more butterflies |
| 23:17 | brehaut | oh right |
| 23:17 | dhm | Anyone used an html parser in clojure? Worth using one of the clojure native libs over a java one? |
| 23:18 | brehaut | dhm: if you use enlive, its built ontop of the java tagsoup library |
| 23:18 | dhm | brehaut: thanks, does it parse html or just do transformations? |
| 23:19 | tmciver | I hope M-x butterfly doesn't actually flip any bits . . . |
| 23:19 | brehaut | dhm: both |
| 23:19 | dhm | brehaut: ah, totally sweet. thanks again. |
| 23:21 | devn | is there already some facility for doing a bunch of (derive ::foo ::bar)? |
| 23:22 | devn | like passing a map to (build-hierarchy {::foo ::bar ::bar ::baz}) |
| 23:26 | spoon16 | technomancy: I'm getting an error in 1.6.2 on lein deps if I have a repositories entry for centeral |
| 23:26 | spoon16 | I'm trying to override with my own proxy server |
| 23:26 | spoon16 | something change, or should I file an issue and debug? |
| 23:32 | amalloy | devn: uh, i think that facility is doseq |
| 23:32 | devn | amalloy: sure, already did that, just curious if there was some contrib library or somesuch I didn't know about |