2011-03-19
| 01:16 | Lulu58e2 | I'm using Slime+Swank and C-c C-k keeps giving me an error about a seemingly out of date file; is there cached files or something I need to clear out? |
| 01:18 | Lulu58e2 | I'm hacking around and tried putting :reload in my :use libspec (not sure if I have the terminology right there) |
| 01:18 | Lulu58e2 | Also tried recompiling all of the required libs |
| 03:43 | Lulu58e2 | I figured out my slime issue: upgraded to emacs 23.2, Swank-Clojure 1.3.0_SNAPSHOT and Slime 20100404.1 |
| 06:09 | khaliG | the java compatibility thing seems to be a bit of a double edged sword. you get a lot of libraries, but the clojure wrappers are usually incomplete or partial ones (just enough for the authors needs), which means there is this tension of not quite being able to do what you want, with the given library. Is this a fair assessment? |
| 06:10 | brehaut | khaliG: you are supposed to just be able to do what you want with the java library; any wrapper is merely a convenience |
| 06:11 | tomoj | of course there is plenty of that tension with the java libraries themselves, just like everywhere else |
| 06:11 | raek | I get the feeling that clojure was built to be able to use "pholosophically compatible" libraries (e.g. immutable objects) without wrapper libs |
| 06:11 | Chousuke | A better way to put it is that Java APIs are usually not very idiomatic in functional-style programs |
| 06:12 | chitsubr | I've read that the python intepreter prompt is not a real REPL like the clojure prompt is, but couldn't understand the difference why. Is that statement true, and if so, why? |
| 06:13 | brehaut | chitsubr: can you link to that claim, i think it needs more detail |
| 06:13 | Chousuke | I suppose python lacks "read" |
| 06:13 | Chousuke | so technically it's not a REPL |
| 06:13 | Chousuke | it's just an EPL :P |
| 06:13 | chitsubr | brehaut: yes, I'll try to find the proggit comment thread where that claim was made |
| 06:13 | brehaut | Chousuke: it has read; it just happens to be inextricably linked to eval |
| 06:13 | raek | I think the argument is something like that you cannot decompose the python prompt into a distinct Reader, Evaluatator and Printer |
| 06:14 | khaliG | chitsubr, from memory you can't redefine a function in the repl but i could be wrong about this i don't remember very well since i never really used python |
| 06:14 | Chousuke | brehaut: yeah |
| 06:14 | brehaut | khaliG: you are completely wrong about that |
| 06:14 | khaliG | brehaut, yea, just checking it now |
| 06:15 | Chousuke | khaliG: remember to indent properly :) |
| 06:15 | khaliG | chouser, heh the repl just complained about just that! |
| 06:15 | brehaut | its a mutable dynamic language; changing things is what it does best :P |
| 06:15 | chitsubr | here's part of the quote: REPL" has taken on more connotation than just "read, eval, print." When people say they want a REPL they usually mean they want: |
| 06:15 | chitsubr | 1) An actual interactive prompt. 2) Per-file and per-region compilation into a running image. 3) Some sort of scratchpad that has state. |
| 06:16 | khaliG | ok scratch that you *can* redefine functions |
| 06:16 | raek | some clojure users seem to want to avoid using java interop at all costs (i.e. refuse to touch a java lib if it doesn't have clojure wrapper) |
| 06:16 | Chousuke | hmm, that's overloading the term a bit too much |
| 06:17 | Chousuke | but yeah with clojure you can start a REPL that's connected to a running application and work with it on the fly |
| 06:17 | chitsubr | here's the link to the comments : http://www.reddit.com/r/programming/comments/g24y3/, the comment I read was made by (search for) rayiner |
| 06:17 | Chousuke | I have no idea if that's possible with python |
| 06:18 | chitsubr | Chousuke: if I have a running Clojure application, will any REPL I start be connected to it? |
| 06:18 | Chousuke | chitsubr: if it's within the same JVM instance, yes |
| 06:18 | Chousuke | most of the time it won't be I suppose |
| 06:19 | chitsubr | Chousuke: so do I have the ability when starting a REPL ot specify the JVM it should attach to? |
| 06:19 | raek | chitsubr: it's the other way around: you start the repl from within an already running instance |
| 06:19 | Chousuke | not really. though I think there are ways to do that using the java debugging facilities. |
| 06:20 | Chousuke | the most common situation is that you start a repl in slime or something |
| 06:20 | Chousuke | and then run your application from there |
| 06:20 | Chousuke | and the repl stays running |
| 06:21 | raek | well, if you have evaluated (swank.swank/start-repl), every time slime connects to the swank server, a new repl will be created |
| 06:21 | Chousuke | technically that should be possible with python too. |
| 06:21 | chitsubr | hmm.. so if I want a startup daemon written in Clojure, I would have to first fire up a repl and then run the daemon in it? |
| 06:21 | brehaut | chitsubr: that thread is a trainwreck |
| 06:22 | Chousuke | chitsubr: only if you need a repl, really |
| 06:22 | chitsubr | brehaut: sorry, my bad in linking to it |
| 06:22 | brehaut | chitsubr: its my bad for clicking on something that clearly had reddit in the domain |
| 06:22 | chitsubr | I was just interested in one comment |
| 06:22 | Chousuke | chitsubr: and there are ways of starting a "remote" repl within an application that can be connected to later. |
| 06:22 | raek | chitsubr: you could have a -main that starts up the daemon and a repl socket server |
| 06:23 | chitsubr | awesome, I'll do some searching for remote REPL's and repl socket servers |
| 06:23 | Chousuke | how's the nrepl project doing? |
| 06:23 | Chousuke | https://github.com/clojure/tools.nrepl |
| 06:25 | raek | chitsubr: check out clojure.main/repl (http://clojuredocs.org/clojure_core/clojure.main/repl) and http://clojuredocs.org/clojure_contrib/clojure.contrib.server-socket/create-repl-server |
| 06:38 | brehaut | Chousuke: chitsubr: BTW, examine pythons ast.parse and __builtin__.compile functions; it clearly has a seperate reader and evaluator. its just not very useful |
| 06:40 | chitsubr | brehaut: and the reason it's not very useful is perhaps because python programs aren't represented as python data structures, AFAIK and unlike Clojure |
| 06:41 | brehaut | chitsubr: they are; it just happens that OO has specific data structures (in this case AST objects) for everything, rather than prefering generic datastructures (even though it has them) |
| 06:41 | chitsubr | brehaut: I've got this (perhaps wrong) idea that Clojure and lisp's repl's are powerful since the programs can be represented by the data structures used in the language |
| 06:41 | chitsubr | brehaut: oh ok |
| 06:42 | Chousuke | brehaut: of course it has a parser and an AST but that's more of an implementation detail :) |
| 06:42 | brehaut | Chousuke: well yes, but if the claim is that python doesnt have a repl because you cant get access to those pieces from python itself, its a faulty claim |
| 06:43 | brehaut | (note, im not suggesting that the ast is going to be particularly useful to 99.99% of python developers, unlike a lisp AST) |
| 06:44 | chitsubr | brehaut: just to clarify, by lisp AST do you mean a list? |
| 06:44 | brehaut | and atoms |
| 06:44 | chitsubr | ok |
| 06:44 | brehaut | (in the lisp sense, not the clojure sense) |
| 06:44 | Chousuke | and in clojure's case, vectors, maps and other things :P |
| 06:44 | chitsubr | right, ok |
| 06:45 | Chousuke | (sets never get any love in code-is-data discussions) |
| 06:45 | brehaut | #9 |
| 06:46 | brehaut | apparently i fail at using clojurebot |
| 06:47 | brehaut | chitsubr: "9. It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures." – Alan J. Perlis |
| 06:47 | chitsubr | brehaut: aha, thanks |
| 06:48 | brehaut | chitsubr: the utility of the AST being in the same datastructures you already know the API to manipulate is extremely powerful. |
| 06:49 | chitsubr | so Perlis's quote is directly applicable to lisp, but for clojure its 100 functions and four data structures? |
| 06:49 | brehaut | clojure just takes the ideas in lisp further |
| 06:49 | brehaut | it acknowledges that data does have different shapes, but those shapes generic (sequences, maps, sets, etc) |
| 06:50 | Chousuke | chitsubr: all of the data structures can pretend to be sequences, so not really :) |
| 06:50 | brehaut | &(seq {:foo 1 :bar 2}) ; ftw |
| 06:50 | sexpbot | ⟹ ([:foo 1] [:bar 2]) |
| 06:52 | chitsubr | brehaut: what does the &(...) do? |
| 06:52 | brehaut | tells sexpbot to evaluate the code |
| 06:52 | chitsubr | oh ok |
| 06:52 | brehaut | comma does the same for clojurebot |
| 06:52 | brehaut | sexpbot just has a nice feature that helps my tired brain |
| 06:53 | chitsubr | :) |
| 06:53 | brehaut | such as ##(map inc [1 2 |
| 06:53 | Raynes | brehaut: >_> |
| 06:54 | brehaut | Raynes: what have i done to sexpbot? is he ignoring me |
| 06:54 | Raynes | $kill |
| 06:54 | sexpbot | KILL IT WITH FIRE! |
| 06:54 | Raynes | He seems okay. |
| 06:54 | brehaut | &(map inc [1 2 |
| 06:54 | sexpbot | ⟹ (2 3) ; Adjusted to (map inc [1 2]) |
| 06:54 | brehaut | :D |
| 06:54 | Raynes | I see. |
| 06:55 | brehaut | Raynes: you must have known about this? |
| 06:55 | chitsubr | brehaut: cool, some AI I see |
| 06:55 | brehaut | chitsubr: hah no |
| 06:55 | Raynes | Yes, of course. I assumed you expected the embedded execution to do the same thing. |
| 06:55 | brehaut | Raynes: i did; why wouldnt it? |
| 06:56 | Raynes | That was weird. |
| 06:56 | brehaut | chitsubr: its just a simple parser with an error handler that matchs up any missing parens if it reaches the end of input |
| 06:56 | chitsubr | brehaut: ok :) |
| 06:56 | brehaut | &(inc 1] |
| 06:56 | sexpbot | ⟹ 2 ; Adjusted to (inc 1) |
| 06:56 | Raynes | brehaut: I don't know. I was just responding to... sigh. I should go to sleep. ._. |
| 06:57 | brehaut | its late over here in the future too. |
| 06:58 | chitsubr | 4 am pst here, I'm off, thanks folks |
| 06:59 | brehaut | Raynes: on the other hand, shiny new TJoC |
| 06:59 | Raynes | I saw. |
| 08:32 | Raynes | chouser: That's one hefty ebook you've got there. |
| 08:32 | Raynes | Weighing in at just over 13 pounds, it's certainly a contender for the heavyweight title. |
| 09:13 | angerman | nifty. |
| 09:15 | __name__ | I'm confused. |
| 09:16 | __name__ | Why does Clojure 1.1 do that: |
| 09:16 | __name__ | user=> (def a 1) |
| 09:16 | __name__ | #'user/a 1 |
| 09:23 | danlarkin | __name__: do what? let you use def? |
| 09:24 | __name__ | danlarkin: See how it defines a 1 instead of a. |
| 09:24 | __name__ | m( |
| 09:24 | __name__ | I've used a non-breaking space, nevermind. |
| 09:24 | __name__ | That's quite interesting, though |
| 09:25 | __name__ | http://paste.pocoo.org/show/356042/] |
| 09:25 | __name__ | http://paste.pocoo.org/show/356042/ even, sorry. |
| 09:25 | fliebel | __name__: I wonder if you read a file that contains backspaces, if you could define even weirder stuff :) |
| 09:26 | __name__ | fliebel: :) |
| 09:26 | __name__ | I think the nbsp should not be allowed in identifiers. |
| 09:26 | __name__ | No whitespace should, imo. |
| 09:26 | danlarkin | __name__: yeah if you just replace your nbsp with another character that behavior becomes more clear |
| 09:26 | fliebel | __name__: How did you insert one? |
| 09:26 | __name__ | fliebel: I had it set to shift+space |
| 09:27 | __name__ | danlarkin: Yes, I just really think no whitespace should be legal in identifiers. |
| 09:27 | __name__ | *allowed evenn |
| 09:28 | fliebel | __name__: Problem is ther eis a lot of dubious whitespace in unicode. |
| 09:28 | __name__ | fliebel: Yeah; would it really be a problem just to exclude them all? |
| 09:28 | __name__ | It's also that I'm not a big fan of Unicode in code anyway :) |
| 09:32 | fliebel | __name__: I think it's great, we just need unicode keyboards :D |
| 09:33 | __name__ | I think ascii is good enough and already widespread, but that's just me. |
| 09:33 | __name__ | I also use a keyboard not designed for my native language, so I am weird. |
| 09:34 | fliebel | __name__: Which are? |
| 09:34 | __name__ | fliebel: I use a 104-key qwerty which does not have some letters on it I need for my language. |
| 09:35 | __name__ | ö, ä, ü and ß. |
| 09:45 | fliebel | __name__: Ah Germany :) My lang does not have these, but I can do them… ö ä ü ß |
| 09:45 | __name__ | I can do them as well, I have a compose key ☺ |
| 09:46 | angerman | ,(map vec [1 2 3] [2 3 4]) |
| 09:46 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$vec |
| 09:48 | angerman | ,(doc unless) |
| 09:48 | clojurebot | Cool story bro. |
| 09:55 | fliebel | &(map vector [1 2 3] [2 3 4]) |
| 09:55 | sexpbot | ⟹ ([1 2] [2 3] [3 4]) |
| 09:55 | fliebel | angerman: |
| 09:56 | angerman | fliebel: thanks. Guess that would be better than (partition 2 (interleave …)) :D |
| 09:57 | angerman | lol. |
| 10:00 | __name__ | fliebel: But actually I come from Austria, not Germany :) |
| 10:01 | angerman | __name__: so you to the cheap gasoline and huge ski resorts :D |
| 10:01 | __name__ | angerman: I don't use a car, but yes :) |
| 10:02 | angerman | __name__: hehe. It's not that far from here. |
| 10:03 | angerman | too far though for it to be economical to refuel in austria... |
| 10:07 | phenom_ | ,(type (vector-of :byte)) |
| 10:07 | clojurebot | clojure.core.Vec |
| 10:09 | __name__ | angerman: Where are you from? |
| 10:10 | angerman | Munich |
| 10:10 | angerman | well, that's where I live. |
| 10:10 | __name__ | People from Passau refuel in Austria :) |
| 10:10 | angerman | yea, but Passau |
| 10:11 | angerman | 's not that far off the boarder :D |
| 10:11 | __name__ | Passau is nice. |
| 10:12 | angerman | don't know. This is actually foreign territory to me. I'm actually from the strip of land between the baltic and north sea. |
| 10:12 | __name__ | Hamburg? |
| 10:13 | angerman | north of that :) |
| 10:13 | __name__ | (territory, not city.) |
| 10:14 | angerman | not even :) |
| 10:14 | __name__ | Oh wait. |
| 10:14 | __name__ | Schleswig-Holstein? |
| 10:14 | angerman | Right behind my parents home is the ancient danish border. |
| 10:14 | angerman | __name__: yes. |
| 10:14 | __name__ | I thought that belonged to Hamburg :( |
| 10:14 | __name__ | But Hamburg is city and territory at once, it seems. |
| 10:15 | __name__ | You learn something new every day :) |
| 10:15 | angerman | __name__: yes. We have some of those city states. |
| 10:15 | __name__ | angerman: Vienna is one too. |
| 10:15 | angerman | Most of the old Hanse states are. |
| 10:16 | __name__ | Vienna is because it was socialist. |
| 10:16 | angerman | __name__: a fellow student keeps telling me that Vienna is weird. (He's CBA) |
| 10:16 | __name__ | And lower Austria was conservative. |
| 10:16 | __name__ | angerman: What's a CBA? |
| 10:17 | angerman | chinese born austrian. |
| 10:17 | angerman | He actually served an extended period in the Bundesheer before coming to Germany to study... |
| 10:17 | __name__ | Is that acronym common? |
| 10:17 | __name__ | angerman: In which way is Vienna weird? |
| 10:18 | patrkris | is it at all possible to use `lein run somescript.clj` since leiningen 1.4.0? |
| 10:18 | angerman | __name__: not so sure. Might be because my friends a from many countries and ABC (American born Chinese) is common, other 3 letter abrevations are used. |
| 10:19 | angerman | __name__: he sais they talk funny and are weird in general… not so sure about that though. He's from Klagenfurt though. |
| 10:19 | __name__ | Hahaha, Klagenfurt :-) |
| 10:19 | __name__ | angerman: I could tell you the same about Klagenfurt :) |
| 10:19 | angerman | yea I guess it like the bavaria thing in Germany I guess. |
| 10:20 | __name__ | Vienna is a bit weird, but I kind of like it |
| 10:20 | __name__ | The people are a bit more … ehm … direct and … ehm … sincere. |
| 10:23 | angerman | __name__: been there only once in my life so far. And that's 6 years ago… the thing I remember most was that the streets were a little dirty. |
| 10:24 | __name__ | angerman: Paris is worst in that regard. |
| 10:24 | angerman | Been last year to Salzburg. That's been quite nice. And the streets were less dirty. But that might have changed in Vienna as well. |
| 10:24 | __name__ | angerman: Salzburg is just smaller. |
| 10:24 | angerman | __name__: yea. Heard about that. But it's the French. So. :D |
| 10:25 | __name__ | And they don't allow you to go up the steeples of their churches :( |
| 10:25 | angerman | And I must admit I like Hong Kong best so far. |
| 10:25 | __name__ | Stupid Salzburgians(?) |
| 10:25 | __name__ | angerman: Have not been there. |
| 10:25 | angerman | well. Not much a problem for me. I don't care for Churches. |
| 10:25 | __name__ | I like the view. |
| 10:26 | __name__ | angerman: Hong Kong is pretty modern, eh? |
| 10:26 | angerman | __name__: it's probably one of the few asian cities (Singapore, maybe?) where you can get by with no word chinese (or in this case cantonese). |
| 10:27 | angerman | And It's damn clean. People are friendly… it's mostly cheap. |
| 10:27 | __name__ | angerman: What about Japan? |
| 10:27 | angerman | Japan was dead expensive. |
| 10:27 | __name__ | But they speak English, right? |
| 10:27 | angerman | haha! |
| 10:27 | angerman | Nice try. |
| 10:27 | __name__ | No? |
| 10:28 | angerman | __name__: as usual the closer you get to the touristy areas the better the english gets. |
| 10:28 | __name__ | Yeah. |
| 10:28 | __name__ | But it's rather good in central Europe. |
| 10:28 | angerman | And of course you can do all kinds of tours in English and find your way with english. But apart from that… (e.g. if you like to go off track, you can get lost quite fast). |
| 10:29 | __name__ | I mean, you can get along with only English quite well here in Austria. |
| 10:29 | angerman | Even in a semi-central area of Osaka, the bank was unable to help me withdraw money (using a VISA card) in english. |
| 10:29 | __name__ | I once knew an Australian who lived here. |
| 10:30 | angerman | __name__: sure. Europe is different. Apart from France I guess we have agreed on one universal language here. |
| 10:30 | __name__ | Yea, France is funny. |
| 10:30 | __name__ | ‘Do you speak English?’ made one person say ‘Non!’ as if I had insulted all of his kin. |
| 10:31 | angerman | you did. |
| 10:31 | __name__ | Haha. |
| 10:31 | __name__ | I speak some French, but I could not understand him. |
| 10:31 | angerman | I can hardly read french. |
| 10:31 | __name__ | There's a huge difference between understanding a language and understanding people :) |
| 10:32 | __name__ | I mean, I don't think many German non-natives understand people in Vorarlberg. |
| 10:33 | __name__ | And there are some communication problems between north and south of the German speaking area. |
| 10:33 | __name__ | I've had people from northern Germany not understand me because the words I use simply do not exist there. |
| 10:34 | angerman | __name__: yes I takes me sometimes a bit as well to understand some people around here. |
| 10:34 | angerman | But with a little imagination you can usually guess what the word means and from where it comes. Not that I'd ever used it that way or in that context. But I can still make sense of it. |
| 10:35 | __name__ | Like “Marille”, “Powidl”, “Knödel” … |
| 10:35 | angerman | And bavarian is still easier than plattdüütsch. |
| 10:35 | angerman | Well Knödel should be known all over Germany. |
| 10:36 | angerman | But yes, I wasn't talking about subjectives. :) |
| 10:36 | __name__ | And the lack of “Weiters” in Germany-German confuses me :) |
| 10:36 | __name__ | It's a great word. |
| 10:37 | angerman | I mean we definitely do not have the work Kren. (Don't know how that's spelled right… It's Rettich) |
| 10:37 | __name__ | Isn't it Meerettich? |
| 10:37 | angerman | __name__: what's Weiters supposed to mean? |
| 10:37 | angerman | yes. |
| 10:37 | __name__ | *Meerrettich even |
| 10:37 | __name__ | angerman: Similar to “zudem”. |
| 10:38 | __name__ | “österreichisch auch, weiterhin, darüber hinaus, außerdem, im Weiteren” |
| 10:39 | angerman | well you can guess from Weiters that it's a supposed addition. But it doesn't fit grammatically. Closes would be Weiteres, though that's probably further away in meaning. |
| 10:40 | __name__ | angerman: Weiteres is something different. |
| 10:40 | __name__ | angerman: Weiters is mosly used eat the beginning of a sentence. |
| 10:41 | angerman | I guess we'd use "Im Weiteren" or some construct like that. |
| 10:41 | __name__ | It's more zudem I think. |
| 10:42 | __name__ | dwds, e.g., has „Die gerichtsmedizinische Sachverständige erhielt weiters den Auftrag, die Blutproben der Unfallbeteiligten chemisch-toxikologisch sowie deren Kleidung und Ausrüstungsgegenstände auf Spuren zu untersuchen“ in the examples. |
| 10:43 | angerman | you could substitute im weiteren… or zudem. |
| 10:43 | __name__ | im Weiteren sounds odd in that context, but that might be because I am used to weiters. |
| 10:43 | angerman | The problem, at least to me, is that weiters does just not sound right. |
| 10:44 | __name__ | angerman: But it is, the Austrian Dictionary, which is the authority, allows it ;) |
| 10:45 | angerman | Language rules are something weird. |
| 10:48 | __name__ | Yes |
| 10:48 | __name__ | They messed that up a bit. |
| 10:48 | __name__ | With all their reforms and revertions of parts thereof. |
| 10:49 | angerman | I can live with quite a lot. But the abusive use of 'r' 'u' 'wif', … in HK really start to get annoying. |
| 10:49 | __name__ | HK? |
| 10:49 | angerman | luckily they have yet to penetrate the government. |
| 10:49 | angerman | Hong Kong |
| 10:50 | angerman | feels like you ended up in aolbonics land. |
| 10:50 | __name__ | What's ‘r’ ‘u’ ‘wif’ |
| 10:50 | __name__ | Are you with? |
| 10:50 | angerman | yes. |
| 10:50 | __name__ | Well, be back soon. |
| 10:50 | angerman | and that's just the beginning. |
| 10:50 | __name__ | Nice talking to you. |
| 10:50 | __name__ | Need to go buy groceries. |
| 10:51 | angerman | right, your shops close so early. |
| 10:51 | angerman | 20min left. |
| 10:51 | angerman | lol |
| 10:51 | __name__ | Yep, we're good Christians :) |
| 10:51 | angerman | bawahahahaha. |
| 10:51 | angerman | Thor for life! |
| 11:27 | devn | Steve Yegge's FOREWORD to JoC is awesome: http://www.manning.com/fogus/excerpt_foreword.html |
| 11:29 | TimMc | I like it. |
| 11:34 | devn | :) |
| 11:34 | phenom_ | anyone know why doing byte equality does reflection into clojure.lang.Util ? |
| 11:34 | __name__ | angerman: Out shops don't close as early as they used to, though. |
| 11:36 | angerman | phenom_: switch on the reflection flag? |
| 11:37 | angerman | __name__: we consider 8pm in Germany conservative on Saturdays. |
| 11:37 | pdk | closing at 8 on a weekend would be lame anywhere |
| 11:38 | angerman | pdk: it used to be 4pm |
| 11:39 | phenom_ | angerman: i have ... i'm doing an equality check on 2 bytes but for some reason it's doing reflection into clojure.lang.Util |
| 11:39 | phenom_ | for "equiv" |
| 11:44 | __name__ | angerman: :O |
| 11:45 | angerman | __name__: yea. People from outside of bavaria complain on a regular basis that shops close at 8pm. |
| 11:45 | angerman | that they close at 8pm thoughout the whole week... |
| 11:54 | phenom_ | (= (byte 10) (byte 10)) throws a refelction warning ... "call to equiv can't be resolved ..." |
| 11:54 | phenom_ | ,(= (byte 10) (byte 10)) |
| 11:54 | clojurebot | true |
| 11:55 | phenom_ | ,(set! *warn-on-reflection* true) (= (byte 10) (byte 10)) |
| 11:55 | clojurebot | java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set |
| 11:59 | TimMc | ,(binding [*warn-on-reflection* true] (= (byte 10) (byte 10))) |
| 11:59 | clojurebot | true |
| 11:59 | scottj | how come clojure uses same hash for 0 and -1? |
| 12:00 | TimMc | ,(map hash [0 -1]) |
| 12:00 | clojurebot | (0 -1) |
| 12:00 | scottj | I guess cause java does, why does java? it means you can't (case x 0 something -1 somethingelse) |
| 12:00 | TimMc | scottj: Not seeing it. |
| 12:01 | TimMc | ,(map (comp hash long) [0 -1]) there we go |
| 12:01 | clojurebot | (0 0) |
| 12:01 | scottj | *clojure-version* => {:major 1, :minor 3, :incremental 0, :qualifier "alpha4"} (map hash [0 -1]) => (0 0) |
| 12:02 | TimMc | Happens in 1.2 as well. |
| 12:02 | TimMc | Oh, interesting -- you're getting that without using long. |
| 12:02 | TimMc | ,(doc case) |
| 12:02 | clojurebot | "([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need not be quoted. If the expression is equal to a test-constant, the corresponding result-expr is returned. A single default expression can fol... |
| 12:03 | scottj | probably tied into 1.3 returning longs by default if it can I think |
| 12:04 | TimMc | I had no idea that case used hashes. |
| 12:05 | TimMc | scottj: What happens if you do #{0 -1} ? |
| 12:07 | scottj | #{0 -1}. (.hashCode 0) and (.hashCode -1) both return 0 |
| 12:07 | devn | ,(hash 0132294329432) |
| 12:07 | clojurebot | Invalid number: 0132294329432 |
| 12:07 | devn | ,(hash 01322) |
| 12:07 | clojurebot | 722 |
| 12:07 | TimMc | Why the leading 0? |
| 12:08 | scottj | base 8 I think |
| 12:08 | scottj | ,07 |
| 12:08 | clojurebot | 7 |
| 12:08 | scottj | ,08 |
| 12:08 | clojurebot | Invalid number: 08 |
| 12:09 | TimMc | I thought Clojure didn't do that! |
| 12:09 | TimMc | 10r08 |
| 12:09 | TimMc | ,10r08 |
| 12:09 | clojurebot | 8 |
| 12:10 | TimMc | Oh well. I guess it is using Java's number parsing. |
| 12:10 | scottj | what's that syntax mean? any base you want? |
| 12:10 | TimMc | yeah |
| 12:10 | scottj | cool |
| 12:11 | TimMc | ,36rnaqk2b |
| 12:11 | clojurebot | 1408757267 |
| 12:11 | TimMc | ,36rrrrrr |
| 12:11 | clojurebot | 46645335 |
| 12:15 | TimMc | ,(case (long 0) (long 0) :zero, (long -1) :neg1) |
| 12:15 | clojurebot | java.lang.IllegalArgumentException: No matching clause: 0 |
| 12:15 | TimMc | ,(case 0 0 :zero, -1 :neg1) |
| 12:15 | clojurebot | :zero |
| 12:16 | TimMc | ,(case -2 0 :zero, -1 :neg1) |
| 12:16 | clojurebot | java.lang.IllegalArgumentException: No matching clause: -2 |
| 12:16 | TimMc | Bah, typo. |
| 12:16 | TimMc | What do you suppose went wrong with my first case statement? |
| 12:22 | devn | ,0x2a |
| 12:22 | clojurebot | 42 |
| 12:22 | TimMc | ,0b1010101 |
| 12:22 | clojurebot | Invalid number: 0b1010101 |
| 12:22 | devn | :) |
| 12:23 | TimMc | scottj: Interesting, so set seems to work. |
| 12:24 | TimMc | scottj: What exactly happens when you write (case -1 0 :zero -1 :neg1) in 1.3? |
| 12:25 | devn | ,[32e-4 +3.14 888/3 \u0042 \u30DE :?] |
| 12:25 | clojurebot | [0.0032 3.14 296 \B \マ :?] |
| 12:32 | TimMc | http://dev.clojure.org/jira/browse/CLJ-426 <-- This is the closest ticket I can find to the long hash issue. |
| 12:41 | jarpiain | ,(case 'long (long 0) :zero, (long -1) :neg1) |
| 12:41 | clojurebot | :neg1 |
| 12:43 | TimMc | wut |
| 12:44 | TimMc | So, in other words... case is entirely fucked. |
| 12:46 | incandenza | it says the tests must be compile-time literals, so I don't think (long 0) qualifies |
| 12:47 | TimMc | Why does it even compile, then? |
| 12:48 | Chousuke | ,(case 'test (foo test) :test, (something else) :test2) |
| 12:48 | clojurebot | :test |
| 12:49 | Chousuke | lists in case specify alternatives |
| 12:49 | Chousuke | ,(case 'foo (foo test) :test, (something else) :test2) |
| 12:49 | clojurebot | :test |
| 12:49 | incandenza | ah |
| 12:54 | __name__ | angerman: are your shops opened at sun? |
| 12:55 | angerman | no |
| 12:55 | __name__ | here only few shops have opened until 8pm. |
| 12:58 | TimMc | OK, so the long hash thing is part of that ticket. |
| 12:59 | TimMc | I see that the collision is discovered at case's macro runtime, not use-time. |
| 13:07 | TimMc | Or wait... is this long hash thing known by the devs? |
| 13:24 | mefesto | Hey everyone |
| 13:24 | mefesto | I have a project that I'd like to layout like this: http://pastie.org/1690020 |
| 13:25 | mefesto | Using leiningen for each subdir. How can I make use of the common lib in the other projects? Do I need to do a lein install the common-lib for each change and a lein deps in the server/client subprojects or is there a better way? |
| 13:29 | TimMc | mefesto: You can use symlinks and lein checkout dependencies. |
| 13:30 | mefesto | TimMc: I'm not clear what you mean, could you expand a bit? |
| 13:32 | dpritchett | when's the JoC party? |
| 13:33 | TimMc | mefesto: Go to the main Leiningen page and search for "checkout dependencies" |
| 13:35 | mefesto | TimMc: cool thanks. Looks like that will work for me. Although a guy I work with is on windows ... too bad for him :) |
| 13:35 | TimMc | indeed |
| 13:36 | TimMc | That's one of the reasons I can never go back to Windows. |
| 13:36 | TimMc | I believe there is some way of making symlink-like things in NTFS, but it isn't in the UI. |
| 14:04 | dpritchett | Clojure and JVM pecadilloes are the reason my newest laptop runs OSX. Got tired of all of my favorite niche languages being harder to play with even with Cygwin. |
| 14:43 | devn | is clojure niche still? |
| 14:44 | devn | i guess it doesn't really matter to me either way, but it seems like the community is growing pretty fast, people are hiring clojure programmers, etc. |
| 14:44 | dpritchett | it's not an LCD sort of thing like java, c#, or php |
| 14:44 | dpritchett | i mean, you're not going to see many job listings for clojure here in memphis |
| 14:45 | TimMc | I'm applying for a position at Akamai where I would be writing Clojure. |
| 14:45 | dpritchett | but what I was referring to is my early experiences with clojure node.js and various other comparatively new and exciting languages |
| 14:45 | dpritchett | the blog posts and tutorials are always written by someone with a real live posix environment |
| 14:46 | dpritchett | trying to follow along under winXP was always frustrating since learning a new language/platform is enough of a headache that mentally translating everything to windows wasn't worth it |
| 14:46 | dpritchett | sort of like trying to raise VC for a startup in alabama. you could do it, but it's harder than it needs to be. |
| 14:46 | devn | im echoing what someone else was saying -- think it was maybe guy steele at strange loop last year? |
| 14:47 | devn | but it's interesting and exciting that new languages are being considered right now |
| 14:47 | dpritchett | sure is! |
| 14:47 | dpritchett | i regret missing strange loop last year, it's only half a day's drive |
| 14:47 | dpritchett | maybe i can get it this year |
| 14:48 | devn | im in WI so I drove down (butt was asleep about half way) |
| 14:48 | devn | but definitely going to go again -- it's a great mix |
| 14:49 | dpritchett | i know at least one guy from Memphis who went... i need to have lunch with him again soon |
| 14:58 | devn | hm, time to play with https://github.com/jonromero/music-as-data.git |
| 15:05 | scottj | I'm not sure the TIOBE language popularity index relates well to industry, it has Objective-C and Lisp neck and neck |
| 15:05 | companion_cube | lisp is as used as objective-C ?? |
| 15:07 | pdk | maybe with some big technicalities slapped on the way they're counting |
| 15:08 | dnolen | scottj: that's combining Common Lisp, Scheme and Clojure I think. |
| 15:09 | scottj | dnolen: don't think so, it has scheme separately |
| 15:09 | dnolen | scottj: perhaps combining CL then. |
| 15:10 | scottj | but I see now how they're doing it. they have 7 sources including job postings on craigslist, bookmarks on delicious, code on google code, projects on freshmeat, books purchases at some retailer, etc |
| 15:10 | incandenza | how are they neck and neck anyway? doesn't look like it to me: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html |
| 15:12 | scottj | oh my bad, I was looking at http://www.langpop.com/ hehe I don't know how I got there looking for tiobe |
| 15:12 | devn | incandenza: hal, is that you? |
| 15:13 | devn | or are you the samizdat? |
| 15:14 | incandenza | I guess I'm not, or I should be incapable of speech |
| 15:15 | devn | wait a minute, this is a terminal window, you're just typing, so how do i know you're not hal? |
| 15:35 | devn | 2 questions: I can't seem to find http://code.google.com/p/jfugue/ in a maven repository, but it seems like it should be there, any ideas on search tools to find its proper home? 2nd related question: what's the best way to get it into my project.clj so it can be redistributed without making people hunt down a jar and add it manually (aside from including it in the repo) |
| 15:37 | mrBliss`` | devn: I usually look on http://jarvana.com but unfortunately it can't find JFugue. |
| 15:38 | devn | yeah i set this up a long time ago and i found an issue for JFugue that stated they were going to make it available there |
| 15:38 | devn | so i know it exists somewhere |
| 15:38 | devn | i just have no idea where it is... |
| 15:39 | TobiasRaeder | hi :) |
| 15:39 | devn | 'lo TobiasRaeder |
| 15:40 | devn | mrBliss``: well, looks like i wasn't alone -- it's on clojars at least... |
| 15:40 | devn | mrBliss``: and whaddya know, I happen to be the one who uploaded it |
| 16:05 | alexyk | anybody used kendall-tau from incanter? |
| 16:56 | TimMc | I had a list of coordinates in n-dimensions, and needed to get the [min max] value for each dimension: ##(map (partial apply (juxt min max)) (apply map vector [[0 1] [2 3] [5 -1] [4 6] [-2 3]])) |
| 16:56 | sexpbot | ⟹ ([-2 5] [-1 6]) |
| 16:56 | TimMc | map partial apply juxt! |
| 17:02 | devn | hm, jfugue is pretty cool |
| 17:03 | TimMc | devn: What is it? |
| 17:03 | devn | it's a music library for java |
| 17:03 | devn | programming music |
| 17:04 | devn | it's big, but i want to write a wrapper for it |
| 17:04 | devn | TimMc: it has its own mini DSL for writing notes, rests, lengths of them, etc. |
| 17:04 | TimMc | Interesting. |
| 17:05 | devn | so (. (new Player) play (Pattern. "C5q Rw")) plays a C5 quarter note followed by a measure-long rest |
| 17:06 | devn | I want to write the wrapper, build an abstraction around the way it does notation to make it more data-like instead of keeping it all in a string |
| 17:07 | devn | although im not sure how the second part of that would be |
| 17:07 | devn | I guess I just want a more generative composable system for writing those strings programatically |
| 17:09 | devn | so (generate-chord-progression [2 5 1 {:measures 4}]) could produce something like Dm, G, C, C |
| 17:11 | zakwilson | PersistantHashMap lookups are O(log32 n), right? |
| 17:13 | devn | zakwilson: yes |
| 17:14 | zakwilson | Lookups aren't faster in the transient, are they? |
| 17:15 | devn | zakwilson: hm, good question |
| 17:15 | zakwilson | I know writes are faster. |
| 17:16 | opqdonut | i'd say not |
| 17:16 | devn | opqdonut: im guessing you're right but i cant say for sure |
| 17:17 | zakwilson | I think I might need to use a Java hashtable if I want more speed. |
| 17:18 | raek | I think transients has the same basic structure, but they allow some things to change in-place |
| 17:18 | opqdonut | yeah |
| 17:19 | opqdonut | no reason for non-transients to have poorer read performance |
| 17:20 | zakwilson | That's what I thought, but I figured I'd ask. I'm dealing with some large maps, and the diminishing read performance is starting to hurt. |
| 17:20 | zakwilson | Unfortunately, (into (Hashtable.) stuff) doesn't work. |
| 17:21 | raek | even if you have about 4 000 000 000 entries, the tree won't have more than 6 levels |
| 17:21 | devn | opqdonut: i mean, going with a transient and tersting could show you pretty quickly |
| 17:21 | devn | testing* |
| 17:21 | Chousuke | transients won't help read performance. :/ |
| 17:21 | opqdonut | indeed |
| 17:22 | devn | oops i read zakwilson say write and not read |
| 17:22 | devn | but i mean, it could still be worth trying a transient |
| 17:22 | devn | it wouldn't take much to benchmark |
| 17:23 | zakwilson | It looks like I'm dealing with 3 or 4 levels, but I'm doing a *lot* of lookups, so being 3-4 times slower is a big deal. |
| 17:23 | devn | what about structmaps? :X |
| 17:24 | devn | is that insane? |
| 17:24 | zakwilson | The keys are arbitrary strings. |
| 17:24 | devn | hmm |
| 17:25 | devn | zakwilson: what about using a database or something instead? |
| 17:25 | devn | it sounds like you're getting into that kind of territory |
| 17:26 | raek | zakwilson: 30000-1000000 entries? |
| 17:26 | devn | redis maybe? |
| 17:26 | zakwilson | Could database calls actually be faster than in-memory lookups? |
| 17:26 | zakwilson | raek: yes, though it could easily go over a million. |
| 17:28 | devn | zakwilson: redis is pretty blazing -- depending on the type you get O(1) in quite a few places |
| 17:28 | zakwilson | Constant time is good, but what's the overhead? |
| 17:28 | devn | there are some config options to care less about consistency and go for speed |
| 17:29 | devn | zakwilson: memory is the trade off with redis |
| 17:29 | zakwilson | (relative to java.util.hashtable) |
| 17:29 | devn | zakwilson: i wish i had a solid answer for you there, but i truthfully do not know |
| 17:30 | zakwilson | Memory is a concern too. I've run in to situations where my laptop is barely big enough for a dataset in memory as a Clojure map |
| 17:32 | devn | zakwilson: forgive me but I need to ask two things: 1, are you sure your reads are the problem |
| 17:33 | zakwilson | devn: yes |
| 17:33 | devn | and 2, how do you know |
| 17:33 | opqdonut | yeah, with clojure it's reflection that's usually the bottle neck |
| 17:33 | zakwilson | devn: because I'm doing tens of millions of them, and it slows down predictably when the dataset gets to a certain size. |
| 17:34 | devn | *nod* -- and that is fine but i think it's always important with performance concerns to have some sort of reliable data to point to that proves it |
| 17:34 | devn | ive seen people have terrible performance because of some seemingly innocuous bit of code somewhere else in the program |
| 17:34 | opqdonut | zakwilson: ah but your code might still have a constant factor slowdown somewhere else |
| 17:34 | devn | opqdonut: exactly |
| 17:34 | opqdonut | even though your asymptotics are expected |
| 17:34 | zakwilson | I suppose it's been a while since I hooked the profiler up to it. |
| 17:35 | devn | zakwilson: im definitely not saying you're wrong |
| 17:35 | opqdonut | try turning reflection warnings on, if you haven't yet |
| 17:35 | devn | but it's always good to have some hard data to look at and be sure you're attacking the right problem |
| 17:35 | devn | and what opqdonut said, but i suspect you've got them on already :) |
| 17:37 | devn | opqdonut: one reason you might look at redis is that it has its own virtual memory |
| 17:37 | devn | so the size of the set can exceed memory |
| 17:39 | devn | a couple of points on that: an OS's page is 4kB, the vsalue of a redis key may touch many pages even if the key is small enough to fit in a single page, and for these reasons, redis objects can be an order of magnitude larger in ram than they are when stored on disk, so if you're using the OS' virtual memory the OS needs to perform and order of magnitude more I/O versus a redis instance with VM |
| 17:39 | zakwilson | Yeah, I think it's time to get out the profiler before I try messing with Java data structures, but I'm pretty sure I want a 3-4x speedup if the option exists. |
| 17:40 | devn | now the only issue is that you end up needing to store ALL of your keys in memory at all times -- you can swap values to disk, but not keys |
| 17:40 | devn | so that poses some memory issues, but the tradeoff is you get some pretty blazing lookups without the extra I/O |
| 17:42 | zakwilson | I'm currently ok with everything in memory at once. Values are ints, so no problem there. |
| 17:42 | zakwilson | When I start exceeding what my laptop can handle, or making a real product out of this, I'll need to care about real datastores. |
| 17:42 | devn | either way, redis is probably worth a look |
| 17:42 | devn | you sacrifice some consistency for performance, but overall it's very fast |
| 17:43 | devn | the CAP problem and all of that |
| 17:43 | zakwilson | Thanks for the pointer to redis. I'm not at all familiar with it, and had been leaning toward Mongo as a place to persist stuff (I'm currently just spitting maps to disk) |
| 17:43 | devn | my suggestion is you dont want to use mongo for this |
| 17:44 | devn | redis is a k/v store, and that sounds like exactly what you have |
| 17:44 | devn | you can use mongo for that, but performance-wise i think redis will be a better fit |
| 17:44 | devn | and i say this with absolutely no context about the actual problem you're trying to solve :) |
| 17:45 | zakwilson | Well, what I really have is a small map where the values are {string int}, but that seems like it would be easy enough to model with a k/v store. |
| 17:45 | devn | when you do a lookup for a key are you just doing something like (:key {:key 1})? |
| 17:46 | devn | or is it fuzzier? |
| 17:46 | devn | and is it a plain map, not sorted right? |
| 17:46 | zakwilson | Correct |
| 17:46 | devn | yeah, redis would probably be a good fit |
| 17:46 | zakwilson | {"foo" {"bar" 4 "baz" 8}} (to oversimplify) |
| 17:47 | devn | one note on redis: if you decide to use it, take your time in configuration |
| 17:47 | zakwilson | It's those inner maps that are often huge, though I sometimes have tens of thousands of keys in the outer. |
| 17:47 | devn | setup a simple harness for testing configuration changes and play with the config for a bit |
| 17:47 | zakwilson | Alright, good to know. |
| 17:47 | devn | there are a lot of options -- when we originally used redis we had the VM off and tried to do 1M records off the bat for fun and we were like: "this seems slow..." |
| 17:48 | devn | revisiting the config changed all of that |
| 17:49 | zakwilson | Have you compared redis reads to in-memory datastructure reads? |
| 18:01 | devn | zakwilson: there are benchmarks out there i think but no, not personally. |
| 18:02 | zakwilson | devn: thanks for the pointer in the right direction. I probably won't be going for redis just yet, but when I need a real datastore, I'll look in to that. |
| 18:13 | quotemstr | The Clojure object-reference syntax is pretty damned neat. Has anyone ported it to CLOS? |
| 18:19 | dnolen | quotemstr: object-reference syntax? |
| 18:19 | quotemstr | The Java interop stuff. |
| 18:20 | quotemstr | In principle, you could implement the same thing with a CLOS system supporting a MOP. |
| 18:20 | quotemstr | It's both safer for slots than with-slots, and more convenient for methods. |
| 18:20 | quotemstr | Granted, you couldn't map all generic functions --- only those following a certain convention. But most do. |
| 18:32 | devn | http://blog.notdot.net/2010/07/Damn-Cool-Algorithms-Levenshtein-Automata |
| 18:45 | DollaMan | does using :> in enlive selectors improve performance? |
| 18:54 | amac | anyone familiar with pallet/jcloud? |
| 19:02 | ekoontz | is there a clojure equivalent of Common LIsp's (progn) |
| 19:03 | wooby | ekoontz: 'do' |
| 19:03 | brehaut | ekoontz: do |
| 19:03 | ekoontz | thanks guys :) |
| 19:04 | wooby | amac: a little, you should check out #pallet |
| 19:04 | amac | ah, good call |
| 19:09 | scottj | quotemstr: if you like that java interop syntax you should look at arc's ssyntax |
| 19:10 | Derander | is it possible to do something like (defn new-draw [the-fn] (defn draw-function [g] (apply the-fn g)) (.repaint pane)) where the-fn is (fn [g] (.drawLine g 100 100 10 15))? |
| 19:10 | Derander | basically I'm trying to swap out the drawing function of a proxy JPanel and redraw it |
| 19:10 | Derander | for lazy repl hacking |
| 19:11 | brehaut | Derander: i believe proxys have a way to duck punch their methods on a per isntance basis |
| 19:11 | brehaut | but the easiest way would be to close over an atom or ref |
| 19:12 | Derander | fair enough |
| 19:13 | raek | Derander: also note that the inner defn will create (or modifiy) a _global var_ and is not limited by the lexical scope (use let or letfn for that) |
| 19:14 | Derander | yeah |
| 19:14 | Derander | I was being lame and hacky. I'm calling draw-function inside of the paintComponent instance method on the proxy |
| 19:14 | Derander | so I figured I'd just swap it out and redraw |
| 19:14 | Derander | it works if I run (defn draw-function ...) in the repl, but then I also have to run (.repaint panel) |
| 19:14 | Derander | I was trying to combine the steps |
| 19:15 | raek | Derander: https://gist.github.com/877894 |
| 19:15 | brehaut | (doc update-proxy) |
| 19:15 | clojurebot | "([proxy mappings]); Takes a proxy instance and a map of strings (which must correspond to methods of the proxy superclass/superinterfaces) to fns (which must take arguments matching the corresponding method, plus an additional (explicit) first arg corresponding to this, and updates (via assoc) the proxy's fn map. nil can be passed instead of a fn, in which case the corresponding method will revert to the default behavior. |
| 19:15 | raek | I also wanted to have a proxy object that was easy to redefine, so it did it like that |
| 19:16 | Derander | raek: I will read and attempt to comprehend this after I try out update-proxy |
| 19:17 | raek | a normal call to proxy will result in something very similar to the body of list-cell-renderer, but with an anonynous fn instead of #'prepare-renderer |
| 19:18 | raek | instead of replacing which function the proxy should use every time I change something, I let it call the var instead (which will deref it at each invokation) |
| 19:18 | raek | update-proxy is a good option too |
| 19:19 | brehaut | &(let [p (proxy [Object] [] (toString [] "Hello"))] (prn (str p)) (update-proxy p {"toString" (constantly "foobar")}) (str p)) |
| 19:19 | sexpbot | java.lang.IllegalStateException: Var null/null is unbound. |
| 19:20 | brehaut | that was unexpected |
| 19:20 | brehaut | ,(let [p (proxy [Object] [] (toString [] "Hello"))] (prn (str p)) (update-proxy p {"toString" (constantly "foobar")}) (str p)) |
| 19:20 | clojurebot | java.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound. |
| 19:20 | brehaut | oh well. it runs fine in my repl |
| 19:20 | Derander | okay, I think this is working adequately |
| 19:21 | Derander | update-proxy does the trick |
| 19:21 | Derander | thanks all |
| 19:21 | raek | it's pretty cool to be able to fix GUI code without even closing the window... |
| 19:21 | Derander | noooo kidding |
| 19:21 | brehaut | totally :) |
| 19:21 | Derander | I'm dicking around with polyganizations and triangulations of point clouds |
| 19:21 | Derander | so being able to see changes quickly is nice |
| 19:22 | DollaMan | hm.... vars work without deref? |
| 19:22 | DollaMan | ,(#'first [1 2 3]) |
| 19:22 | clojurebot | 1 |
| 19:22 | raek | yes, they call the thing they contain |
| 19:22 | DollaMan | I thought I had to do ##(@#'first [1 2 3]) |
| 19:22 | sexpbot | ⟹ 1 |
| 19:23 | raek | (yes, they work without deref *in a function position*) |
| 19:23 | brehaut | DollaMan: they are derefable, but thats not all they are |
| 19:24 | DollaMan | so how about my enlive question :) |
| 19:24 | brehaut | DollaMan: i dont know if anyone has ever benchmarked it |
| 19:25 | DollaMan | I am speaking from a theoretical perspecive |
| 19:25 | DollaMan | if I use :> in a selector I am basically saying "search only 1 level deep for the next piece of selector" |
| 19:25 | DollaMan | which constrains the search |
| 19:25 | DollaMan | which should make it faster in theory |
| 19:26 | brehaut | well it is pruning a search space so from a 100 mile view; yes |
| 19:26 | DollaMan | I'm just asking if enlive prunes the search or not |
| 19:27 | brehaut | dollaman, how about you find out and report back: https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj |
| 19:27 | brehaut | i think you want to look at compile-keyword (line 295) |
| 19:28 | brehaut | and work out |
| 19:28 | DollaMan | too hard for me to understand I'm afraid |
| 19:29 | DollaMan | cgrand's code is short but hard to understand |
| 19:29 | brehaut | we are going to have to disagree on that point |
| 19:29 | DollaMan | ok :) |
| 19:45 | TimMc | I am totally using α, β, and γ as variable names. |
| 19:45 | brehaut | TimMc: amazing |
| 19:45 | TimMc | It is wonderful. |
| 19:45 | brehaut | without doubt |
| 19:45 | amac | pretty |
| 19:46 | Derander | is there something like apply that works with java methods? so (.drawOval g oval-coords) would work where oval coords is some vector containing integers [x, y, width, height]? |
| 19:46 | Derander | I suppose I could write a clojure wrapper fn |
| 19:47 | Derander | oh hey, I suppose I should try apply and see if it works on java methods |
| 19:48 | Derander | oh darn, nope. |
| 19:48 | raek | Derander: the compiler will look up the signature of .drawOval at compile time. it is possible to do a "apply" using reflection, but if you know the signature at compiletime, that feels a bit bloated to me |
| 19:49 | raek | you can do something like (apply #(.drawOval %1 %2) some-coll) though |
| 19:49 | Derander | yeah |
| 19:49 | Derander | that's what I'll do |
| 19:55 | brehaut | Derander: potentiall memfn could help too? |
| 19:55 | Derander | brehaut: reading |
| 19:56 | Derander | brehaut: yes, I think that works. |
| 19:57 | raek | isn't memfn from before the #() syntax was introduced? I think it results in exactly the same thing |
| 19:57 | brehaut | raek: maybe? |
| 19:57 | brehaut | raek: but there has always been #() as long as ive been following clojure |
| 19:57 | raek | http://clojure.org/java_interop#Java Interop-The Dot special form-(memfn method-name arg-names*) |
| 19:58 | raek | Note it almost always preferable to do this directly now, with syntax like: [example using #()] |
| 19:58 | raek | "" |
| 19:58 | brehaut | raek: cool thanks :) |
| 19:59 | raek | hrm, but with memfn you can name the arguments... |
| 20:00 | Derander | (apply #(.drawOval %1 %2 %3 %4 %5) g (point x y)) does not seem equivalent to (apply (memfn drawOval) g (point x y)), but my understanding of the documentation says it should be |
| 20:00 | Derander | (point x y is a vector with 4 values) |
| 20:00 | Derander | (point x y)* |
| 20:01 | devn | raek: crazy you just mentioned that |
| 20:01 | devn | raek: i was just reading about something similar |
| 20:02 | devn | http://objectcommando.com/blog/2010/05/17/easy-java-interop-with-clojure/ |
| 20:03 | Derander | oh |
| 20:03 | Derander | I understand |
| 20:06 | raek | ,(macroexpand-1 '(memfn split re limit)) |
| 20:06 | clojurebot | (clojure.core/fn [target__3915__auto__ re limit] (. target__3915__auto__ (split re limit))) |
| 20:06 | raek | ,(macroexpand-1 '(memfn drawOval)) |
| 20:06 | clojurebot | (clojure.core/fn [target__3915__auto__] (. target__3915__auto__ (drawOval))) |
| 20:07 | raek | Derander: (memfn drawOval) expands to 0-ary function, so that's why you can't apply it with 5 args |
| 20:07 | Derander | raek: right |
| 20:07 | Derander | raek: that was my "I understand" moment :-) |
| 20:07 | raek | ah. :) |
| 20:07 | brehaut | Derander: sorry for leading you astray |
| 20:07 | Derander | it's fine. I like the memfn syntax better regardless |
| 20:08 | raek | for mor than 2 args, it definitely helps with readability |
| 20:14 | devn | raek: any existing libs come to mind that are the "gold standard" of wrapper library? |
| 20:14 | devn | as in, a wrapper around java code primarily |
| 20:15 | brehaut | devn: clojure.core? :P |
| 20:15 | devn | ha! yes but it is not "regular" I don't believe. Or is it? |
| 20:15 | devn | I'm talking about directly taking a java library and simply writing a clojure "interface". |
| 20:16 | devn | There are a lot of choices one has when wrapping a lib. The above example is good proof. |
| 20:16 | devn | Readability matters and I'm looking for a very readable and elegant version of a wrapper lib |
| 20:17 | devn | that uses clojure.core's existing abstractions |
| 20:18 | brehaut | enlive perhaps? its a wrapper around tagsoup i think? (ok, so wrapper sells it short, but nevertheless) |
| 20:18 | devn | yeah it's hard to find a wrapper that doesn't introduce additional functionality and muddy the water a bit |
| 20:18 | brehaut | yeah |
| 20:18 | devn | not really muddying so much as it is improving and enhancing |
| 20:18 | devn | still, nice to see a really clean vision of what an elegant wrapper looks like |
| 20:19 | brehaut | what about clj-time? |
| 20:19 | devn | i was just about to say i bet jodatime was well wrapped |
| 20:19 | devn | :D |
| 20:27 | raek | devn: well, I dunno what would make up a "gold standard"... |
| 20:28 | Derander | is there a simple built-in to do something like this? [[1 1] [2 2] [3 3] [4 4]] -> [[1 1 2 2] [2 2 3 3] [3 3 4 4]] |
| 20:29 | Derander | it is not popping out to me in the function list in the api reference |
| 20:29 | brehaut | &(partition-all 2 1 [[1 1] [2 2] [3 3] [4 4]]) |
| 20:29 | sexpbot | ⟹ (([1 1] [2 2]) ([2 2] [3 3]) ([3 3] [4 4]) ([4 4])) |
| 20:29 | shachaf | Derander: I don't know about Clojure, but you can probably do something like Haskell > (\l -> zipWith (++) l (tail l)) [[1,1],[2,2],[3,3],[4,4]] |
| 20:30 | Derander | shachaf: I wish my haskell foo were stronger |
| 20:30 | brehaut | &(map concat (partition-all 2 1 [[1 1] [2 2] [3 3] [4 4]])) |
| 20:30 | sexpbot | ⟹ (([1 1] [2 2]) ([2 2] [3 3]) ([3 3] [4 4]) ([4 4])) |
| 20:30 | Derander | brehaut: then map that |
| 20:30 | Derander | brehaut: I knew there would be something |
| 20:30 | shachaf | Derander: Just zip the list with its tail and then concat the result. |
| 20:30 | brehaut | hmm |
| 20:30 | brehaut | &(map flatten (partition-all 2 1 [[1 1] [2 2] [3 3] [4 4]])) |
| 20:30 | sexpbot | ⟹ ((1 1 2 2) (2 2 3 3) (3 3 4 4) (4 4)) |
| 20:30 | Derander | brehaut: that behavior is actually better -- I need to combine 4 4 at the end with another separate vector |
| 20:31 | brehaut | &(map flatten (partition 2 1 [[1 1] [2 2] [3 3] [4 4]]) |
| 20:31 | sexpbot | ⟹ ((1 1 2 2) (2 2 3 3) (3 3 4 4)) ; Adjusted to (map flatten (partition 2 1 [[1 1] [2 2] [3 3] [4 4]])) |
| 20:31 | Derander | shachaf: haha. I am reading learnyouahaskell right now |
| 20:31 | Derander | shachaf: it's on my list of languages to learn when not sleep deprived |
| 20:32 | Derander | brehaut: partition is such a useful function. perhaps this time it'll stick in my mind |
| 20:33 | DollaMan | how do I make a handler in Ring which returns an image (or other non-text data) |
| 20:34 | DollaMan | how do I host images in Ring |
| 20:34 | brehaut | DollaMan: ring response maps are allowed to have a file as the body |
| 20:34 | DollaMan | java.io.File? |
| 20:34 | clojurebot | chouser: Some high-tech profiling with Activity monitor and println shows that I'm doing 100% of one core and not so much IO, though the number of files being read is huge(I estimate 5 per second). |
| 20:35 | DollaMan | what about a stream? |
| 20:35 | raek | DollaMan: you can have an InputStream as a body too |
| 20:35 | brehaut | DollaMan: yes; may i suggest examining the ring spec? closely followed by the available middleware https://github.com/mmcgrana/ring/blob/master/SPEC |
| 20:36 | raek | DollaMan: my IRC bot has a web server that serves png files piped from dot: http://raek.se/trattern/src/se/raek/trattern/graph.clj |
| 20:36 | brehaut | DollaMan: https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/file.clj, https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/static.clj |
| 20:37 | brehaut | raek: thats a very nice example |
| 20:39 | raek | (the result: http://services.raek.se/graphs/irc/quakenet/d1d) |
| 20:39 | DollaMan | already implemented what this middleware does :D |
| 20:40 | brehaut | DollaMan: time to delete some code then! :D |
| 20:40 | amac | raek: neato. |
| 20:45 | ataggart | &(/ 1 3) |
| 20:45 | sexpbot | ⟹ 1/3 |
| 20:45 | ataggart | &(/ 1 3M) |
| 20:45 | sexpbot | java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. |
| 20:45 | ataggart | anyone else think that should turn into a Ratio? |
| 20:47 | amac | probably, that would likely create annoying-to-reproduce bugs |
| 20:47 | amac | implementation might be tricky though |
| 20:53 | amac | raek: thanks for introducing me to clojure through that code example... very handy. |
| 20:53 | amac | err loom in your clojure example |
| 20:55 | DollaMan | these ring wrappers can be confusing |
| 20:55 | brehaut | DollaMan: how so? |
| 20:55 | DollaMan | wrap-static for instance takes my handler as an argument |
| 20:56 | DollaMan | but when conditions are met |
| 20:56 | DollaMan | it ignores my handler and serves a file |
| 20:56 | brehaut | yes |
| 20:56 | brehaut | its a middleware; it interposes some logic between your code and the web server |
| 20:56 | brehaut | either (or both) on the request or response |
| 20:57 | DollaMan | ah..... I see now |
| 20:57 | DollaMan | I got confused because the guy was using app variable in code |
| 20:57 | DollaMan | which I confused with the app macro of moustache |
| 20:57 | brehaut | app is moustache's handler swissarmy knife |
| 20:57 | brehaut | oh right |
| 20:57 | DollaMan | the git coloring was misleading |
| 20:57 | brehaut | i see what you are saying |
| 20:57 | DollaMan | the app in let binding wasn't colored |
| 20:58 | DollaMan | but in fn call it was |
| 20:58 | DollaMan | my bad |
| 20:59 | Derander | https://gist.github.com/877961 <-- great success. |
| 20:59 | Derander | http://cl.ly/0e3d1D1t340L2g1s241T is the output |
| 21:00 | Null-A | Let's say I want a configuration file, both reading in and outputting. Do I require it to read it?, and to output it, what do I do? |
| 21:00 | Null-A | some way to serialize a hash-map is lisp reader syntax |
| 21:00 | amac | (doc slurp) |
| 21:00 | clojurebot | "([f & opts]); Reads the file named by f using the encoding enc into a string and returns it." |
| 21:00 | amac | ,(doc slurp) |
| 21:00 | clojurebot | "([f & opts]); Reads the file named by f using the encoding enc into a string and returns it." |
| 21:01 | amac | ,(doc spit) |
| 21:01 | clojurebot | "([f content & options]); Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/writer." |
| 21:01 | Null-A | amac: there's some encoding? |
| 21:02 | amac | Null-A: what do you mean? |
| 21:03 | amac | oh, no |
| 21:03 | amac | your config files are probably just straight text; pass them into slurp and it'll read them just fine |
| 21:03 | Null-A | amac: ok, so i'll use print-str to produce the config files from clojure hash maps |
| 21:03 | Null-A | I want to use clojure style |
| 21:05 | Null-A | er, prn-str is what I want |
| 21:05 | Null-A | for output |
| 21:05 | Null-A | now I just need the inverse |
| 21:05 | amac | you can just dump the map in there &(spit "aoeu.txt" {:a 1}) |
| 21:06 | amac | slurp/spit are for read/write respectively |
| 21:07 | Null-A | amac: slurp returns a string of the file contents |
| 21:07 | Null-A | now I want to turn it into a hashmap |
| 21:09 | amac | well, not exactly safe but you could use read-string |
| 21:09 | amac | (doc read-string) |
| 21:09 | clojurebot | "([s]); Reads one object from the string s" |
| 21:09 | amac | (read-string "{:a 1}") |
| 21:10 | amac | ,(read-string "{:a 1}") |
| 21:10 | clojurebot | {:a 1} |
| 21:10 | amac | there it goes |
| 21:11 | scottj | anyone have a convention they really like for locals that share name of functions? name*, aname, name', name1? |
| 21:11 | amac | just be careful that you're basically executing whatever is in your config |
| 21:11 | Null-A | amac: ok |
| 21:11 | Null-A | amac: thanks! |
| 21:11 | amac | scottj: I think * is what is most common, at least to replace core fns. |
| 21:12 | amac | Null-A: np. :) |
| 21:13 | Null-A | amac: Yah I just found example code that did the same thing "(with-in-str ... (read)) |
| 21:13 | Null-A | there was a comment "Security risk?" |
| 21:14 | amac | yeah, someone could easily write some nastyness into your config file |
| 21:14 | amac | your other option is to write a parser, but that's more time consuming |
| 21:15 | brehaut | if you only read the config file, but not eval it, there shouldnt be any risk |
| 21:15 | Null-A | There's so many security holes on unix systems I think if people have access to your file system |
| 21:15 | Null-A | just change dot emacs or something |
| 21:15 | Null-A | brehaut: does read-string do eval? |
| 21:16 | brehaut | no |
| 21:16 | brehaut | ,(read-string "#(inc %)") |
| 21:16 | clojurebot | (fn* [p1__5464#] (inc p1__5464#)) |
| 21:16 | amac | brehaut: well, at some point he'll be doing something with that object and it will get evaluated |
| 21:16 | Null-A | ,(read-string {:a (+ 1 1)}) |
| 21:16 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String |
| 21:16 | Null-A | ,(read-string "{:a (+ 1 1)}") |
| 21:16 | clojurebot | {:a (+ 1 1)} |
| 21:17 | brehaut | amac: i might have missed something, but i didnt see any mention of that |
| 21:17 | Null-A | ,(:a (read-string "{:a (+ 1 1)}")) |
| 21:17 | clojurebot | (+ 1 1) |
| 21:17 | Null-A | ,(eval (:a (read-string "{:a (+ 1 1)}"))) |
| 21:17 | clojurebot | DENIED |
| 21:17 | Null-A | that's pretty cool |
| 21:17 | brehaut | yeah |
| 21:17 | amac | brehaut: I'm assuming |
| 21:18 | brehaut | amac: if its just a config, then it just needs to be data, so you never need to call eval |
| 21:18 | brehaut | its no different to using json frinstance |
| 21:24 | amac | brehaut: yeah that's true I suppose. |
| 22:02 | devn | anyone here read programming clojure, practical clojure, clojure in action, and joy of clojure? |
| 22:02 | devn | i know that's a tall order, but they're all fairly short |
| 22:02 | devn | as far as programming books go |
| 22:03 | devn | im curious and interested to compare notes |
| 22:27 | brehaut | seems to me that an library that compiled template snippets to both enlive (using enlive syntax) and javascript using jquery and scriptjure would be pretty awesome |
| 22:31 | mec | There doesnt happen to be a way to define java in clojure is there? |
| 22:32 | brehaut | mec what do you mean by that? construct java asts and render them to .java source? |
| 22:36 | mec | I havnt really thought about how it would be done, but maybe define a java method inline |
| 22:36 | brehaut | mec: step back a moment. what purpose do you want this for? |
| 22:39 | mec | trying to write some faster math stuff, although im probably doing the hints all wrong |
| 22:40 | brehaut | which version of clojure are you using? |
| 22:40 | mec | 1.2 cant get 1.3 to work right with clojurebox |
| 22:41 | brehaut | ok. your a bit out of luck there. typically if you want to call out to some java code for your project, you write the java in a seperate java source tree and let your project tool manage it |
| 22:41 | mec | i thought so |
| 22:42 | brehaut | it would be pretty horrible to have java just smushed into a clojure block :P |
| 22:43 | mec | i don't think its too abnormal, a lot of languages let you inline the lower level language |
| 22:44 | brehaut | clojure isnt a lot of languages :P |
| 23:02 | scottj | mec: if you can get 1.3 working then you should be able to get a lot closer to java like performance in regular clojure |
| 23:03 | mec | I'm trying to find something on that now |
| 23:04 | brehaut | mec: what does clojurebox provide you? is it a clojure install + emacs configuration? |
| 23:04 | mec | ya for windows |
| 23:04 | scottj | it's really nice |
| 23:05 | brehaut | does it run ontop of a project tool like lein? |
| 23:06 | scottj | I don't think so, it predates lein |
| 23:06 | mec | it works with lein swank, but i havnt played with any build tools yet, too painful |
| 23:06 | scottj | how does it not work with 1.3? |
| 23:07 | scottj | if you start a lein project, use clojure 1.3, then lein swank can you connect to it from clojurebox? |
| 23:07 | brehaut | mec lein is your build tool |
| 23:11 | mec | does contrib not have an alpha6 release? |
| 23:13 | brehaut | contrib is getting a big shakedown for 1.3 |
| 23:27 | mec | i just dont have a clue how to get clojurebox to run a different version |
| 23:29 | scottj | you would run lein swank and then M-x slime-connect |
| 23:30 | scottj | I'm guessing now you're running M-x slime, don't do that to connect to a 1.3 running lein swank |
| 23:31 | mec | right now i either just start clojurebox or click on a .clj file, i dont use lein |
| 23:33 | scottj | well you should learn it :) hopefully it works better on windows now |
| 23:33 | scottj | or you can look in the clojure box configs (.el files probabl) and find where it points to the clojure jar and point it to the 1.3 one |
| 23:40 | mec | that just gives all sorts of errors |
| 23:41 | mec | i believe when i tried lein with 1.3 it wouldnt give me a slime repl at all, just inferior |
| 23:44 | mec | do i just do [org.clojure/clojure "1.3.0"] ? |
| 23:51 | rdeshpande | hey guys, as a new clojure programmer is it advised to learn on clojure 1.3 instead of 1.2? if so, what resources are recommended for 1.3 learning? |
| 23:52 | brehaut | start with 1.2 |
| 23:52 | brehaut | 1.3 is very much an alpha ATM |
| 23:52 | mec | ... |
| 23:53 | mec | lein swank is just giving me the same errors clojurebox did :x |
| 23:53 | brehaut | mec: i think it needs -ALPHA6 |
| 23:53 | mec | brehaut: ya fixed that one |
| 23:54 | pdk | 1.3 is hardly ready for production use |
| 23:54 | rdeshpande | interesting that labrepl has you install 1.3 |
| 23:55 | brehaut | rdeshpande: more experienced clojure users have good reasons to be wanting to work with 1.3, but if you are starting out 1.2 is the stable release, has the majority of tooling and library support etc |
| 23:59 | brehaut | rdeshpande: oh. misread your statement. yeah that is interesting |