2009-03-04
| 00:26 | slashus2 | durka42: If the first is a symbol should it give an error? |
| 00:26 | durka42 | i mean, would you ever use a symbol as doc |
| 00:26 | durka42 | that seems strange |
| 00:27 | durka42 | is doc required to be a literal string? |
| 00:27 | slashus2 | It appears so. |
| 00:27 | slashus2 | (def testing2 "test doc") and used testing2 and it didn't work. |
| 00:31 | hiredman | uh |
| 00:31 | hiredman | that is because you just def'ed resting2 to a string |
| 00:31 | hiredman | testing2 |
| 00:31 | hiredman | if you want to add a docstring with def you have to use #^ |
| 00:33 | ayrnieu | you can also add documentation after the fact, with .setMeta |
| 00:34 | arohner | so struct-map takes the name of a defstruct, and key value pairs. i.e. (defstruct foo :a 1, :b 2) |
| 00:34 | slashus2 | I was talking about doing something like (defn testing testing2 [x y] y) |
| 00:34 | arohner | if I have a map of key value pairs, how do I call struct-map? |
| 00:34 | hiredman | ,(doc defstruct) |
| 00:34 | clojurebot | "([name & keys]); Same as (def name (create-struct keys...))" |
| 00:34 | hiredman | ,(doc create-struct) |
| 00:34 | clojurebot | "([& keys]); Returns a structure basis object." |
| 00:34 | hiredman | doesn't say anything about values |
| 00:35 | arohner | ,(doc struct-map) |
| 00:35 | clojurebot | "([s & inits]); Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none of the basis keys - where values are not supplied they will default to nil. keyvals can also contain keys not in the basis." |
| 00:35 | arohner | struct-map wants a list of key value pairs, rather than a map |
| 00:36 | lisppaste8 | slashus2 pasted "sigs" at http://paste.lisp.org/display/76450 |
| 00:36 | slashus2 | durka42: How does this look? |
| 00:37 | durka42 | seems to make sense... |
| 00:37 | durka42 | but i'm not an authority on these things |
| 00:40 | slashus2 | hiredman: Do you think that this is acceptable? |
| 00:40 | ayrnieu | arohner, (apply struct-map some-struct (interleave (keys some-hash) (vals some-hash))) |
| 00:41 | arohner | ayrnieu: thanks |
| 00:50 | arohner | is there a built in function to replace the name of a key in a map, keeping the value intact? |
| 00:51 | arohner | i.e. (dissoc (assoc my-map new-name (my-map old-name)) old-name)) |
| 00:51 | durka42 | i think you just wrote said function :) |
| 00:51 | cp2 | heh |
| 00:51 | arohner | :-) yeah, I was just wondering if I needed to write it |
| 00:52 | Raynes | Someone said "Oh Clojure is Scheme for the JVM." I replied "Bite your tongue." Started a whole uproar as they thought I was dissing Scheme. |
| 00:54 | arohner | Raynes: where was that conversation? |
| 00:55 | Raynes | #Haskell-Blah Nice guys <3 the uproar only lasted until I said "I would never dis Scheme". |
| 00:55 | cp2 | lol |
| 00:56 | ayrnieu | "I would never diss Scheme, but I do think it so shameful for Clojure to be called 'Scheme for the JVM' that I demanded you harm yourself after saying that." |
| 00:56 | ayrnieu | but it's a silly thing to say, anyway. There are already several schemes for the JVM. |
| 00:58 | Raynes | ayrnieu: You took that completely out of context. |
| 00:58 | Raynes | I never meant it as being shameful. Clojure is a world-a-way from being "Scheme for the JVM" that's all I meant. |
| 01:00 | ayrnieu | world-a-way meaning 'world-a-better': if it had been asserted that Clojure was "Forth for the JVM", you'd react differently. This assertion is simply wrong. |
| 01:01 | Raynes | ayrnieu: What are you even talking about? |
| 01:01 | Raynes | Had he have said "Fourth for the JVM" I would have asked him was he out of his mind. |
| 01:01 | Raynes | Of course I would of reacted differently. |
| 01:01 | Raynes | It doesn't take a genius to realize I'm not putting Scheme down. |
| 01:02 | Raynes | There is around 10 different ways one could take what I said. |
| 01:02 | Raynes | Not just "Scheme is shameful" |
| 01:02 | Raynes | Anyways, I need sleep. |
| 01:02 | Raynes | Good night. |
| 01:03 | ayrnieu | I suppose that it's conversations like this that led people to come up with 'EQ'. |
| 01:04 | cmvkk | EQ? |
| 01:04 | ayrnieu | Emotional Quotient. Like IQ. |
| 01:04 | cmvkk | ohh. |
| 01:22 | slashus2 | durka42: I will have to change that a little bit. cond isn't defined by that point, nor is symbol. |
| 01:24 | redalastor | If I have a vector that that contain cartesian coordinates (something like [[3 17] [24 62] [21 99]]), how can I find the right-most or left-most value? If two values are right-most or left-most, any is fine. |
| 01:25 | redalastor | In Python I'd use min and max but in clojure this would not work. |
| 01:26 | cmvkk | (reduce (fn [x y] (min x (first y)) myvec) ? |
| 01:26 | redalastor | I could always sort it but that seems wasteful. |
| 01:27 | cmvkk | wait that wouldn't work |
| 01:27 | redalastor | cmvkk: Thanks! |
| 01:27 | redalastor | Why not? |
| 01:27 | cmvkk | well i think that might be slightly broken, hold on. |
| 01:27 | ayrnieu | sort it by the dimension of interest or else fold over it. |
| 01:27 | cmvkk | (reduce (fn [x y] (min (if (coll? x) (first x) x) (first y)) myvec) |
| 01:28 | cmvkk | otherwise when reduce calls it with the first two values it will choke on the first coordinate. |
| 01:28 | redalastor | thanks |
| 01:29 | cmvkk | oh and that will only return the left value, not the whole coordinate... |
| 01:29 | cmvkk | hmm... |
| 01:30 | cmvkk | (reduce (fn [x y] (if (< (first x) (first y)) x y)) myvec) |
| 01:31 | Chouser | (reduce (fn [x y] (if (pos? (compare x y)) x y)) coll) |
| 01:32 | cmvkk | ooh compare does things i didn't realize it did. |
| 01:34 | redalastor | Yes, interesting. I didn't know vectors were comparables. |
| 01:34 | cmvkk | if 'compare' can do that, i think 'min' ought to be able to do it too. |
| 01:35 | redalastor | min insists on comparing numbers |
| 01:35 | cmvkk | yeah. but clearly it would be trivial to write a min that works anywhere compare does |
| 01:36 | redalastor | Yeah, that's what Python and Ruby (I think?) do. |
| 01:36 | cmvkk | same with max, <, >, etc... |
| 01:36 | cmvkk | could be an efficiency thing I guess |
| 01:37 | redalastor | Probably. But they could be diffrently named. |
| 01:37 | redalastor | I kinda expect someone will tell us it already exists in contrib :) |
| 01:42 | cmvkk | man. defn is so much harder to write a macro over than defun was. |
| 01:45 | ayrnieu | yep. Clojure doesn't have some points of macro-hostility that Scheme has, but then it has superfluous syntax that must be checked and reconstructed properly. |
| 01:47 | cmvkk | i have a bad habit of doing things like this: (defn get-filter-stuff [thing & stuff] ...) |
| 01:47 | cmvkk | "poor variable naming habits" |
| 01:48 | ayrnieu | names are hard. |
| 01:48 | cmvkk | names are hard, let's go shopping! |
| 01:49 | cmvkk | in this case, though, [thing & stuff] is everything in a defn but the name. so "thing" could be a string, an arglist, a function body... |
| 03:21 | eevar2 | (conj 10 [1 2 3]) |
| 03:22 | ayrnieu | ,[(conj [1 2 3] 10) (cons 10 [1 2 3])] |
| 03:22 | clojurebot | [[1 2 3 10] (10 1 2 3)] |
| 03:41 | eevar2 | ,(doc conj) |
| 03:41 | clojurebot | "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type." |
| 03:41 | eevar2 | ,(conj [1 2 3] 10) |
| 03:41 | clojurebot | [1 2 3 10] |
| 03:41 | eevar2 | ,(conj 10 [1 2 3]) |
| 03:41 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection |
| 03:42 | eevar2 | (conj [1 2 3] 10) |
| 04:13 | BigTom | Hi |
| 04:14 | BigTom | does anyone have an example of reading a file, tweaking it, and writing it, using duck streams? |
| 04:18 | BigTom | I can do something with reading the whole file in processing it and writing it out but I was hoping to do it a line at a time |
| 04:26 | BigTom | Other question, can 'doseq' be considered a "strict" 'for' |
| 04:26 | BigTom | ? |
| 04:26 | hiredman | nope |
| 04:26 | kotarak | BigTom: no. doseq returns nil and is purely for side-effects. for returns a seq |
| 04:26 | hiredman | for is not a loop |
| 04:27 | kotarak | clojurebot: for |
| 04:27 | clojurebot | for is not used often enough |
| 04:27 | kotarak | clojurebot: for |
| 04:27 | clojurebot | for is not a loop |
| 04:28 | ayrnieu | clojure doesn't need separate 'strict' procedures, anyway; you can dorun or doall a lazy one. |
| 04:29 | hiredman | eager is the term |
| 04:30 | kotarak | doall is so ugly.... |
| 04:30 | ayrnieu | it turns out that people have many terms. |
| 04:31 | ayrnieu | kotarak - (def work doall) ? |
| 04:31 | ayrnieu | maybe (def WORK! doall) |
| 04:32 | kotarak | ayrnieu: I mean the concept itself. Not the name. I understand that for resource management, doall makes sense, but (dorun (map #(println ..) ..)) or (doall (map #(println ..) ..)) is *ugly*. |
| 04:33 | ayrnieu | oh, sure. |
| 04:39 | ayrnieu | kotarak: (defmacro dolist [[v list] & body] `(loop [~v ~list] (when ~v (let [~v (first ~v)] ~@body) (recur (next ~v))))) |
| 04:41 | kotarak | ayrnieu: what is the difference to doseq? |
| 04:43 | ayrnieu | if you mean to ask why anyone would use this instead of doseq: *shrug*. |
| 04:44 | kotarak | ayrnieu: I'm a bit confused, what you want to tell me with this macro. |
| 04:46 | ayrnieu | that's OK. I'm going to bed. |
| 04:51 | Lau_of_DK | ,(int (* 100 (/ 1966 2864))) |
| 04:51 | clojurebot | 68 |
| 04:51 | Lau_of_DK | According to my head, that should give 69, why dont it ? |
| 04:52 | Holcxjo | Lau_of_DK: It doesn't to rounding |
| 04:52 | Holcxjo | ,(/ 1966.0 2864.0) |
| 04:52 | clojurebot | 0.6864525139664804 |
| 04:52 | cmvkk | yep, the real result is 68.64, which int just chops off the decimal part of. |
| 04:52 | Lau_of_DK | Thats cheap |
| 04:53 | Lau_of_DK | Do we have a func for ceiling it ? |
| 04:53 | cmvkk | Math/ceil? |
| 04:53 | Lau_of_DK | or roudinging |
| 04:53 | Lau_of_DK | thanks |
| 04:53 | cmvkk | you still have to call int if you want an int though; that always tripped me up. |
| 04:53 | cmvkk | for some reason, (Math/ceil 68.64) will return 69.0 rather than 69. |
| 04:54 | Lau_of_DK | A little odd, but quickly fixed :) |
| 04:54 | Lau_of_DK | Thanks for the help guys |
| 04:55 | Holcxjo | ,(int (+ 1/2 (* 100 (/ 1966 2864)))) |
| 04:55 | clojurebot | 69 |
| 04:55 | cmvkk | heh, that's one way of doing it. |
| 04:55 | Holcxjo | truncation becomes rounding if you add 1/2 (or subtract for negative numbers) |
| 04:56 | Holcxjo | Math/round is the other option |
| 05:01 | kotarak | ,(.split "c.c" ".") |
| 05:01 | clojurebot | #<String[] [Ljava.lang.String;@adb24> |
| 05:01 | kotarak | ,(seq (.split "c.c" ".")) |
| 05:01 | clojurebot | nil |
| 05:01 | leafw | Holcxjo: that (int (+ 0.5 x)) is the best way to round in java/c/c++, AFAIK, all errors considered |
| 05:01 | kotarak | Am I missing something= |
| 05:02 | kotarak | ? |
| 05:02 | hiredman | ,(count (.split "c.c" ".")) |
| 05:02 | clojurebot | 0 |
| 05:02 | hiredman | ,(count (.split "c.c" "\.")) |
| 05:02 | clojurebot | Unsupported escape character: \. |
| 05:02 | hiredman | ,(count (.split "c.c" "\\.")) |
| 05:02 | clojurebot | 2 |
| 05:02 | kotarak | argh. |
| 05:02 | kotarak | hiredman: thanks |
| 05:50 | lenst | I don't like the new repl_utils. It seems to start some GUI junk. |
| 05:51 | cgrand | lenst: to start? |
| 05:52 | cgrand | can you be more precise? |
| 05:54 | lenst | I'm running Mac OS 10.4 and when I load repl_utils I get a clojure.main process in my dock. |
| 05:54 | cgrand | and no actual window? |
| 05:55 | lenst | No window. It probably loads some swing classes, and that makes the java process into a GUI process. |
| 05:57 | lenst | A |
| 05:57 | lenst | oops. And when it starts it becomes forground process and steals focus. |
| 06:00 | cgrand | lenst: can you try to evaluate javax.swing.JEditorPane in a fresh REPL to see if the simple loading of a gui class causes the process to appear in the dock? |
| 06:01 | lenst | It does. |
| 06:03 | lenst | clojure.contrib.javadoc.browse/open-url-in-swing might be the problem |
| 06:05 | cgrand | lenst: ok, can you open an issue, I'll look at it. |
| 06:11 | BigTom | Thanks for the correction on doseq and for |
| 06:16 | AWizzArd | clojurebot: max people |
| 06:16 | clojurebot | max people is 149 |
| 06:52 | timothypratley | macro question: |
| 06:53 | timothypratley | I want to do something like this: |
| 06:53 | timothypratley | (defmacro fun [ & body] |
| 06:53 | timothypratley | `(let [name (javax.swing.JLabel. "hi")] |
| 06:53 | timothypratley | ~@body) |
| 06:53 | timothypratley | (fun (.getText name)) |
| 06:53 | timothypratley | <- contrived example |
| 06:54 | timothypratley | is that possible? |
| 06:55 | Lau_of_DK | sure is |
| 06:56 | kotarak | (defmacro fun [& body] `(let [~'name (javax.swing.JLabel. "hi")] ~@body)) |
| 06:56 | kotarak | timothypratley: but you should clearly document the capture |
| 06:56 | timothypratley | :) |
| 06:57 | timothypratley | great! |
| 06:58 | kotarak | I hope I don't go to Hell for giving such tips. ;) |
| 06:58 | timothypratley | how does it work? ~' is clearly unquote quote ---- does that avoid the namespacing --- or something else? |
| 06:59 | kotarak | ~'name is the same as ~(quote name) |
| 06:59 | clojurebot | 'Sea, mhuise. |
| 06:59 | kotarak | You just have to remember, that ~ means "do the following in the context where the macro is defined". |
| 07:00 | kotarak | Where everything else is done in the context the macro is called. |
| 07:00 | kotarak | (rough, but as a general guideline) |
| 07:01 | kotarak | So ~'name means: "fill in (~) the quoted (') symbol 'name'" |
| 07:01 | kotarak | One could as well say: ~(symbol "name") |
| 07:02 | timothypratley | oooo |
| 07:03 | timothypratley | I almost understand that :) |
| 07:03 | kotarak | timothypratley: writing macros is actually simple. (I know, I know, ... let me explain) |
| 07:04 | kotarak | (defmacro foo [] `(bla blub)) |
| 07:04 | kotarak | This means simply: replace (foo) with (bla blub) and continue compilation. |
| 07:05 | kotarak | Now first step: ~ |
| 07:05 | kotarak | `(bla ~blub) |
| 07:05 | kotarak | This basically means: expand to a call to bla with the second argument replaced by blub from the enclosing context. |
| 07:06 | kotarak | blub could eg. be a macro argument. |
| 07:06 | kotarak | (defmacro foo [blub] `(bla ~blub)) |
| 07:06 | kotarak | This can also be any computation: ~(symbol blub) |
| 07:06 | kotarak | Second step: ~@ |
| 07:07 | kotarak | This is a bit more complicated, because it "removes" an outer set of parens. So the unquoted thing must be a sequence. |
| 07:08 | kotarak | `(bla ~@[1 2 3]) => (bla 1 2 3) |
| 07:08 | kotarak | This is maybe a simplified view, but I got me very far, when writing a macro. |
| 07:08 | timothypratley | so far so good |
| 07:09 | papermachine | Is there a mirror for the blip.tv screencast? |
| 07:13 | timothypratley | user=> (macroexpand-1 '(foo)) |
| 07:13 | timothypratley | (user/bla user/blub) |
| 07:13 | timothypratley | user=> (defmacro foo [] `(bla ~'blub)) |
| 07:13 | timothypratley | user=> (macroexpand-1 '(foo)) |
| 07:13 | timothypratley | (user/bla blub) |
| 07:15 | timothypratley | we removed the name space qualifier, but presumably being in the current namespace blub and user/blub are the same? |
| 07:15 | timothypratley | (evidently not) |
| 07:24 | timothypratley | Oh I think I'm starting to see the light... |
| 07:24 | timothypratley | user=> (let [user/blub 2] blub) |
| 07:24 | timothypratley | java.lang.Exception: Can't let qualified name: user/blub (NO_SOURCE_FILE:12) |
| 07:24 | timothypratley | So I understand your solution better now kotarak thanks |
| 07:28 | djpowell | What are the recent checkins related to constants all about? |
| 07:31 | rhickey | representing constants as bytecode yields big startup improvement on lowly hardware (like Android phones) |
| 07:31 | Chouser | djpowell: they appear to be mostly about altering the indentation of else-if blocks |
| 07:32 | Chouser | or what rhickey said. :-) |
| 07:34 | djpowell | cool |
| 07:34 | rhickey | I was hoping for a size reduction too, but no joy there |
| 07:36 | djpowell | does it help startup time a lot then? |
| 07:38 | kotarak | timothypratley: ~'blub basically resolves blub in the context the macro is called, while simply blub is resolved in the context the macro is defined and then replaced by the fully qualified name. So when the macro is expanded, it references the same blub, that the macro knows about. |
| 07:40 | djpowell | just tried it, it does seem faster |
| 07:42 | timothypratley | kotarak: thanks for the help :) |
| 07:42 | kotarak | timothypratley: np :) |
| 08:08 | Lau_of_DK | Anyone here who has some experience with AXIS? |
| 08:10 | banisterfiend | Lau_of_DK: my grandfather was a nazi |
| 08:11 | Lau_of_DK | Im talking about the Apache servlet system |
| 08:11 | banisterfiend | oh |
| 08:13 | p_l | ... |
| 08:13 | timothypratley1 | Kotarak: I have another macro question :) From your explanation I understand why this doesn't work: |
| 08:13 | timothypratley1 | (defmacro my-set! |
| 08:13 | timothypratley1 | [obj constraint] |
| 08:13 | timothypratley1 | `(set! (. ~obj ~(symbol (name (first constraint)))) ~(second constraint))) |
| 08:15 | timothypratley1 | because constraint can only have first/second taken if it is a form at macro compile time |
| 08:16 | timothypratley1 | so (my-set! obj (:gridx 1)) works fine, but (my-set! obj c) where c is '(:gridx 1) doesn't |
| 08:16 | timothypratley1 | but how can I get around that constraint? |
| 08:19 | timothypratley1 | I suspect I must mix a function and a macro in some clever way... I can't make it just a function because set! is a special form hence why I'm trying to trick it. |
| 08:23 | Holcxjo | Don't use the tilde in front of (symbol and (second if you don't want it evaluated at macro-expansion time |
| 08:26 | timothypratley1 | Holcxjo: but then (set! does not work at all because it expects a symbol, not a form).... I guess what I'm trying to do is an impossible chicken/egg scenario. |
| 08:33 | Holcxjo | timothypratley1: set! does not evaluated the symbol expression to see what it is?!? |
| 08:33 | timothypratley1 | nope :( |
| 09:00 | cemerick | Building my first multimethod hierarchy. It's a joy so far. |
| 09:00 | cemerick | Didn't isa? imply instance? at one point, though? |
| 09:01 | kotarak | timothypratley1: I'm afraid you can't. Macro cannot depend on such runtime information. |
| 09:03 | kotarak | cemerick: yes, instance? should also imply isa? (instance? String foo) <=> (isa? String (class foo)) (I'm not sure about the order for isa?, though) |
| 09:04 | rhickey | ,(doc isa?) |
| 09:04 | clojurebot | "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy" |
| 09:05 | kotarak | so it probably should be (isa? (class foo) String). I always confuse the order.... :| |
| 09:06 | cemerick | ah-ha, I was being thrown off by the same classname floating around in my ns, but from a different package. |
| 09:10 | kotarak | timothypratley: that's a common mistake in macro development by the way. You correctly recognised the limits of a macro. Don't make the mistake of trying to hard to push this limit, eg. coming up with some eval using idea. This just gives more problems. See the limits of macros and you just improved your macro-fu by an order of magnitude. :) |
| 09:12 | timothypratley | :) |
| 09:13 | cemerick | is there a builtin that will return two colls given one coll and a predicate (where one of the returned colls is the result of filtering the input coll using the pred, the other is the result of removing)? |
| 09:15 | timothypratley1 | cemerick: split-with |
| 09:15 | cemerick | timothypratley1: well, almost -- that uses take-while and drop-while |
| 09:16 | kotarak | recursive split-with until the seq is consumed. |
| 09:17 | kotarak | hmmm... maybe not. Why not simply (defn unzip-with [pred coll] [(filter pred coll) (remove pred coll)]) |
| 09:18 | cemerick | yeah, I already wrote that, but I figured there'd be a builtin. |
| 09:18 | cemerick | also, I'm not so hot on pred being invoked 2n with approaches like that |
| 09:18 | cemerick | picky, picky :-) |
| 09:19 | kotarak | hmmm... How would this be done lazily w/o calling pred 2n times? |
| 09:19 | kotarak | You would need some kind of Queue, no? |
| 09:20 | kotarak | When I ask one seq and it finds an item, which doesn't belong there, it stuffs it into the Queue of the other. |
| 09:20 | Holcxjo | First create a (lazy) sequence of ((filter pref elem) elem) tuples and then split them? |
| 09:23 | Holcxjo | Something like this? (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))])) |
| 09:27 | lisppaste8 | cemerick pasted "split without 2n pred invocations (sloppy first cut)" at http://paste.lisp.org/display/76458 |
| 09:28 | cemerick | that's super-sloppy, but I gotta run for a bit |
| 09:28 | kotarak | Well, it's not lazy? |
| 09:28 | cemerick | right, not lazy, but I don't care about that in this case |
| 09:30 | cemerick | my predicate in this case is pretty expensive and all of the results will be consumed anyway |
| 09:41 | pjstadig | I got past the classloader issue |
| 09:41 | pjstadig | now i (when starting a second repl) i get an arity exception |
| 09:42 | pjstadig | wrong number of args passed to: core$map |
| 09:42 | pjstadig | it happens in clojure/main.java when it tries to require the clojure.main namespace on line 38 |
| 09:43 | pjstadig | i can connect JSwat and step through the code, bouncing between the java code and code in core.clj |
| 09:43 | pjstadig | mind blowing |
| 09:49 | timothypratley1 | wohooo I solved by set! woes: (clojure.lang.Reflector/setInstanceField gbc (name (first c)) (second c)) |
| 09:49 | timothypratley1 | who needs stinking special forms? |
| 09:53 | timothypratley1 | pjstadig are you able to debug exceptions with JSwat or is it too late by then? |
| 09:56 | pjstadig | i can step through until the exception happens |
| 09:56 | pjstadig | and when an uncaught exception happens i can see the call stack |
| 09:56 | pjstadig | and poke around |
| 09:56 | timothypratley1 | great! |
| 09:57 | pjstadig | this is weird |
| 09:57 | pjstadig | the problem appears to be in the 'spread function |
| 09:57 | pjstadig | actually 'nil? |
| 09:58 | danlarkin | well spread is private to core.clj |
| 09:58 | Hooke | hello |
| 09:58 | pjstadig | 'nil? is returning true for (nil? ArraySeq instance) |
| 10:00 | danlarkin | (doc nil?) |
| 10:00 | clojurebot | Returns true if x is nil, false otherwise.; arglists ([x]) |
| 10:00 | pjstadig | hehe |
| 10:00 | pjstadig | oh good point |
| 10:01 | pjstadig | so apply is calling (. f (applyTo (spread args))) |
| 10:01 | Hooke | I'm trying technomancy's emacs clojure-mode. The clojure-install command gives me the error "(Shell command failed with error)" can anyone help, plz |
| 10:03 | pjstadig | spread returns nil |
| 10:04 | pjstadig | so it tries to apply f (which is loadlibs) to null |
| 10:04 | pjstadig | which is where i'm getting my exception |
| 10:05 | danlarkin | spread returns nil because the collection you pass is nill |
| 10:05 | danlarkin | I'm assuming |
| 10:07 | shoover | danlarkin: what's the problem with jswat? are you on JDK 1.6? |
| 10:08 | pjstadig | no the collection is not nil |
| 10:08 | pjstadig | the collection is [:require 'clojure.main] |
| 10:09 | danlarkin | shoover: java 1.5.0_16-133 on osx 10.5, when I launch it crashes with an NPE |
| 10:10 | shoover | danlarkin: I think it needs 1.6 |
| 10:11 | danlarkin | pjstadig: spread "expands" to as many args as the function accepts, what's the arglist on the function you're trying to call? |
| 10:12 | danlarkin | shoover: that would explain it, then, thanks |
| 10:12 | cooldude127 | does swank-clojure allow using jswat for debugging without writing a shell script to start clojure? |
| 10:13 | shoover | danlarkin: you'll need to wipe jswat and reinstall, taking pains to associate it with jdk 1.6. unfortunately I can't remember exactly how I did that |
| 10:13 | shoover | cooldude127: yes, it has a variable for extra jvm args |
| 10:13 | cooldude127 | shoover: great |
| 10:32 | cooldude127 | jswat is cool |
| 10:47 | pjstadig | nope it's not a problem with 'nil? |
| 10:47 | pjstadig | nil? is returning RT.F |
| 10:48 | pjstadig | for some reason it is not thinking that Boolean.FALSE == Boolean.FALSE across VMs |
| 10:48 | rhickey | pjstadig: ouch |
| 10:48 | Holcxjo | A very philosophical POV |
| 10:48 | rhickey | that will be a problem |
| 10:49 | pjstadig | it is probably something i'm doing wrong |
| 11:14 | kotarak | cemerick: how about this unzip-with? http://paste.pocoo.org/show/106457/ |
| 11:15 | kotarak | general comments welcome |
| 11:25 | cgrand | kotarak: I think you don't need to use PersistentQueue: vectors can suffice |
| 11:27 | cgrand | in make-seq, replace the cons with a concat and the alter by a ref-set [] |
| 11:28 | kotarak | cgrand: ah, ok. :) Hadn't thought of that. |
| 11:28 | kotarak | Just a sec. |
| 11:30 | kotarak | http://paste.pocoo.org/show/106463 |
| 11:50 | rhickey | (defn unzip-with [pred coll] |
| 11:50 | rhickey | (let [pvs (map #(vector (pred %) %) coll)] |
| 11:50 | rhickey | [(remove nil? (map (fn [[p v]] (when p v)) pvs)) |
| 11:50 | rhickey | (remove nil? (map (fn [[p v]] (when-not p v)) pvs))])) |
| 11:54 | kotarak | rhickey: yes. Holcxjo proposed something similar. |
| 11:55 | Holcxjo | rhickey: Can't the "(remove nil? (map ..." be done with some for ? |
| 11:56 | rhickey | kotarak: sorry, didn't see that |
| 11:56 | Holcxjo | Also: What if any element *is* nil ? It'll appear on neiher of the output lists |
| 11:57 | kotarak | rhickey: np :) |
| 11:59 | rhickey | Holcxjo: heh, just doing that, did you already post it? |
| 12:01 | lisppaste8 | rhickey annotated #76458 "unzip-with" at http://paste.lisp.org/display/76458#1 |
| 12:01 | Holcxjo | My solution was an ugly (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))])) |
| 12:01 | Holcxjo | Sorry for lack of formatting |
| 12:02 | Holcxjo | You version on pastebin is certainly nicer |
| 12:02 | Holcxjo | Hadn't thought of for until I saw your solution |
| 12:04 | Holcxjo | BTW: why "#(vector (pred %) %)" and not "#([(pred %) %])" ? Would you consider the latter too terse for readability? |
| 12:04 | kotarak | Holcxjo: #([]) is (fn [] ([])) |
| 12:05 | kotarak | Note the "call" to the vector. |
| 12:05 | Holcxjo | Bah -- the #() syntax is a bit too brittle for my brain |
| 12:07 | replaca | That is the one annoying thing to me about #(). It seems like about half the time I'm using it to create a quick vector. Well, that and the lack of nesting. :-) |
| 12:07 | kotarak | replaca: then simply use #(vector ....) |
| 12:15 | cemerick | kotarak, rhickey: thanks for the impls, I'll keep those under my belt for when I need laziness |
| 12:18 | replaca | kotarak: yeah, I do, it's just not as purty |
| 12:26 | te | rhickey: I just discovered your podcast on iTunes -- thanks! |
| 12:27 | te | rhickey: one other note -- you are a remarkably good speaker for a compsci guy |
| 12:29 | rhickey | te: thanks, although I'm not really a compsci guy |
| 12:30 | te | rhickey: you fooled me :) |
| 12:30 | te | rhickey: did i hear right that you're just a professional developer that got an itch one day? |
| 12:30 | mtz | :) |
| 12:31 | rhickey | te: yes, I'm just a developer |
| 12:31 | te | a good speaker AND humble |
| 12:31 | te | i'm beginning to like you more and more |
| 12:31 | te | :) |
| 12:32 | cemerick | wait, wait, wait -- a podcast, you say? :-D |
| 12:32 | te | indeed. |
| 12:32 | rhickey | cemerick: I think all the blip things end up as podcasts |
| 12:33 | te | It's just his video of clojre for lisp programmers |
| 12:33 | cemerick | ah, OK |
| 12:33 | te | or at least that's the one im watching right now |
| 12:33 | te | it would be cool to have someone comment weekly on the state of clojure, cool projects, etc. |
| 12:33 | te | community = win |
| 12:34 | te | err sorry: (= (community win)) |
| 12:35 | mtz | (profit community) |
| 12:36 | pjstadig | te: i would listen to your postcast |
| 12:36 | pjstadig | *podcast |
| 12:40 | zakwilson | "I'm not really a compsci guy" -- rhickey |
| 12:40 | zakwilson | And that's why you can get stuff done in Clojure. |
| 12:41 | gnuvince | For a non-compsci guy, you sure are knowledgeable about it |
| 12:42 | Raynes | "I should probably learn LISP, but it seems so foreign..." - Paul Graham |
| 12:42 | zakwilson | I keep saying that about Haskell. |
| 12:43 | rhickey | gnuvince: I mean I'm not a researcher or anything, just a practitioner |
| 12:43 | gnuvince | ok |
| 12:43 | BigTom | is rhickey one of Zed Shaw's Coming Professional Masters ? |
| 12:43 | BigTom | http://www.zedshaw.com/essays/master_and_expert.html |
| 12:43 | zakwilson | Though I think I may finally do it just to purify my mind after working on an especially bad PHP project (http://paste.lisp.org/display/76132). |
| 12:43 | Raynes | zakwilson: Haskell is fun. |
| 12:45 | zakwilson | Raynes: I keep hearing that, but I haven't quite figured out why monads work. I almost get it, but not quite. |
| 12:45 | Raynes | zakwilson: When they say it's a mindfuck - They mean it. |
| 12:46 | zakwilson | But I need to do *something* to purge the evil from my mind (look at the paste, really). |
| 12:46 | Raynes | However, I never got to the monads chapter. Haskell gains and loses my interest several times over time. |
| 12:46 | Raynes | Clojure stole my interest. |
| 12:46 | Raynes | My god. |
| 12:46 | Raynes | That's some nasty PHP. |
| 12:47 | zakwilson | I get FP. Really strong static typing makes sense, though I'm not good at using it. Monads are the part I really need to get. |
| 12:47 | zakwilson | Raynes: that printf call appered in three different files, slightly modified. The rest of the code is about as bad. |
| 12:47 | danlarkin | you can write bad code in any language |
| 12:48 | Raynes | danlarkin: But it's less hard to write it in Haskell. |
| 12:48 | Raynes | In Haskell you either write good code or don't write it at all. There aren't many options. |
| 12:48 | zakwilson | danlarkin: yes you can, and I'm not blaming PHP for the above badness. You could, in fact write essentially the same thing in Haskell. |
| 12:48 | danlarkin | or clojure for that matter |
| 12:49 | Raynes | Clojure is a different story. |
| 12:49 | zakwilson | Anything with printf or something like it... which is pretty much every general-purpose language. |
| 12:49 | Raynes | It's easier to write bad code in Clojure than Haskell I feel, because you aren't held back by Haskell's strongness. |
| 12:49 | gnuvince | I agree |
| 12:49 | Raynes | Clojure will pat you on the back, Haskell will smack your face. |
| 12:49 | Lau_of_DK | Rich might smack you aswell Raynes - Good evening all =) |
| 12:50 | gnuvince | Haskell is like Gunnery Sergeant Hartman from Full Metal Jacket |
| 12:50 | Raynes | You didn't see the context, it wasn't anything bad about Clojure. |
| 12:50 | gnuvince | It's gonna yell at you until all your shit is nice and square |
| 12:50 | Lau_of_DK | I know Raynes , I was just making a funny |
| 12:50 | Raynes | :p |
| 12:51 | Raynes | Good evening Lau_of_DK |
| 12:51 | zakwilson | Yes... Haskell will refuse to compile many common errors and warn you about a host of others. |
| 12:52 | BigTom | Hi |
| 12:52 | kotarak | gnuvince: and finally it gets shot? |
| 12:52 | BigTom | I am processing a log file with for, which is nice and simple and works |
| 12:52 | Lau_of_DK | leafw or someone today, mentioned that (int (+ 1/2 x)) is the best way of rounding in c and java - Why is that? |
| 12:52 | BigTom | now I want to sometimes generate a couple of lines for each log line |
| 12:52 | BigTom | is there a neat way of doing that? |
| 12:53 | cmvkk | hmm, so the for returns a list of lines? |
| 12:53 | BigTom | yup |
| 12:53 | gnuvince | kotarak: don't push analogies too far |
| 12:53 | Lau_of_DK | gnuvince: he always does that :) |
| 12:53 | cmvkk | i guess you could wrap each output in an extra list, then do (map concat ...) on the result |
| 12:53 | leafw | Lau_of_DK: (int (+ 0.5 x)) -- AFAIK, involves the least assembly instructions and does the right thing. |
| 12:54 | Lau_of_DK | isnt that a mapcat cmvkk ? :) |
| 12:54 | Lau_of_DK | ah ok |
| 12:54 | kotarak | BigTom: (mapcat (fn [one-line] [one-line1 one-line2 one-line3]) log-lines) |
| 12:54 | BigTom | cmvkk: that's a thought |
| 12:54 | BigTom | Hi kotarak :-) |
| 12:54 | leafw | Lau_of_DK: I guess the clojure version would be (int (+ (float 0.5) x)) |
| 12:55 | BigTom | Thanks, that'll get me going again |
| 12:55 | Lau_of_DK | leafw: no 1/2 works fine |
| 12:55 | leafw | Lau_of_DK: but 1/2 is not a primitive. |
| 12:55 | Lau_of_DK | ,(+ 1/2 (* 100 (/ 68 20))) |
| 12:55 | clojurebot | 681/2 |
| 12:55 | Lau_of_DK | oops, forgot int |
| 12:56 | Lau_of_DK | But yea, true, its not a primitive |
| 13:11 | Lau_of_DK | Gents - Ive made a little webservice using compojure and I want the result to be an image which contains 1 colored bar and a pie-chart - i which direction should I be looking to accomplish this? |
| 13:12 | danlarkin | definitely an image? or will you use a javascript api for charting? |
| 13:12 | kotarak | Lau_of_DK: dejcartes? |
| 13:12 | Lau_of_DK | dejcartes is for swing apps I believe |
| 13:12 | Chouser | google charts |
| 13:12 | Lau_of_DK | danlarkin: I think I need to supply and image, which another sige can just incorporate ala <img src="myservice?arg=1"/> |
| 13:12 | kotarak | Lau_of_DK: it uses JFreeCharts, which can export images |
| 13:13 | Lau_of_DK | oh ok - I'll look into it |
| 13:13 | Chouser | you could use dejcartes to produce a .png, but google's service would allow you to let their servers do the work. |
| 13:13 | Lau_of_DK | But is it fast and stable? |
| 13:13 | gregh | you can have myservice?arg=1 redirect to google charts with the appropriate chart creation parameters |
| 13:14 | Lau_of_DK | I cant imagine GC being as flexibl as I need - The design its very clearly described |
| 13:14 | gregh | it's probably at least worth a look: http://code.google.com/apis/chart/ |
| 13:15 | Lau_of_DK | Thanks greg |
| 13:37 | candera | Anyone have a clue how a ref can get completely trashed? As in, I can still do (class @foo), but @foo results in an NPE. I can isolate so that commenting out one line of code makes the problem go away, but the line of code in question doesn't try to modify the ref... |
| 13:38 | candera | I hesitate to suggest a Clojure bug (since I know how often it turns out to be the app, not the RT), but that's my best theory at present. |
| 13:38 | jayfields | clojurebot url |
| 13:38 | jayfields | hmm, how do I get the url for pasting code? |
| 13:38 | candera | There's paste.lisp.org - is that the one you're thinking of? |
| 13:39 | jayfields | no, there's some way to get the clojurebot in this room to give you a url. |
| 13:39 | jayfields | @clojurebot url |
| 13:39 | jayfields | #clojurebot url |
| 13:40 | Chouser | lisppaste8: url |
| 13:40 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 13:40 | Chouser | candera: what does (class @foo) return? Can you do (def tmp @foo)? |
| 13:40 | jayfields | thanks Chouser. |
| 13:41 | Chouser | jayfields: np |
| 13:41 | candera | (class @foo) => clojure.lang.LazySeq |
| 13:42 | candera | I can (def tmp @foo), but evaluating tmp throws the same NPE. |
| 13:42 | replaca | candera: yeah, cause it's lazy til you try to get the head |
| 13:43 | replaca | candera: so when you try to evaluate the head (with @foo) the evaluation throws an NPE |
| 13:43 | replaca | candera: that's my guess anyway |
| 13:43 | candera | Makes sense. |
| 13:43 | candera | Still leaves me guessing as to what the problem is, however. :) |
| 13:47 | Chouser | you should get a stack trace from the NPE that shows the root cause |
| 13:49 | candera | Chouser: So, this is a game. The error that's thrown is from the next deref of the ref. The update occurs previously. If I make a change in the update code, it no longer barfs. |
| 13:53 | AWizzArd | what is an easy way to convert a java HashTable or HashMap into a Clojure map? |
| 13:53 | Chouser | right, the update code is apparently creating a new lazy seq |
| 13:53 | AWizzArd | is into the best way? |
| 13:53 | Chouser | candera: it's in the evaluation of one of the items in the lazy seq that the NPE is thrown. |
| 13:54 | candera | Chouser: Ah, duh. Man I thought I had finally internalized this laziness stuff... |
| 13:54 | candera | Chouser: Thanks! I'll proceed down that road. |
| 13:55 | Chouser | candera: here's a simple example, in case it helps: (def foo (lazy-cat [1 2 3] (.x nil))) |
| 13:55 | Chouser | (take 3 foo) will work fine |
| 13:55 | Chouser | but just foo by itself blows up, because the repl will evaluate the whole thing in order to print it. |
| 13:56 | Chouser | AWizzArd: unless you're going to "update" the map, you should be able to just pass around the Java collection. |
| 13:56 | candera | Chouser: yep. That makes sense. Thanks again! |
| 13:56 | AWizzArd | Chouser: well, in reality I have a HashMap with strings as keys. In Clojure I would prefer to have them translated into keywords |
| 13:56 | Chouser | AWizzArd: otherwise, (into {} the-map) |
| 13:58 | Chouser | AWizzArd: (zipmap (map keyword (keys the-map)) (vals the-map)) |
| 13:59 | Chouser | (reduce (fn [m [k v]] (assoc m (keyword k) v)) {} the-map) |
| 13:59 | AWizzArd | btw, does keys and vals guarantee the same order? |
| 14:00 | Chouser | if the underlying map does. I think but do not know that that's the case. |
| 14:00 | AWizzArd | provided no other thread writes to the map while we want to zipmap them, is it guaranteed that the key/value pairs will still match? |
| 14:01 | Chouser | AWizzArd: you should verify that or use the reduce version |
| 14:06 | lisppaste8 | jayfields pasted "user defined globals" at http://paste.lisp.org/display/76474 |
| 14:06 | lisppaste8 | jayfields annotated #76474 "using printer.clj" at http://paste.lisp.org/display/76474#1 |
| 14:08 | lisppaste8 | jayfields annotated #76474 "failing version" at http://paste.lisp.org/display/76474#2 |
| 14:09 | jayfields | okay, so I want to use (defonce *flag* ...) to allow users to set a flag when consuming my library, but when I try to set the flag and consume the printer class I get a failure (code available at the last link from lisppaste8) |
| 14:10 | jayfields | I can get around this issue by defining the *flag* in the same namespace, but that seemed like poor form, or is that the correct way? |
| 14:13 | tashafa | jayfields: dont know what you are trying to do, but have you tried "require" instead of "use" in the ns form |
| 14:14 | jayfields | nope, I check the docs. I don't know the difference. |
| 14:17 | lisppaste8 | tashafa annotated #76474 "using require" at http://paste.lisp.org/display/76474#3 |
| 14:19 | jayfields | that code executes without throwing an exception, but 'hello' is printed |
| 14:19 | tashafa | i think 'use' infers all the symbols in the corresponding namesapce into the current namespace |
| 14:19 | jayfields | because (I assume) *should-print* from helpers.printer is being used by print-hello |
| 14:20 | jayfields | what I want to be able to do is define a flag that will cause the print not to happen. |
| 14:22 | tashafa | i have no idea what *should-print* does... maybe someone more knowlegabel can help |
| 14:23 | jayfields | *should-print* is just the name of my flag |
| 14:23 | jayfields | you could just as easily use *my-flag* |
| 14:23 | jayfields | there's nothing special about it. |
| 14:23 | tashafa | and if that flag is set println shouldnt print? |
| 14:23 | tashafa | set to false that is |
| 14:23 | kefka | If I call a function at a top-level (using emacs shell) that blocks, is there any way to stop it without killing the whole toploop? |
| 14:24 | jayfields | did you see helpers.printer? |
| 14:24 | ayrnieu | kefka - no. |
| 14:24 | tashafa | yeah |
| 14:25 | jayfields | oh, sorry, I missed some code, one second. |
| 14:25 | lisppaste8 | jayfields annotated #76474 "print-hello that notices *should-print*" at http://paste.lisp.org/display/76474#4 |
| 14:26 | jayfields | sorry, missed the conditional logic the first time. |
| 14:27 | jayfields | so, given the last annotation, what I'm trying to do is let someone defonce *should-print* to false if they don't want the print to happen. |
| 14:27 | tashafa | i think you may want to use a ref |
| 14:29 | tashafa | or be more functional |
| 14:31 | Raynes | Needs moar functional. |
| 14:31 | tashafa | Raynes: ha, you know what i mean |
| 14:32 | hiredman | why use a ref? |
| 14:32 | jayfields | okay. so the problem is, I need to define a test, and in one context, immediately run that test, and in another context, don't do anything. |
| 14:32 | cemerick | my first day seriously using a hierarchy -- I seem to be writing a lot of code like (some #(isa? (class foo) %) [::type1 ::type2 ::typeN]). Is there a better (and likely faster) way to work with determine if an object is a match against some set of hierarchy "types" that are only available at runtime? |
| 14:32 | hiredman | if you are using a ref you shouldn't use ** |
| 14:32 | jayfields | I'm writing some tests that I want to execute one at a time sometimes, but also as part of a larger suite at other times |
| 14:33 | hiredman | ** is used to mark things that are intended to be dynamicaly rebound |
| 14:33 | jayfields | I created a macro that defines the test (using deftest from test-is) and runs the test when I want to execute individually |
| 14:33 | ayrnieu | jayfields - when you put this a library and have someone else use it, their defonce'd *should-print* will appear in another namespace. If you also export a (def *should-print* true) , then they could (bindings [*should-print* false] ...) to disable that. If you want a toplevel setting, then offer a ref for them to set or export a 'config' or like function that they can pass keywords to. |
| 14:34 | Raynes | I need to buy some ink so I can print the CA. |
| 14:34 | tashafa | hiredman: true, no **, @your-flag |
| 14:34 | jayfields | but I also want to not execute the individual test and run them all as a suite. |
| 14:36 | tashafa | Reaynes: CA? |
| 14:36 | lisppaste8 | jayfields pasted "run individual tests" at http://paste.lisp.org/display/76476 |
| 14:36 | shoover | jayfields: have you looked at binding? by definition it establishes a binding per thread, but it works great for doing different things in different contexts |
| 14:37 | hiredman | ^- |
| 14:37 | hiredman | binding and set! |
| 14:37 | lisppaste8 | jayfields annotated #76476 "with *execute-individual-test* set to do nothing" at http://paste.lisp.org/display/76476#1 |
| 14:37 | hiredman | re-defing is bad, don't do it |
| 14:37 | ayrnieu | jayfields - ^ my last answer |
| 14:37 | jayfields | I get binding, but it doesn't work in my case because I want the code to execute without doing anything extra when run in isolation. |
| 14:38 | hiredman | ,(doc set!) |
| 14:38 | clojurebot | java.lang.Exception: Unable to resolve var: set! in this context |
| 14:38 | hiredman | bah |
| 14:38 | ayrnieu | jayfields - OK, now read that last part. Use a ref internally but export a nice function by which they can control your library's behavior. |
| 14:38 | hiredman | ugh |
| 14:43 | tashafa | what ayrnieu said... hiredman: are you disagreeing? |
| 14:44 | jayfields | okay, so in my test_runner namespace I'll use a ref, but I'll also create a function that changes that ref, right? And, couldn't I just use an atom? |
| 14:45 | hiredman | ,(binding [*in* 1] (set! *in* 2) (println *in*)) |
| 14:45 | clojurebot | 2 |
| 14:45 | hiredman | Yes |
| 14:45 | ayrnieu | jayfields - yes, for the sake of offering decent interface that you can extend later. You could. |
| 14:46 | hiredman | the mechanism used for setting things like that in core.clj is set! |
| 14:47 | hiredman | ,(do (set! *in* 2) (println *in*)) |
| 14:47 | clojurebot | java.lang.IllegalStateException: Can't change/establish root binding of: *in* with set |
| 14:47 | hiredman | I see |
| 14:49 | hiredman | well |
| 14:49 | hiredman | *cough* |
| 14:49 | shoover | jayfields: can you paste examples of calling into helpers.test_runner? |
| 14:49 | hiredman | if you do go the ref route, you will most likely want an atom instead |
| 14:50 | candera | Chouser: your advice was helpful in tracking down the problem. However, it's still weird: if I alter a vector via concat without first materializing it via vec, it still blows up. |
| 14:50 | hiredman | unless there is the potentional for lots of contention |
| 14:50 | shoover | jayfields: re atom vs. ref, yes, atom is fine instead of ref if you don't need to synchronize with other state |
| 14:50 | candera | That is, (alter foo concat (additional-items)) blows on me, but (alter foo (fn [v] (vec (concat v (additional-items))))) does not. |
| 14:51 | ayrnieu | ,(concat [1] [2]) |
| 14:51 | clojurebot | (1 2) |
| 14:52 | lisppaste8 | jayfields annotated #76476 "example using test_runner" at http://paste.lisp.org/display/76476#2 |
| 14:52 | jayfields | shoover: there's a simple example |
| 14:55 | shoover | ok, and from the REPL you'd want that def-test to define and run the test, but from a suite you'd want to define everything and then run them all at the end? |
| 14:56 | jayfields | shoover: I'm doing it in IntelliJ with La Clojure, but I believe the result is the same. |
| 14:56 | Victorr | hello, I can't get Slime to work with clojure, I get "java.lang.Exception: Unable to resolve symbol: lazy-seq in this context (core.clj:70)", does anyone have any hint? |
| 14:57 | shoover | how about defining the default to actually run an individual test, so that works with IntelliJ, then define a suite-runner function that binds *execute-individual-test* to do nothing and inside that binding runs all the tests? |
| 14:57 | Victorr | I'm using the latest slime/swank/clojure from their repositories |
| 14:57 | hiredman | Victorr: it has come up before |
| 14:58 | AWizzArd | ,(map identity {:a 1, :b 2}) |
| 14:58 | clojurebot | ([:a 1] [:b 2]) |
| 14:58 | hiredman | Victorr: can you start the repl by itsself? |
| 14:58 | AWizzArd | Is there a function that will put the key/value pairs of a java HashMap or HashTable into a vector, as in that example above? |
| 14:58 | Victorr | hiredman: I can |
| 14:59 | Victorr | hiredman: it seems to me that perhaps lazy-seq moved? It is in clojure-contrib, yet I don't see a (:use) statement for it in swank's core.clj |
| 14:59 | hiredman | nah |
| 15:00 | shoover | jayfields: actually, I see that because your macro expands to code to run the test right away, you will need to use an atom or find a way for the suite to actually load tests.heartbeat's code in a binding that nulls out *execute-individual-test* |
| 15:00 | hiredman | Victorr: I would check again that you have the latest everything |
| 15:00 | shoover | or manually def it in your IntelliJ interactive session to actually do something |
| 15:00 | Victorr | I just checked out from their repositories just now :-( |
| 15:01 | hiredman | I don't use emacs, but other people have come in here with that Exception before |
| 15:01 | Victorr | google is not turning up anything, unfortunately |
| 15:01 | hiredman | I have four or five hits for that exception in my irclogs |
| 15:02 | Victorr | ok, I'll see if I can irc logs for this channel.. |
| 15:02 | shoover | Victorr: lazy-seq is defined in clojure.core in versions of clojure as of a few weeks ago. If it doesn't exist, swank is not running in a recent enough version of clojure |
| 15:03 | shoover | perhaps your swank-clojure settings are looking at the wrong clojure, or you haven't rebuilt clojure.jar? |
| 15:03 | Victorr | ok, I'm pretty sure I just downloaded the latest clojure, but I'll try again |
| 15:03 | Victorr | I'll build from source |
| 15:03 | hiredman | the latest release is way old |
| 15:04 | hiredman | and I am sure the latest swank/slime/etc won't work with it |
| 15:04 | Victorr | hiredman, thanks a lot, indeed building clojure from source fixed it! |
| 15:08 | cooldude127 | did PersistentQueue disappear or something? |
| 15:09 | kotarak | cooldude127: just used it today clojure.lang.PersistentQueue/EMPTY |
| 15:10 | cooldude127 | shouldn't have, looks like it's in the source tree. so why does simply typing clojure.lang.PersistentQueue into the REPL spit an error |
| 15:10 | cooldude127 | i have some code that was using it and worked fine, and now when i try to load that file it whines |
| 15:10 | jayfields | thanks shoover. |
| 15:10 | kotarak | cooldude127: well. it does not for me |
| 15:11 | kotarak | ,clojure.lang.PersistentQueue |
| 15:11 | clojurebot | clojure.lang.PersistentQueue |
| 15:13 | cooldude127 | ok, i did ant in the clojure dir, killed SLIME, brought it back and we're good |
| 15:13 | cemerick | it would be very handy if when-let could accept more than one binding, returning nil if any binding in the binding-form is nil |
| 15:14 | ayrnieu | cemerick - 'whereas' is a name for a syntax like this. It makes some legalistic sense :-) |
| 15:14 | cemerick | ayrnieu: is that what CL calls it? |
| 15:15 | ayrnieu | cemerick - CL doesn't have a name for it, but the name came up in a discussion on comp.lang.lisp |
| 15:15 | cemerick | ah |
| 15:16 | cemerick | it doesn't seem like another name should be at all necessary |
| 15:16 | cemerick | at least given when-let's general charter |
| 15:18 | ayrnieu | yeah, the limitation is arbitary. I'll post a patch. |
| 15:18 | taggart | ,(abs -2) |
| 15:18 | clojurebot | java.lang.Exception: Unable to resolve symbol: abs in this context |
| 15:18 | jwinter | ,(Math/abs -1) |
| 15:18 | clojurebot | 1 |
| 15:19 | taggart | aha interop |
| 15:19 | jwinter | :) |
| 15:20 | taggart | am I correct, that that is calling java.lang.Math.abs()? |
| 15:20 | taggart | or is it a namespaced clojure func? |
| 15:20 | ayrnieu | that is calling Math.abs() |
| 15:20 | cooldude127 | taggart: you should look at clojure.contrib.math |
| 15:21 | taggart | ah yes thanks |
| 15:21 | cooldude127 | it provides better definitions of certain math functions like abs and sqrt that work on all numeric types |
| 15:21 | cooldude127 | including clojure's ratios |
| 15:22 | jwinter | clojure.contrib.math url:http://github.com/kevinoneill/clojure-contrib/blob/a19a1d1921618fe802e57fb835eb98c2164e51ba/src/clojure/contrib/math/tests.clj |
| 15:26 | tashafa | question, this might not even apply to clojure so please forgive me |
| 15:27 | cooldude127 | go for it |
| 15:27 | tashafa | im using the lazy-xml from clojure.contrib to parse xml from a url |
| 15:27 | tashafa | im getting the sax parse error "Content in prolog" |
| 15:28 | tashafa | and i know the cause |
| 15:28 | Chouser | tashafa: what's the value of clojure.contrib.lazy-xml/has-pull |
| 15:28 | Chouser | oh. |
| 15:29 | Chouser | good, then. :-) |
| 15:29 | lisppaste8 | ayrnieu pasted "n-binding when-let" at http://paste.lisp.org/display/76480 |
| 15:29 | tashafa | the xml from the server doesnt start with <?xml ... ?> |
| 15:30 | tashafa | anyway i can modify the stream before i send it to parse-trim |
| 15:31 | lisppaste8 | ayrnieu annotated #76480 "oh, right, we have zero? at this point" at http://paste.lisp.org/display/76480#1 |
| 15:32 | tashafa | Chouser: has-pull is false |
| 15:33 | tashafa | The exact SaxParseException is "Content is not allowed in prolog." |
| 15:33 | Chouser | tashafa: ok, that just means you're a sax parser (instead of pull parser) running in its own thread using a blocking queue for communication with the main thread. |
| 15:35 | tashafa | ok... so i need to chage has-pull to true? |
| 15:35 | Chouser | nono, it's fine. |
| 15:35 | Chouser | but since you were getting an error from the parser, it might be useful to know which parser. |
| 15:36 | Chouser | if you don't specify one, it'll use the pull parser if available, otherwise the builtin sax parser |
| 15:37 | tashafa | has-pull is def'ed false |
| 15:37 | cemerick | ayrnieu: looks good, but it should probably assert (pos? (count bindings)) too |
| 15:38 | tashafa | so i dont see how it would use parse-seq-pull which in turn usess the pull parser |
| 15:39 | ayrnieu | cemerick - (let [] ...) also works. The user doesn't need to be protected here, and it helps with macros over when-let [including when-let itself, here]. |
| 15:40 | cemerick | ah, I didn't realize that (let [] ) worked. |
| 15:40 | tashafa | i do have XPP in my calss path |
| 15:40 | tashafa | classpath* |
| 15:42 | lisppaste8 | ayrnieu annotated #76480 "grammar-fix in assert string" at http://paste.lisp.org/display/76480#2 |
| 15:43 | tashafa | unless i change lazy_xml/has-pull to true in the source |
| 15:44 | tashafa | which i dont want to do |
| 15:44 | tashafa | :-/ |
| 15:47 | ayrnieu | (def x 1) (.bindRoot #'x 2) x => 2 |
| 15:49 | tashafa | anyways back to the original question |
| 15:50 | tashafa | can a stream be modified before being used? |
| 15:50 | tashafa | if so, how? |
| 15:51 | pjstadig | so after some tests with a simple java app... |
| 15:52 | pjstadig | it appears that I shouldn't expect Boolean.TRUE to be == across VMs |
| 15:52 | pjstadig | I could make Boolean.TRUE a root so that it is the same instance across VMs, but I get an error when I try to do that |
| 15:53 | pjstadig | so they either need to be compared using equals or .booleanValue == .booleanValue |
| 15:53 | pjstadig | or i could create another static field make it a root and make sure that field is always used instead of Boolean.TRUE and Boolean.FALSE |
| 15:54 | pjstadig | we almost have that with RT.T and RT.F, but there are some cases where Boolean.TRUE and Boolean.FALSE are used directly |
| 15:55 | tashafa | let me rephrase... |
| 15:56 | tashafa | all i need to do is parse some xml, the xml is valid but has no prolog and i have no way to modify the stream |
| 15:57 | tashafa | to add the prolog |
| 15:58 | tashafa | actually its the xml declaration |
| 15:58 | tashafa | and i think the saxparser chokes on this |
| 15:58 | Chouser | tashafa: (load "lazy_xml/with_pull") is supposed to re-def has-pull if it successfully loads xpp |
| 15:59 | tashafa | Chouser: but (load "lazy_xml/with_pull") is only called when has-pull is true |
| 16:00 | tashafa | ([s] (if has-pull (parse-seq-pull s) (parse-seq s startparse-sax))) |
| 16:00 | tashafa | (defn- parse-seq-pull [& _]) (try (load "lazy_xml/with_pull") ... |
| 16:01 | dcnstrct | Clojure + HtmlUnit FTW!! it's the ultimate web-interaction testing system. It totally blows away any of the Ruby libs for this kind of thing. |
| 16:01 | tashafa | or i'm i missing somethign |
| 16:02 | tashafa | brb... meeting :( |
| 16:03 | Chouser | tashafa: no, that code is unusual and confusing. It may be buggy, but not in the ways you've mentioned yet. |
| 16:03 | Chouser | tashafa: feel free to ping me when you get back. |
| 16:03 | dcnstrct | infact I'm finding so many java libraries that are better than most of the Ruby stuff I'm used to dealing with.. it's just that they were so painful to use before.. but now... |
| 16:07 | jwinter | what are you comparing HTMLUnit to? |
| 16:13 | Hooke | hi |
| 16:18 | Raynes | http://groups.google.com/group/LSharp/browse_frm/thread/f966f9a809cc702b Read what Rob said. (Yes this is relevant.) |
| 16:22 | tashafa | Im back |
| 16:22 | Chouser | Hooke: hi |
| 16:23 | Hooke | hi Chouser :) |
| 16:23 | Chouser | tashafa: the 'try' is not part of the definition of parse-seq-pull. It could probably do with a blank line in there. |
| 16:24 | tashafa | ah |
| 16:24 | tashafa | i see |
| 16:24 | Chouser | if you really want to try using xpp, which may or may not solve your real problem, you could try commenting out the try and catch parts |
| 16:25 | Chouser | that should give you a stack trace of what's actually failing in with_pull |
| 16:29 | tashafa | ok, so there isnt a way to add the xml declaration to an xml stream |
| 16:31 | Chouser | I'm surprised you need it. let me try some things.. |
| 16:32 | Chouser | ok, the xpp parser doesn't complain when given a correct xml document with no <?xml?> header. |
| 16:35 | tashafa | cool |
| 16:36 | tashafa | aight let me see whats up |
| 16:36 | tashafa | IT keeps deleting my .emacs file |
| 16:36 | tashafa | they think its some sort of virus file |
| 16:37 | hiredman | makes sense to me |
| 16:40 | shoover | Hooke: I'm happy for you and sad that the conquest merits such elation |
| 16:40 | shoover | tashafa: THAT is a new one |
| 16:41 | shoover | +1 for emacs, -1 for emacs. dead even yet again |
| 16:41 | Hooke | shoover: thanks, .. I guess :D |
| 16:43 | Chouser | tashafa: I also get no error with the standard SAX parser. I think your problem must be somethine else? |
| 16:44 | tashafa | Chouser: for real |
| 16:44 | tashafa | shoover: if it doesnt look like a windows file and its sitting in root they delete it |
| 16:45 | Chouser | (clojure.contrib.lazy-xml/parse-trim (java.io.StringReader. "<foo/>")) |
| 16:45 | shoover | tashafa: that's understandable. can you put it in your user profile directory? |
| 16:46 | tashafa | yeah thats what i need to do |
| 16:49 | tashafa | chouser: if i give you the url to the xml could you try it on your end? |
| 16:49 | Chouser | sure |
| 16:50 | tashafa | pm'ed |
| 16:56 | cemerick | if-let has the same limitation of a single binding form as when-let. That probably makes more sense, though (especially since one wouldn't know what bindings are false in the else branch). |
| 17:02 | ayrnieu | cemerick - 'none of them' is wise. |
| 17:05 | cemerick | ayrnieu: what made me think of it is a situation where I needed to test whether any of a set of bindings were true, so I don't know about the friendliness/obviousness of that. |
| 17:10 | Raynes | (doc defonce) |
| 17:10 | clojurebot | defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated; arglists ([name expr]) |
| 17:10 | Raynes | Lot's of def's. |
| 17:23 | replaca | tashafa: re: .emacs on Windows, you can set your HOME environment var and then put your .emacs file there instead of in c:\ |
| 17:25 | tashafa | Chouser: figured it out |
| 17:25 | Chouser | ah, great, what was it? |
| 17:26 | tashafa | the respponse from the server is compressed |
| 17:26 | tashafa | gzip |
| 17:26 | Chouser | ah, ok. |
| 17:26 | tashafa | now to figure out how to umcompress |
| 17:27 | Chouser | there's a java library for that! TM |
| 17:27 | tashafa | un* |
| 17:28 | Chouser | java.util.zip.GZIPInputStream |
| 17:29 | tashafa | thanks |
| 17:39 | cmvkk | it's not safe to use | as a symbol right? |
| 17:40 | cmvkk | or rather, it's possible/likely that it will be used for something in the future? |
| 17:47 | tashafa | chouser: golden! thanks for all your help man! |
| 17:47 | tashafa | Chouser: golden! thanks for all your help man! |
| 17:49 | kotarak | cmvkk: the allowed characters for a symbol are detailed on the clojure site: http://clojure.org/reader I would only rely on those. |
| 17:51 | cmvkk | kotarak, yeah, that's why I asked, actually. Just wondering if there was any updated information along those lines. |
| 17:51 | cmvkk | thanks though |
| 18:01 | tashafa | ftw, add an item to the end of a list? |
| 18:02 | jakewins | Hi! I'm really wanting to try clojure out, but I am something of a newbie in Java-environments, and as such am having trouble getting my first clojure project to run. |
| 18:02 | jakewins | Could someone point me to a hello-world example or something? |
| 18:02 | tashafa | ,"hello world" |
| 18:02 | clojurebot | "hello world" |
| 18:02 | jakewins | lol |
| 18:03 | jakewins | Thanks. I need it to build together with a java application though, |
| 18:03 | tashafa | jakewins: do you already know your way around the repl? |
| 18:03 | jakewins | Tashafa: I know my way around nothing, I am afraid |
| 18:04 | tashafa | what exactly are you trying to build |
| 18:05 | tashafa | or from what programming language are you coming from |
| 18:05 | tashafa | ? |
| 18:05 | tashafa | web, desktop, etc.. |
| 18:05 | jakewins | Php mostly, some c |
| 18:06 | jakewins | And I know java as a language, ie, I can write pretty decent applications |
| 18:06 | jakewins | So I can get a normal java app to run without any trouble |
| 18:06 | jakewins | What I want to do is go into "clojure-land" from my java class |
| 18:07 | jakewins | One sec |
| 18:08 | tashafa | ftw, add an item to the end of a list? cons |
| 18:08 | tashafa | god, im losing it today |
| 18:08 | jakewins | From my main()-method in java, I run something in the likes of |
| 18:08 | jakewins | clojure.lang.RT.var("com.example.clotest.test", "main").invoke(args); |
| 18:08 | jakewins | Which indeed launches clojure |
| 18:09 | jakewins | But it launches it into the interactive-loop |
| 18:09 | jakewins | or whatever it's referred to as |
| 18:09 | jakewins | ie. I don't think it even runs the clojure function "main" |
| 18:10 | tashafa | nah...clojure doesnt work anything like java |
| 18:10 | Hooke | jakewins, I'm new too, but I'd say that the first you have to decide is what IDE to use. if you want netbeans, there the "enclojure" plugin. if you like emacs, there's clojure-mode |
| 18:11 | jakewins | Tashafa: Which is what I'm after :) My companies clients demand stuff that runs on java-platforms, but I'm not a fan of java, which is why i'd like to try this out |
| 18:11 | jakewins | Hooke: I use eclipse |
| 18:11 | jakewins | I found a clojure plugin for it, I haven't been able to figure out if it's any good though |
| 18:12 | jakewins | *company's, sorry bout the spelling |
| 18:12 | tashafa | i tried the eclipse plugin for clojure a while back and it was a bit immature, dont know how well it fairs now |
| 18:12 | Hooke | ah, yeah, I installed that one too. didnt try it much though |
| 18:13 | tashafa | fares* |
| 18:13 | jakewins | Hooke, tashafa: I dunno, I haven't been able to really try it yet :) |
| 18:14 | Hooke | now I configured emacs according to http://riddell.us/clojure/ |
| 18:14 | Hooke | if you do emacs, i think thats best |
| 18:14 | tashafa | i'm also coming from eclipse... i would suggest emacs |
| 18:14 | Hooke | especially the example, ants |
| 18:14 | Hooke | ants.clj |
| 18:14 | jakewins | Hmm.. I'll definately looked into that |
| 18:14 | Hooke | very impressive |
| 18:14 | tashafa | its a step learning curve, but worth every minute once you are comfortable |
| 18:15 | Hooke | if you try emacs, try the paredit mode |
| 18:15 | tashafa | ants.clj is pretty much on the advanced side |
| 18:15 | jakewins | Tashafa: I gave emacs a shot a while back, and I can see that once you've got the basic keyboard-shortcuts down it will rock your world |
| 18:16 | tashafa | what is the paredit mode anyawas |
| 18:16 | cp2 | ants.clj is my favorite :) |
| 18:17 | Hooke | tashafa: it's for never having unballanced brackets |
| 18:17 | jakewins | Oh well, I'll dig deeper into this at work tomorrow, I've gotta get up in 7 hrs |
| 18:17 | jakewins | Thanks for your help guys |
| 18:18 | tashafa | im i just turn on the Paren Hihglight matching |
| 18:18 | tashafa | jakewins: come back on tomorrow |
| 18:18 | tashafa | we'll be here |
| 18:18 | Hooke | all commands do things to sexprs, like splice, nest, and so on, without ever deleting a bracket on one side only |
| 18:19 | tashafa | hmm i have to try it out |
| 18:20 | Hooke | http://www.emacswiki.org/cgi-bin/wiki/ParEdit |
| 18:20 | tashafa | ftw, add an item to the end of a list? cons -> false |
| 18:22 | Hooke | http://mumble.net/~campbell/emacs/paredit.html |
| 18:24 | Hooke | tashafa: sorry, I dont get what you mean |
| 18:25 | tashafa | Hooke: sorry i was asking how you would add an item to the end of a list |
| 18:26 | Hooke | ah, yeah, I understand that, but .. do you mean bringing an item from outside or writing it .. I mean, write it you always can |
| 18:26 | tashafa | from outside |
| 18:26 | Hooke | bringing it from after the list would be the command paredit-forward-slurp-sexp |
| 18:26 | tashafa | i guess |
| 18:27 | tashafa | nah not talking ide anymore |
| 18:27 | Hooke | C-), C-<right> |
| 18:28 | Hooke | ahm, sorry, what are you talking about now? |
| 18:28 | tashafa | ,(cons '( 1 2 3) 4) |
| 18:28 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 18:29 | tashafa | ,(conj '( 1 2 3) 4) |
| 18:29 | clojurebot | (4 1 2 3) |
| 18:29 | schoppenhauer | ,blah |
| 18:29 | clojurebot | java.lang.Exception: Unable to resolve symbol: blah in this context |
| 18:29 | tashafa | ,(cons 4 '( 1 2 3)) |
| 18:29 | clojurebot | (4 1 2 3) |
| 18:29 | schoppenhauer | ,(lambda () ()) |
| 18:29 | clojurebot | java.lang.Exception: Unable to resolve symbol: lambda in this context |
| 18:29 | schoppenhauer | ,(fn () ()) |
| 18:29 | clojurebot | java.lang.NullPointerException |
| 18:29 | schoppenhauer | ,(fn [] ) |
| 18:29 | clojurebot | #<sandbox$eval__7396$fn__7398 sandbox$eval__7396$fn__7398@3813c> |
| 18:30 | schoppenhauer | ,(do (fn []) (fn [])) |
| 18:30 | clojurebot | #<sandbox$eval__7402$fn__7407 sandbox$eval__7402$fn__7407@12421db> |
| 18:30 | schoppenhauer | scnr |
| 18:31 | tashafa | is it even possible to add to the end of a list cause of lazy-seq? |
| 18:32 | tashafa | ,(conj [1 2 3] 4) |
| 18:32 | clojurebot | [1 2 3 4] |
| 18:32 | hiredman | ,(concat '(a b) |
| 18:32 | clojurebot | EOF while reading |
| 18:32 | hiredman | ,(concat '(a b) '(c)) |
| 18:32 | clojurebot | (a b c) |
| 18:32 | hiredman | but don't do that |
| 18:32 | tashafa | ok... |
| 18:32 | hiredman | lists are for fast adding to the head |
| 18:32 | tashafa | change to a vec and conj that |
| 18:33 | hiredman | ugh |
| 18:33 | tashafa | vec the list and then add it to the end |
| 18:34 | hiredman | I guess, but it would be to either always use a vector or always use a list |
| 18:34 | tashafa | turn the list into a vector and conjoin the item? |
| 18:35 | hiredman | you just said the same thing three times in a row |
| 18:35 | hiredman | and I said "ugh" the first time |
| 18:35 | tashafa | sorry i thought you didnt understand what i said |
| 18:35 | hiredman | ,(time (vec (range 1000))) |
| 18:35 | clojurebot | [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 13 |
| 18:35 | clojurebot | "Elapsed time: 0.999 msecs" |
| 18:36 | Hooke | ,(+ 2 2) |
| 18:36 | clojurebot | 4 |
| 18:36 | hiredman | ,(time (do (vec (range 100000)) nil)) |
| 18:36 | clojurebot | "Elapsed time: 66.523 msecs" |
| 18:36 | hiredman | I guess that could be acceptable |
| 18:39 | tashafa | no p i was applying a list to a partial struct ... |
| 18:39 | tashafa | so i jest changed the structure of the list |
| 18:39 | tashafa | so i just changed the structure of the defstruct* |
| 18:39 | tashafa | if that makes any sense |
| 18:40 | tashafa | i need to take a break... |
| 18:40 | tashafa | my typing is awful |
| 18:40 | tashafa | goodnight folks |
| 18:40 | Hooke | gnite taggart |
| 18:40 | Hooke | sorry |
| 18:40 | Hooke | gnite tashafa |
| 19:14 | stuhood | ,(class (vec (range 10))) |
| 19:14 | clojurebot | clojure.lang.LazilyPersistentVector |
| 19:14 | stuhood | hiredman: i thought 66ms looked suspicious... heh |
| 19:15 | stuhood | ,(class (doall (vec (range 10)))) |
| 19:15 | clojurebot | clojure.lang.LazilyPersistentVector |
| 19:16 | stuhood | ~source vec |
| 19:17 | stuhood | ,(class (to-array (range 10))) |
| 19:17 | clojurebot | [Ljava.lang.Object; |
| 19:18 | stuhood | nevermind... it wasn't actually being lazy. it's just that fast |
| 19:48 | yonatan__ | newbie question: any way to get a stack trace on an exception? |
| 19:49 | yonatan__ | i'm getting "java.lang.IndexOutOfBoundsException (bitmap.clj:0)" |
| 19:49 | yonatan__ | how do you debug this? |
| 19:52 | Chouser | yonatan__: you're at a regular repl? |
| 19:52 | yonatan__ | yeah |
| 19:52 | Chouser | (.printStackTrace *e) |
| 19:52 | yonatan__ | thanks! |
| 19:54 | Chouser | np |
| 19:55 | Drakeson | is this: (import '(org.postgresql Driver)) supposed to work, when I have obtained http://jdbc.postgresql.org/download/postgresql-8.3-604.jdbc4.jar ? |
| 19:57 | Chouser | yes. That .jar must be in your classpath. |
| 19:58 | Chouser | or must be in a directory named by -Djava.ext.dirs= |
| 20:02 | Drakeson | Chouser: thanks |
| 20:02 | jhawk28 | related to Issue 34: is there any good way to access the value of a Var in the dynamic scope on the Java side? |
| 20:07 | jhawk28 | I can look up the var using the find method, but it has the global value instead of the dynamic scope |
| 20:09 | Chouser | jhawk28: you'd have to be within dynamic scope, of course, but then you should be able to call the .get() method |
| 20:33 | jhawk28 | chouser: I think my issue is the dynamic scope |
| 20:42 | jhawk28 | Chouser: is there a reason why the eval reader does not have visibility of the *myVar* in: (binding [*myVar* false] #=(eval (def x 3))) |
| 20:43 | Chouser | forms are processed in several phases. string->data which is called "read", and that's when the #=() form is evaluated. |
| 20:43 | Chouser | then compilation, then eval. |
| 20:44 | jhawk28 | so, even though it is in the scope from a lexical perspective, it is not actually in the dynamic scope? |
| 20:45 | ayrnieu | jhawk, #=() is also not in the form's lexical scopes. |
| 20:46 | hiredman | the answer is, don't use #= |
| 20:47 | ayrnieu | jhawk - it's as if you were copying some text from one page to another by hand, and you resolved to always replace lowercase symbols with uppercase symbols, to always replace 'foo with (quote foo) , etc. So you do this -- and this is when #=() happens -- and *then* turn to what you've written and say: should I expand any macros, here? |
| 20:47 | ayrnieu | the answer is: understand what you're doing. |
| 20:49 | jhawk28 | hehe |
| 20:50 | gnuvince_ | Anybody knows git here? |
| 20:50 | ayrnieu | gnuvince - ask a question about it. |
| 20:54 | gnuvince_ | I think I found it |
| 20:55 | gnuvince_ | I had committed and pushed a file with a DB password |
| 20:55 | gnuvince_ | I wanted to rewrite the history |
| 20:55 | gnuvince_ | I think I found it |
| 21:37 | yangsx | what is the best way to get the numeric value of a char? |
| 21:37 | ayrnieu | ,(int \a) |
| 21:37 | clojurebot | 97 |
| 21:39 | yangsx | ayrnieu: thanks, I thought that's for numbers :) |
| 22:02 | hiredman | ~translate to ru: they just chug half-and-half in the morning |
| 22:02 | clojurebot | ??? ?????? chug ??????? ? ?????? ???????? ??? |
| 22:06 | drewr | ~translate to es: clojurebot is so crazy |
| 22:06 | clojurebot | clojurebot es tan loco |
| 22:12 | jhawk28 | clojurebot: where are you? |
| 22:12 | clojurebot | http://github.com/hiredman/clojurebot/tree/master |
| 22:56 | felzix | I find that if I define function A before function B then A cannot call B. Is there a way around this? |
| 22:57 | hiredman | ,(doc declare) |
| 22:57 | clojurebot | "([& names]); defs the supplied var names with no bindings, useful for making forward declarations." |
| 22:57 | felzix | ah, thank you :) |
| 22:58 | cooldude127 | is there any difference between def and declare in that case except that declare accepts multiple names? |
| 22:58 | cooldude127 | i.e. (def x) == (declare x) ? |
| 22:59 | felzix | cooldude127: no |
| 22:59 | felzix | it just maps over what you supply, def'ing it |
| 23:00 | felzix | but you can do lots at once :) |
| 23:00 | cooldude127 | felzix: so for the single case, it is the same? |
| 23:00 | cooldude127 | that's what i was asking |
| 23:00 | felzix | yes |
| 23:00 | cooldude127 | k, cuz i had been using def for that purpose |
| 23:00 | cooldude127 | didn't even know declare existed |
| 23:02 | felzix | me either. I'm still fuzzy on how globals work in clojure so I wasn't sure I could def things like that |
| 23:04 | cooldude127 | we don't call them globals :) |
| 23:04 | cooldude127 | do we? |
| 23:04 | hiredman | def once, run anywhere |
| 23:05 | cooldude127 | lol |
| 23:05 | felzix | ah |
| 23:06 | Chouser | they do the same thing, but they imply different things to the human reader. |
| 23:06 | Chouser | use 'declare' for forward declarations that will be re-def'ed. |
| 23:06 | cooldude127 | yeah i figured that was the ideal way |
| 23:07 | Chouser | use 'def' with no initial value for things that you will thread-local bind later. |
| 23:27 | dreish | ~translate to ru: I can eat glas, it does not hurt me. |
| 23:27 | clojurebot | ? ???? ?????? Glas, ??? ?? ?????? ???. |
| 23:27 | cooldude127 | where did that sentence come from? |
| 23:27 | dreish | If I'd spelled it correctly, it would have come from http://www.geocities.com/nodotus/hbglass.html |
| 23:27 | dulanov | ~trabsltae to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup. |
| 23:28 | clojurebot | excusez-moi |
| 23:28 | dreish | Which is in turn devoted to a long-extinct page from I'll say 1995. |
| 23:28 | dulanov | ~translate to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup. |
| 23:28 | clojurebot | ??? ?????? ?????? ?????? ????????, ????? ?? ???????? ??????? ????????? ???????, ????????????? ? ?????????? ??? ????? ?????????. |
| 23:50 | cooldude127 | can clojurebot translate to other languages? |
| 23:51 | cooldude127 | ~translate to es: your mother |
| 23:51 | clojurebot | tu madre |
| 23:51 | cooldude127 | that answers that |
| 23:53 | slashus2 | su madre? |
| 23:53 | cooldude127 | tu madre is the informal version |
| 23:54 | cooldude127 | ~translate to es: I'm on a boat mother fucker, don't you ever forget |
| 23:54 | clojurebot | Estoy en un barco de puta madre, �nunca se olvide |
| 23:54 | cooldude127 | lol |
| 23:56 | cooldude127 | ~translate to es: I'm on a boat, mother fucker, don't you ever forget |
| 23:56 | clojurebot | Estoy en un barco, hijo de puta, no te olvides nunca |
| 23:58 | cooldude127 | ~translate to ro: I'm on a boat, mother fucker, don't you ever forget |
| 23:58 | clojurebot | Sunt pe o barca, mama fraiere, nu te mai uita |