2011-06-27
| 00:30 | davekong | I have a function that is working fine in the REPL, but if the pcall version of it is called from a java class, it hangs after printing the result. Also, from java, whether calling the parallel version or not, it gives grossly inacurrate results, despite all of the number manipulation being done in clojure (the function is just passed arrays of strings). Any hints on how to fix these issues? Should I |
| 00:30 | davekong | paste my code? |
| 00:34 | amalloy | davekong: ##(doc shutdown-agents) |
| 00:34 | sexpbot | ⟹ "([]); Initiates a shutdown of the thread pools that back the agent system. Running actions will complete, but no new actions will be accepted" |
| 00:35 | amalloy | probably why it's "hanging". no ideas about the other thing |
| 00:43 | davekong | amalloy: thanks that seems to have fixed the first issue |
| 00:45 | amalloy | don't do that unless you want to shut down the system, though |
| 00:45 | davekong | oh |
| 00:47 | davekong | well I don't want to until much later except now while I am testing |
| 00:48 | davekong | I am doing some calculations in clojure but the main program is on java |
| 00:50 | davekong | Or you just mean shut down all the agents? |
| 00:54 | davekong | seems like half the time I get a bad result and half the time it is good |
| 00:56 | davekong | and it has been regular for several runs good, bad, good, bad |
| 01:00 | symbole | Why does (defn foo [&{:keys...}] work? Isn't everything after & collected into a list, and you can't destructure a list using {:keys...}? |
| 01:06 | davekong | Would java be less safe with memory or something like that and maybe memory is getting corrupted? |
| 03:00 | amalloy | ~source destructure |
| 03:00 | amalloy | symbole: it works because the above makes it work |
| 03:00 | amalloy | (i haven't looked actually, but where else can the logic be) |
| 03:17 | amalloy | for the curious, it looks like line 3434 there says, "if you destructure a seq into a map, apply hash-map on it first" |
| 03:20 | amalloy | &(let [{:keys [test]} '(:test 1)] test) |
| 03:20 | sexpbot | ⟹ 1 |
| 05:48 | rfgpfeiffer | clojurebot: seen drcode |
| 05:48 | clojurebot | Pardon? |
| 05:49 | rfgpfeiffer | ~seen drcode |
| 05:49 | clojurebot | Excuse me? |
| 07:32 | tomoj | how does this make sense? https://gist.github.com/d24bf93fb851b9835305 |
| 07:32 | tomoj | I realize it's silly to create a bunch of new Randoms |
| 07:33 | tomoj | but still, shouldn't I sometimes see more positive than negative? |
| 07:33 | tomoj | every time I look for positives I get less positives than negatives |
| 07:33 | tomoj | less positives than nonpositives I should say |
| 07:34 | tomoj | every time I look for negatives I get fewer negatives than nonnegatives |
| 07:34 | tomoj | yet every time I look for zeros I get zero... |
| 07:37 | tomoj | if I instead use just one Random, the results make sense |
| 07:37 | tomoj | hah |
| 07:55 | tomoj | (repeateadly #(.nextLong (java.util.Random.))) is a strange thing |
| 07:56 | tomoj | s/ead/ed/ |
| 07:57 | raek | tomoj: I think that when a Random is instantiated the random seed is initialized with the current time |
| 07:57 | raek | tomoj: so if you instantiate a lot of them in the same millisecond/microsecond, the will give the same values |
| 07:57 | raek | *they will |
| 07:59 | tomoj | strange thing is, I can't ever see any dups |
| 08:01 | tomoj | but since the behavior depends on how you consume the seq... |
| 08:03 | raek | ,(java.util.Random.) |
| 08:03 | clojurebot | #<Random java.util.Random@1746634> |
| 08:03 | tomoj | I think there's just some weird dependency where if you take longer to consume positive values, and so delay generation of Randoms a bit more for positive values than negative values, fewer positive values are produced in general |
| 08:03 | tomoj | s/in general// |
| 08:04 | raek | ,(let [f #(.nextInt (java.util.Random.))] (loop [l (), n 10] (if (zero? n) l (recur (cons (f) l) (dec n))))) |
| 08:04 | clojurebot | (1135657559 -1653233976 1129285394 1624057155 -285451636 110824407 -1401623519 -906851758 1078467891 -246900125) |
| 08:06 | raek | ,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) (recur (cons (java.util.Random) l) (dec n))))) |
| 08:06 | clojurebot | () |
| 08:06 | raek | ,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) l (recur (cons (java.util.Random) l) (dec n))))) |
| 08:06 | clojurebot | java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn |
| 08:06 | raek | ,(map #(.nextInt %) (loop [l (), n 10] (if (zero? n) l (recur (cons (java.util.Random.) l) (dec n))))) |
| 08:06 | clojurebot | (1079184460 -905735116 -412502350 -735306677 -337491639 2058739835 1328101674 1724377717 608990656 386974692) |
| 08:07 | raek | ok, I can't seem to construct a example of what I'm thinking about... :-) |
| 08:08 | rpglover64 | interop question |
| 08:10 | rpglover64 | I (by which I mean my friend's students) have been given a jar, with the assignment that they should write program logic conforming to the api provided by the jar in java; I'd like to try to do this in clojure. |
| 08:10 | rpglover64 | suggestions on how to start? |
| 08:18 | gfrlog | rpglover64: can you be more specific? like, are you already familiar with clojure's interop features, or do you need help with those? |
| 08:19 | gfrlog | (e.g., have you already read http://clojure.org/java_interop ?) |
| 08:20 | rpglover64 | no, I'm not |
| 08:20 | rpglover64 | in fact, I'm not familiar with java classloaders |
| 08:20 | rpglover64 | I have read that |
| 08:21 | rpglover64 | and my tripup right now seems to be getting access to the java api from within clojure |
| 08:21 | gfrlog | rpglover64: do you have the jar on the classpath? have you tried importing the relevant classes? |
| 08:22 | rpglover64 | ah, the answer is simple. I'm an idiot who tries importing packages as if they were classes |
| 08:22 | gfrlog | :) |
| 08:22 | rpglover64 | thank you |
| 08:23 | gfrlog | np |
| 08:52 | gfrlog | I wish (for) had an implicit do :( |
| 08:53 | rpglover64 | can't you write a macro for that? |
| 08:53 | rpglover64 | (I know I can't, but shouldn't it not be too difficult?) |
| 09:00 | terom | gfrlog`: what do you mean? doseq has similar bindings as for |
| 09:00 | gfrlog` | terom: does it return a seq? |
| 09:00 | gfrlog` | ,(doseq [x (range 5)] (inc x)) |
| 09:01 | clojurebot | Execution Timed Out |
| 09:01 | gfrlog` | ?? |
| 09:01 | gfrlog` | is it too early for writing code? |
| 09:01 | gfrlog` | my repl says it returns nil |
| 09:01 | gfrlog` | so doseq would not be a good substitute |
| 09:01 | terom | Maybe... doseq returns nil, it's for side effects. |
| 09:02 | gfrlog` | terom: right. I want to use for primarily, but adding debugging statements is a pain |
| 09:02 | gfrlog` | I cannot say (for [x (range 10)] (prn x) (inc x)) |
| 09:04 | terom | Well.. you could say (do (prn x) (inc x)), but the results can be a bit suprising. |
| 09:04 | gfrlog` | terom: that's what I do. I know that for is lazy. |
| 09:04 | gfrlog` | When my lazy seq crashes in some completely other part of the code because of something in the body of the for, adding the (prn) there can usually help |
| 09:09 | rpglover64 | looks like you've run into a problem common in haskell |
| 09:31 | tomoj | &(= (Long/toBinaryString -9223372036854775808) (Long/toBinaryString 27670116110564327424)) |
| 09:31 | sexpbot | java.lang.Exception: EvalReader not allowed when *read-eval* is false. |
| 09:32 | tomoj | oh, unsigned.. |
| 09:32 | tomoj | wait.. |
| 09:33 | tomoj | ,(long 27670116110564327424) |
| 09:33 | clojurebot | java.lang.ExceptionInInitializerError |
| 09:34 | gfrlog` | tomoj: I've noticed the bots don't like reading big numbers |
| 09:34 | gfrlog` | ,2823589289358923847289348923523423423 |
| 09:34 | clojurebot | 2823589289358923847289348923523423423 |
| 09:34 | gfrlog` | okay nm I don't know what I'm talking about |
| 09:35 | gfrlog` | ,(first (range 8923895829348929835982389498234923)) |
| 09:35 | clojurebot | java.lang.ExceptionInInitializerError |
| 09:44 | mattmitchell | anyone know of a good validation lib? I want to do things like, make sure input is of a certain type, provide defaults, provide useful error messages etc.. This will be used in a library full of search finder functions |
| 09:52 | jcromartie | -> and update-in are just about the best things ever |
| 09:52 | jcromartie | next to Nutella |
| 09:56 | gfrlog` | mattmitchell: I know clojure provides function preconditions built in |
| 09:56 | gfrlog` | mattmitchell: but that's probably not as extensive as what you want |
| 09:58 | mattmitchell | gfrlog`: yeah I want to play with the preconditions a bit. The simpler the better for sure. |
| 10:00 | gfrlog` | mattmitchell: the defaults you could probably handle with a macro pretty simply |
| 10:01 | gfrlog` | I think clojure.core had a private method that it used for declaring constraints for inputs and reporting errors |
| 10:01 | wastrel | hi i stopped learning clojure because of busy |
| 10:02 | mattmitchell | gfrlog`: interesting, that'd be a good thing to have |
| 10:02 | mattmitchell | gfrlog`: could you show me an example of using a macro for defaults? |
| 10:02 | gfrlog` | sure, one sec |
| 10:02 | gfrlog` | the clojure.core macro is here: https://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L1383 |
| 10:03 | gfrlog` | I can't guarantee that one's a good idea though; some of the code in core is primitive |
| 10:04 | gfrlog` | mattmitchell: what kind of default behavior do you want? do you just want nil args to be converted to something else, or do you want the function to be able to accept any number of args? |
| 10:06 | mattmitchell | gfrlog`: well for example, if I have a param called :sort, I want to make sure it is an array, and contains valid sort fields: [:score.dec :price.asc]. If the values aren't valid, then fallback to a default like [:score.desc]. But it'd be great to throw an exception if needed too. |
| 10:09 | gfrlog` | mattmitchell: so for each arg you want to define what valid means and you want to provide an alternative for invalid inputs? |
| 10:09 | gfrlog` | or you want to throw an exception? :/ |
| 10:10 | mattmitchell | gfrlog`: yes, the former. The exception stuff isn't as important, thanks :) |
| 10:15 | edw | I'm consistently getting a "No value supplied for key: <PORTNUM>" exception when using M-x clojure-jack-in. Anyone else run into this? This is new to me; I've been using jack-in for a while now. |
| 10:16 | gfrlog` | mattmitchell: try this and tell me how it breaks :) https://gist.github.com/1048931 |
| 10:17 | edw | Hmm, seems related to incanter-1.2.3... Hmm. |
| 10:19 | pyr | whenever timers are brought up |
| 10:19 | pyr | concurrency issues are mentionned |
| 10:20 | raek | edw: iirc, incanter has an old version of swank-clojure as a dev-dep |
| 10:25 | mattmitchell | gfrlog`: thanks! |
| 10:25 | mattmitchell | gfrlog`: will check it now |
| 10:25 | gfrlog` | yepps |
| 10:31 | mattmitchell | gfrlog`: OK running your example I get "Can't let qualified name: user/arg-nam" |
| 10:31 | mattmitchell | sorry, that last part was "arg-name" |
| 10:31 | gfrlog` | mattmitchell: that sounds plausible. Kay I'll put it in my repl and beat out the problems :) |
| 10:31 | mattmitchell | gfrlog`: cool thanks! |
| 10:32 | gfrlog` | mattmitchell: you see what it's trying to do though right? |
| 10:32 | mattmitchell | gfrlog`: yes i think i understand the idea there and how it works. I'm not real experienced with macros though, so the quoting throws me off a bit |
| 10:32 | gfrlog` | yeah it's a bit weird |
| 10:35 | gfrlog` | mattmitchell: okay, I updated it. Seems to work now. |
| 10:35 | mattmitchell | awesome i'll check it |
| 10:36 | gfrlog` | mattmitchell: using macroexpand probably makes it more explicit what it's doing |
| 10:36 | mattmitchell | gfrlog`: good idea |
| 10:37 | gfrlog` | mattmitchell: maybe renaming it let-defaults would make more sense :/ dunno |
| 10:37 | gfrlog` | or....whatever you want |
| 10:37 | mattmitchell | ok sure yeah. i'm going to play around with this. thanks for taking the time to write this up :) |
| 10:38 | gfrlog` | no problem |
| 10:55 | mattmitchell | is there a predicate for testing if something is an array-like type? |
| 10:56 | mattmitchell | Or is it just (or (vector? x) (list? x) ? |
| 10:57 | pcavs_ | mattmitchell: (seq? my-list) I believe |
| 10:57 | mattmitchell | that's what i thought too, but then: |
| 10:57 | terom | seq? returns false for vectors |
| 10:58 | mattmitchell | ,(seq? [1]) |
| 10:58 | clojurebot | false |
| 10:58 | mattmitchell | yeah |
| 10:58 | pcavs_ | well it depends what you're testing |
| 10:58 | pcavs_ | ,(seq? (list 1 2 3)) |
| 10:58 | clojurebot | true |
| 10:58 | pcavs_ | is because it implements (head my-list) and (rest my-list) |
| 10:58 | pcavs_ | ,(head (list 1 2 3)) |
| 10:58 | clojurebot | java.lang.Exception: Unable to resolve symbol: head in this context |
| 10:59 | pcavs_ | doh |
| 10:59 | terom | first |
| 10:59 | pcavs_ | w/e it's called in clojure |
| 10:59 | pcavs_ | there we go |
| 10:59 | pcavs_ | ,(first (list 1 2 3)) |
| 10:59 | clojurebot | 1 |
| 10:59 | pcavs_ | ,(rest (list 1 2 3)) |
| 10:59 | clojurebot | (2 3) |
| 10:59 | pcavs_ | ,(type [1]) |
| 10:59 | clojurebot | clojure.lang.PersistentVector |
| 11:00 | mattmitchell | ,(first [1]) |
| 11:00 | clojurebot | 1 |
| 11:00 | mattmitchell | ,(rest [1 2 3]) |
| 11:00 | clojurebot | (2 3) |
| 11:00 | pcavs_ | mattmitchell: now I'm confused myself... =\ |
| 11:01 | mattmitchell | ok :). yeah I was totally expecting seq? to return true for vectors |
| 11:01 | terom | first and rest probably call seq on the vector |
| 11:03 | bsteuber | what you want is sequential? |
| 11:03 | bsteuber | ,(sequential? [1 2 3]) |
| 11:03 | clojurebot | true |
| 11:04 | bsteuber | ,(sequential? (list 1 2 3)) |
| 11:04 | clojurebot | true |
| 11:04 | bsteuber | ,(sequential? {:a 4}) |
| 11:04 | clojurebot | false |
| 11:07 | rfgpfeiffer | ,(doc sequential?) |
| 11:07 | clojurebot | "([coll]); Returns true if coll implements Sequential" |
| 11:08 | mattmitchell | ,(sequential? "test") |
| 11:08 | clojurebot | false |
| 11:08 | mattmitchell | good |
| 11:10 | rfgpfeiffer | ,(seqable? ()) |
| 11:10 | clojurebot | java.lang.Exception: Unable to resolve symbol: seqable? in this context |
| 11:10 | raek | re. seq vs seqable, I recommend this post: http://kotka.de/blog/2011/06/On_types.html |
| 11:10 | pcavs_ | raek: thanks |
| 11:11 | bsteuber | ,(clojure.contrib.core/seqble? "foo") |
| 11:11 | clojurebot | java.lang.ClassNotFoundException: clojure.contrib.core |
| 11:12 | raek | when the ISeq is eventually protocolized, checking for "seqable" would be more intuitive |
| 11:12 | rfgpfeiffer | is there a way to refer to array types in multimethod signatures? |
| 11:13 | raek | rfgpfeiffer: what do you mean by "multimethod signatures"? dispatch value? type hints? |
| 11:13 | bsteuber | rfgpfeiffer: clojure.lang.Sequential |
| 11:13 | rfgpfeiffer | dispatch value |
| 11:14 | rfgpfeiffer | I can write (def bytes (type (byte-array 0))) |
| 11:14 | rfgpfeiffer | and use that as a dispatch value |
| 11:14 | raek | I think the easiest way is to create an instance of an array with the correct type and then store the (class the-array) in a var |
| 11:15 | raek | I've seen this in clojure core code, I think |
| 11:15 | rfgpfeiffer | ,(type (byte-array 0)) |
| 11:15 | clojurebot | [B |
| 11:16 | raek | ,(resolve '[B) |
| 11:16 | clojurebot | Unmatched delimiter: ) |
| 11:16 | raek | ,(resolve (symbol "[B")) |
| 11:16 | clojurebot | [B |
| 11:16 | raek | ,(Class/forName "[B") |
| 11:16 | clojurebot | [B |
| 11:16 | raek | ,(Class/forName "[Invalid") |
| 11:16 | clojurebot | java.lang.ClassNotFoundException: [Invalid |
| 11:17 | raek | hrm, this might work too |
| 11:17 | rfgpfeiffer | ,(= (Class/forName "[B") (type (byte-array 0))) |
| 11:17 | clojurebot | true |
| 11:17 | rfgpfeiffer | interesting |
| 11:19 | raek | mattmitchell: for macros, one idea is to define cases for seq? (lists), vector?, map?, set?, and everything else. |
| 11:20 | raek | if you want to define new meaning for clojure source code data structures |
| 11:26 | sritchie | hey all -- is there some way to get metadata at read-time, for a function passed in to another function as an argument? |
| 11:27 | sritchie | (defn get-meta [x] (retrieve-meta x)) |
| 11:27 | sritchie | which would just be retrieve-meta, of course |
| 11:28 | sritchie | oh, actually, better question -- can function values hold metadata? |
| 11:28 | pdk | the return values or the functions themselves |
| 11:29 | pdk | also (meta x) returns a map with the metadata of x |
| 11:29 | sritchie | the functions themselves |
| 11:29 | gfrlog` | ,(vector (meta cons) (meta (var cons))) |
| 11:29 | clojurebot | [{:line 28} {:ns #<Namespace clojure.core>, :name cons, :file "clojure/core.clj", :line 22, :arglists ([x seq]), :doc "Returns a new seq where x is the first element and seq is\n the rest.", :added "1.0"}] |
| 11:29 | pdk | functions can carry metadata |
| 11:30 | sritchie | pdk: cool, that's perfect |
| 11:30 | sritchie | thanks |
| 11:30 | gfrlog` | I'm curious why one is :line 28 and the other is :line 22 |
| 11:30 | gfrlog` | the function seems to be about six lines long... |
| 11:31 | rpglover64 | how is proxy expected to be used (there seems to be a dearth of examples); I'm slightly confused as to what would be the equivalent of (in java) writing a class which implements an interface. |
| 11:32 | gfrlog` | rpglover64: I think you can implement java interfaces with defrecord |
| 11:36 | raek | rpglover64: a typical usage is to interface with swing, e.g. you might need to implement ActionListener |
| 11:37 | raek | http://www.dreamincode.net/code/snippet3252.htm |
| 11:37 | raek | (example by Raynes) |
| 11:38 | rpglover64 | ah; illuminating |
| 13:10 | derp__ | I want to try and make a simple project using lein, but I don't really know where to go after creating my main function in core.clj |
| 13:10 | derp__ | would anyone recommend a small example project using lein for me to look at? |
| 13:10 | technomancy | clojurebot: google mire |
| 13:10 | clojurebot | First, out of 4660000 results is: |
| 13:10 | clojurebot | Mire | Define Mire at Dictionary.com |
| 13:10 | clojurebot | http://dictionary.reference.com/browse/mire |
| 13:10 | technomancy | oops |
| 13:10 | technomancy | clojurebot: google mire clojure |
| 13:10 | clojurebot | First, out of 103 results is: |
| 13:10 | clojurebot | in which slime and mire and other sludges come into play - Technomancy |
| 13:10 | clojurebot | http://technomancy.us/122 |
| 13:12 | technomancy | derp__: lame link, but whatever; what I meant to say is that I built mire as a sample type app |
| 13:12 | derp__ | technomancy: thank you, this looks like a great place to start |
| 13:12 | wastrel | is clojurebot yours ? |
| 13:12 | wastrel | technomancy: ^^ |
| 13:13 | technomancy | wastrel: I convinced hiredman to implement it. |
| 13:14 | gfrlog` | clojurebot belongs to whoever feeds him the most |
| 13:15 | wastrel | botsnack? |
| 13:15 | wastrel | !botsnack |
| 13:15 | gfrlog` | ~botsnack |
| 13:15 | gfrlog` | clojurebot does not belong to me |
| 13:15 | raek | clojurebot: have some botsnack |
| 13:15 | ejackson | $botsnack |
| 13:15 | sexpbot | ejackson: Thanks! Om nom nom!! |
| 13:15 | justinlilly | ,botsnack |
| 13:15 | ejackson | haha ! |
| 13:16 | gfrlog` | ,(prn "botsnack") |
| 13:17 | pjstadig` | ~ping |
| 13:17 | manutter | clojurebot: say something foreign... |
| 13:17 | gfrlog` | this is what happens when you forget to love your bot |
| 13:17 | manutter | sigh, he died |
| 13:18 | gfrlog` | manutter: is that the one phrase that he will absolutely always respond to unless he is completely dead? |
| 13:18 | hiredman | I suspended the screen it runs it |
| 13:19 | manutter | gfrlog`: I dunno, whenever I try to have a conversation clojurebot always says somthing foreign to me |
| 13:19 | gfrlog` | oh right |
| 13:20 | derp__ | I'm trying to start using slime/swank, but for some reason this tutorial isn't helping me: http://data-sorcery.org/2009/12/20/getting-started/ |
| 13:20 | derp__ | specifically launching "lein swank" in the mire directory isn't working, I get "That's not a task. Use "lein help" to list all tasks." |
| 13:20 | manutter | clojurebot: welcome back. |
| 13:20 | technomancy | aquamacs? =\ |
| 13:20 | clojurebot | Titim gan éirí ort. |
| 13:20 | derp__ | nope |
| 13:21 | derp__ | emacs23 on 11.04 |
| 13:21 | gfrlog` | ~botsnack |
| 13:21 | clojurebot | Thanks! Can I have chocolate next time |
| 13:21 | technomancy | derp__: https://github.com/technomancy/swank-clojure#readme |
| 13:21 | raek | derp__: try "lein plugin install swank-clojure 1.3.1" |
| 13:25 | derp__ | okay, I tried that command and lein swank, but I got this error: https://gist.github.com/1049322 |
| 13:25 | technomancy | derp__: see "known issues" in the readme |
| 13:27 | derp__ | technomancy: okay, I removed the swank requirement in mire, but now I get this error |
| 13:27 | derp__ | https://gist.github.com/1049325 |
| 13:27 | derp__ | woops |
| 13:30 | derp__ | technomancy: I assume you were referring to the :dev dependencies bug, just to be clear |
| 13:30 | technomancy | right |
| 13:31 | derp__ | but this new error, is that related to my own mistake or an actual bug? |
| 13:33 | technomancy | your last gist is also caused by having more than one copy of swank installed |
| 13:35 | derp__ | uh, I guess I had it through elpa (totally forgot about that). when I do M-x package-list-packages, what is the command to delete/remove a highlighted package? |
| 13:36 | technomancy | not sure; rm -rf ~/.emacs.d/elpa/foo works for me |
| 13:37 | technomancy | but that problem is caused by the swank-clojure lein plugin, not the swank-clojure elisp package |
| 13:37 | derp__ | that okay to do? emacs isn't going to throw a fit about a package being removed unceremoniously or whatever? |
| 13:38 | technomancy | you should definitely get rid of the swank-clojure elisp package |
| 13:38 | technomancy | it's been deprecated for over a year |
| 13:39 | technomancy | if I could delete it off elpa I would |
| 13:52 | derp__ | now I am getting "symbols value as variable is void: slime-clj" |
| 13:52 | derp__ | but lein swank works, so I'm halfway there |
| 13:53 | technomancy | never heard of that one before |
| 13:56 | derp__ | I have clojure-mode (1.9.1), slime (20100404.1), slime-clj (0.1.6), slime-fuzzy (20100404), slime-repl (20100404) installed |
| 13:56 | technomancy | I have never heard of slime-clj before |
| 13:57 | hiredman | looks like it comes from swank-clj |
| 13:59 | hugod | slime-clj is from swank-clj |
| 14:00 | derp__ | ooh, now I think I got it almost working |
| 14:00 | derp__ | it says Host: 127.0.0.1 |
| 14:00 | derp__ | but the mode-bar thingy hasn't changed |
| 14:01 | derp__ | now it just has (Lisp Interaction ElDoc Paredit AC yas Fill) |
| 14:02 | raek | derp__: note that swank-clojure and swank-clj are different projects |
| 14:03 | davekong | If I have a function that takes an argument of type {[""] <double>} what would be the type I would pass from java to call it? |
| 14:03 | hugod | I think I should rename swank-clj to something completely different… |
| 14:03 | raek | clojure-mode, slime and slime-repl are the elisp packages you would use with swank-clojure |
| 14:04 | raek | derp__: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs |
| 14:05 | amalloy | davekong: huh? what type is that? |
| 14:05 | amalloy | a map from vector of string to double? |
| 14:07 | amalloy | just pass it an IPersistentMap, or a j.u.Map if your java code is lazy |
| 14:08 | davekong | amalloy: yea |
| 14:23 | mattmitchell | is it possible to do nested destructuring for function args? |
| 14:25 | raek | mattmitchell: yes |
| 14:26 | raek | each parameter can be destructured with the usual rules |
| 14:27 | raek | but the whole "paramter vector" is not a destructuring form, so you can't do something like (defn foo [a b c :as all] ...) |
| 14:27 | amalloy | &((fn [{[x] :values}] x) {:values [1 2 3 4]}) ;; mattmitchell |
| 14:27 | sexpbot | ⟹ 1 |
| 14:27 | fmw` | I'm trying to add a test to https://github.com/clojure/tools.logging, but it doesn't seem to be run when I execute mvm install or mvn test. I can't find where the test functions are called either. any suggestions? |
| 14:28 | mattmitchell | ok thanks. I'll play around with that for a bit |
| 14:42 | wastrel | do you use emacs GUI or cli? |
| 14:44 | sritchie | gui |
| 14:47 | amalloy | even the cli is pretty gooey |
| 14:48 | gfrlog` | :-| |
| 14:52 | sritchie | on OS X, I like using command as the meta key |
| 14:52 | sritchie | and terminal likes escape |
| 14:52 | sritchie | (though this sounds like a fixable issue :)) |
| 14:59 | hugod | fmw`: you could try mvn clojure:test if it is using the clojure-maven-plugin |
| 15:53 | rando | I'm building a project using leiningen and I'm trying to add the S3 wagon following the steps here: http://blog.anzix.net/2010/12/07/using-amazon-s3-as-a-maven-repository/ How can I add the extension to my pom.xml without lein clobbering it? |
| 16:13 | symbole | rando: You might be able to include that in your settings files. |
| 16:14 | rando | symbole: Yeah, i was trying that, but there's no place to put build/extensions in settings.xml that it won't yell at me |
| 16:16 | symbole | rando: It probably goes inside a profile. |
| 16:17 | rando | symbole: any idea where? http://maven.apache.org/ref/2.2.1/maven-settings/settings.html#class_profile |
| 16:18 | symbole | rando: http://maven.apache.org/guides/mini/guide-building-for-different-environments.html |
| 16:18 | rando | oh, look at that |
| 16:20 | rando | symbole: nope, still yells: Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Unrecognised tag: 'build' |
| 16:21 | rando | thats annoying that the docs say its possible |
| 16:21 | derp__ | so in emacs, what's the key combo to go to a function definition? |
| 16:21 | amalloy | M-. |
| 16:21 | amalloy | in slime, anyway |
| 16:22 | rando | symbole: yeah, that example is for the pom.xml |
| 16:23 | derp__ | okay when I type M-. I get "Find tag (default server)" and I have slime/swank talking to each other I think |
| 16:23 | derp__ | but I don't know where this tag file is or how to generate it |
| 16:24 | amalloy | then slime and swank aren't talking to each other |
| 16:24 | amalloy | if slime is going in the current buffer then M-. doesn't try to do tags stuff |
| 16:26 | scgilardi | for OS X, I use https://github.com/aim-stuff/cmd-key-happy as part of a setup to allow my cmd key to act as a meta key with terminal-based emacs. |
| 16:26 | derp__ | okay, now it's working |
| 16:26 | derp__ | so how do I do the opposite of M-. and go backwards? |
| 16:27 | scgilardi | M-, (or meta *) |
| 16:33 | derp__ | when would one use defn-? |
| 16:35 | amalloy | mad cow disease. (an overstatement, but generally don't use it) |
| 16:35 | dnolen | derp__: I see it as a way to control which definitions get imported w/ use. Better I think to lift private stuff into a separate ns I think. |
| 16:36 | Somelauw | defn is private so that it won't conflict with methods of other modules and namespaces |
| 16:36 | Somelauw | and reduces complexity |
| 16:36 | symbole | rando: Maybe this will help http://maven.apache.org/guides/mini/guide-wagon-providers.html |
| 16:37 | Somelauw | I think |
| 16:43 | rando | symbole: I'll give it a shot |
| 17:21 | sjl | Ugh, this "no unsigned bytes datatype" is really annoying. |
| 17:28 | derp__ | what does the # sign do? |
| 17:28 | amalloy | like a hundred things |
| 17:28 | derp__ | I tried (doc #) but got a weird error from slime |
| 17:28 | derp__ | well what's it called? |
| 17:28 | derp__ | if I want to google it |
| 17:29 | sritchie | the dispatch macro |
| 17:29 | amalloy | derp__: it's a "reader macro": based on the next character in the file, it reads forms specially |
| 17:29 | sritchie | search for that here: http://clojure.org/readera |
| 17:29 | sritchie | http://clojure.org/reader |
| 17:29 | amalloy | eg, {a b} is a map, but #{a b} is a set |
| 17:31 | derp__ | okay, thank you |
| 17:35 | Cozey | hello. what's the best way to return json under compojure? |
| 17:36 | Cozey | middleware or overriding render ? |
| 17:36 | Cozey | or .. ? |
| 17:38 | amalloy | uhhhh? |
| 17:39 | amalloy | just return a string, possibly by using a middleware that converts your map to json, and add a middleware that adds a content-type header |
| 17:39 | sjl | What's the best way to say: "split this byte into (int top-four-bits) and (int bottom-four-bits)"? I must be missing something simple... |
| 17:41 | sritchie | (juxt #(bit-and % 0x1100) #(bit-and % 0x0011) ) |
| 17:42 | sritchie | sorry, missing some two ones and zeros from each |
| 17:42 | sritchie | s/some// |
| 17:42 | sexpbot | <sritchie> sorry, missing two ones and zeros from each |
| 17:42 | sjl | hmm |
| 17:43 | sritchie | don't trust that guess, actually, I think something's wrong there |
| 17:43 | amalloy | sritchie: the problem that hex isn't binary, i think :P |
| 17:44 | amalloy | &(let [b 137] (map #(bit-and b %) [0xf0 0x0f])) |
| 17:44 | sexpbot | ⟹ (128 9) |
| 17:45 | sritchie | amalloy: haha, yes, there we go |
| 17:45 | sjl | sritchie: the tricky part is that (byte 137) doesn't work :\ |
| 17:45 | amalloy | &((juxt quot rem) 137 0x10) |
| 17:45 | sexpbot | ⟹ [8 9] |
| 17:46 | sritchie | sjl: amalloy's got you covered -- bit-masking the number will wipe out the first two and last two bits, giving you back the ints you wanted |
| 17:46 | amalloy | sritchie: only if he has an int, though - it won't work with a byte |
| 17:47 | sritchie | true. back to observation mode for me :) |
| 17:48 | sjl | Grrrr (.toString (BigInteger. (byte-array [(byte -122)])) 2) -> "-1111010" |
| 17:48 | amalloy | sjl: working with unsigned numbers in java is terrible, yes |
| 17:48 | sjl | Is there a "just show me the damn bits you're using to represent this" function somewhere? |
| 17:49 | amalloy | &(.toString (BigInteger. (byte-array [(byte 0) (byte -122)])) 2) |
| 17:49 | sexpbot | ⟹ "10000110" |
| 17:49 | amalloy | sjl: not really. a number of libraries have implemented it |
| 17:49 | sjl | Hmm, ok, that's a start. Thanks |
| 17:50 | sjl | Stupid Minecraft protocol and its using nibbles for data. |
| 17:50 | amalloy | *chuckle* |
| 17:50 | justinlilly | wait what? They have a protocol which uses the nibbles game? |
| 17:51 | justinlilly | seems really interesting to transport information as 100x100 grids of a nibbles game in progress :) |
| 17:53 | fmw` | hugod: Sorry, got interrupted by a long skype conversation with the girlfriend. I've added a test function, but it doesn't seem to be run, however the other 21 functions are run, so the tests themselves are running fine |
| 17:57 | fmw` | hugod: but it seems the test is within a comment function, so the current tests aren't all being run either |
| 17:57 | fmw` | hugod: so sorry for bothering you ;) |
| 18:01 | hugod | fmw`: no bother :) mvn test should work too, looking at the parent pom |
| 18:29 | DerGuteMoritz | hello everyone, I am trying to install http://search.maven.org/#artifactdetails%7Cjavax.ws.rs%7Cjsr311-api%7C1.1.1%7Cjar via leiningen like this: lein install javax.ws.rs/jsr311-api 1.1.1 |
| 18:29 | DerGuteMoritz | however, I get this error: Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:0) |
| 18:29 | DerGuteMoritz | am I doing something wrong? |
| 18:31 | dnolen | sjl: https://gist.github.com/1050007 |
| 18:31 | DerGuteMoritz | hm putting it into a project.clj and running lein deps works though |
| 18:32 | dnolen | sjl: not sure if you need something perf conscious, but if all you want to do is introspect this should be fine. |
| 18:32 | sjl | dnolen: Ohh, nice. But is that extremely slow compared to magical bit shifting? |
| 18:32 | dnolen | sjl: if you want something fast you need to bit-and then shift. |
| 18:33 | dnolen | (bit-and n 0xf0) and (bit-and n 0x0f) |
| 18:34 | dnolen | I'm sure there are faster ways, I'm not a bit-twiddling expert |
| 18:35 | sjl | hmm, (defn top [b] (bit-shift-right (bit-and b 0xf0) 4)) |
| 18:38 | dnolen | sjl: yeah that's about 2 orders of magnitude faster. |
| 18:40 | sjl | yeah, that's much more workable |
| 18:41 | Raynes | DerGuteMoritz: lein and cake's install features are meant to install a jar created from a Clojure project's project.clj file. |
| 18:41 | sjl | thanks! |
| 18:41 | dnolen | sjl: np |
| 18:43 | DerGuteMoritz | Raynes: I see - that's a little odd as at least on my installation the maven.org repository is included by default and it does indeed work through lein deps. cljr install javax.ws.rs/jsr311-api 1.1.1 also works though. |
| 18:44 | Raynes | DerGuteMoritz: I was wrong anyway. The lein install task works a little differently than the cake one now. |
| 18:44 | Raynes | So, you have reason to complain, methinks. :p |
| 18:45 | seancorfield | anyone using clojure.contrib.sql with SQL server or PostgreSQL? |
| 18:45 | DerGuteMoritz | Raynes: I was just surprised by that, not really complaining :-) |
| 18:45 | seancorfield | i just pushed a fix for clojure.java.jdbc for generated keys which needs testing against those DBs... 0.0.3-SNAPSHOT |
| 18:45 | DerGuteMoritz | the reason why I wanted that package in the first place is more complaint-worthy |
| 18:47 | dnolen | sjl: yeah the issue is that a bit-shift-right on a negative number fills w/ 1 |
| 18:47 | sjl | yep |
| 18:47 | technomancy | DerGuteMoritz: thanks for the bug report; just fixed it |
| 18:47 | technomancy | I don't think anyone's ever tried to use that task on a non-clojure project |
| 18:47 | DerGuteMoritz | technomancy: oh, it was an actual bug? you're welcome then! :-) |
| 18:48 | DerGuteMoritz | ok looks like I am way off common territory here so I might as well ask for advice, maybe I am doing something wrong |
| 18:48 | Raynes | technomancy: Man, you should really let me know when you add functionality like that so that I can do the same for cake. Stop being competitive! <3 |
| 18:48 | DerGuteMoritz | I'd like to construct an URI (well, URL to be more precise) from a given one |
| 18:49 | DerGuteMoritz | turns out that java.net.URI and URL are not quite up to that |
| 18:49 | technomancy | Raynes: changelog's that way =) |
| 18:49 | Raynes | I'm allergic to changelogs. |
| 18:49 | DerGuteMoritz | so I found out about javax.ws.rs.core.UriBuilder |
| 18:50 | DerGuteMoritz | which, judging from the API, looks quite promising |
| 18:50 | DerGuteMoritz | first question! |
| 18:51 | DerGuteMoritz | how do I know from that reference page (which looks kind of official to me) that it is indeed not part of the standard Java distribution? http://download.oracle.com/javaee/6/api/javax/ws/rs/core/package-tree.html |
| 18:51 | DerGuteMoritz | or is my JDK version too old or something? |
| 18:51 | technomancy | DerGuteMoritz: IIUC "javax" means "not part of the JDK" |
| 18:51 | technomancy | kind of like clojure.contrib |
| 18:51 | DerGuteMoritz | a-ha! |
| 18:51 | seancorfield | btw, if anyone does want to test that, they'd need to pull from sonatype snapshots :) |
| 18:52 | DerGuteMoritz | thanks technomancy |
| 18:52 | DerGuteMoritz | so has anyone ever used UriBuilder? |
| 18:53 | carllerche | technomancy: Any idea how I might be able to have lein deploy use an s3 wagon? It seems that it requires setting build extensions in the pom file |
| 18:54 | carllerche | or is that something that would require writing a plugin for? |
| 18:54 | DerGuteMoritz | I am new to Clojure but the reference page has this example at the beginning: UriBuilder.fromPath("{arg1}").build("foo#bar"), which I converted into this hopefully idiomatic Clojure call: (. (UriBuilder/fromPath "{arg1}") build "foo#bar") |
| 18:54 | technomancy | carllerche: hmm... it could probably go in a plugin and/or future lein version |
| 18:54 | DerGuteMoritz | this results in this interesting exception: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl |
| 18:55 | technomancy | carllerche: pom entries usually correspond to pretty straightforward calls on the Model object, so often it's easy to translate to the Java API |
| 18:55 | rando | technomancy, carllerche: specifically, the pom entry in step 1 of this: http://blog.anzix.net/2010/12/07/using-amazon-s3-as-a-maven-repository/ |
| 18:56 | DerGuteMoritz | does that mean that the jsr311-api jar is missing a dependency perhaps? |
| 18:57 | amalloy | technomancy: that's not accurate. javax.swing.*, for example, is part of the jdk |
| 18:57 | DerGuteMoritz | ; just in case |
| 18:57 | DerGuteMoritz | hehe |
| 18:57 | DerGuteMoritz | ! |
| 18:57 | technomancy | amalloy: huh; didn't know that. |
| 18:57 | DerGuteMoritz | then what is javax? hm |
| 18:57 | DerGuteMoritz | Java + Chemical X |
| 18:57 | Raynes | It means the developers got sick of typing 'java' and wanted to spice things up a bit. |
| 18:58 | amalloy | i think it's like..."stuff that not every deployment platform is required to have"? or "less stable"? i dunno |
| 18:58 | DerGuteMoritz | searching the tubes for com.sun.ws.rs.ext.RuntimeDelegateImpl yields all kinds of results referencing something named "Jersey" |
| 18:59 | Bronsa | http://mindprod.com/jgloss/javax.html |
| 18:59 | carllerche | technomancy: Alright, I will take a stab at writing a plugi |
| 19:00 | technomancy | carllerche: start a mailing list thread if you get stuck |
| 19:00 | carllerche | cool, will do, thanks |
| 19:00 | technomancy | will probably have 1.6 released in a few days, otherwise I'd consider putting it in leiningen itself |
| 19:00 | DerGuteMoritz | Bronsa: thanks! why does that page contain a link to file:///J:/mindprod/jgloss/javax.html? |
| 19:00 | Bronsa | DerGuteMoritz: i have no idea. |
| 19:00 | Bronsa | just found it on google |
| 19:01 | DerGuteMoritz | oh it seems to be some kind of offline cache |
| 19:01 | carllerche | ha, well, i'll see if i can get it done tonight :P I have yet to dig into maven though... so we'll see |
| 19:01 | technomancy | if you want to do it in a fork of lein rather than a plugin that could work too; less messing with hooks that way |
| 19:02 | technomancy | because that really should be built-in |
| 19:02 | technomancy | but then it won't work with older versions. |
| 19:07 | DerGuteMoritz | ok, apparently I need an implementation of JAX-RS |
| 19:07 | DerGuteMoritz | any recommondations? |
| 19:10 | DerGuteMoritz | ok, Jersey it is |
| 19:56 | XPherior | Can anyone point me to a good place to learn lambdas? I couldn't find anything good on Google. Maybe I'm just blind. |
| 19:56 | amalloy | XPherior: new to functional programming? what other languages are you used to? |
| 19:57 | XPherior | I've been trying out Lisp for a few weeks. I sort of understand functional programming. Used to Ruby, Python, Java, C# |
| 19:57 | XPherior | For the record, Clojure is the coolest thing I've seen in a while. It just gives me shivers looking at how idiomatic it can be. |
| 19:58 | amalloy | XPherior: don't python and ruby have lambdas? are you just looking for clojure's syntax? |
| 19:59 | XPherior | Er, yeah. Looking for how it's done in Clojure. |
| 19:59 | XPherior | Sorry for not being clear. |
| 19:59 | amalloy | ,((fn [x y z] (+ x (* y z))) 1 2 3) |
| 19:59 | clojurebot | 7 |
| 19:59 | DerGuteMoritz | XPherior: it's called `fn' in Clojure |
| 20:00 | XPherior | Woah, evaluator bot. Cool. |
| 20:00 | XPherior | Why's a function definition called defn and a lambda fn, then? |
| 20:00 | gfrlog` | ,(let [f (fn [x y] (- x y))] (+ (f 12 15) 9)) |
| 20:00 | clojurebot | 6 |
| 20:00 | XPherior | Ha! That's brilliant. |
| 20:00 | gfrlog` | XPherior: "defn" sorta means "def fn" |
| 20:01 | DerGuteMoritz | XPherior: (defn foo ...) is short for (def foo (fn ...)) |
| 20:01 | XPherior | Does that imply that all functions return functions? |
| 20:01 | DerGuteMoritz | Clojure is a weird mix of Common Lisp and Scheme in that regard |
| 20:01 | gfrlog` | XPherior: no |
| 20:02 | DerGuteMoritz | XPherior: depends on what you mean by that :-= |
| 20:02 | DerGuteMoritz | :-) |
| 20:02 | XPherior | DerGuteMoritz: Do all functions return a (fn ...) ? |
| 20:02 | gfrlog` | XPherior: do you understand the expression (def foo "bar")? |
| 20:02 | DerGuteMoritz | XPherior: no, `fn' constitutes a function, (fn ...) *is* a function |
| 20:02 | XPherior | I think. It's a function named foo that's given a string "bar" parameter? |
| 20:03 | DerGuteMoritz | note the difference between def and defn! |
| 20:03 | XPherior | Mind boggling! |
| 20:03 | XPherior | I don't think I quite got it. |
| 20:03 | gfrlog` | XPherior: no; it's a lot closer to setting a variable to a value like foo = "bar" |
| 20:03 | amalloy | DerGuteMoritz: i don't think your distinction between "constitutes" and "is" makes any sense |
| 20:03 | XPherior | Oh! Right. foo would be like a global, correct? |
| 20:03 | amalloy | right |
| 20:03 | gfrlog` | XPherior: sort of -- it's still qualified by whatever namespace you're in |
| 20:03 | DerGuteMoritz | amalloy: that's possible, I made that up :-) |
| 20:04 | gfrlog` | so not like a $global in ruby |
| 20:04 | XPherior | Okay, wait. So if fn is lamba, what's the hash do? |
| 20:04 | gfrlog` | XPherior: syntactic sugar |
| 20:04 | gfrlog` | #(+ % 6) <=> (fn [%] (+ % 6)) |
| 20:04 | amalloy | ,'#(inc %) |
| 20:04 | clojurebot | (fn* [p1__72#] (inc p1__72#)) |
| 20:04 | XPherior | ,(reduce (fn + %1 %2) (range 100)) |
| 20:04 | clojurebot | java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol |
| 20:04 | XPherior | Ah D: |
| 20:05 | XPherior | Hm.. That's interesting |
| 20:05 | amalloy | demonstrations in #clojure: if you can still read it, there isn't enough punctuation |
| 20:05 | DerGuteMoritz | amalloy: wait, it makes a little sense. "constitutes" emphasizes the function of fn while "is" emphasizes the result of the expression, or something like that! |
| 20:05 | XPherior | Haha |
| 20:06 | gfrlog` | ,(#(% %) #(% %)) |
| 20:06 | clojurebot | java.lang.StackOverflowError |
| 20:06 | amalloy | DerGuteMoritz: whatever helps you sleep at night. if you said "constructs" instead of "constitutes" i might buy it |
| 20:06 | XPherior | Is it correct to say the body of defn is always a fn, and the fn's result is returned? |
| 20:06 | DerGuteMoritz | ("function of" not to be taken literally there) |
| 20:07 | DerGuteMoritz | amalloy: ok, let's say that instead! |
| 20:07 | DerGuteMoritz | XPherior: defn doesn't return anything, it binds a function to a name |
| 20:07 | gfrlog` | XPherior: (defn foo [x] (bar x)) <==> (def foo (fn [x] (bar x))) <~~> foo = lambda{|x|bar(x)} |
| 20:07 | DerGuteMoritz | hm wait, I haven't actually verified that |
| 20:07 | gfrlog` | DerGuteMoritz: I think it returns the var |
| 20:08 | DerGuteMoritz | I see |
| 20:08 | DerGuteMoritz | well, but that's secondary anyway |
| 20:10 | XPherior | Okay. So what's with all the wacky %s? |
| 20:10 | amalloy | XPherior: gfrlog` is just being a smart-ass |
| 20:10 | XPherior | Ah |
| 20:10 | amalloy | but when you use the #(...) syntax for a lambda, the paramters are implicitly named %1, %2, %3... |
| 20:10 | amalloy | and % is short for %1 |
| 20:10 | XPherior | But even (fn [%] (+ % 6) uses it |
| 20:10 | XPherior | Ahh, cool |
| 20:10 | XPherior | So I can still do (fn[name age] (...)) if I wanted? |
| 20:10 | amalloy | right |
| 20:10 | XPherior | That's nice that I can still name arguments in anonymous function |
| 20:10 | XPherior | Functions* Keeps the code more understandable sometimes |
| 20:10 | amalloy | XPherior: in *that* context, % is just a symbol like any other. you could replace % with a, or with lkdfahfakf, or with -!$+ |
| 20:10 | XPherior | That makes sense. |
| 20:10 | amalloy | only in #(..) does it have special meaning |
| 20:10 | XPherior | Ironically, I really didn't want any documentation of lambas in Clojure. |
| 20:10 | amalloy | haha |
| 20:11 | XPherior | Hmm |
| 20:11 | XPherior | What's the purpose of the body being a fn? |
| 20:11 | XPherior | I mean, why would we want that? |
| 20:11 | amalloy | XPherior: "the body being a fn" is something you keep saying that i don't understand |
| 20:11 | XPherior | (def foo (fn [x] (bar x)) ... (fn [x] (bar x)) <- I'm calling that the body |
| 20:12 | XPherior | What would one call that? |
| 20:12 | amalloy | don't. call it the value |
| 20:12 | amalloy | because def just assigns a value to a var |
| 20:12 | DerGuteMoritz | XPherior: in your example, (bar x) would be the body of the function actually |
| 20:13 | amalloy | defn does the work of turning the body into a function and then calling def |
| 20:13 | XPherior | Okay. So def assigns a variable, fn is a lambda, and defn assigns a fn to a def'ed var? |
| 20:13 | amalloy | full marks |
| 20:13 | hiredman | except for the use of the word variable |
| 20:14 | XPherior | What do Clojure people call it? |
| 20:14 | amalloy | we call it "oh god, please no, never let anything vary" |
| 20:14 | DerGuteMoritz | heh |
| 20:14 | XPherior | Hahaha |
| 20:14 | gfrlog` | unless you call def again |
| 20:14 | hiredman | XPherior: def creates a var |
| 20:14 | technomancy | varies-but-not-at-runtime-able |
| 20:14 | DerGuteMoritz | and var is not short for variable? |
| 20:14 | hiredman | no |
| 20:15 | DerGuteMoritz | aha! |
| 20:15 | XPherior | I really like this language. I hope I go far with it. |
| 20:15 | hiredman | a var is a specific thing with precises semantics, a variable is not |
| 20:15 | amalloy | presumably var was short for variable when it was named, but they are now two distinct concepts |
| 20:16 | DerGuteMoritz | as opposed to atoms and refs and whatnot? |
| 20:16 | amalloy | DerGuteMoritz: those aren't variables either |
| 20:16 | DerGuteMoritz | yeah |
| 20:16 | gfrlog` | well how do I get my hands on a damn variable then?? |
| 20:16 | DerGuteMoritz | I mean err |
| 20:16 | amalloy | clojure doesn't have variables in the classic sense; just locals, which don't vary |
| 20:17 | amalloy | and reference types |
| 20:17 | DerGuteMoritz | you have things like vars, bindings, refs and atoms which are lumped together as "variables" in most other languages |
| 20:17 | XPherior | So it's like Haskell in its emphasis on immutability? |
| 20:17 | gfrlog` | guess it's time to "lein new variables-clj" |
| 20:17 | amalloy | XPherior: a little less so |
| 20:17 | amalloy | but a lot more than scala, say |
| 20:17 | DerGuteMoritz | gfrlog`: I hear there are transients which are mutable |
| 20:17 | amalloy | or, god forbid, ruby |
| 20:17 | XPherior | Think reading Programming Clojure is the quickest way to really learn the details of the language? |
| 20:18 | technomancy | gfrlog`: there's with-local-vars, but you didn't hear that from me |
| 20:18 | amalloy | Joy of Clojure |
| 20:18 | gfrlog` | DerGuteMoritz: ah yes. So my library will just figure out how to make transients less restrictive |
| 20:18 | XPherior | I kind of want to make an IRC bot in Clojure. Seems like an alright first project. |
| 20:18 | amalloy | XPherior: fork sexpbot or clojurebot |
| 20:18 | technomancy | gfrlog`: *whimper* |
| 20:18 | amalloy | $whatis source |
| 20:18 | sexpbot | source is http://github.com/cognitivedissonance/sexpbot |
| 20:18 | gfrlog` | :) |
| 20:18 | amalloy | clojurebot: source? |
| 20:18 | clojurebot | source is http://github.com/hiredman/clojurebot/tree/master |
| 20:18 | XPherior | Thanks! |
| 20:18 | DerGuteMoritz | gfrlog`: why not use Scheme then ;-) |
| 20:18 | gfrlog` | DerGuteMoritz: clojure is the hipster language right now |
| 20:19 | XPherior | I notice Clojure's author didn't write any books on it. Wonder why |
| 20:19 | DerGuteMoritz | gfrlog`: ah okay, I didn't know that was a requirement |
| 20:19 | gfrlog` | XPherior: he didn't have to? |
| 20:19 | XPherior | It's just kind of common, I guess. |
| 20:19 | amalloy | busy writing it, i imagine |
| 20:19 | DerGuteMoritz | by the way, on the clojars site there are no links to the project sites or upstream repositories, or am I mistaken? |
| 20:19 | amalloy | he's done several good lectures, which are online |
| 20:20 | gfrlog` | "The Richness of Clojure" |
| 20:20 | technomancy | DerGuteMoritz: clojars needs help |
| 20:20 | XPherior | I'll check those out. |
| 20:20 | technomancy | there's a list of "somebody needs to implement this please" features |
| 20:20 | XPherior | Are there any good IDES for Windows other than Enclojure? |
| 20:20 | technomancy | nobody's bothered yet |
| 20:20 | gfrlog` | VirtualBox? |
| 20:20 | halfprogrammer | But he has released a bunch of wonderful videos :-) |
| 20:20 | DerGuteMoritz | technomancy: cool, where is that list kept? |
| 20:21 | halfprogrammer | I mean Rich ^ |
| 20:21 | technomancy | DerGuteMoritz: http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1 |
| 20:21 | XPherior | Does Rich ever come in here? |
| 20:21 | gfrlog` | yes |
| 20:22 | gfrlog` | it makes all but the most confident of us shut up for 30 minutes |
| 20:22 | XPherior | Hahah |
| 20:22 | XPherior | I think Clojure is going to take my skills to the next level. |
| 20:22 | technomancy | if anyone is interested in hacking clojars, I've got an automated VM setup for hacking clojars that I'm working on |
| 20:22 | technomancy | will publish it soon |
| 20:23 | technomancy | it's a bit of a bear to config by hand |
| 20:23 | gfrlog` | clojars isn't a 30-line compojure app? |
| 20:24 | cemerick | XPherior: check out Counterclockwise for eclipse |
| 20:24 | technomancy | gfrlog`: there's a bunch of scp-handing stuff necessary to handle deploys |
| 20:24 | technomancy | gfrlog`: ~900 LOC |
| 20:24 | gfrlog` | technomancy: in clojure? |
| 20:24 | technomancy | aye |
| 20:25 | gfrlog` | that's respectable |
| 20:25 | gfrlog` | c.c.shell-out ftw |
| 20:25 | technomancy | gfrlog`: no, scp *server* handling |
| 20:26 | technomancy | can't shell out for that |
| 20:26 | gfrlog` | it'd be fun to have a repl plugin where any command that throws an exception gets retried as a shell command |
| 20:26 | gfrlog` | s/command/expression |
| 20:26 | gfrlog` | sexpbot: botsmack |
| 20:26 | gfrlog` | worthless |
| 20:27 | gfrlog` | technomancy: I see. |
| 20:27 | amalloy | gfrlog`: i remember someone trying to do that as a macro |
| 20:28 | amalloy | basically impossible for about ten reasons |
| 20:28 | gfrlog` | haha |
| 20:28 | gfrlog` | wait really? |
| 20:28 | gfrlog` | it sounds too easy |
| 20:28 | technomancy | gfrlog`: eshell accepts shell commands and lisp in the same prompt |
| 20:28 | DerGuteMoritz | does anyone know of a maven repository that has Jersey 1.8? |
| 20:28 | technomancy | it's awesome |
| 20:28 | gfrlog` | technomancy: I bet |
| 20:28 | technomancy | apart from the lack of lexical scope, I mean. =( |
| 20:29 | gfrlog` | I once tried to write a macro that would allow any [sub-]expression to be in reverse order; THAT was impossible |
| 20:29 | DerGuteMoritz | lexical-let ftw :-) |
| 20:29 | DerGuteMoritz | gfrlog`: you mean a reverse polish notation macro? |
| 20:29 | gfrlog` | DerGuteMoritz: (defmacro with-dyslexia ...) |
| 20:30 | scgilardi | technomancy: any way to compare the awesomeness of eshell with, say, the awesomeness of the piranhamoose? |
| 20:30 | DerGuteMoritz | hm |
| 20:30 | technomancy | scgilardi: that's hard! the piranhamoose is _pure_ awesome, whereas eshell is extremely awesome but not 100%. |
| 20:31 | XPherior | cemerick: I'll check it out now. |
| 20:31 | scgilardi | got it, thanks. |
| 20:31 | amalloy | gfrlog`: interesting. i would have guessed the "optional reversing" would be totally viable. what problems did you have? |
| 20:31 | amalloy | i mean, aside from compile times in the 2^n range |
| 20:31 | gfrlog` | amalloy: well the strategy would be to wrap every [sub-]expression in a try-catch, where the catch tries in reverse |
| 20:31 | DerGuteMoritz | that's what I expected |
| 20:32 | technomancy | clojurebot: piranhamoose is unadulterated awesome: http://blog.howfastareyou.net/wp-content/uploads/2009/08/piranhamoose.jpg |
| 20:32 | clojurebot | Ok. |
| 20:32 | technomancy | attaboy |
| 20:32 | gfrlog` | you could do that, but higher order functions might run in reverse-form as well |
| 20:32 | gfrlog` | maybe something about special forms as well? :/ I dunno, maybe it'd be halfway workable |
| 20:33 | DerGuteMoritz | ooh, like that, I see. that's ambiguous then |
| 20:33 | gfrlog` | I guess you could do better than try-catch some of the time by resolving the symbol and seeing what it means |
| 20:35 | gfrlog` | ...if it's even a symbol |
| 20:37 | DerGuteMoritz | just make it a one character macro that reverses the current expression |
| 20:37 | gfrlog` | DerGuteMoritz: well the idea was that you could accidentally input things in reverse, so you wouldn't be indicating it explicitely |
| 20:38 | DerGuteMoritz | right but that's not possible |
| 20:38 | DerGuteMoritz | because of ambiguities |
| 20:38 | gfrlog` | so yes, redefining the goal does make it easier :) |
| 20:39 | DerGuteMoritz | or ... unintended reverse evaluation |
| 20:39 | amalloy | DerGuteMoritz: a risk you have to take when you're dyslexic. not a failing of the library |
| 20:39 | gfrlog` | (defmacro <> [& forms] (map reverse forms)) |
| 20:39 | amalloy | things often work, but then sometimes for reasons you don't understand you have to manually reverse the order to make it work |
| 20:40 | amalloy | sounds like dyslexia to me |
| 20:40 | amalloy | gfrlog`: that is like 17 steps away from working |
| 20:40 | gfrlog` | ((forms reverse map) [forms &] <> defmacro) |
| 20:40 | gfrlog` | maybe it'll work that way |
| 20:41 | amalloy | hah |
| 20:41 | gfrlog` | it can't be seventeen, it's more like 3 |
| 20:41 | amalloy | yes, first step when defining a new macro: see if it's already included in the language |
| 20:41 | gfrlog` | I think it's two, but I said three just to be safe |
| 20:41 | amalloy | i'm choosing to count each irc message you send as a step in adjusting your thinking the right way |
| 20:42 | gfrlog` | I don't accept the rules of your game |
| 20:42 | gfrlog` | okay let's try my two fixes |
| 20:43 | gfrlog` | (defmacro <> [& forms] (list `do (map #(if (list? %) (reverse %) %) forms))) |
| 20:43 | gfrlog` | aw crap |
| 20:43 | gfrlog` | s/list/list* |
| 20:43 | gfrlog` | or s/list/cons |
| 20:43 | amalloy | s/list*/cons |
| 20:44 | gfrlog` | list* in case I decide to put anything else in there :) |
| 20:44 | amalloy | gfrlog`: you could do a good job of making it totally unreadable with postwalk-replace |
| 20:44 | gfrlog` | amalloy: but then I'd have to learn how to do that |
| 20:45 | amalloy | just wrap the top-level form with (<> ...) and then you'll have a terrible time making anything work |
| 20:45 | hiredman | ,(pl (↕map (replicate 3 (↕apply vector $ (↕map range $ 10 inc · inc · inc) call · ⌽* $ 10 · call · (⌽+ -2) map)) shuffle))) |
| 20:45 | clojurebot | ([80 50 100 60 10 40 70 30 20 90] [80 90 30 60 20 100 10 50 70 40] [70 50 20 100 30 90 40 80 60 10]) |
| 20:45 | gfrlog` | &(pl (↕map (replicate 3 (↕apply vector $ (↕map range $ 10 inc · inc |
| 20:45 | sexpbot | java.lang.Exception: Unable to resolve symbol: pl in this context |
| 20:46 | gfrlog` | it's clojurebot voodoo |
| 20:46 | amalloy | gfrlog`: (use 'clojure.walk) (defmacro <> [& args] (postwalk-replace reverse args)) |
| 20:46 | XPherior | Thanks for your wonderful help everyone! You've been excellent. I shall be back! |
| 20:46 | XPherior | Good bye. |
| 20:46 | gfrlog` | XPherior: bye |
| 20:46 | gfrlog` | amalloy: ahh -- that's different from mine too isn't it? |
| 20:47 | amalloy | quite |
| 20:47 | gfrlog` | reversing at all levels instead of top |
| 20:47 | amalloy | yeah |
| 20:47 | gfrlog` | I will submit a talk to clojure conj offering to compare and contrast the two approaches |
| 20:48 | hiredman | ,(pl inc $ inc $ 1) |
| 20:48 | clojurebot | 3 |
| 20:48 | gfrlog` | hiredman: what's going on? |
| 20:48 | hiredman | ,(macroexpand '(pl inc $ inc $ 1)) |
| 20:48 | clojurebot | (do (inc (inc 1))) |
| 20:49 | hiredman | I like to trot pl when people talk about crazy macros |
| 20:49 | hiredman | pl out |
| 20:49 | gfrlog` | ah ha |
| 20:49 | amalloy | haha |
| 20:49 | gfrlog` | very good |
| 20:49 | amalloy | oh, i read that as "pl out" |
| 20:49 | amalloy | like "it's done its job and it's leaving" |
| 20:52 | gfrlog` | alright fine I'll go mudge around in hiredman's github account looking for pl |
| 20:53 | hiredman | ~functional |
| 20:54 | clojurebot | I don't understand. |
| 20:54 | hiredman | ~pl |
| 20:54 | clojurebot | examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples |
| 20:54 | hiredman | ~transform |
| 20:54 | clojurebot | transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj |
| 20:56 | gfrlog` | that kevin.clj is pretty weird |
| 20:56 | gfrlog` | maybe using emacs results in files like this... |
| 21:03 | tomoj | gfrlog`: like what? |
| 21:03 | gfrlog` | tomoj: lots of functions mixed with expressions trying them out |
| 21:04 | gfrlog` | I think emacs lets you highlight stuff and eval it, so it makes sense of that |
| 21:04 | gfrlog` | I only use stone-age tools, so I don't know what it's like to have that kind of power. |
| 21:04 | tomoj | not exactly good to stick them in toplevel |
| 21:04 | gfrlog` | tomoj: I don't think it's serious code at all |
| 21:04 | tomoj | because e.g. they might run on uberjar and stuff |
| 21:04 | tomoj | sure |
| 21:05 | tomoj | but if one expression takes a long time to run and you C-c C-k (loads the entire file) |
| 21:05 | tomoj | ... |
| 21:05 | tomoj | better to stick those in (comment ) blocks |
| 21:05 | tomoj | where they still work just as well for emacs |
| 21:05 | tomoj | s/blocks/forms/ |
| 22:42 | symbole | Is there a lazy http library for Clojure? I looked at clj-http, but it seems like it downloads entire files before returning. |
| 22:51 | symbole | clojure.contrib.http.agent seems to be what I want. |
| 23:06 | mrnex2010 | are there functions to modify a fn, such as to add an arity overload to a fn? |
| 23:08 | mrnex2010 | (im building an util to add arity overload to all the functions that use a fn that has been overloaded, all the way up to the functions that use it |
| 23:08 | mrnex2010 | ) |
| 23:14 | symbole | mrnex2010: I don't quite follow. |
| 23:15 | symbole | Clojure has arity overloading, which is specified during function definition. |
| 23:21 | mrnex2010 | symbole: sorry for the vaguity, what i meant was a function that returns a function with another arity |
| 23:22 | mrnex2010 | overload |
| 23:23 | mrnex2010 | i can do it inserting it into the function as a string, but i got curious if we had higher order fns that did that kind of stuff |
| 23:23 | symbole | You can use macros to do that for you. |
| 23:24 | symbole | Make a macro that creates a function with however many params you want. |
| 23:24 | amalloy | this sounds like the sort of thing that doesn't need a macro, but it's hard to understand what the goal is. are you just reinventing partial? |
| 23:25 | amalloy | eg, maybe you could gist an example usage of your function and the desired result |
| 23:25 | mrnex2010 | no, supose you have a fn with 2 params, another fn uses it, and yet another one uses the intermediate fn |
| 23:26 | mrnex2010 | then you make an overload on the first |
| 23:26 | mrnex2010 | but your fingers are too delicate to rewrite the other fns with overloads that reflect the overload on the first fn |
| 23:27 | amalloy | mrnex2010: you're looking for like a refactoring tool that will add a default argument? |
| 23:27 | amalloy | or pass along an argument, i guess |
| 23:28 | mrnex2010 | amalloy: yes a refactoring tool but not necesarilly a default arg but the arg that is added on a fn yes to pass it along |
| 23:28 | mrnex2010 | sorry for the boraty writing on the prev line lol |
| 23:29 | amalloy | i see. on the one hand, i can see why that would be convenient. on the other, if you have N functions calling each other, and a change to function f requires a change in the api to all N functions, you're probably doing something wrong |
| 23:30 | mrnex2010 | yeah i can imagine that stuff |
| 23:30 | mrnex2010 | i just meant it for abstractions like the ones on SICP first chaps |
| 23:31 | mrnex2010 | and hacking libs |
| 23:36 | amalloy | i don't think there's any nice way to do it. you could write a macro which wraps a defn, adds an extra arg to it, and is told what function to internally pass along that function to |
| 23:36 | amalloy | but i think it will be less readable and more work |
| 23:37 | amalloy | * pass along that arg to |