2011-02-25
| 00:44 | Sgeo | @(macroexpand '(comment Lah de dah)) |
| 00:44 | Sgeo | &(macroexpand '(comment Lah de dah)) |
| 00:44 | sexpbot | ⟹ nil |
| 00:47 | Null-A | Gen-class isn't working for me https://gist.github.com/843408 |
| 00:47 | Null-A | When I execute the let statement, i get class not found. |
| 00:57 | Sgeo | It simply won't run :( |
| 00:59 | Sgeo | Here we go |
| 02:08 | no_mind | using compojure, I want to defien a route which has an optional param. How do I this ? |
| 02:42 | Derander | no_mind: my routing api knowledge is low because it's late right now, but I would define the route twice once w/ param, once w/o |
| 03:16 | bartj | If I reference a string as: |
| 03:16 | bartj | blah/x |
| 03:16 | bartj | I am not able to dynamically construct it: |
| 03:17 | bartj | ie. given "blah" and "x" are strings |
| 03:17 | Derander | no_mind: oh, I was also thinking rails instead of compojure. whoooooooooooooooooops |
| 03:27 | TobiasRaeder | morning |
| 03:28 | bartj | anyone ? |
| 03:34 | Chousuke | bartj: I don't understand your question |
| 03:34 | Chousuke | bartj: do you mean creating a symbol like blah/x? Just (symbol "blah" "x") |
| 03:35 | bartj | yes and evaluate it |
| 03:35 | Chousuke | sounds suspicious |
| 03:36 | Chousuke | you can evaluate things with eval, of course, but make sure it's what you really need to do. |
| 03:36 | Chousuke | most clojure code will never need to use eval directly. |
| 03:37 | Chousuke | and if user input is involved, it becomes somewhat of a security issue. |
| 03:37 | mroh | hey |
| 03:41 | Adamant | Chousuke: not somewhat, it does. one of the classic security issues for the Lisps and derived languages with an eval function |
| 03:50 | bartj | Chousuke, when I do a : (eval (symbol "blah" "x")) |
| 03:50 | bartj | I get a: No namespace blah |
| 03:50 | bartj | but, things work just fine when I do a: blah/x |
| 03:51 | Chousuke | huh |
| 03:53 | Chousuke | so what is it that you're trying to do anyway? |
| 03:54 | Chousuke | It's hard to tell what's broken when there's no real code to look at |
| 03:54 | Chousuke | and I'm interested in what you are trying to accomplish by using eval anyway. |
| 04:01 | bartj | sorry for the delay |
| 04:01 | bartj | let me explain |
| 04:02 | bartj | I dynamically want to pick up strings from a files |
| 04:02 | bartj | let us call them A and B |
| 04:02 | bartj | these files have the same variables defined: x |
| 04:03 | bartj | no, I would like to pick up B/x if B is the file I would like to get it from |
| 04:03 | bartj | *now |
| 04:04 | bartj | so, what I do is: |
| 04:04 | bartj | (:require [path.A :as A] [path.B :as B]) |
| 04:05 | bartj | and (eval (symbol "B" "x")) |
| 04:09 | fliebel | morning |
| 04:12 | raek | bartj: I don't know if this approach is the best way to do it (what you presented is a solution, but we still don't know the underlying problem you are trying to solve), but I don't see where the error is: http://pastebin.com/DH1P5Bfb |
| 04:14 | raek | if you are making your own file format, it's probably safer to make a function that interprets it rather than converting it to clojure code and evaling it. |
| 04:15 | raek | (interpret-in-context {:x "hello"} (slurp "filename.txt")), rather than (eval (slurp "filename.txt")) |
| 04:34 | fliebel | Does anyone here have experience with protobuf? |
| 04:38 | fliebel | I was thinking it could be used to parse binary files, but it seems to generate and parse a fixed type of file? |
| 04:41 | bartj | raek, sorry, I was away for lunch |
| 04:41 | bartj | strangely, it does work from the REPL |
| 06:15 | hoeck | lypanov: why? are you afraid of the climate change and a flooded country? |
| 06:15 | lypanov | hoeck: various reasons - no startup culture, annoying health care (bad personal experiences) |
| 06:16 | lypanov | as for climate change... no response. |
| 06:16 | lypanov | :) |
| 06:16 | hoeck | just joking :P |
| 06:16 | lypanov | phew :P |
| 06:17 | lypanov | dutch people sometimes even have that view... kinda scares me. probably the safest (from water level issues) country on the planet other than maybe tibet. |
| 06:17 | lypanov | america / india / etc, now they are fucked ;) they hire dutch people... |
| 06:18 | hoeck | lypanov: where do you live currently, and what do you expect from moving to germany? |
| 06:20 | lypanov | hoeck: the hague. previously amsterdam. as i said - start up culture, actual programmers in large companies. etc. |
| 06:21 | ogrim | Does anyone know how I may store '(101010 001100) as integers instead of (101010 576) as it evaluates to? |
| 06:21 | babilen | lypanov: and where do you plan to move? (just curious) |
| 06:21 | lypanov | probably berlin |
| 06:21 | hoeck | personally, I was astonished that there are even some "startups" in the city I'm living in (dresden), thought at first that such things only exist in the big urban areas |
| 06:21 | lypanov | maybe frankfurt |
| 06:22 | tomoj | ,010 |
| 06:22 | clojurebot | 8 |
| 06:22 | babilen | lypanov: don't move to frankfurt. berlin is a good choice, but you might want to look around. hamburg is nice as well. anyway, one goes where the job is :) |
| 06:22 | hoeck | lypanov: if I would have to move, I'd either move to Hamborg or Berlin |
| 06:23 | hoeck | there are even some companies there listing clojure on their job ads :) |
| 06:24 | ejackson | ogrim: (Integer/parseInt "10101" 2) if they are strings initially |
| 06:25 | ogrim | tomoj: I see that converts 001100 to 576, but I just want to store 001100 in a list. ejackson: they should be integers initially. I do (def init-pop '(001100)) and want it to stay 001100 |
| 06:26 | ogrim | The only workaround I found was parsing it with java calls, but that seemed uncessesarily complex |
| 06:27 | Chousuke | ogrim: there's no way to do that. |
| 06:27 | ejackson | the convention is that if it starts with 0 its octal |
| 06:27 | Chousuke | since 001100 *is* 576 |
| 06:27 | ejackson | you could make it a list of integers, or a bit array i guess |
| 06:27 | clgv | ogrim: you understand that integers are always stored as binary? just the repl prints them as decimals bei default? ;) |
| 06:28 | Chousuke | (dunno if it actually is, just going by what you said :P) |
| 06:28 | Chousuke | the point being, numbers are numbers, no matter which base they're in. |
| 06:28 | clgv | Chousuke: lol it isnt. 001100 = 12 ;) |
| 06:28 | Chousuke | clgv: that's what I thought. :P |
| 06:29 | Chousuke | hm |
| 06:29 | ogrim | oh ok. I'll see what I'll figure out then. I'm pretty new to Clojure as I come straight from Java and CLisp |
| 06:29 | ejackson | octal |
| 06:29 | Chousuke | I guess 001100 gets parsed as octal |
| 06:29 | Chousuke | yeah |
| 06:29 | clgv | ah leading zero, ok ;) |
| 06:29 | Chousuke | what was the binary syntac? |
| 06:30 | Chousuke | syntax |
| 06:30 | ogrim | thanks for the help everyone :) |
| 06:30 | clgv | ogrim: in java it's the same ;) |
| 06:32 | ejackson | Chousuke: I cant find one ! |
| 06:37 | Chousuke | ,2r1010 |
| 06:37 | clojurebot | 10 |
| 06:37 | Chousuke | that works at least |
| 06:37 | Chousuke | but there was another one too |
| 06:38 | ejackson | nice |
| 06:38 | Chousuke | ,0b1010 |
| 06:38 | clojurebot | Invalid number: 0b1010 |
| 06:38 | Chousuke | hm |
| 06:38 | clgv | ,1010d |
| 06:38 | clojurebot | Invalid number: 1010d |
| 06:38 | Chousuke | ,b1010 |
| 06:38 | clojurebot | java.lang.Exception: Unable to resolve symbol: b1010 in this context |
| 06:39 | Chousuke | gah, oh well |
| 06:40 | Chousuke | I should know, I've written a clojure reader before ;/ |
| 06:41 | clgv | chousuke: http://faustus.webatu.com/clj-quick-ref.html seems there isnt |
| 07:03 | tscheibl | hi there |
| 07:04 | tscheibl | (if a a b) ... is there a function which does the same without the redundant 'a' ? |
| 07:04 | ejackson | or |
| 07:05 | tscheibl | ahhhh |
| 07:05 | Dranik | hi all! |
| 07:05 | tscheibl | ,(let [a 42 b 43] (or a b) |
| 07:05 | clojurebot | EOF while reading |
| 07:05 | tscheibl | ,(let [a 42 b 43] (or a b) ) |
| 07:06 | clojurebot | 42 |
| 07:06 | Dranik | again, what's the difference between #^ and ^ except that #^ is old? |
| 07:06 | tscheibl | ,(let [a nil b 43] (or a b) ) |
| 07:06 | clojurebot | 43 |
| 07:06 | tscheibl | I'm such a noob :( |
| 07:07 | ejackson | we're all noobs. |
| 07:07 | ejackson | if we're not, we're working below potential. |
| 07:10 | tscheibl | for the last 5 days I manage to reduce the lines of code of my project for about 75% while retaining all the functionality |
| 07:10 | ejackson | that is the joy of clojure :) |
| 07:10 | ejackson | wel... one of them. |
| 07:10 | tscheibl | I mean I mange to reduce it to 75% EVERY day |
| 07:11 | clgv | tscheibl: calling it a success depends on whether it's still readable and easily understandable ;) |
| 07:11 | ejackson | it also has lots or lurvely, curvely parentheses. That cuonts for something |
| 07:11 | tscheibl | I just ask 1 question at irc every where the answer enlightens me so much to make this possible |
| 07:12 | tscheibl | clgv: it gets more readable every day, indeed |
| 07:12 | clgv | ok thats good then ;) |
| 07:13 | tscheibl | and the indentation depth also has been reduced by at least 50% since the start |
| 07:13 | tscheibl | luv that language and the really helpful irc community |
| 07:14 | raek | Dranik: in 1.1, #^ was used for attaching metadata to source code and ^foo was sugar for (meta foo). since 1.2, ^ is for attaching metadata to source code and #^ should be unused (but behaves as 1.2's ^ for backward compability, I think) |
| 07:15 | Dranik | raek, so the main conclusion: just use ^ and forger about #^ completely, yep? |
| 07:15 | Dranik | *forget |
| 07:15 | raek | unless you have to deal with 1.1 code, yes |
| 07:15 | Dranik | ok, thanks |
| 07:15 | tscheibl | (forget "#^") |
| 07:16 | tscheibl | ;) |
| 07:16 | clgv | I noticed that sometimes ^:keyword doesnt work and causes a compiler error in a defn or defn- |
| 07:17 | raek | I think that shortcut (^:foo instead of ^{:foo true}) was added in 1.3 |
| 07:17 | clgv | but I couldnt tell the difference between the few calls where it didnt and the plenty ones where it did |
| 07:17 | raek | clgv: was this within the same clojure version? |
| 07:17 | clgv | raek: it was all in clojure 1.2 |
| 07:19 | raek | hrm. I think I got something wrong. ^:foo does compile in 1.2 for me, but it becomes ^{:tag :foo} |
| 07:19 | raek | ...just like typehints behave |
| 07:21 | clgv | ah ok. didnt realize that. |
| 07:21 | clgv | I tried it with ^:static |
| 07:22 | clgv | though I am still curious what ^{:static true} does |
| 07:22 | raek | it is/was a 1.3 feature |
| 07:23 | raek | I don't know if :dynamic has replaced it |
| 07:23 | raek | clgv: http://clj-me.cgrand.net/2010/06/10/primitive-types-support-for-fns-coming-to-a-clojure-branch-near-you/ |
| 07:24 | clgv | raek: oh thanks. reads to be enlightened ;) |
| 07:26 | raek | I think the idea is that if a function is static, then every call to it will be hard coded to that version of the function (so if you redefine the function, you have to reevaluate all the dependent defns too) |
| 07:26 | raek | this allows for better performance and primitive support, or something like that |
| 07:27 | clgv | sounds reasonable |
| 07:27 | clgv | wow. my program is twice as fast on my home computer compared to the one at university :D |
| 07:27 | clgv | I like the core-i7 cpus ;) |
| 07:29 | raek | clgv: I would also check out the new :dynamic thing. It is a more recent approach that might solve the same problem as :static. |
| 07:29 | clgv | the other one is a core2 for comparison |
| 07:30 | clgv | raek: I didn't necessarily need :static but found it when trying to optimize the runtime of the arithmetic part of my program |
| 07:34 | clgv | raek: the static thing has structural similarities with the :inline one |
| 07:37 | tscheibl | hah.. reduced by 5%, again |
| 07:39 | tscheibl | my boss will ask me what I did all the time when he counts the lines of code... maybe I should switch back to C++ again :D |
| 07:40 | clgv | what is the most efficient way to calculate all partial sums of a sequence of doubles? |
| 07:40 | clgv | I'd guess: loop-recur |
| 07:40 | ejackson | reductions ? |
| 07:41 | ejackson | ,(reductions + 0 [1 2 3 4 5 6]) |
| 07:41 | clojurebot | (0 1 3 6 10 15 21) |
| 07:42 | ejackson | ,(reductions + [1 2 3 4 5 6]) |
| 07:42 | clojurebot | (1 3 6 10 15 21) |
| 07:42 | ejackson | is better, if I understand what you mean by 'partial sums' |
| 07:42 | clgv | oh interesting. I didnt know that one |
| 07:42 | ejackson | its a cutey |
| 07:42 | clgv | &(doc reductions) |
| 07:42 | sexpbot | ⟹ "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init." |
| 07:43 | clgv | $source reductions |
| 07:43 | sexpbot | reductions is http://is.gd/cZqevO |
| 07:45 | clgv | thx :) |
| 08:05 | Bleadof | Should (identical? "foo" "foo") be false? |
| 08:06 | Bleadof | I was just looking at Clojure data structures video where it returned false for that, but I tested and it returns true... It was a bit spooky. |
| 08:33 | jcromartie | Bleadof: I think it's reasonable for two string literals to be the same object. |
| 08:33 | jcromartie | strings, keywords, numbers |
| 08:34 | jcromartie | empty lists |
| 08:34 | jcromartie | empty vectors |
| 08:34 | jcromartie | heh |
| 08:34 | jcromartie | interesting |
| 08:34 | jcromartie | NOT symbols though |
| 08:34 | jcromartie | every symbol parsed is a new object? |
| 08:36 | Dranik | is clojure 1.2 available for .NET ? |
| 08:48 | tscheibl | Dranik: https://github.com/richhickey/clojure-clr |
| 08:48 | Dranik | tscheibl, the question is whether it is stable or not? |
| 08:49 | tscheibl | https://github.com/richhickey/clojure-clr/zipball/1.2.0 |
| 08:49 | Dranik | thanks! |
| 08:49 | tscheibl | dunno... there is a zipball at least |
| 08:50 | tscheibl | u can also find a 1.3.0 alpha there |
| 08:50 | Dranik | hmmm... intriguing... |
| 09:00 | phenom_ | anyone tried out 1.3.0 with the developer jdk7 release ? |
| 09:06 | Dranik | phenom_, really interesting... |
| 09:07 | phenom_ | Dranik: did you see any improvements outside primitive math? |
| 09:07 | Dranik | in java7? |
| 09:09 | Dranik | well, for me java7 contains just some enhancements of the existing functional |
| 09:09 | Dranik | NIO.2, new file system api and so on -- nothing special |
| 09:09 | Dranik | the only interesting thing there is InvokeDynamic |
| 09:10 | Dranik | but who knows how much time will pass before every java scripting language will use it |
| 09:14 | phenom_ | and the invoke dynamic is there to support tco ? |
| 09:16 | Dranik | whats tco? |
| 09:17 | stuartsierra | invokedynamic is basically an easier way to do what Clojure already does –– dynamic method calls without reflection |
| 09:29 | Bleadof | jcromartie, I think that's because symbol is always itself so they must not be identical. :) |
| 09:41 | ejackson | If I have a namespace hierarchy like: ns1 :uses ns2 :uses ns3. What do I do in ns2 to make vars from ns3 visible in ns1 ? |
| 09:42 | stuartsierra | ejackson: you can't |
| 09:42 | ejackson | that's a bummer. |
| 09:42 | ejackson | thanks. |
| 09:43 | stuartsierra | It's a feature: each namespace declaration shows exactly where every symbol in that namespace comes from. |
| 09:43 | ejackson | that makes sense. |
| 09:44 | stuartsierra | It's a huge help for debugging and refactoring. |
| 09:44 | ejackson | i'll :require ns3 in ns2, and make defs. |
| 09:44 | stuartsierra | Or just ;use ns3 in ns1. |
| 09:44 | ejackson | i have a sprawling namespace (accounting.*) and want an interface nampsace acconting. cose. |
| 09:44 | ejackson | s/acconting. cose/accounting.core |
| 09:44 | sexpbot | <ejackson> i have a sprawling namespace (accounting.*) and want an interface nampsace accounting.core. |
| 09:45 | ejackson | but I'll refactor to clean up. Thanks stuartsierra. |
| 09:45 | stuartsierra | 'welcome |
| 09:47 | raek | jcromartie: symbols with the same names are the same instances |
| 09:48 | raek | ,(identical? 'foo 'foo) |
| 09:48 | clojurebot | false |
| 09:48 | raek | hm? |
| 09:48 | stuartsierra | raek: Clojure symbols are not interned like in Common lisp. |
| 09:48 | stuartsierra | Keywords are. |
| 09:48 | ejackson | ,(identical :foo :foo) |
| 09:48 | clojurebot | java.lang.Exception: Unable to resolve symbol: identical in this context |
| 09:48 | stuartsierra | ,(identical? :foo :foo) |
| 09:48 | clojurebot | true |
| 09:48 | ejackson | ha |
| 09:48 | raek | hrm. I assumed they were... |
| 09:49 | raek | I imagined symbols and keywords to work exactly the same way, modulo eval semantics |
| 09:50 | stuartsierra | Nope, symbols are just labels, almost like Strings. |
| 09:50 | raek | whose literals are interned..? |
| 09:50 | raek | ,(identical? "foo" "foo") |
| 09:50 | clojurebot | true |
| 09:51 | raek | I recall that changed at some point |
| 09:51 | stuartsierra | Yeah, that's a little odd. Symbols probably could be interned, ... |
| 09:51 | stuartsierra | Yes, very early on, as a perf optimization. |
| 09:51 | stuartsierra | But since you rarely do equality tests on symbols, there's less benefit. |
| 09:51 | _fogus | stuartsierra: How would metadata on interned symbols work? |
| 09:51 | dnolen | fliebel: exist has an implicit all. exist is like let. all is like do. |
| 09:51 | stuartsierra | _fogus: An excellent point! |
| 09:52 | stuartsierra | That's probably why. |
| 09:52 | raek | ah! |
| 09:52 | raek | then it makes much more sense |
| 09:53 | raek | _fogus: *bows* |
| 09:56 | dnolen | fliebel: (a c b d) is a possible odering, but it's important to make no assumptions about ordering. No assumptions also means that the notion of concurrency is sort of baked in. |
| 09:56 | _fogus | staurtsierra: BTW, you can do some nasty side-effecty stuff using create-ns and intern |
| 09:57 | ogrim | /quiy |
| 09:57 | ogrim | |
| 09:57 | stuartsierra | _fogus: Oh yes, I've had evil fun with that. |
| 09:57 | _fogus | Yeah really (eville == fun) |
| 10:01 | fliebel | dnolen: Ah, thanks for explaining that. |
| 10:01 | _fogus | I once had an idea for a namespace library with a thin prototypal skin over it. But I'm fairly sure that would get my Clojure card revoked. |
| 10:02 | fliebel | Is Logos concurrent/parallel? |
| 10:02 | dnolen | fliebel: no yet, but that's a goal, and it's built on a good conceptual foundation to allow it. |
| 10:03 | _fogus | dnolen: Do you mind elaborating? What foundation do you mean? |
| 10:05 | dnolen | _fogus: no assumptions about the ordering of results from disjunction. |
| 10:07 | _fogus | Is that a property of kanren or your impl? |
| 10:07 | dnolen | _fogus: property of kanren, and miniKanren. |
| 10:08 | _fogus | Are there interesting variants of parallel-kanren? |
| 10:08 | _fogus | (I'm using "kanren" to stand in for both mini- and not) |
| 10:10 | dnolen | _fogus: miniKanren researchers did a parallel version, but just forking processes on every disjunction is of course not going to work. |
| 10:10 | dnolen | Ciao-Prolog does task granularity analysis. So perhaps that's a direction of investigation for miniKanreners |
| 10:12 | dnolen | http://clip.dia.fi.upm.es/papers/granularity.pdf |
| 10:15 | pjstadig | _fogus: you have a clojure card?! |
| 10:16 | _fogus | pjstadig: Yeah, my kid colored one for me. |
| 10:16 | pjstadig | nice |
| 10:21 | _fogus | "just be- cause something can be done in parallel does not nec- essarily mean, in practice, that it should be done in parallel." |
| 10:21 | _fogus | What!?! But I just got done seding all of my maps to pmap! |
| 10:21 | jcromartie | :P |
| 10:21 | jcromartie | pmap |
| 10:22 | jcromartie | I was having some fun with that yesterday... http://imgur.com/HUXsI |
| 10:22 | jcromartie | &(dorun (pmap #(dorun (pmap println %)) '((I put a thread in your thread) (so you can compute while you compute)))) |
| 10:22 | sexpbot | ⟹ nil |
| 10:22 | jcromartie | oh wait |
| 10:22 | jcromartie | ,(dorun (pmap #(dorun (pmap println %)) '((I put a thread in your thread) (so you can compute while you compute)))) |
| 10:22 | clojurebot | nil |
| 10:23 | jcromartie | printing from other threads doesn't work in these bots eg? |
| 10:23 | jcromartie | eh? |
| 10:24 | pjstadig | haha it took me a second to get that one |
| 10:24 | pjstadig | i was like, "this doesn't make any sense its all mixed togeth--oooooohhh" |
| 10:26 | ejackson | _fogus: thank god I'm use Firefox and it doesn't load.... lucky break. |
| 10:29 | rsenior | it's not clear to me how to do an internal forward using compojure, i.e. a form was submitted, I take some action and want another page to render the results, am I missing something? |
| 10:30 | jcromartie | rsenior: you would just pass the request off to the appropriate handler no? |
| 10:31 | ejackson | yes, I imagine there is only one function on the compojure end the accepts the POST, processes and renders the results ? |
| 10:34 | rsenior | jcromartie: do you mean call the name I bind the defoutes to? I'm using defroutes, not the handlers directly |
| 10:34 | rsenior | ejackson: I have one now, but can break it up |
| 10:34 | jcromartie | I have to admit I'm a bit confused by some changes to compojure lately, myself. |
| 10:35 | jcromartie | Can you paste your routes code? |
| 10:37 | Dranik | !seen rhicker |
| 10:37 | Dranik | !seen rhickey |
| 10:38 | rsenior | not much to see, but it's here https://gist.github.com/843940 |
| 10:39 | rsenior | the template stuff is enlive |
| 10:39 | jcromartie | three cheers for protocols, BTW... check out https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj |
| 10:39 | rsenior | jcromartie: just saw that not long ago, I had always been using maps |
| 10:41 | Raynes | $seen rhickey |
| 10:41 | sexpbot | rhickey was last seen quitting 6 days and 16 hours ago. |
| 10:41 | jcromartie | rsenior: you could redirect by passing a new request to admin-app from within a handler |
| 10:41 | tscheibl | can I somehow get a reference to the currently executing function object? .. I'm not sure that I used the correct terminology here but I don't know better... |
| 10:41 | Raynes | Draggor: ^ |
| 10:41 | jcromartie | just make sure it's not a loop |
| 10:41 | Raynes | Dranik, even. |
| 10:41 | Dranik | Raynes, thanks |
| 10:42 | tscheibl | I mean from within that function? |
| 10:42 | Dranik | $where_is rhickey |
| 10:42 | Dranik | doesn't work any more :-( |
| 10:42 | tscheibl | Dranik: I hope busy finishing 1.3 :) |
| 10:42 | Dranik | :-) |
| 10:42 | mduerksen | Dranik: he does work, and that's why he isn't on chatrooms all the time ;) |
| 10:43 | Dranik | that's good! I can't wait for 1.3! |
| 10:43 | Dranik | :-) |
| 10:44 | rsenior | jcromartie: so that admin app accepts a uri snippet and params? |
| 10:44 | jcromartie | rsenior: check out https://gist.github.com/843950 |
| 10:44 | jcromartie | anybody else, please comment |
| 10:44 | tscheibl | ,(let [f (println f)] ()) |
| 10:44 | clojurebot | java.lang.Exception: Unable to resolve symbol: f in this context |
| 10:45 | tscheibl | exctly |
| 10:45 | tscheibl | exactly |
| 10:45 | tscheibl | but I'd need a reference to this function |
| 10:45 | tscheibl | inside it |
| 10:46 | rsenior | jcromartie: ahh, takes a map that has the url |
| 10:46 | raek | tscheibl: an anonymous function? you can have a "named anonymous" function: (fn f [] (... f ...)) |
| 10:46 | tscheibl | ahh |
| 10:46 | raek | this is also done if you use letfn |
| 10:46 | raek | ,(letfn [(f [] (str f))] (f)) |
| 10:46 | clojurebot | "sandbox$eval2185$f__2186@359a33" |
| 10:47 | jcromartie | rsenior: what do you mean |
| 10:47 | jcromartie | it just takes the original request, a new uri, and the handler to apply |
| 10:47 | jcromartie | but it's not complete |
| 10:47 | jcromartie | it's not really a redirect |
| 10:48 | jcromartie | you should be doing a HTTP redirect |
| 10:48 | jcromartie | what I wrote is really a handler transfer |
| 10:48 | jcromartie | although actually, I'm not sure what you want... but if you're trying to implement the POST/redirect/GET pattern |
| 10:48 | rsenior | I mean this part of your code (handler (assoc req :uri uri :redirected-to uri)) |
| 10:49 | jcromartie | well handlers (and routes, which are handlers) only ever take a request map |
| 10:49 | jcromartie | http://en.wikipedia.org/wiki/Post/Redirect/Get |
| 10:49 | rsenior | right |
| 10:49 | jcromartie | so you want a HTTP 303 |
| 10:50 | jcromartie | if that's what you're trying to do |
| 10:50 | tscheibl | raek: thx for the enlightenment :) but I checked back and saw that is was a proxy (let [timer-task (proxy [TimerTask] []... so I could use 'this' within the implemented members |
| 10:50 | raek | rsenior: you don't need to (apply str ...) the output from enlive. ring adapters accept seqs-of-strings |
| 10:53 | rsenior | jcromartie: I think that is what I'm trying to do, it's been a while since I've done web development at that low of a level |
| 10:53 | jcromartie | yeah welcome to the trenches :P |
| 10:53 | rsenior | raek: good idea, I'll switch it |
| 12:00 | TimMc | jcromartie: There's a *name* for that? |
| 12:15 | DespiteItAll | Hmm, the clojure.xml api page is missing the emit function. Now I'm wondering what else isn't on the api pages |
| 12:22 | cinch | raek: regarding "ring adapters accept seqs-of-strings", wrap-lint throws an exception if you feed it a seq of strings, but i think it's a bug in wrap-lint because the ring spec says seqs are allowed but wrap-lint doesn't check for seqs. i should submit a bug report |
| 12:34 | sritchie_ | hey all -- I'm having trouble figuring out how to use clojure.contrib.probabilities.random-numbers/rand-stream |
| 12:34 | sritchie_ | I see it's using defstream, |
| 12:35 | sritchie_ | and I want to be able to take values off of it -- I'm just not sure how to bind a new stream to anything |
| 12:36 | sritchie_ | (for now, I'm using (defn rands [x] (take x (repeatedly rand))) |
| 12:36 | sritchie_ | ) |
| 12:47 | kencausey | sritchie_: https://github.com/clojure/clojure-contrib/blob/master/modules/stream-utils/src/main/clojure/clojure/contrib/stream_utils.clj (includes doc at top) |
| 12:50 | sritchie_ | kencausey: great, thanks for that, time to do some reading |
| 14:57 | Max-69 | ciao |
| 15:03 | Sgeo | Hmm |
| 15:03 | Sgeo | Is it my imagination, or is it too easy to do concurrency wrongly, even with Clojure's primitives, thanks to ability to read without being in a transaction? |
| 15:03 | Sgeo | I should write an example |
| 15:04 | pdk | you don't need to worry about catching only half an update |
| 15:05 | Sgeo | But I do have to worry about making decisions in the wrong place |
| 15:24 | Sgeo | Can I make ending parentheses not automatically be placed in La Clojure? |
| 15:27 | Sgeo | http://ideone.com/NpTeh |
| 15:29 | TimMc | Sgeo: You don't want Paredit mode? |
| 15:30 | Sgeo | TimMc, if that's the name for it, how do I disable it? |
| 15:31 | TimMc | Dunno. I haven't used La Clojure, but it sounds like Paredit mode. (Paredit is an Emacs minor mode that has analogs in many s-expression editing programs.) |
| 15:31 | TimMc | You probably want it, even if you don't know it yet. :-P |
| 15:32 | TimMc | (That said, La Clojure might do it poorly, for all I know.) |
| 15:32 | Sgeo | I want to know why Clojure doesn't provide security against what I posted >.> |
| 15:33 | TimMc | Are you proposing a language that only allows reading inside transactions? Because that could still be misused very easily. |
| 15:33 | TimMc | I don't think there's a way to protect against that. |
| 15:34 | Sgeo | Just curious, how could it be misused? |
| 15:34 | TimMc | Simple, by wrapping each read in a separate transaction. :-P |
| 15:35 | hiredman | if you do that you are using agents incorrectly |
| 15:35 | TimMc | Anyway, I think your example is flawed. Aren't agents supposed to be updated with functions that run entirely inside the agent's update transaction? |
| 15:35 | hiredman | if you need coordination and the stm you want refs |
| 15:36 | hiredman | clojure provides a number of different concurrency primitives with different options for you to choose from |
| 15:37 | Sgeo | I think it may be too easy for people to choose the wrong concurrency primitives |
| 15:37 | TimMc | Don't worry about other people. |
| 15:39 | hiredman | Sgeo: and? |
| 15:39 | TimMc | There will always be a large supply of programmers who will mess up concurrency no matter how easy it is in some language. YOu have to let that go. |
| 15:40 | Null-A | I'm trying to use gen-class with slime, I C-c k the filed, but I still can't import or reference it |
| 15:40 | Null-A | the file* |
| 15:47 | DespiteItAll | Seeing all the cool stuff in IDE's makes me wish I'd never gotten attached to vim |
| 15:48 | TimMc | DespiteItAll: Like what? |
| 15:49 | DespiteItAll | somebody mentioned la clojure earlier, so i googled it and came up with this http://plugins.intellij.net/preview/popup/?sid=2625&pid=4050 I don't know what's going on there but it looks cool. |
| 15:49 | TimMc | Autocompletion and javadocs are the only thing I really use in Eclipse, for instance. |
| 15:50 | raek | Null-A: gen-class requires compilation. http://clojure.org/compilation |
| 15:50 | Null-A | raek: So how do I use it with slime? |
| 15:50 | raek | Null-A: you usually use some thing like "lein/cake compile" to start the compilation |
| 15:50 | Null-A | raek: run lein compile, add aot to project.clj |
| 15:51 | TimMc | I assume Emacs can do autocomplete, etc., but I don't know how to do it yet. :-P |
| 15:51 | Null-A | raek: restart swank server? |
| 15:51 | raek | Null-A: yes, you have to restart the clojure instance if you need to update a class that you have already loaded |
| 15:51 | Null-A | k |
| 15:52 | raek | the first time, you should be able to compile the namespace with the 'compile' clojure function and then just use the class |
| 15:52 | Null-A | cool, thanks raek |
| 15:53 | DespiteItAll | yeah, emacs has a bunch of cool features that I wish I had in vim. |
| 15:53 | jcromartie | TimMc: M-/ for a simple text lookup and M-Tab for the Swank autocomplete |
| 15:53 | DespiteItAll | I could probably duplicate them, but the effort is always too much |
| 15:53 | jcromartie | M-Tab does autocomplete on things like Java packages and Clojure namespaces such |
| 15:54 | amalloy | jcromartie: i can't give up M-Tab as my window-manager window-switching key :P |
| 15:54 | jcromartie | hm |
| 15:54 | jcromartie | well on Mac I use the Mac option key as Emacs meta |
| 15:55 | jcromartie | but on Windows yeah that's tricky |
| 15:55 | jcromartie | or Linux |
| 15:55 | jcromartie | I think just plain Tab works in the repl though |
| 15:55 | amalloy | jcromartie: i could use the windows key as Super (which i do), but i don't want to rebind everything to S-Tab |
| 15:56 | amalloy | and the autocomplete plugin does a pretty good job for me without having to manually activate it |
| 15:56 | amalloy | so i'm not inclined to add a binding |
| 15:56 | jcromartie | What plugin? |
| 15:56 | amalloy | jcromartie: http://www.emacswiki.org/emacs/AutoComplete |
| 15:56 | jcromartie | oh my |
| 15:56 | amalloy | also Sgeo your example is wrong in more ways than you intended :P |
| 15:58 | amalloy | (send agent #(%2) {:balance result}) is not the same as (send agent (constantly {:balance result})) |
| 15:59 | amalloy | &(let [a (agent {:balance 1000})] (send a #(%2) {:balance 500}) (Thread/sleep 1000) @a) |
| 15:59 | sexpbot | ⟹ {:balance 1000} |
| 16:00 | amalloy | &(let [a (agent {:balance 1000})] (send a (constantly {:balance 500})) (Thread/sleep 1000) @a) |
| 16:00 | sexpbot | ⟹ {:balance 500} |
| 16:03 | jcromartie | that's the wrong way to model an account anyway |
| 16:03 | jcromartie | how about a better example? |
| 16:05 | Sgeo | amalloy_, ok.. why? |
| 16:06 | jcromartie | amalloy_: THANK YOU <3 for auto-complete-mode |
| 16:06 | jcromartie | awesome |
| 16:07 | Sgeo | Why does it work like that? |
| 16:07 | jcromartie | #(%2) is a function that calls its second argument |
| 16:08 | jcromartie | &(#(%2) nil {:foo :bar}) |
| 16:08 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentArrayMap |
| 16:08 | Sgeo | How would I make it just return the second argument? |
| 16:08 | jcromartie | &((constantly {:foo :bar})) |
| 16:08 | sexpbot | ⟹ {:foo :bar} |
| 16:08 | jcromartie | &(#(identity %2) nil :foo) |
| 16:08 | sexpbot | ⟹ :foo |
| 16:09 | jcromartie | but if you already have what you want, you don't need to muck with args... just use constantly |
| 16:09 | Sgeo | Maybe I should stick with fn? |
| 16:09 | jcromartie | !doc constantly |
| 16:09 | jcromartie | is that how you do it? |
| 16:09 | Sgeo | &((fn [a b] b) 5) |
| 16:09 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox6385$eval9330$fn |
| 16:09 | Sgeo | &(fn [a b] b) 5 |
| 16:09 | sexpbot | ⟹ #<sandbox6385$eval9339$fn__9340 sandbox6385$eval9339$fn__9340@19b38d7> |
| 16:10 | jcromartie | Sgeo: we're trying to solve the wrong problem here |
| 16:10 | Sgeo | &((fn [a b] b) 0 5) |
| 16:10 | sexpbot | ⟹ 5 |
| 16:10 | jcromartie | &(#(do %2) :foo :bar) |
| 16:10 | sexpbot | ⟹ :bar |
| 16:10 | jcromartie | but anyway |
| 16:11 | Sgeo | That's... unintuitive to me |
| 16:11 | Sgeo | Hm wait |
| 16:11 | Sgeo | I think I get it |
| 16:11 | jcromartie | it's exactly the same as (fn [_ b] b) |
| 16:11 | Sgeo | #(stuff) seems to be (fn [] (stuff)) |
| 16:11 | jcromartie | yes |
| 16:12 | Sgeo | Ok |
| 16:12 | jcromartie | but you never do #(stuff) because you could just use stuff |
| 16:12 | jcromartie | &(map inc [1 2 3]) |
| 16:12 | sexpbot | ⟹ (2 3 4) |
| 16:13 | jcromartie | well, that's a bad example |
| 16:13 | jcromartie | #(stuff) is pretty useless |
| 16:13 | jcromartie | unless it's purely for side-effects |
| 16:14 | jcromartie | &(let [counter (atom 0) count #(send counter inc)] (map #(count) [1 2 3]) @counter) |
| 16:14 | sexpbot | ⟹ 0 |
| 16:14 | jcromartie | &(let [counter (atom 0) count #(send counter inc)] (doall (map #(count) [1 2 3])) @counter) |
| 16:14 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox6385$eval9386$fn |
| 16:14 | jcromartie | heh |
| 16:14 | jcromartie | anyway |
| 16:14 | Sgeo | jcromartie, I didn't mean literally stuff |
| 16:14 | jcromartie | I know |
| 16:14 | jcromartie | but #(foo) |
| 16:16 | jcromartie | but anyway, don't store an account balance :) |
| 16:27 | Sgeo | Are refs readable outside of transactions? |
| 16:27 | stuartsierra | yes |
| 16:28 | Sgeo | :/ |
| 16:28 | danbell | is there a core way to map a set of arguments across a sequence of functions? |
| 16:28 | stuartsierra | Sgeo: deref on a Ref will always return the most-recently-committed value, never the value inside a transaction. |
| 16:29 | hiredman | ,((apply juxt [inc dec]) 1) |
| 16:29 | clojurebot | [2 0] |
| 16:29 | danbell | ,(doc juxt) |
| 16:29 | clojurebot | "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, a... |
| 16:29 | danbell | cool, thanks |
| 16:30 | DespiteItAll | why would you not store an account balance? |
| 16:32 | Sgeo | There is something about Clojure that .. hmm |
| 16:36 | amalloy | jcromartie: ouch, you think thunks (that is, no-arg functions) aren't useful? |
| 16:37 | jcromartie | amalloy: they can be useful but it's almost always for side-effects and it's hard to think of an example off the top of my head |
| 16:37 | Sgeo | I was recently fascinated by Slate. They have something called Prototypes with Multiple Dispatch. They talk about methods being defined in terms of all their objects. I know Clojure uses immutable stuff, so it's not exactly the same, but I think multimethods serve a similar purpose. |
| 16:37 | Sgeo | And may be more flexible |
| 16:37 | amalloy | jcromartie: try implementing lazy-seqs without thunks |
| 16:37 | Sgeo | I should translate their example to Clojure |
| 16:38 | amalloy | eg, (range 10) is a pair of (data, thunk-for-next-data) elements |
| 16:38 | stuartsierra | Sgeo: Clojure doesn't implement Prototype inheritance directly, but it's easy to implement yourself. |
| 16:40 | Sgeo | The PMD paper on Multiple Dispatch alone: " |
| 16:40 | Sgeo | However, there remain problems with the example, as expressed. It is still |
| 16:40 | Sgeo | awkward to express stateful behavior; this is still represented by the control |
| 16:40 | Sgeo | flow branches inside encounter methods. Furthermore, the code describing that |
| 16:40 | Sgeo | unhealthy sharks swim away from all other animals is duplicated in two different |
| 16:40 | Sgeo | encounter method" |
| 16:40 | Sgeo | Sorry |
| 16:40 | Sgeo | The first criticism does not apply to Clojure's multimethods, I think |
| 16:40 | Sgeo | As it's not strictly "class" based |
| 16:41 | dnolen | stuartsierra: prototypal inheritance is simple via ad-hoc hierarchies. rhickey based his work on the Self paper if I recall correctly. |
| 16:41 | amalloy | jcromartie: that is, they're useful not just for side effects, but for delaying/modifying computation/evaluation. eg in sexpbot, most user code is wrapped up in a thunk to be computed on another thread while the core engine goes back to listening for requests |
| 16:41 | stuartsierra | dnolen: cool, I'll have to look that up. |
| 16:42 | dnolen | http://dosync.posterous.com/beyond-javascript-prototype-chains |
| 16:42 | dnolen | I compared JS prototypal inheritance to Clojure's more general facilities a while back ^ |
| 16:42 | jcromartie | amalloy: true, I guess I was just scratching the surface |
| 16:42 | stuartsierra | dnolen: thanks, I'll take a look |
| 16:43 | jcromartie | hooray for thunks! |
| 16:43 | jcromartie | :) |
| 16:43 | amalloy | lol |
| 16:43 | amalloy | there we go, that's the kinda of enthusiasm i like to see! |
| 16:44 | Sgeo | type? |
| 16:44 | clojurebot | http://www.assembla.com/wiki/show/clojure/Datatypes |
| 16:45 | Sgeo | Oh, I was skipping ahead? |
| 16:45 | Sgeo | Bad bot |
| 16:45 | Sgeo | And that wasn't a question. I was skipping ahead |
| 16:46 | Sgeo | Oh, wait |
| 16:46 | Sgeo | ,(doc type) |
| 16:46 | clojurebot | "([x]); Returns the :type metadata of x, or its Class if none" |
| 16:48 | Null-A | raek: So each NS `foo` as a foo_init.class generated for it. Will this coperate with java namespaces of the same name? |
| 16:49 | Null-A | cooperate* |
| 16:49 | Null-A | I think normally in java you can't have a package 'foo' and a class 'foo', name conflict |
| 16:52 | Null-A | hmh, maybe you can after all |
| 16:52 | Null-A | with the jvm |
| 17:09 | amalloy | jcromartie: oh, and you're welcome re autocomplete |
| 17:12 | Sgeo | How difficult could it be to make a very very basic DrClojure? |
| 17:13 | amalloy | it took me a while to realize, but M-n and M-p are the intended way to move through the suggested completions |
| 17:14 | Sgeo | Maybe I should try emacs |
| 17:14 | Sgeo | I certainly like emacs on the command-line |
| 17:14 | Sgeo | But in Windows, as a Windows program? |
| 17:14 | lucian | Sgeo: it's fine, if you like emacs, use it everywhere |
| 17:15 | Sgeo | I like it just fine when my choices are pretty much emacs, vim, nano, is what I meant |
| 17:16 | lucian | ah, so you don't actually like emacs all that much |
| 17:17 | lucian | me, i like vim everywhere (in particular it's input scheme) |
| 17:18 | lucian | s/it's/its/ |
| 17:18 | sexpbot | <lucian> me, i like vim everywhere (in particular its input scheme) |
| 17:18 | lucian | sexpbot: you're not being very useful with that |
| 17:21 | jcromartie | Sgeo: Emacs for Windows is pretty solid. |
| 17:23 | lucian | jcromartie: except he doesn't actually like emacs |
| 17:28 | amalloy | lucian: i can make him stop sedding your messages if you want |
| 17:29 | amalloy | people seem to have a love/hate relationship with the feature so it's not gonna go away, but if it bugs you... |
| 17:29 | stuartsierra | w00t! No red dots on http://build.clojure.org for the first time! |
| 17:29 | lucian | amalloy: meh |
| 17:30 | lucian | amalloy: it's not really that annoying, but it doesn't seem very useful either |
| 17:35 | hugod_ | just ran into http://dev.clojure.org/jira/browse/CLJ-444 in clojure 1.2 - if I read file:///Users/duncan/lisp/docs/java/docs/api/java/lang/ref/ReferenceQueue.html#poll%28%29 correcty though there is still an issue with enqueued references being dropped by the call to rq.poll and not being cleared from the table |
| 17:36 | amalloy | hugod_: puzzlingly enough that file: link is no good for the rest of us :P |
| 17:36 | hugod_ | oops |
| 17:38 | hugod_ | this one works a little better http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ref/ReferenceQueue.html#poll() |
| 17:38 | raek | Null-A: when AOT compiling the namespace foo.bar.baz, the class foo.bar.baz_init will be generated (baz_init class in foo.bar package). you would get a conflict if you have "package foo.bar; public class baz_init { ... }" in any java sources... |
| 17:41 | raek | there shouldn't be any problem with calling the class the same as the last component of the package |
| 17:50 | Null-A | raek: k, when you use :gen-class on ns, interestingly it creates directory baz, and class file baz.class as siblings in the directory |
| 17:51 | Null-A | (direcotry foo/bar/) |
| 18:48 | raek | Null-A: the baz_init class has a static initializer that will evaluate the code of the namespace, and the baz class is the one that will have the methods declared in :gen-class. you can set that name to something else by adding the option :name OtherName to the :gen-class part |
| 18:50 | Null-A | awesome thanks |
| 18:51 | raek | (methods of generated classes will always have an implementation that calls a clojure fn in a ns) |
| 18:51 | Null-A | yah that's really convinient |
| 18:52 | Null-A | convenient* |
| 18:53 | raek | so by reevaluating the corresponding defn form, you update the behaviour of all existing instances of the generated class |
| 18:53 | Null-A | exactly :) |
| 19:01 | ossareh | hola |
| 19:09 | TimMc | Sgeo: I think most Emacs users on GNU/Linux systems use the graphical version anyway. |
| 19:12 | sritchie_ | hey all -- one quick question on storing records of data |
| 19:12 | sritchie_ | I want to encode some of the information on these MODIS products as a clojure datastructure -- |
| 19:12 | sritchie_ | https://lpdaac.usgs.gov/lpdaac/products/modis_products_table |
| 19:13 | sritchie_ | I'll be using the product name as a key, but I want to be able to store multiple values |
| 19:13 | sritchie_ | is this a job for defrecord? |
| 19:19 | TimMc | I've enever actually been clear on the use-cases of defreord over, say, maps. |
| 19:20 | TimMc | I suppose defrecord with (.field-name obj) gets you some type hinting. |
| 19:22 | sritchie_ | here's one about maps... say I want to check a substring against a few possible options |
| 19:22 | sritchie_ | is it more efficient to look the substring up in a map? Or to use cond? |
| 19:24 | sritchie_ | https://gist.github.com/1455e310c21417ad13b5 |
| 19:24 | sritchie_ | as an example |
| 19:27 | amalloy | sritchie_: well your cond example is broken |
| 19:27 | sritchie_ | because it has no :else? |
| 19:27 | amalloy | no, because you're using cond as if it were case |
| 19:28 | sritchie_ | amalloy: oh, whoops |
| 19:28 | sritchie_ | condp = s, then |
| 19:28 | amalloy | to answer your actual question: case is going to be way faster, though at the scales we're talking about, even if it were a million times faster it wouldn't matter |
| 19:28 | amalloy | so like case < map < cond |
| 19:29 | sritchie_ | amalloy: got it |
| 19:29 | sritchie_ | so the issue at this scale is reusability of the cases, I guess |
| 19:30 | amalloy | actually for small maps i'm not sure whether cond or map is faster b/c small maps are implemented as arrays |
| 19:30 | sritchie_ | so a map makes sense if I need access from multiple functions, case or cond for a single function |
| 19:30 | amalloy | sritchie_: not so! you can reuse them with case. the issue is that you have to know it all at compile time |
| 19:30 | Sgeo | Hmm |
| 19:31 | Sgeo | Maybe Clojure multimethods aren't more powerful than Factor's system |
| 19:31 | Sgeo | I'd need to think about what Factor does to be sure |
| 19:31 | sritchie_ | amalloy: hmm, interesting |
| 19:31 | sritchie_ | amalloy: how would I reuse cases? |
| 19:32 | Sgeo | " there's a multi-methods vocabulary. the core generics implementation is single-dispatch though" |
| 19:32 | amalloy | eg (let [tests [1 2 4] ] (defmacro switch-with-values [elt & rets] `(case ~elt ~@(for [[test val] (map vector tests rets)] test val)))) |
| 19:33 | amalloy | sritchie_: haven't typed it into a repl, but something like that would work, and allows you to use the same test values (1 2 4) with different return values |
| 19:33 | amalloy | it's simpler if you always want to use the exact same map |
| 19:34 | sritchie_ | got it. I'm still not used to thinking about how macros can sub in anything at compile time, and produce the same code |
| 19:34 | sritchie_ | sorry, I mean, condense that idea of reusing a block of cases down, so nothing gets repeated |
| 19:35 | amalloy | (defmacro mapped-case [elt] (cons 'case (cons elt (for [[test val] {1 1000 2 500 4 250}] test val)))) ; a different style to keep you on your toes |
| 19:36 | sritchie_ | time to go study these |
| 19:36 | amalloy | also that one doesn't compile. that's what i get |
| 19:36 | amalloy | for trying to be clever |
| 19:37 | sritchie_ | amalloy: once I can recognize the fact that it won't compile at a glance, I'll have studied enough |
| 19:37 | sritchie_ | amalloy: on this example, anyways |
| 19:37 | amalloy | sritchie_: hah. i didn't recognize it either. i got up a real repl |
| 19:40 | amalloy | aha |
| 19:40 | amalloy | this version works and is much tidier: (defmacro mapped-case [elt] `(case ~elt ~@(apply concat {1 1000 2 500 4 250}))) |
| 19:40 | sritchie_ | amalloy: I didn't realize that destructuring a map split it into keys and values |
| 19:41 | amalloy | sritchie_: destructuring a map *entry* splits it |
| 19:41 | sritchie_ | ah, and in your example, for walked across a map, which produced entries |
| 19:42 | amalloy | &(let [m {1 2 3 4}] [(seq m) (first m) (let [[k v] (first m)] [k v])) |
| 19:42 | sexpbot | java.lang.Exception: Unmatched delimiter: ) |
| 19:42 | sritchie_ | &(take 2 {1 1000 2 500}) |
| 19:42 | sexpbot | ⟹ ([1 1000] [2 500]) |
| 19:42 | sritchie_ | got it |
| 19:42 | amalloy | &(let [m {1 2 3 4}] [(seq m) (first m) (let [[k v] (first m)] [k v])]) |
| 19:42 | sexpbot | ⟹ [([1 2] [3 4]) [1 2] [1 2]] |
| 19:46 | amalloy | ANYWAY. moral of the story: you can use case or a map, and there are differences, and it's up to you to pick |
| 19:47 | sritchie_ | amalloy: haha, that is a good takeaway |
| 19:47 | sritchie_ | thanks for the help |
| 19:55 | Null-A | any idea on how to declare array of bytes return value in gen-class :methods? |
| 19:55 | Null-A | its not `bytes` |
| 19:56 | amalloy | Null-A: i seem to recall seeing this on the mailing list in the last couple weeks |
| 19:56 | Null-A | i'll take a look |
| 19:56 | amalloy | ^"[B" probably works |
| 19:57 | amalloy | but (in 1.3, at least - not sure about 1.2) i think ^bytes is supposed to be the hint for a byte[], which won't work for clojure fns but ought to for gen-class methods |
| 19:57 | amalloy | Null-A: ^ |
| 19:58 | Null-A | ah, well i'm on 1.2 |
| 19:58 | Null-A | amalloy: you think :methods [[foo [] "[B"]] will work? |
| 19:59 | Null-A | there's never a caret |
| 19:59 | amalloy | that would be my best try |
| 20:02 | amalloy | looks like no, though |
| 20:03 | amalloy | actually maybe i just don't know how to use gen-class :P. anyway try it out and let me know, Null-A |
| 20:03 | Null-A | amalloy: didn't work |
| 20:03 | Null-A | amalloy: i think I can get by with ByteArrayOutputStream as return type |
| 20:03 | Null-A | amalloy: thanks for the help ;) |
| 20:05 | hiredman | b |
| 20:10 | amalloy | hiredman: for returning a byte[]? |
| 20:21 | hiredman | amalloy: focus on the wrong window, that b was meant for emacs |
| 20:22 | amalloy | that was my second guess (modulo specificity about where you meant to send it) |
| 21:00 | sattvik | Null-A: For gen-class, you can have a return type of "[B" for an array of bytes |
| 21:01 | sattvik | For example: (ns MyClass (:gen-class :methods [[myMethod [] "[B"]])) |
| 21:02 | Null-A | sattvik: I did try that |
| 21:03 | Null-A | sattvik: are you sure it works? it didn't work when I tried it |
| 21:03 | Null-A | classnotfound "[B" |
| 21:05 | sattvik | Hmmm... I just tried it out, but let me be sure. |
| 21:11 | sattvik | Null-A: This code seems to be working for me: https://gist.github.com/844849 |
| 21:12 | Null-A | sattvik: on 1.2 clojure? |
| 21:12 | sattvik | yes |
| 21:12 | Null-A | k, i'll retry |
| 21:12 | TimMc | The "[Foo" notation offends my balancing sensibilities. :-( |
| 21:12 | sattvik | It is rather ugly. |
| 21:12 | TimMc | (Interestingly, emoticons do not.) |
| 21:13 | TimMc | I suppose my brain sees "face" before "code". |
| 21:16 | Sgeo | I think Clojure might have gotten me interested in Haskell again >.> |
| 21:17 | Lulu58e2 | Haskell keeps defeating me and I keep coming back for more |
| 21:23 | Sgeo | Maybe I'll find Leksah to be a nice usable IDE |
| 21:23 | Sgeo | Which is more than I can say for all the Clojure stuff I've found |
| 21:24 | Sgeo | Then again, I probably should try to get familiar with a Lisp at some point |
| 21:27 | Sgeo | Although my Android phone does have a nice Clojure REPL, which is more than I can say for Hasell |
| 21:27 | Sgeo | Haskell |
| 21:27 | Null-A | sattvik: ah it did work |
| 21:27 | Null-A | thanks |
| 21:27 | sattvik | No problem. I'm glad it helped. |
| 21:29 | Null-A | sattvik: doesn't seem to work with gen-interface though, just gen-class |
| 21:30 | Null-A | that's why I originally thought it didn't work |
| 21:31 | sattvik | Null-A: Yes, that's right. The patch to get it to work in gen-interface and definterface just got committed today. For those, you can use ^bytes. |
| 21:32 | Lulu58e2 | Huzzah! Finally got Clojure running through Slime |
| 21:35 | gfrlog | so let's say I want to load several versions of a namespace at the same time... |
| 21:35 | sattvik | Actually, with the new patch, you will be able to use bytes instead "[B" for gen-class, too. |
| 21:36 | dnolen | Sgeo: or you could stop wasting your time looking for an 'perfect' environment and start writing code. From what I hear Simon Peyton Jones writes GHC in Emacs :) |
| 21:36 | dnolen | and debugs w/ print statements. |
| 21:37 | Sgeo | Decent environments I have seen: Newspeak's IDE, and DrRacket. Although I seem to be satisfied with things like Notepad++ when it comes to Python |
| 21:38 | Sgeo | Then again, I have little experience with Newspeak's IDE or with DrRacket |
| 21:43 | groovy2shoes | DrRacket has some nice features for Lisps. One of my favorites is the way it highlights nested lists with different shades depending on how deep they are. |
| 21:57 | amalloy | combining -> and doto yields some pretty powerful stuff. it's really nice how these two play nice together automatically - props to whoever thought them up |
| 22:09 | spewn | groovy2shoes: Not exactly the same, but emacs and vim can be set up to have rainbow parens. |
| 22:17 | groovy2shoes | spewn: Yeah. The shading makes it even more visually distinct :) |
| 22:42 | Lulu58e2 | Is there a new f macro that expands to fn? |
| 22:46 | amalloy | Lulu58e2: uh, i don't think so but maybe you'd better clarify |
| 22:54 | Null-A | I have :aot all, but when I run lein compile, it can't find my gen-class |
| 22:54 | Null-A | its not even generating any class files inside classes/ dir |
| 22:55 | tomoj | you have literally ":aot all" ? |
| 22:55 | Null-A | tomoj: yah |
| 22:55 | Null-A | in my project clj |
| 22:55 | joshua__ | $find-fn 1 2 3 |
| 22:56 | tomoj | what made you think that would work? |
| 22:56 | joshua__ | &find-fn 1 2 3 |
| 22:56 | sexpbot | java.lang.Exception: Unable to resolve symbol: find-fn in this context |
| 22:56 | joshua__ | &findfn 1 2 3 |
| 22:56 | sexpbot | java.lang.Exception: Unable to resolve symbol: findfn in this context |
| 22:56 | Null-A | tomoj: my boss wrote it |
| 22:56 | tomoj | ah :) |
| 22:56 | Null-A | what works? |
| 22:56 | tomoj | I'd guess lein would say "well, I don't see any namespace called 'all'.." |
| 22:56 | tomoj | sample.project.clj says you can supply a regex |
| 22:56 | Null-A | ohm |
| 22:57 | tomoj | but doesn't provide an example.. wonder if it means :aot #".*" or :aot ".*" |
| 22:57 | Null-A | tomoj: actually its ":aot :all" |
| 22:58 | Null-A | which I think is valid |
| 22:58 | tomoj | yeah, that looks more likely to work |
| 22:58 | tomoj | :aot [#""] appears to work |
| 22:58 | joshua__ | find-fn 1 2 3 |
| 22:59 | Null-A | tomoj: i'll try it.. |
| 22:59 | Null-A | I tried the namespace too |
| 22:59 | Null-A | none of it worked |
| 22:59 | tomoj | I do see checks for :all |
| 22:59 | tomoj | should work |
| 22:59 | tomoj | then :all is not the problem, I guess |
| 22:59 | Null-A | tomoj: wierd how classes/ dir is empty |
| 23:02 | joshua__ | $find-fn 2 2 4 |
| 23:02 | joshua__ | $findfn 2 2 4 |
| 23:02 | sexpbot | [clojure.core/unchecked-multiply clojure.core/+ clojure.core/* clojure.core/unchecked-add] |
| 23:03 | tomoj | Null-A: does `lein compile` say it's compiling things, or nothing? |
| 23:04 | Null-A | tomoj: i took out the references to my clojure genenerated class, and now it compiles |
| 23:04 | Null-A | tomoj: but none of the clojure classes are present in classes/ dir |
| 23:05 | Null-A | oh I see some stuff, actually |
| 23:05 | Null-A | just not my gen-class, hmh |
| 23:10 | Null-A | uhg, bbl |
| 23:16 | Lulu58e2 | amalloy: I'm running Clojure in Emacs via swank; I tried (filter (fn [x] (< 2 x) [1 2 3 4 5 6]) and it complains that it can't find "fnn" |
| 23:16 | Lulu58e2 | amalloy: So I try it (filter (f [x] (< 2 x) [1 2 3 4 5 6]) and it works |
| 23:17 | DespiteItAll | clearly you have an invisible 'n' |
| 23:17 | DespiteItAll | oh, actually, i know what it is |
| 23:17 | Lulu58e2 | I did C-c C-m over "f" and it shows "fn" in whatever the slime buffer is called |
| 23:17 | DespiteItAll | it's turning fn into the greek letter |
| 23:17 | DespiteItAll | it's an annoying thing that clojure mode does sometimes |
| 23:18 | amalloy | Lulu58e2: is that the parens you're actually using? cause there should be an ) after (< x 2) |
| 23:18 | Lulu58e2 | So, that's why I asked about the "f" macro; seems "f" is macro-expanding to "fn" |
| 23:18 | Lulu58e2 | amalloy: lol, no, I had a 2nd ) after the anon fn |
| 23:19 | DespiteItAll | Lulu58e2: look at the 'f' closely. it's not really an 'f' |
| 23:19 | amalloy | Lulu58e2: i'm inclined to agree with DespiteItAll: there's an invisible n in there somewhere |
| 23:19 | Lulu58e2 | Okay, it does look like a fancy f with a bit of a tail |
| 23:20 | Lulu58e2 | lol, okay, interesting. |
| 23:20 | DespiteItAll | yeah, you need to turn off 'pretty-fns' I'm not sure how to |
| 23:20 | Lulu58e2 | Yup, did backspace and it goes back to regular old "f" |
| 23:20 | Lulu58e2 | Thanks! |
| 23:21 | amalloy | heh. when no logical solution is possible, search for ghosts |
| 23:21 | Lulu58e2 | :) |
| 23:22 | Lulu58e2 | I'm making the switch from Clojure in IDEA on Windows to Clojure in Emacs on Ubuntu. |
| 23:22 | Lulu58e2 | Garsh, what a mind-job. |
| 23:23 | Lulu58e2 | (and I'm quite new at Clojure at that) |
| 23:24 | amalloy | nice. i made the switch, more or less, from java in eclipse on windows to clojure in emacs on ubuntu at about the same time |
| 23:25 | amalloy | every choice well worth it |
| 23:25 | Lulu58e2 | Same, switching from Java after reading Seven Languages in Seven Weeks |
| 23:26 | Lulu58e2 | I'm not sold on emacs yet, but it gets good press. Worth a shot. |
| 23:26 | Lulu58e2 | I did the tutorial and watched "Meet Emacs" from PeepCode |
| 23:26 | amalloy | http://norvig.com/21-days.html |
| 23:26 | Lulu58e2 | lol "in Ten Years" |
| 23:27 | amalloy | true words |
| 23:27 | Lulu58e2 | Oh I'm sure truer words were never spoken |
| 23:28 | amalloy | i think the url is almost as funny as the rest of the article |
| 23:29 | Lulu58e2 | I like the Alan Perlis "... change the way you think ..." quote |
| 23:29 | Lulu58e2 | Haskell had me thinking like a crazy person. :D |
| 23:30 | amalloy | sure it didn't just make you crazy? |
| 23:30 | Lulu58e2 | <snicker> |
| 23:31 | Lulu58e2 | I'm convinced there's something there. After I get a little more comfortable with Clojure I'm going to hit that last chapter in 7Lin7W |
| 23:31 | amalloy | Lulu58e2: something "there" where? |
| 23:32 | amalloy | cuz in isolation "i'm convinced there's something there" sounds like a crazy person :) |
| 23:32 | Lulu58e2 | rofl |
| 23:33 | Lulu58e2 | Come on, with words like monad and things like "function lifting" I'm sure it must have 110% of awesome baked right into it. |
| 23:33 | Lulu58e2 | Plus, the "Learn you a Haskell for Great Good" sells it all by itself. |
| 23:33 | amalloy | oh in haskell |
| 23:34 | amalloy | yeah haskell is a language that i am convinced will be fabulous for me if i can ever muster the strength to really learn it like i did clojure |
| 23:35 | Lulu58e2 | I can still read it fairly well, which surprised me, but I think Clojure will help me learn more of the FP I need to tackle Haskell |
| 23:35 | Lulu58e2 | I need Clojure to change the way I think (i.e. functionally) and then Haskell to take it to the "pure" level. |
| 23:41 | Lulu58e2 | Okay, why does clojure-mode insist on doubling up my parens? Is it Paredit or Fill doing it? |
| 23:41 | amalloy | paredit |
| 23:42 | amalloy | i hated it for a while but it's actually super-handy |
| 23:42 | Lulu58e2 | Hmm, okay, thx |
| 23:42 | Lulu58e2 | What's the idiomatic way to look up Paredit info? Google? |
| 23:42 | amalloy | not so much because it doubles your parens, but because it knows your code is well-balanced it can perform handy list-editing functions on it for you |
| 23:43 | amalloy | Lulu58e2: or #emacs. i'm not a pro myself |
| 23:43 | amalloy | the ones i use most are C-<RIGHT>, M-(, M-<UP>, and M-r |
| 23:44 | Lulu58e2 | Please excuse my ignorance, but what's with the different colours? (I'm using XChat) |
| 23:44 | amalloy | uhm, what colors? |
| 23:44 | Lulu58e2 | (I tried Googling it but I'm not sure if it's XChat, Freenode, or what) |
| 23:44 | Lulu58e2 | Sometimes your nick and text is red, sometimes blue |
| 23:44 | Lulu58e2 | Mine is light grey |
| 23:44 | amalloy | mine? it's something your client is doing, but i don't know what |
| 23:45 | amalloy | Lulu58e2: maybe it has to do with whether ive mentioned you in the message |
| 23:45 | Lulu58e2 | I suppose I should find a #xchat or #irc-retards channel |
| 23:45 | Lulu58e2 | Hmm, yes, that does seem to be a pattern |
| 23:45 | amalloy | Lulu58e2: lol, i would join that channel. i actually just use pidgin as a holdover from my windows days |
| 23:45 | amalloy | it's a pretty awful irc client, but i'm comfortable with it |
| 23:45 | seancorfield | Lulu58e2: how many IRC clients have you tried on Ubuntu? i tried a bunch and settled on Konversation |
| 23:46 | Lulu58e2 | Um, let me count ... 1 |
| 23:46 | seancorfield | oh... heh... ok... |
| 23:46 | Lulu58e2 | I suppose I should try more but Clojure-Emacs-Swine-Swank takes precedence |
| 23:47 | amalloy | slime, or is swine an actual thing? |
| 23:47 | Lulu58e2 | D'oh |
| 23:47 | Lulu58e2 | nvmd, is slime |
| 23:48 | Lulu58e2 | (had to quickly double-check my web page :) |
| 23:48 | Lulu58e2 | Okay, C-<RIGHT> is cool |
| 23:49 | Lulu58e2 | Ack! M-<UP> |
| 23:49 | amalloy | lol |
| 23:49 | amalloy | C-/ to undo |
| 23:53 | Lulu58e2 | seancorfield: are you using KDE? |
| 23:56 | Lulu58e2 | lol "slurp" and "barf" commands (paredit) |
| 23:58 | amalloy | oh, and paredit's C-k is imo a lot more useful than the built-in |
| 23:59 | Lulu58e2 | amalloy: yeah, I can see now the value of paredit |
| 23:59 | Lulu58e2 | amalloy: I didn't even realize there were commands associated with it. |
| 23:59 | Lulu58e2 | That's another point for Emacs |
| 23:59 | Lulu58e2 | (and obviously for paredit itself) |