2009-01-19
| 00:02 | blbrown | has the xml/parse library been moved. like with the code found at the bottom is giving me an error. http://clojure.org/java_interop |
| 00:03 | durka42 | clojure.xml/parse |
| 00:03 | durka42 | or import clojure.xml first |
| 00:04 | blbrown | someone update the docs!!! just kidding |
| 00:04 | danlarkin | durka42: still managing to find time for clojure at school eh? |
| 00:05 | durka42 | well, classes start tomorrow |
| 00:10 | eyeris | I am trying to use clojureql with compojure. When I use a compojure route with: (my-func (route :id)), then in (defn my-func [id] (sql/run [*conn* rows] (sql/query [[*]] MyTable (= ID id)) (first rows))) |
| 00:10 | eyeris | The SQL passed to the mysql server contains WHERE ID = id, instead of WHERE ID = <the value stored in id> |
| 00:15 | eyeris | I'm pretty sure the problem is with the call to (= ID id) rather than what is passed to (my-func) |
| 00:16 | eyeris | However all of the clojueql demos use literals in their use of query conditions |
| 00:20 | danlarkin | eyeris: your all up to date on clojureql? |
| 00:21 | eyeris | A few days old, IIRC. I will update now. |
| 00:24 | eyeris | Yep, just updated. The problem is still there |
| 00:27 | eyeris | This is a paste of the code: http://pastebin.ca/1312292 |
| 00:27 | eyeris | I'm probably just doing something stupid, since I'm a lisp newb |
| 00:28 | eyeris | The problem is in (get-case-record) |
| 00:29 | durka42 | do you need to use ~id like ~sort-col in get-cases? |
| 00:30 | eyeris | Yep |
| 00:30 | eyeris | That worked |
| 00:30 | eyeris | Thanks for spotting it |
| 00:30 | eyeris | I knew it had to be a silly mistake |
| 00:31 | eyeris | I think I am just over tired :/ |
| 00:51 | blbrown | anyone think the docs should have examples ...<runs for cover> |
| 00:52 | blbrown | in terms of an example for each function or form |
| 00:54 | Cark | you're not the first one mentioning that |
| 00:54 | Cark | i beleive someone started a list of examples on the wiki |
| 02:13 | eyeris | How can I tell whether a given class contains a given static method? |
| 02:16 | blbrown | is there no length function against sequences |
| 02:17 | eyeris | blbrown count? |
| 02:18 | blbrown | got ya |
| 02:43 | blbrown | can I create a map datastructure but not have all the values known at once. E.g. with the java hash map, I can create the object and then populate the data later? |
| 02:44 | Cark | {:name nil :address nil} or {:name :empty :address :empty} |
| 02:46 | Cark | still working on that octane viewer ? |
| 02:47 | blbrown | yea |
| 02:47 | Cark | what's the secondary buffer view for ? |
| 02:48 | blbrown | Cark, ideally this is a kind of a log viewer. I want to be able to open a log file and then on exception, open up the Java code in the secondary buffer view |
| 02:48 | blbrown | that and it is a misc window |
| 02:48 | Cark | ah ok |
| 02:49 | blbrown | I have simple Java parsing code too with syntax highlighting |
| 02:50 | blbrown | (let [a {:name nil :address nil} or {:name :empty :address :empty}] ...) can I update 'a' with another value? |
| 02:50 | blbrown | (set! (a :name) "dog") ...maybe? |
| 02:50 | blbrown | Cark ... |
| 02:50 | Cark | not quite, 'a' is imutable ! |
| 02:50 | blbrown | exactly, that is I might go with the java.util.HashMap for now |
| 02:51 | Cark | ,(let [a {:name nil :address nil} b (assoc a :name "cark")] b) |
| 02:51 | clojurebot | {:name "cark", :address nil} |
| 02:51 | Cark | well you're not embracing clojure then |
| 02:52 | Cark | the idea is to have all your state in a single ref |
| 02:52 | Cark | or atom i guess |
| 02:52 | Cark | and use functional programing |
| 03:02 | Cark | ,(let [a (ref {:name nil})] (dosync (alter a assoc :name "cark"))) |
| 03:02 | clojurebot | {:name "cark"} |
| 04:01 | Lau_of_DK | Top of the morning gents |
| 05:07 | Lau_of_DK | Anyone here who can lend a hand in producing a somewhat complicated RegEx ? :) |
| 05:12 | hoeck | Lau_of_DK: don't ask to ask, just paste :) |
| 05:15 | Lau_of_DK | <span>blablabla<nobr>RECORD THIS STRING</nobr>blabla<nobr>RECORD THIS STRING</nobr>...continue until </span> |
| 05:15 | Lau_of_DK | How do I regex-capture this? |
| 05:17 | Lau_of_DK | @ hoeck |
| 05:18 | hoeck | mhh, maybe "<nobr>.*?<nobr>" |
| 05:19 | hoeck | or do you mean the whole line starting with <span>? |
| 05:20 | Lau_of_DK | No, but the stuff I capture needs to be between two spans, <span> and </span> |
| 05:20 | Lau_of_DK | And your regex works OK, but it captures too much |
| 05:22 | Lau_of_DK | No wait, I think I can actually manage from here |
| 05:22 | Lau_of_DK | The filter needs to be a little more advanced |
| 05:22 | Lau_of_DK | Thanks alot hoeck |
| 06:11 | Lau_of_DK | (def reGetSpan #"<span>(.|\n)+?</span>") <-- Returns nil |
| 06:12 | Lau_of_DK | (def reGetSpan #"<(.|\n)+?>") <-- Returns all text inside html-tags |
| 06:12 | Lau_of_DK | Why doesnt the first, return everything in spans ? |
| 06:17 | hoeck | Lau_of_DK: try #"<span>(.*)</span>" |
| 06:18 | Lau_of_DK | nil |
| 06:19 | Lau_of_DK | @ hoeck |
| 06:19 | hoeck | btw, which re-* function do you use? |
| 06:19 | Lau_of_DK | re-seq |
| 06:20 | Lau_of_DK | It does look like [<span>](.*)[^</span>] seems to work |
| 06:24 | hoeck | and i thought i knew regular expressions :( |
| 06:26 | Lau_of_DK | Its tough...and cryptic |
| 06:31 | cgrand | Lau_of_DK: your last one doesn't work: try to put an "s" at the start of your input |
| 06:32 | cgrand | try #"\<span\>(.*)\</span\>" |
| 06:33 | Lau_of_DK | No dice cgrand |
| 06:34 | cgrand | sample input + expected output? |
| 06:34 | Lau_of_DK | (def reGetSpan #"[<span>](.*)[^</span>]") <-- This seems to be the closest thing |
| 06:35 | Lau_of_DK | <span style="font-size:16px;font-family:Times"> |
| 06:35 | Lau_of_DK | <div style="position:absolute;top:2062;left:48"><nobr><b>ZZ0169 </b>Vurdering af </nobr></div> |
| 06:35 | Lau_of_DK | <div style="position:absolute;top:2082;left:132"><nobr>behov for </nobr></div> |
| 06:35 | Lau_of_DK | <div style="position:absolute;top:2103;left:132"><nobr>foranstaltninger </nobr></div> |
| 06:35 | Lau_of_DK | </span> |
| 06:35 | Lau_of_DK | |
| 06:35 | Lau_of_DK | This is what Im parsing. For that example, I need to get "ZZ0169" and "Vurdering af behov for foranstaltninger" |
| 06:39 | cgrand1 | and as a first step you try to get the content of teh surrounding span? |
| 06:42 | Lau_of_DK | Yes, if I could isolate the spans, then parse them individually |
| 06:42 | Lau_of_DK | It might not be the best way, but it was my first idea |
| 06:42 | Lau_of_DK | 1) Get spans, 2) get <b>CODE</b>, 3) get all content of <nobr></nobr> |
| 06:42 | Lau_of_DK | That would work |
| 06:55 | cgrand1 | I encounter troubles with the input string being multiline. On one line, the following regex seems to work: #"(?m)<span[^>]*>((?:(?!</span>).)*)</span>" |
| 06:55 | Chousuke | eh. :P |
| 06:59 | Lau_of_DK | eh... |
| 06:59 | cgrand1 | well the (?m) is not required since it does not work (it is intended tow switch the regx to multiline mode) |
| 07:00 | cgrand1 | are you sure you can't use a proper html or xhtml parser? |
| 07:00 | Lau_of_DK | No I think they would work - But when I thought out the above strategy, it seemed very simple |
| 07:02 | Lau_of_DK | cgrand1: Do you know of a Java tool that I could use to wrap this up in a hurry, Ive wasted too much time on it |
| 07:03 | cgrand1 | use tagsoup it's an html sax parser |
| 07:07 | cgrand1 | if you can store the whole document in memory, use tagsoupe + clojure.xml + chouser's zip-filter |
| 07:10 | Lau_of_DK | I can... I'll look into it, thanks alot |
| 08:13 | AWizzArd | How can I dynamically instatiate objects of a given class? (defn foo [class] (new class)) ==> java.lang.IllegalArgumentException: Unable to resolve classname: class |
| 08:13 | AWizzArd | This could be nice for a Swing app, where I want to have one Clojure function (show-frame FrameClass). |
| 08:16 | cgrand1 | (.newInstance class) |
| 08:37 | AWizzArd | ws� |
| 08:37 | AWizzArd | oops... |
| 08:37 | AWizzArd | thx cgrand1 |
| 08:43 | Chouser | cgrand1: enlive is an interesting idea. |
| 08:46 | Chouser | the replacement part of each deftemplate pair can be either a string or a seq of whatever 'at' returns? |
| 08:50 | cgrand1 | chouser: thanks |
| 08:52 | cgrand1 | each replacement site (a node matched by a selector) is replaced by a form which, at runtime, yields a string or a seq of strings |
| 08:54 | cgrand1 | 'at denotes a sub-template (the definition of deftemplate uses 'at) |
| 08:56 | Chouser | ok |
| 09:20 | gnuvince | Did you guys read the blog post by Brian Carper? I thought it was very good |
| 09:22 | rhickey | cgrand1: did you see this? http://paste.lisp.org/display/73823 |
| 09:23 | rhickey | my take on the LFEs, still no map, but early termination and (potentially) chaining. I think the model is still difficult for extenders (if not consumers) though |
| 09:23 | rhickey | no multi-source map |
| 09:23 | Lau_of_DK | rhickey: I didnt understand, what are the great advantages of LFE ? |
| 09:24 | rhickey | Lau_of_DK: it is one way to manage resource scope (scope and when-scope discussed yesterday are another), and it is purely functional |
| 09:25 | Lau_of_DK | Oh ok - And what alternatives are there? |
| 09:25 | cgrand1 | rhickey: ok, looking at it |
| 09:26 | rhickey | Lau_of_DK: scopes handle resources: http://paste.lisp.org/display/73838 |
| 09:26 | rhickey | so, scopes + seqs are enough |
| 09:27 | Lau_of_DK | Ok |
| 09:27 | rhickey | But I have been working on 'safe' streams |
| 09:27 | Chousuke | I wish I'd understand how that LFE stuff actually works so I could see if I could use monads to implement it |
| 09:28 | rhickey | Chousuke: if you want a description in terms of monads: http://okmij.org/ftp/Haskell/Iteratee/DEFUN08-talk-notes.pdf |
| 09:29 | Chousuke | I'm really bad at reading haskell though :p |
| 09:29 | rhickey | monads do nothing to simplify the inherent model, which involves handling: source termination, consumer termination, leftover source items, horizontal and vertical combination and errors |
| 09:31 | rhickey | cgrand1: I don't have your vote on fully-lazy seqs vs nil punning either |
| 09:32 | Lau_of_DK | cgrand1: You really liked the idea of fully-lazy seqs right? :) |
| 09:33 | cgrand1 | rhickey: I wrote a similar implementation (fn returning either a fn or [value] or [value remaining]) after reading thoses slides (some days after my initial experiment with LFE) |
| 09:35 | rhickey | cgrand1: I'd hate to have to explain how to write a correct enumerator or iteratee though |
| 09:36 | cgrand1 | I agree: right now it's an interesting formal exercise |
| 09:40 | cgrand1 | About nil punning, I like it but I also understand that fully lazy seq would get us rid of a whole family of subtle and nasty bugs. I haven't make my mind yet. |
| 09:55 | cgrand1 | Las time I thought about it I ended up thinking that I would prefer to have map and filter always return fully-lazy-seqs but to have thess fully lazy seqs treated like another collection type: calling seq on them would return an usual seq. |
| 10:04 | Chouser | gnuvince: I thought that blog post was good too. His commenters were brutal, though. |
| 10:05 | gnuvince | Chouser: that's to be expected from people who hang on c.l.l |
| 10:06 | gnuvince | Clojure seems to get a lot of flak there for being a more practical Lisp. |
| 10:07 | gnuvince | People complain about the JVM, lack of TCO (and ignore the mentions of recur and trampolines), that the Java libs are not Lispy enough, and a bunch of other stuff. |
| 10:07 | gnuvince | But the reality is, I've had pretty much the same experience as Brian's had: getting something working in Clojure is just easier and faster. |
| 10:08 | Chouser | yep, me too. |
| 10:11 | rhickey | the problem is inherently X vs Y - while it should always be ok to say - I had a better experience with X, saying X is better than Y will always rankle fans of Y |
| 10:11 | rhickey | how they behave when rankled is another matter :) |
| 10:12 | Lau_of_DK | Where can I observe this rankling? :) |
| 10:13 | rhickey | http://briancarper.net/2009/01/19/clojure-1-common-lisp-0/ |
| 10:13 | Lau_of_DK | Thanks |
| 10:16 | Chouser | rhickey: too true, though even "fans of Y" suggests an unhelpful emotional connection, especially when Y is programming language. |
| 10:17 | Chouser | I wouldn't deny such a connection with Clojure personally, but I'll admit it can be unhelpful. :-) |
| 10:17 | gnuvince | Although there was a bit of "mini trash talk" against CL, I think that most of his argument were based on reasonable points. |
| 10:18 | gnuvince | Using dates and times within Clojure *is* easier than in CL |
| 10:18 | gnuvince | It doesn't mean that it couldn't be easy in CL |
| 10:18 | gnuvince | Just that at the moment, Clojure has an advantage there. |
| 10:20 | rhickey | I think Brian was fair, and did qualify "better language for the job", but most people stop at "better" |
| 10:30 | gnuvince | On reddit, the longest comment thread is about Emacs and SLIME |
| 10:30 | gnuvince | That's sort of missing the point of the article |
| 10:30 | Chouser | and it's pain you can import directly to Clojure! |
| 10:31 | arbscht_ | gnuvince: standard reddit fare, then :) |
| 10:37 | gnuvince | arbscht_: yeah |
| 10:37 | gnuvince | Reddit: |
| 10:37 | gnuvince | Haskell story: Monads are hard |
| 10:37 | gnuvince | Java story: JVM is bloated, Yahoo toolbar! |
| 10:37 | gnuvince | etc. |
| 10:50 | schluete | why does (defn addone-plain [x] (lazy-cons x (addone (+ 1 x)))) |
| 10:50 | schluete | work as expected while (defn addone-recur [x] (lazy-cons x (addone (+ 1 x)))) |
| 10:50 | schluete | doesn't do anything at all? |
| 10:51 | schluete | I thought I understood the way recur works... |
| 10:52 | edw | The only differene I see between those two functions is their names. |
| 10:53 | schluete | hmm... sorry, cut'copy'paste... the second example should have been |
| 10:53 | schluete | (defn addone-recur [x] (lazy-cons x (recur (+ 1 x)))) |
| 10:54 | schluete | I tried to use recur instead of the function name for the recursion, but when calling (take 10 (addone-recur 1)) clojure just stalled. |
| 10:55 | danlarkin | schluete: you don't want recur there, you want addone-recur |
| 10:56 | schluete | but addone-recur would call the method itself, eventually exhausting the stack because of the missing tail call optimisation in clojure |
| 10:56 | schluete | I always thought that this was the rational for the recur form... |
| 10:58 | danlarkin | except that you're using lazy-cons |
| 10:58 | edw | This is an interesting question. |
| 10:58 | danlarkin | change lazy-cons to cons and yep, you blow the stack |
| 10:59 | edw | `lazy-cons' leads to...something happening. |
| 10:59 | danlarkin | but look at the doc for lazy-cons |
| 10:59 | danlarkin | (doc lazy-cons) |
| 10:59 | clojurebot | Expands to code which produces a seq object whose first is first-expr and whose rest is rest-expr, neither of which is evaluated until first/rest is called. Each expr will be evaluated at most once per step in the sequence, e.g. calling first/rest repeatedly on the same node of the seq evaluates first/rest-expr once - the values they yield are cached.; arglists ([first-expr & rest-expr]) |
| 11:00 | schluete | danlarkin: but lazy-cons IMHO only delays the execution but doesn't change the way the recursion works? |
| 11:01 | edw | So the `recur' is calling some dynamic var, not a captured reference to the `addone-recur' function? |
| 11:01 | schluete | either way, what's the explanation for clojure just stalling with 100% cpu on the "recur" version? a bug? |
| 11:02 | edw | Some `*most-recently-encountered-recursion-point*' sort of dynamic variable? |
| 11:02 | edw | That makes sense...but is nasty. |
| 11:02 | danlarkin | to be honest I don't really know |
| 11:02 | edw | But that makes total sense. |
| 11:04 | schluete | edw: IMHO recur it meant to replace the recursion you would normally have by a jump, preventing the stack from blowing on deep recursion levels. This is because the JVM doesn't support proper TCO |
| 11:04 | Chouser | when the compiler sees a 'loop' or 'fn', it pushes its location onto a stack (I think), so that when it sees a 'recur' it essentially puts in a goto to the item at the top of that stack. |
| 11:04 | schluete | but obviously I'm using recur the wrong way... and I don't understand why |
| 11:06 | Chouser | so using a self-call in the 'rest' part of a lazy-cons does not endanger the stack. |
| 11:08 | schluete | Chouser: could you elaborate this a little more? what does the usage of lazy-cons vs. cons change in terms of stack behaviour? |
| 11:08 | Chouser | lazy-cons returns an object with its 'first' and 'rest' args each in a closure. |
| 11:09 | Chouser | the key to our discussion being "returns" |
| 11:09 | Chouser | so the stack shrinks by one frame. |
| 11:09 | Chouser | when you call 'rest' on that object, only then does it execute that closure |
| 11:10 | edw | If something like this is happening, you never know what context that `rest' is going to be evaluated, so a delayed evaluation for should set the recurison point to something that throws an exception. |
| 11:10 | Chouser | in the self-call case, this calls your functions again (consuming a stack frame) which then returns a new lazy-cons object (giving back that stack frame). Net stack usage is none. |
| 11:10 | edw | "...so a delayed evaluation FORM..." |
| 11:11 | schluete | Chouser: thanks, this makes sense. |
| 11:12 | Chouser | in the case of calling 'recur' from the "rest" clause, as soon as you call 'rest' on the seq, it'll go into an unterminated loop. 'first' works fine though. |
| 11:13 | Chouser | edw: you're right about not know the context where 'rest' is called, but what do you mean by a "delayed evaluation form"? |
| 11:13 | edw | So let's get this out there: the recursion point for a lazily evaluated expression should be something like #(throw "no sensical recursion point"). |
| 11:14 | Chouser | 'recur' is used in places where you're *not* creating a lazy seq, but still want to avoid consuming the stack. For an example like this, along with 'recur' you'd want 'cons' instead of 'lazy-cons', and you'd want to add a termination case. |
| 11:14 | Chouser | the recursion point for 'recur' is lexical, not dynamic. |
| 11:15 | edw | Right, but can you see my point? Clojure should not explode -- or implode or whatever -- when someone does that. |
| 11:16 | edw | Actually, isn't it dynamic? Because it's about what's on the stack right now, in the dynamic context of the running program. |
| 11:17 | Chouser | I'm not sure clojure can know what you meant for it to do. I don't see why 'recur' in a lazy-cons 'rest' would always be wrong. |
| 11:17 | edw | How could it ever be correct? |
| 11:18 | Chouser | 'recur' is always in danger of becoming an infinite loop, just while "while" in any imperative language. |
| 11:18 | Chouser | anytime you see a 'recur' you should look for how you're going to escape the loop. |
| 11:18 | edw | What function is being invoked in that `addone-recur' when I type (first (rest (addone-recur 1)))? |
| 11:19 | edw | When I type that at the REPL? |
| 11:19 | edw | Chouser, yes, I am familiar with the concept. I've written tens of thousands of lines of Scheme code. |
| 11:24 | rhickey | lazy-cons wraps the rest-expr in a fn, so if you use recur there that wrapping fn is the target of the recur, if you haven't used loop in your rest-expr |
| 11:24 | Chouser | ok, I see your point. The lexical recur point for both a lazy-cons' first and rest clause is a fn created by lazy-cons. |
| 11:24 | rhickey | Chouser: right |
| 11:25 | Chouser | in which case it might be useful to have some sort of flag to tell 'recur' that this fn may not be used as a recur point. |
| 11:25 | edw | I was trying to write a `safe-lazy-cons' macro but getting that to work would take a bit thinking. |
| 11:26 | edw | (set! *recur-point* #(throw "no cookie for you")) |
| 11:26 | Chouser | but it's not dynamic. I still don't see how a var is going to help. |
| 11:27 | edw | How is it not dynamic? The recur point is the top of stack, no? |
| 11:27 | Chouser | at compile time |
| 11:28 | edw | `Let' is just an evaled lambda: (let [x 1] (+ x 1)) => ((lambda (x) (+ x 1)) 1). |
| 11:28 | rhickey | edw:not true |
| 11:28 | Chouser | at runtime, the call stack has no knowledge of recur points. That's kinda the idea, to avoid using the Java stack so that we don't use it up. |
| 11:29 | edw | Am I thinking too schemely? |
| 11:29 | rhickey | edw: in Clojure let is not lambda |
| 11:29 | rhickey | let is sequential |
| 11:29 | rhickey | binding-wise |
| 11:30 | edw | Err, how about: `Loop' is just an evaled lambda? |
| 11:30 | rhickey | also not true in Clojure |
| 11:30 | edw | Are you referring to `let' being "really" `let*'? |
| 11:31 | rhickey | edw: it is more like let*, but also is not defined in terms of lambda, ditto loop |
| 11:32 | rhickey | In Scheme, lamba has properties that allow its use for looping with the same guarantees as loop, in Clojure it doesn't, so loop is not defined in terms of it |
| 11:32 | rhickey | lambda |
| 11:32 | rhickey | fn |
| 11:33 | rhickey | so Clojure has more primitive ops let/loop and fn |
| 11:34 | Chouser | I hadn't thought about how the fact that Clojure (and code written in it) doesn't assume the VM has TCO will help get it into more VMs -- javascript, android, CLR, etc. |
| 11:35 | Chouser | even if/when JVM gets TCO, these others might not. |
| 11:35 | edw | rhickey: Can you think of a use for `recur' inside a delayed expression without an enclosing, recursion point-defining form? Alternatively, do you think it makes sense to throw an exception if you try to `recur' without an explicit enclosing form in a delayed expression? |
| 11:36 | edw | And if not, is there a way to get out of an infinite loop in SLIME without blowing up the inferior Lisp process? ;) |
| 11:36 | rhickey | edw: there is no use without an enclosing fn/loop |
| 11:38 | rhickey | not sure what it would take to throw an exception in that case, but adding runtime overhead to loop is a non-option |
| 11:38 | edw | I hear you. I was thinking of overhead inside lazy-cons and friends. |
| 11:39 | rhickey | edw: an unfortunately, you'll find the JVM far less tolerant of infinite loops than your typical CL/Scheme :( |
| 11:39 | rhickey | and thus Clojure too |
| 11:39 | edw | When in doubt, trace? |
| 11:40 | Chouser | (defmacro no-recur [& body] `(loop [x# 'x#] (assert (= x# 'x#)) ~@body)) |
| 11:40 | rhickey | edw: in a debugger, you'd have break options |
| 11:40 | Chouser | but that's an extra compare per iteration |
| 11:41 | edw | Using a Java IDE is something I promised my mother I'd never do again. |
| 11:41 | rhickey | Chouser: yeah, any runtime overhead here is bad |
| 11:41 | rhickey | edw: you can use Clojure with JSwat and leave the IDE out of it |
| 11:41 | Chouser | right, you don't use 'recur' generally, unless you're in a tight inner loop. Otherwise you'd probably be using seqs. |
| 11:42 | rhickey | this problem might best be solved with enhanced documentation |
| 11:42 | rhickey | I don't consider it a common problem |
| 11:48 | Chouser | the fn produced by lazy-cons could take 8 or 9 args instead of 0 or 1. That would catch most attempts at using 'recur'. |
| 11:50 | hiredman | Chouser: heh |
| 11:55 | rhickey | Chouser: actually just switching first to one arg, rest to zero would catch a bunch, as recur most likely in rest and with value |
| 11:55 | kotarak | Would it be possible to include a trivial patch, to make :source in Var meta data a classpath relative/full pathname? |
| 11:55 | lisppaste8 | kotarak pasted "trivial patch to help IDEs" at http://paste.lisp.org/display/73866 |
| 11:55 | kotarak | Just the basename of the file is ambiguous.... |
| 11:56 | rhickey | kotarak: you have CA? |
| 11:56 | kotarak | Yes. Meikel Brandmeyer. Shall I open a ticket on gc? |
| 11:57 | rhickey | kotarak: sure, thanks |
| 11:57 | kotarak | ok. |
| 12:04 | danlarkin | rhickey: with regard to the CA, do I /need/ to provide my mailing address, phone number? My mailing address will be changing soon so it won't be applicable for much longer |
| 12:05 | scottj | Should {:foo 1\n:bar 2} be indented with the : in :foo and :bar lined up, or with :bar one character to the right of :foo? I feel like clojure mode in emacs often indents incorrectly. |
| 12:06 | rhickey | danlarkin: you should supply whatever is current |
| 12:07 | rhickey | scottj: :foo and :bar should line up |
| 12:07 | danlarkin | rhickey: will you send me a present? :) |
| 12:07 | rhickey | danlarkin: unlikely :) |
| 12:07 | scottj | rhickey: that's how I felt, but I don't think that's the default behavior of the clojure emacs mode |
| 12:07 | rhickey | scottj: seems to be how it works for me |
| 12:08 | hiredman | clojure.vim often does some wonky indents too, like pulling :bar out so it lines up with { |
| 12:08 | hiredman | (btw) |
| 12:08 | danlarkin | FWIW I updated clojure-mode yesterday and my indenting still works as you'd expect |
| 12:09 | kotarak | hiredman: huh? Could you give me an example? I try very hard to indent correctly.... |
| 12:10 | scottj | ok, I'll look at it. thanks! |
| 12:11 | hiredman | kotarak: you never know, could be something else I have installed fighting with clojure.vim |
| 12:12 | hiredman | I just opened up test.clj and type "{:a 1\n:b 2}" and the :b lined up with the curly brace |
| 12:12 | kotarak | hiredman: the indent works for more in 95% of the cases. There are some edges which are round yet, but "often" should definitively be not the word you have to use... |
| 12:12 | kotarak | Let me check. |
| 12:12 | scottj | rhickey: do you have any indent settings beyond the clojure-mode defaults? |
| 12:13 | kotarak | hiredman: nope. Works for me. :a and :b are lined up. |
| 12:13 | rhickey | scottj: nope, just clojure-mode |
| 12:15 | hiredman | kotarak: *shrug* |
| 12:15 | hiredman | once I line :a and :b up, :c lines up correctly |
| 12:16 | kotarak | Hmm... Ominous.... |
| 12:33 | drewr | http://is.gd/gt4s/clojure/search/ |
| 12:57 | hiredman | clojurebot: emacs is also <reply>"Learning Emacs and SLIME was just about the most painful computer experience I've ever been through." |
| 12:57 | clojurebot | Ok. |
| 13:00 | danlarkin | clojurebot: how many things do you know? |
| 13:00 | clojurebot | Pardon? |
| 13:00 | danlarkin | jerk! |
| 13:01 | technomancy | that's funny; you'd think a bot written in Lisp would have an easier time learning how to use a lisp machine. |
| 13:04 | hiredman | 131 |
| 13:05 | danlarkin | Ooo lots |
| 13:09 | Lau_of_DK | Good evening all |
| 13:09 | technomancy | hi Lau |
| 13:10 | danlarkin | Afternoon |
| 13:13 | Lau_of_DK | rhickey: I read through that blog/comparison of CL and Clojure you posted earlier today. Two interesting things come-up. 1) The blogger would probably have enjoyed it even more if we picked up ClojureQL, and 2) The guy "Lars" in the comment was actually the guy who got me into Lisp way back when :) |
| 13:13 | technomancy | Lau_of_DK: link? |
| 13:14 | Lau_of_DK | http://briancarper.net/2009/01/19/clojure-1-common-lisp-0/ |
| 13:14 | hiredman | Lau_of_DK: I am reading the comment thread on reddit for that right now |
| 13:14 | technomancy | Lau_of_DK: I like it already. =) |
| 13:14 | Lau_of_DK | hehe :) |
| 13:14 | hiredman | man those CL people are militant |
| 13:15 | hiredman | which, uh, I guess I can understand, but wow |
| 13:15 | Lau_of_DK | No its just Lars :) |
| 13:15 | Lau_of_DK | The rest are peaceful, when I first met him, his words and arguments didnt do alot for me, but his code sure did |
| 13:16 | hiredman | Lau_of_DK: I am looking at the comments on reddit, not the blog itsself |
| 13:17 | Lau_of_DK | k |
| 13:17 | Lau_of_DK | I referred to the comments directly on the Blog |
| 13:18 | hiredman | "I don't find most of these criticisms particularly valid. It sounds like the author just didn't bother to understand CL, and then his lack of understanding bit him." |
| 13:18 | Lau_of_DK | I think he makes valid points |
| 13:19 | gnuvince | Who? The author or the commenter? |
| 13:19 | Lau_of_DK | author |
| 13:19 | gnuvince | Yes he does. |
| 13:20 | gnuvince | That's a second success story in 2 weeks |
| 13:20 | Lau_of_DK | The first being? |
| 13:21 | hiredman | well, uh, his gallery is not up, so I dunno about calling it a success |
| 13:21 | gnuvince | The Veterinarian Hspital |
| 13:21 | gnuvince | hiredman: it was up. |
| 13:21 | hiredman | 503's |
| 13:22 | gnuvince | Reddit effect must have brought it down. |
| 13:22 | hiredman | yeah |
| 13:22 | gnuvince | I was able to view it earlier this morning. |
| 13:22 | gnuvince | Nothing amazing per se, but it's a cute site written quickly in Clojure |
| 13:23 | technomancy | do you think there'd be a good market for a commercial hour-long screencast on Clojure? |
| 13:23 | hiredman | ugh, I hate the web |
| 13:23 | mattrepl | would be interesting to see server stats and an autopsy to identify what failed |
| 13:33 | gnuvince | technomancy: peepcode? |
| 13:35 | technomancy | gnuvince: yeah. thinking about putting one together. |
| 13:35 | gnuvince | technomancy: If it's the same quality as the Emacs one, I'd definitely be in. |
| 13:35 | gnuvince | I wonder however how much you can cover in one hour |
| 13:35 | technomancy | it's a small market, but since there's hardly any docs out there, I think there's a chance it could sell well. |
| 13:36 | technomancy | gnuvince: that's the problem, it would be very beginner-level; you personally might not learn much you don't already know. |
| 13:36 | gnuvince | Yeah |
| 13:36 | gnuvince | Unlike the Emacs screencast where I learned about a bunch of packages. |
| 13:36 | technomancy | gnuvince: I haven't been using Clojure for as long as I've been using Emacs, (actually... no one has!) but I think it could turn out pretty well. =) |
| 13:38 | technomancy | I'm playing with writing a simple MUD as an example project to step through for the video. fun stuff. |
| 13:38 | technomancy | seems like a pretty fun, approachable project that still involves a fair amount of concurrency code. |
| 13:40 | hiredman | hmmmmm |
| 13:41 | hiredman | ring seems to be breaking my unicode |
| 13:41 | technomancy | gnuvince: if I act fast I could get it out before the book, which would make it the first published commercial documentation for Clojure. |
| 13:46 | gnuvince | I need some assistance with compiling Java code: there's one file in a Java project that I want to compile and use from Clojure. I did javac File.java to create the class files. Now what? Do I need to jar them together? |
| 13:46 | danlarkin | hiredman: mmcgrana/ring? I haven't tried it with any unicode inputs yet |
| 13:48 | rhickey | gnuvince: the .class files just need to be in your classpath, in dir structure corresponding to package |
| 13:48 | hiredman | clojurebot has some unicode in its factoids |
| 13:49 | hiredman | clojurebot: pcl -> clojure? |
| 13:49 | clojurebot | pcl -> clojure is http://blog.thinkrelevance.com/2008/09/16/pcl-clojure |
| 13:49 | gnuvince | rhickey: that's it? |
| 13:49 | hiredman | I have a webpage dumping clojurebot's brain, and the -> shows up as ? |
| 13:49 | hiredman | damn it |
| 13:49 | hiredman | wrong character encoding in the browser |
| 13:50 | gnuvince | Ah, cool. Thanks rhickey |
| 13:50 | danlarkin | hiredman: :-o |
| 13:52 | blbrown | have any of you considered working with your existing spring mvc app or you wouldn' |
| 13:52 | blbrown | want to mix the two? |
| 13:52 | hiredman | still no unicode love |
| 13:52 | hiredman | I wonder why that would be |
| 13:53 | hiredman | maybe the font the browser is using doesn't have this glyph |
| 13:54 | danlarkin | clojurebot: brain dump |
| 13:54 | clojurebot | brain dump is http://clj.thelastcitadel.com/clojurebot |
| 13:54 | danlarkin | shows up as ? for me too |
| 13:54 | danlarkin | it's literally "?" in the HTML |
| 13:55 | hiredman | :( |
| 13:55 | technomancy | should probably be encoded as HTML entities anyway |
| 13:55 | danlarkin | so yeah, coding problem somewhere in the line |
| 13:55 | technomancy | clojurebot: seattle? |
| 13:55 | clojurebot | seattle is have the coldest temps since the 1950's |
| 13:56 | hiredman | oh, which reminds me |
| 14:20 | Lau_of_DK | Poll: If ClojureQL was totally DB-agnostic, EXCEPT for adding FOREIGN keys in Create-table (which would break on Oracle), would that be good enough? |
| 14:21 | technomancy | as long as it doesn't require code modification to switch DBs, it should be fine. |
| 14:21 | hiredman | sounds good enough to me, but I've never used Oracle |
| 14:21 | technomancy | (so just don't do the FK stuff; simply warn instead of making folks go in and disable FK-related code.) |
| 14:22 | Lau_of_DK | technomancy: You never specify which DB youre working on with ClojureQL technomancy , it always works it out on its own |
| 14:24 | technomancy | sure |
| 14:24 | Lau_of_DK | The only thing it would mean in practice, was that if you know about this, you can actually modify the create string manually when writing it up |
| 14:25 | Lau_of_DK | But standard (create-table foo [id "int" name "varchar"] :foreign-key (id bar)) would break on Oracle |
| 14:26 | technomancy | see I would prefer if it simply discarded the incompatible bits with a warning but continued to work without modification |
| 14:26 | karmazilla | Oracle supports foreign keys, doesn't it? |
| 14:26 | technomancy | ... but I'm not ever going to use Oracle, so whatever. =) |
| 14:28 | danlarkin | Lau_of_DK: so the issue is that you can make clojureql work for all DBs on all operations /except/ CREATE TABLE on Oracle? |
| 14:34 | Lau_of_DK | danlarkin: More specifically. ClojureQL works on all major SQL implementations, with every single operation without knowing which DB its interfacing with, with 1 single exceptions: Create-table with a foreign key constraint on Oracle |
| 14:34 | Lau_of_DK | karmazilla: It sure does, but has a bad way of declaring them |
| 14:36 | danlarkin | Add check for oracle in there, I'd say. Always better to let the library encapsulate ugly code than force it on the user |
| 14:38 | Lau_of_DK | danlarkin: Its not possible to add a check, because the statements never realize which DB theyre working on. I think the best path would then be in the docs to specificy, that in this unique case, supply a key like :oracle) |
| 14:39 | danlarkin | :-/ I'll never use oracle so this doesn't bother me practically, but bothers me in principle |
| 14:39 | gnuvince | Lau_of_DK: I like how Django's ORM does it: common operations (selecting, inserting, updating) are DB agnostic, but it is possible to drop down to raw SQL to use some of the DB-specific features. |
| 14:40 | danlarkin | When creating a connection to the database could you allow a parameter for database type? that would be the correct place for :oracle to go |
| 14:41 | danlarkin | and then it would let you scale when you find other idiosyncrasies for other RDBMS' |
| 14:41 | Lau_of_DK | True, but the backend works very simply like (run conn-info (query foo bar baz)). Its the query construct that needs to conform to any specific syntax, not the backend bit |
| 14:42 | danlarkin | perhaps the backend could pass its db-type parameter in to query? |
| 14:42 | Chouser | Lau_of_DK: have you tried any tables or columns with mixed upper/lower case? |
| 14:43 | danlarkin | I haven't spent much time with the source of clojureql, sorry if my suggestions don't really jive with how it works |
| 14:43 | Lau_of_DK | Chouser: Tried with Capital firsts |
| 14:43 | Lau_of_DK | danlarkin: Its always nice to have feedback, disregarding the depths of your understanding |
| 14:44 | Chouser | hm. I'm really surprised this is the only time you've had to know which dbms you're producing SQL for. |
| 14:45 | Lau_of_DK | Chouser: Its quite an impressive piece of work |
| 14:45 | danlarkin | Lau_of_DK: you forgot to feign modesty :) |
| 14:45 | Lau_of_DK | Yea, I dont use that very often |
| 14:46 | hiredman | clojurebot: clojureql is also a quite impressive piece of work |
| 14:46 | clojurebot | 'Sea, mhuise. |
| 14:46 | Lau_of_DK | Chouser, if you consider this |
| 14:46 | Lau_of_DK | (create-table table1 [id "int" name "varchar(100)"] :primary id :auto-inc id) |
| 14:47 | Lau_of_DK | This will need to be written directly to either Oracle, Mysql, or Sqllite, theyre all different |
| 14:47 | Lau_of_DK | Instead we do this |
| 14:47 | Lau_of_DK | dk.bestinclass.clojureql> (vb (create-table table1 [id "int" name "varchar(100)"] :primary id :auto-inc id)) |
| 14:47 | Lau_of_DK | (primary key) |
| 14:47 | Lau_of_DK | CREATE TABLE table1 ( id int,name varchar(100) ) |
| 14:47 | Lau_of_DK | ALTER TABLE table1 add primary key (id) |
| 14:47 | Lau_of_DK | ALTER TABLE table1 change id id int AUTO_INCREMENT |
| 14:47 | Lau_of_DK | |
| 14:47 | Lau_of_DK | (vb= View batch) |
| 14:47 | Lau_of_DK | That works on all dbms's |
| 14:47 | technomancy | sqlite supports foreign keys? |
| 14:49 | Lau_of_DK | kotarak ? |
| 14:49 | kotarak | here? |
| 14:49 | Lau_of_DK | sqllite + foreign keys? |
| 14:50 | kotarak | It seems, it is supported. |
| 14:50 | danlarkin | I definitely think eventually you're going to need to produce custom SQL for different RDBMS'. It's impressive you've gone this far without having to |
| 14:50 | technomancy | cool! guess I haven't really looked into it in a while. |
| 14:50 | Chouser | a column named FooBar requires double-quotes in psql, but mysql interprets double-quotes as a string, and requires back-quotes instead. |
| 14:51 | kotarak | This alter table was a good idea. Chapeau |
| 14:53 | hiredman | Lau_of_DK: doesn't work with postgresql |
| 14:54 | Lau_of_DK | hiredman: Post is next on my test list, most cases should work fine with it |
| 14:54 | hiredman | well, the create-table example you just gave does not |
| 14:54 | Lau_of_DK | I'll look into it |
| 14:58 | Lau_of_DK | hiredman: A little odd, since it matches what their docs specificies.. I'll have to install to check it out |
| 14:59 | hiredman | Lau_of_DK: actually I looked at it before, and from what I recall, you need the word "set" in there somewhere |
| 14:59 | Lau_of_DK | http://www.postgresql.org/docs/7.4/interactive/sql-altertable.html |
| 15:00 | Lau_of_DK | If you find the ADD PRIMARY KEY example, and check your batch, you'll see its the same |
| 15:00 | hiredman | Lau_of_DK: that is not where it fails |
| 15:00 | hiredman | it fails on the auto inc bit |
| 15:00 | Lau_of_DK | "The ADD COLUMN form conforms with the SQL standard, with the exception that it does not support defaults and not-null constraints, as explained above. The ALTER COLUMN form is in full conformance. " |
| 15:03 | danlarkin | AFAIK postgres uses sequences for auto incrementing behavior |
| 15:03 | danlarkin | not int AUTO INCREMENT |
| 15:04 | Lau_of_DK | How do you mean ? |
| 15:06 | danlarkin | so I have table auth_user with "id serial NOT NULL" |
| 15:07 | danlarkin | and then I have an auth_user_id_seq sequence |
| 15:07 | hiredman | http://pointbeing.net/weblog/2008/03/mysql-versus-postgresql-adding-an-auto-increment-column-to-a-table.html |
| 15:09 | danlarkin | the first comment makes it seem not too bad to deal with |
| 15:10 | Lau_of_DK | haha |
| 15:10 | Lau_of_DK | Nice omment |
| 15:10 | Lau_of_DK | comment |
| 16:37 | durka42 | i can't figure out how to formulate this with lazy-cons |
| 16:38 | durka42 | the server returns 100 results at a time, and i want a lazy seq of results |
| 16:38 | durka42 | if you have 100 elements, you don't know whether there is another page |
| 16:38 | durka42 | if there isn't, the server throws a 404 and i get a FileNotFoundException |
| 16:39 | durka42 | i've been trying things with flatten and lazy-cons, but lazy-cons seems to freeze when an exception is thrown inside it |
| 16:39 | hiredman | durka42: you can put a (try (catch)) in the rest part of the lazy-cons |
| 16:40 | durka42 | i did... maybe i'm catching the wrong exception |
| 16:40 | Chouser | you want a lazy seq of more than 100? |
| 16:40 | durka42 | is that a bad idea? |
| 16:40 | hiredman | wait |
| 16:41 | Chouser | no, I'm just trying to understand. |
| 16:42 | Chouser | I think I need a more concrete example. Like some code. But in general one might produce a lazy seq out of several others seqs by using 'concat' |
| 16:42 | durka42 | the idea is that an http request occurs when you ask for the 100n+1'th element |
| 16:42 | durka42 | right, the problem is knowing where to end it |
| 16:43 | hiredman | sounds kind of icky |
| 16:43 | durka42 | i need my "rest" to either call lazy-cons again or swallow an exception and return nil |
| 16:43 | durka42 | or i need to rethink this function |
| 16:43 | Chouser | ah! |
| 16:43 | durka42 | i'll paste what did, except i know it can't work because recur isn't allowed across try |
| 16:43 | Chouser | lazy-cons isn't going to swallow any exception by itself, nor will it "freeze" |
| 16:44 | durka42 | the freeze could be in gorilla somewhere |
| 16:44 | lisppaste8 | durka pasted "broken lazy seq" at http://paste.lisp.org/display/73888 |
| 16:45 | hiredman | you have a recur in your lazy-cons |
| 16:45 | Chouser | he knows |
| 16:45 | hiredman | that is pretty much a no-no |
| 16:46 | durka42 | i guess i don't really understand how to use lazy-cons |
| 16:46 | hiredman | Chouser: you can never be sure |
| 16:46 | Chouser | durka42: I think you're close |
| 16:52 | durka42 | i meant to recur to the fetch fn, because i need the offset variable as state |
| 16:54 | Chousuke | OT, but did you see this already? I'm laughing, but I think I shouldn't be. http://blog.uncool.in/2009/01/19/computer-science-fail-higher-education-in-india/ |
| 16:55 | durka42 | yeah that's pretty bad |
| 16:56 | Chousuke | I'd classify that as antieducation |
| 16:56 | Chousuke | better remain ignorant than be taught by someone with that level of knowledge. |
| 16:56 | danlarkin | those poor students |
| 16:56 | Lau_of_DK | Thats impressive, imagine in a general introduction stateting "to compile code hit ALT-F9" |
| 16:57 | Lau_of_DK | :) |
| 16:57 | lisppaste8 | Chouser annotated #73888 with "maybe more like this?" at http://paste.lisp.org/display/73888#1 |
| 16:57 | Chousuke | At that point I'd probably contact the administration and request they check the professor's qualifications. |
| 16:57 | Lau_of_DK | That might be the way to go |
| 16:59 | durka42 | Chouser: but, there may be an indefinite number of pages |
| 17:00 | Chouser | durka42: yes, the 'rest' part should be recursive. I didn't quite understand what the two different arg-overloaded bodies of that function were doing. |
| 17:03 | durka42 | hmm, what if the second overload swallows the exception itself, and then lazy-cons will stop at nil... |
| 17:04 | durka42 | i have to go, but we'll see what happens to the s-exps floating around in my head |
| 17:04 | Chouser | oh, is the one that takes 'offset' essentially just internal? never called from outside the fn? |
| 17:04 | durka42 | yes |
| 17:05 | durka42 | i mean, maybe if you wanted the third page -- but i kind of want the fact that it's broken up to be an implementation detail |
| 17:05 | durka42 | especially because offset is only allowed to be multiples of 100 |
| 17:15 | lisppaste8 | Chouser annotated #73888 with "tell me if I'm getting warmer" at http://paste.lisp.org/display/73888#2 |
| 17:16 | durka42 | ooh, i like that one |
| 17:17 | durka42 | so in (at 200), (request ...) dies with a FNFE, lazy-cat never gets called, and the lazy-cat from (at 100) gets a nil |
| 17:19 | Chouser | are you saying it works? this is the sort of thing you could run through seque to let it do the fetching a little ahead-of-time in another thread. |
| 17:20 | durka42 | it works with a one-page query |
| 17:20 | durka42 | let me try to find a two-page query |
| 17:23 | durka42 | yeah, that works |
| 17:24 | durka42 | thanks chouser |
| 17:24 | durka42 | and thanks for the pointer to seque |
| 17:31 | Chouser | you're welcome |
| 17:34 | Chouser | it'd be pretty easy to allow for an initial offset without fetching early pages unnecessarily. |
| 17:35 | durka42 | yeah, although the new york times only allows multiples of 100 |
| 17:38 | technomancy | so if I accidentally def a symbol in a namespace and then realize that I actually want that symbol to refer to another namespace, how do I unset it? |
| 17:39 | hiredman | ,(doc unmap) |
| 17:39 | clojurebot | java.lang.Exception: Unable to resolve var: unmap in this context |
| 17:39 | hiredman | ,(doc ns-unmap) |
| 17:39 | clojurebot | "([ns sym]); Removes the mappings for the symbol from the namespace." |
| 17:39 | technomancy | thanks! |
| 17:40 | karmazilla | newsflash: textjure* grows new arms: undo-redo (chunking still pending), toggle/configurable word-wrap in editor and - dun-dudun - closing files! :) |
| 17:41 | hiredman | nice |
| 17:41 | danlarkin | yesss closing files!!! the killer feature!!! |
| 17:41 | danlarkin | :) |
| 17:42 | karmazilla | survey concludes: all users agree; newest feature is "the killer" |
| 17:43 | clows | wouldn't that have to be "delete files"? |
| 17:43 | Chouser | durka42: ok, but if you wanted the 104th item, right now you'd have to fetch the first 100 and throw them away. |
| 17:43 | edw | A question, karmazilla: How do you start textjure |
| 17:43 | edw | ? |
| 17:44 | karmazilla | clj textjure.clj |
| 17:44 | karmazilla | where "clj" is your favority Clojure shell script |
| 17:44 | Chouser | you might need to give it a filename to open. |
| 17:44 | durka42 | Chouser: yes. I added an initial-offset version, so the 104th item is (nth (donor-search "president" 2008 {...} 1) 4) |
| 17:48 | durka42 | by the way, this project is bindings for http://developer.nytimes.com/docs/campaign_finance_api |
| 17:48 | edw | karmazilla: Thanks. |
| 17:50 | ecret | anyone know when clojure-dev(eclipse plugin) will be released? |
| 17:54 | edw | karmazilla: Where does textjure live? The github code looks a month old. |
| 17:55 | karmazilla | edw: my fork: http://github.com/karmazilla/textjure/tree/master |
| 17:55 | edw | Thanks. |
| 17:59 | technomancy | sweet; server-sockets.clj just got checked into contrib |
| 18:15 | technomancy | since keywords are functions of maps, is this something you should always take advantage of? |
| 18:15 | technomancy | in other words, when is it idiomatic to have the keyword first vs the map first? |
| 18:16 | danlarkin | IMO it's just preference |
| 18:17 | danlarkin | although I am trying to put the hash as the first arg |
| 18:17 | danlarkin | because I have a lot of cases where the keys are not keywords |
| 18:18 | danlarkin | so it's nice to always use the same order for lookups |
| 18:19 | Chouser | I aim for putting keywords first iff it's a literal keyword |
| 18:19 | hiredman | ^- |
| 18:20 | Chouser | Dunno if that's good or correct or anything, just the rule I'm following for now. When I think of it. |
| 18:20 | technomancy | Chouser: that's what I've been doing; yeah |
| 18:20 | danlarkin | I will admit that (:keyword map) looks better than (map :keyword) to me, at least... visually |
| 18:20 | technomancy | because it's easy to tell at a glance that it's a lookup |
| 18:21 | technomancy | but when :keyword is a variable that's bound to a keyword, you don't have the colors to tell you what's going on right away, so it's better to put the map first |
| 18:21 | technomancy | am I right in supposing that the problem with this code is that it calls remove with the args in the wrong order? (dosync (alter (ref [1 2 3]) remove #(= 2 %))) |
| 18:22 | maacl | Complete newb here - Can anybody explain why I can't get the practical-cl-clojure examples at http://github.com/stuarthalloway/practical-cl-clojure/tree/master to run - I get a lot of complaints about "No such namespace: clojure" |
| 18:22 | hiredman | maacl: old code |
| 18:22 | hiredman | the clojure namespace is now clojure.core |
| 18:23 | hiredman | ,(doc remove) |
| 18:23 | clojurebot | "([pred coll]); Returns a lazy seq of the items in coll for which (pred item) returns false. pred must be free of side-effects." |
| 18:23 | maacl | ok |
| 18:24 | technomancy | hiredman: but alter will try to call remove with the collection first? |
| 18:25 | hiredman | ,(doc alter) |
| 18:25 | clojurebot | "([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref." |
| 18:25 | technomancy | looks like it then. |
| 18:25 | hiredman | (apply remove [1 2 3] #(= 2 %)) |
| 18:26 | hiredman | you could use partial, |
| 18:26 | technomancy | yeah, embed the call to remove inside an fn then? |
| 18:26 | hiredman | ,(alter (ref [1 2 3]) (partial remove #(= 2 %))) |
| 18:26 | clojurebot | java.lang.IllegalStateException: No transaction running |
| 18:26 | technomancy | huh |
| 18:26 | maacl | hiredman: any idea how to update it ? has this at the top:(clojure.core/in-ns 'pcl.chap_03) |
| 18:26 | maacl | (clojure.core/refer 'clojure) |
| 18:26 | maacl | (use 'clojure.core.contrib.duck-streams) |
| 18:26 | hiredman | ,(dosync (alter (ref [1 2 3]) (partial remove #(= 2 %)))) |
| 18:27 | clojurebot | (1 3) |
| 18:27 | technomancy | sweet. |
| 18:27 | hiredman | maacl: looks like a bug, the (clojure.core/refer 'clojure) only got halfway updated |
| 18:27 | technomancy | hiredman: what's the benefit of partial over just constructing an fn there? easier for the compiler to optimize? |
| 18:27 | hiredman | should be (clojure.core/refer 'clojure.core) |
| 18:27 | hiredman | technomancy: no idea |
| 18:28 | hiredman | it lets use a #() |
| 18:28 | technomancy | ok, will check it out; thanks |
| 18:28 | hiredman | and you cannot nest #() |
| 18:28 | Chousuke | technomancy: I think it just looks nicer. :p |
| 18:29 | hiredman | it is very functional |
| 18:29 | hiredman | partially applying functions |
| 18:29 | hiredman | I would use it way more often if I did have to type 'partial' each time |
| 18:29 | technomancy | yeah. to me the fn approach looks more recognizable, but that's just because I didn't know about partial until now I guess. =) |
| 18:30 | maacl | hiredman: thanks - that got me some of the way - now have to figure out how to get contrib working |
| 18:30 | hiredman | maacl: I think you just need a copy of the contrib jar in your classpath |
| 21:24 | gnuvince_ | Is there a reason I can refer to a class by its FQDN, but cannot import it? |
| 21:25 | durka42 | that seems a little strange |
| 21:25 | durka42 | was the class compiled by a JVM newer than the one you are running? |
| 21:25 | Chouser | what does your attempt to import it look like? |
| 21:25 | gnuvince_ | user> hu.belicza.andras.bwhf.control.BinReplayUnpacker |
| 21:25 | gnuvince_ | hu.belicza.andras.bwhf.control.BinReplayUnpacker |
| 21:25 | gnuvince_ | user> (import '(hu.belicza.andras.bwhf.control BinReplayUnpacker)) |
| 21:25 | gnuvince_ | ; Evaluation aborted. |
| 21:26 | gnuvince_ | Just trying to play around with the class |
| 21:26 | gnuvince_ | durka42: I just compiled it now |
| 21:29 | gnuvince_ | I did add the path with add-classpath |
| 21:31 | gnuvince_ | Yeah, it works with -cp directly |
| 21:49 | djkthx | is this a recent change? |
| 21:49 | djkthx | user=> (clojure.contrib.str-utils/str-join "." [127 0 0 1]) |
| 21:49 | djkthx | java.lang.ClassNotFoundException: clojure.contrib.str-utils (NO_SOURCE_FILE:1) |
| 21:49 | djkthx | user=> (use 'clojure.contrib.str-utils) |
| 21:49 | djkthx | nil |
| 21:49 | djkthx | user=> (str-join "." [127 0 0 1]) |
| 21:49 | djkthx | "127.0.0.1" |
| 21:51 | Chouser | you have to use 'require' or 'use' before you can call a function |
| 21:51 | Chouser | from another namespace |
| 21:51 | djkthx | even if i give the full qualified namespace? |
| 21:51 | djkthx | hmm |
| 21:51 | djkthx | weird, alright |
| 21:51 | djkthx | thanks :) |
| 21:52 | danlarkin | djkthx: weird? I've never seen a language that doesn't require such a thing |
| 21:52 | Chouser | well, you can refer to a class without ever loading it in any way |
| 21:52 | djkthx | well, weird because the beta version of the clojure book i have seems to imply you can/coule at some point |
| 21:53 | djkthx | could just be an old version |
| 21:54 | Chouser | no |
| 21:55 | Chouser | beta 4 of the book? what page? |
| 21:55 | djkthx | 53 |
| 21:55 | djkthx | b4 |
| 21:57 | durka42 | are you looking at the ellipsize example? |
| 21:58 | Chouser | intro to namespaces |
| 21:59 | durka42 | oh |
| 21:59 | durka42 | yes, it does say you can do that |
| 21:59 | Chouser | looks like an oversight in the prose |
| 22:03 | djkthx | hmm |
| 22:03 | djkthx | well, good to know i'm not crazy |
| 22:08 | yangsx | what are possible reasons to prefer structmap to map besides giving a name to the map for the compiler to check? |
| 22:09 | Chouser | more space efficient |
| 22:11 | yangsx | Chouser: I see. |
| 22:11 | Chouser | actually, I think that's just about it. access can be made a bit faster |
| 22:12 | devinus | what does java -server do? |
| 22:13 | Chouser | as i understand it, that causes it to use a completely different VM implementation |
| 22:14 | hiredman | the hotspot vm |
| 22:14 | Chouser | the -server vm does takes a bigger CPU hit early to do more long-term optimization |
| 22:15 | devinus | nice |
| 22:15 | devinus | is there a script that packages jLine and clojure into an easy to use unix command? |
| 22:24 | durka42 | there's a pretty simplistic one here http://clojure.org/getting_started |
| 22:24 | durka42 | you'd probably want to add things to the classpath, at least |
| 22:24 | durka42 | also, clojure.lang.Repl has been replaced by clojure.main |
| 22:25 | hiredman | I still use Repl |
| 22:26 | hiredman | I could not figure out how to load a script and launch a Repl at the same time with clojure.main |
| 22:26 | Cark | hum |
| 22:26 | Chouser | hiredman: I asked about that on the group. |
| 22:27 | Cark | that may be why i didn't manage to make the new clojure work with slime ! |
| 22:33 | Chouser | http://groups.google.com/group/clojure/msg/ea51b0fb25dbb402 |
| 22:35 | hiredman | ugh |
| 22:35 | Chouser | what? |
| 22:35 | hiredman | Nothing. |
| 22:41 | hiredman | interesting |
| 22:44 | Chouser | djkthx: in the beta5 version of the book, the previous page has a call to 'use' to load str-utils and and refer str-join |
| 22:56 | djkthx | ah |
| 22:57 | djkthx | gotcha |
| 23:24 | djkthx | im curious why a LOOP macro hasn't been written for clojure |
| 23:24 | djkthx | is there anything similar? |
| 23:24 | djkthx | (like the CL macro) |
| 23:25 | Chouser | there are 'for' and 'doseq' which are vaguely related |
| 23:25 | technomancy | hrm... I updated my swank-clojure and slime, and now my slime-repl buffer doesn't show up anymore. |
| 23:25 | Chouser | LOOP is far more powerful, of corse, as well as much more complicated. |
| 23:26 | technomancy | is there a fix, or should I roll back to a known good version? |
| 23:26 | technomancy | otherwise I'm stuck with the repl I've got and have to be veeeeery careful not to quit this one session that's working. =) |
| 23:26 | Chouser | heh |
| 23:27 | Cark | technomancy : i have the same problem, i'm now using clojure-mode + a repl in *inferior-lisp* |
| 23:27 | Chouser | slime must be pretty great to be worth so much pain |
| 23:27 | technomancy | it is! |
| 23:27 | djkthx | slime is quite nice |
| 23:27 | technomancy | Cark: you didn't happen to notice the SHA of the last good rev, did you? |
| 23:28 | djkthx | technomancy: i had similar issues because (require 'slime-fancy) didn't work before |
| 23:28 | Cark | nope, sorry |
| 23:28 | djkthx | so i did some weirdass workaround |
| 23:28 | djkthx | if you did the same thing, switch it out for just (require 'slime-fancy) and you should be fine |
| 23:28 | technomancy | Cark: inferior-lisp is probably OK as long as C-c C-l works |
| 23:28 | technomancy | djkthx: what's slime-fancy? |
| 23:28 | djkthx | it just loads a bunch of extra stuff |
| 23:28 | djkthx | doc info, autocomplete, etc. |
| 23:29 | Cark | technomancy : ah i had to edit the source code of clojure mode to make it work |
| 23:29 | djkthx | it's a feature you add to your ~/.emacs |
| 23:44 | technomancy | yeah, inf- is pretty reasonable; doesn't look like you miss too much without rep |
| 23:46 | apage43 | slime is alright... |
| 23:46 | apage43 | gorilla is good enough for me =P |
| 23:47 | technomancy | http://github.com/technomancy/mire/tree/master <= my simple MUD |
| 23:48 | technomancy | server-socket is really nice; gets you what you need without a lot of java.io.fuss |
| 23:50 | Cark | hey if you have 2 players and one takes the key for instance |
| 23:51 | Cark | what happens when he is disconnected ? |
| 23:51 | technomancy | it's gone! |
| 23:51 | technomancy | forever |
| 23:51 | Cark | =) |
| 23:51 | technomancy | but it's not too big of a deal since the key isn't good for anything anyway |
| 23:51 | technomancy | the bunny, on the other hand... |
| 23:53 | technomancy | I was pretty excited just to get to the "player 1 took the key, now player 2 doesn't see it any more" stage. =) |
| 23:54 | Cark | yep pretty nice already |
| 23:54 | Cark | and very readable |
| 23:54 | technomancy | next step is to make it so players can see each other |
| 23:55 | technomancy | the logic should be very similar to take/drop of items though |
| 23:55 | Cark | and most importantly, fight the bunny ! |
| 23:55 | technomancy | oh man... I should base it on Dwemthy's Array |
| 23:55 | Cark | what is it ? |
| 23:56 | technomancy | (http://poignantguide.net/dwemthy/) |
| 23:56 | technomancy | "These are the living, breathing monstrosities of Dwemthy's Array. I don't know how they got there. No one knows. Actually, I'm guessing the IntrepidDecomposedCyclist rode his ten-speed. But the others: NO ONE knows." |
| 23:57 | Cark | bleh better do your own stuff |
| 23:58 | technomancy | I don't do enough drugs to really pull something like that off |