2011-01-30
| 02:37 | duck1123 | Does anyone know if CDT works with 1.3? I'm able to set breakpoints and step around, but whenever I try to reval, I get an exception |
| 06:23 | LauJensen | Morning all ya'll |
| 06:25 | robonobo | mornin' |
| 06:25 | bsteuber | hi |
| 07:57 | robonobo | is there a macro for (cond (= foo bar) (...) (= baz bar) (...) ...) |
| 07:57 | robonobo | ? |
| 07:59 | MayDaniel | robonobo: (case bar foo (..) baz (...)) or (condp = bar foo (...) baz (...)) |
| 07:59 | robonobo | MayDaniel: thanks! |
| 08:24 | pyr | hi |
| 08:24 | pyr | when starting lein repl, should i be able to directly access my namespaces ? |
| 09:11 | odyssomay | which is best? http://pastebin.com/5DcT5zM8 |
| 09:13 | cinch | pyr: yes, when you start the repl you're in the user namespace, then you can switch to another namespace with (in-ns 'my.name.space) |
| 09:16 | bsteuber | odyssomay: I'd use (reduce * (range 1 x)) |
| 09:16 | bsteuber | ,(reduce * (range 1 3)) |
| 09:16 | clojurebot | 2 |
| 09:17 | bsteuber | ,(reduce * (range 1 (inc 3))) |
| 09:17 | clojurebot | 6 |
| 09:18 | odyssomay | bsteuber: yes, that's alot better |
| 09:21 | odyssomay | More generally: is it OK to create different versions of a function wich is only used by the function itself? (as I did with fact2 in the paste above) |
| 09:22 | bsteuber | I think if it's not meant to be used from other functions, an inner function is cleaner |
| 09:23 | odyssomay | ok |
| 09:23 | bsteuber | or a private helper function |
| 09:30 | odyssomay | bsteuber: btw, using (reduce * (range 1 (inc x))) takes ~10ms with x=1000, recursively (with recur) it takes ~4ms |
| 09:44 | LauJensen | odyssomay: Like, that is just Hotspot warming up, test with Criterium |
| 09:49 | odyssomay | LauJensen: hotspot? |
| 09:49 | LauJensen | odyssomay: yes sir |
| 09:51 | LauJensen | odyssomay: grab this https://github.com/hugoduncan/criterium then run (bench :verbose ...) where ... is first your reducer version and second the recur version, then paste the results in here |
| 10:17 | no_mind | is there an online index for clojure symbols/operators such as ~@, ->, --> . Searching google for these is useless |
| 10:19 | opqdonut | clojuredocs.org is pretty nice |
| 10:20 | Vinzent | there is cheatsheet in pdf on clojure.org |
| 10:21 | mrBliss | no_mind: like opqdonut said: http://clojuredocs.org/quickref/Clojure%20Core |
| 10:44 | raek | how would you interleave two sequences (def a [0 1 2 3]) (def b [:a :b :c]) into (0 :a 1 :b 2 :c 3)? |
| 10:45 | raek | I'm only interested in interleaving two sequences, where the first one might have one element more than the second one |
| 10:45 | opqdonut | ,(flatten (map vector [0 1 2 3] [:a :b :c])) |
| 10:45 | clojurebot | (0 :a 1 :b 2 :c) |
| 10:46 | raek | the 3 is missing ;-) |
| 10:46 | opqdonut | yeah |
| 10:46 | tomoj | I think this works https://gist.github.com/73c9627bb97c36bbe6e0 |
| 10:46 | tomoj | gotta be a nicer way to do it of course |
| 10:46 | opqdonut | of course a recursive solution is easy to write |
| 10:51 | raek | my recursive solution: https://gist.github.com/802959 |
| 10:53 | raek | tomoj: opqdonut: thanks for the input |
| 11:22 | robonobo | i tried to make a lazy interweave as well, but the lazy part doesn't seem to work. https://gist.github.com/802982 What am i doing wrong? |
| 11:24 | Chousuke | robonobo: loop is not lazy |
| 11:25 | robonobo | is there something i could use in replacement? |
| 11:25 | raek | robonobo: you should do the work inside the lazy-seq form |
| 11:25 | Chousuke | what is interweave supposed to do? |
| 11:25 | odyssomay | LauJensen: http://pastebin.com/MarSzNJs |
| 11:25 | robonobo | Chousuke: Take two collections and return a lazy seq of alternating items |
| 11:25 | robonobo | from the first coll, then from the second etc until one of the |
| 11:25 | robonobo | collections is runs out of elements. |
| 11:25 | raek | robonobo: yes. ordinary recursive calls, but having the code that performs the recursive call inside a lazy-seq form |
| 11:25 | Chousuke | robonobo: interleave? :P |
| 11:26 | raek | (I renamed mine "alternate") |
| 11:26 | LauJensen | odyssomay: Would be great to see the code as well |
| 11:26 | robonobo | raek: so (lazy-seq (loop [] (recur)) ? |
| 11:27 | raek | almost. do the looping by recursive calls: (defn foo [x] (lazy-seq ... (foo (rest x)) ...)) |
| 11:27 | odyssomay | LauJensen: http://pastebin.com/pWNP7z7x |
| 11:27 | raek | all code inside lazy-seq will be delayed |
| 11:28 | raek | it will be evaluated when the you call seq (or any sequence function) on the object returned by the lazy-seq form |
| 11:28 | raek | s/when the you/when you/ |
| 11:28 | sexpbot | <raek> it will be evaluated when you call seq (or any sequence function) on the object returned by the lazy-seq form |
| 11:29 | LauJensen | odyssomay: I think it may be because fact4 is working on a seq and fact3 isnt. Also internalReduce is probably doing some optimization. |
| 11:30 | tomoj | &(do (map inc (lazy-seq (println "foo") '(3))) nil) |
| 11:30 | sexpbot | ⟹ nil |
| 11:30 | LauJensen | &(time (dotimes [i 1000] (loop [acc 1 x (range 1 100)] (if (seq x) (recur (* acc (first x)) (next x)))))) |
| 11:30 | sexpbot | ⟹ "Elapsed time: 122.954677 msecs" nil |
| 11:30 | LauJensen | &(time (dotimes [i 1000] (reduce * (range 1 100)))) |
| 11:30 | sexpbot | ⟹ "Elapsed time: 117.813001 msecs" nil |
| 11:33 | odyssomay | LauJensen: I see |
| 11:35 | raek | robonobo: to play around with laziness, I recommend something like this: https://gist.github.com/480608 |
| 11:36 | raek | try something like (def x (ask-the-user-seq)) and try to call (first x) (take 3 x) etc |
| 11:36 | robonobo | raek: thanks, I find laziness hard to wrap my brain around. Are there any good tutorials? |
| 11:38 | raek | well, there's this one: http://clojure.blip.tv/file/734409/ |
| 11:38 | raek | but it's slightly out of date |
| 11:39 | robonobo | the example you gave is a pretty good starting point |
| 11:39 | raek | (lazy-cons has been replaced by lazy-seq, empty seq and nil is not the same thing anymore) |
| 11:39 | raek | ,(doc lazy-seq) |
| 11:39 | clojurebot | "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it ... |
| 11:40 | pppaul | hey, i'm having problems with (ns mynamespace (:require [myfile :as :mycode]). clojure can't find myfile.clj even though it's in the same folder as the file looking for it |
| 11:41 | raek | I think the docs for lazy-seq accurately describes how it works. though it probably does not help you with getting a feel for how lazy seqs are written |
| 11:41 | raek | robonobo: also, check out this: http://clojure.org/lazy |
| 11:41 | pppaul | ,(#(% # (% %))) |
| 11:41 | clojurebot | No dispatch macro for: |
| 11:42 | raek | pppaul: are you using leiningen or cake? |
| 11:42 | pppaul | leiningen (but i'm outside of it now, running from emacs) |
| 11:42 | pppaul | should i start up my project from leiningen |
| 11:43 | raek | why? swank-clojure + slime allows you to have both... |
| 11:43 | pppaul | i cus i think my emacs is a bit broken (swank/slime problems) |
| 11:43 | pppaul | my slime is fucked |
| 11:44 | pppaul | is it hard to do this without swank/slime? |
| 11:44 | raek | I find it easiest to install slime from ELPA/package.el |
| 11:44 | raek | and then M-x slime-connect to the swank server |
| 11:44 | raek | that you start with "lein swank" at the terminal |
| 11:45 | pppaul | so, do i start up the server via lein, and then connect in emacs? |
| 11:45 | raek | managing the classpath yourself is (IMHO) not worth it |
| 11:45 | pppaul | will this solve the problem i'm having with clojure having the wrong classpath? |
| 11:45 | raek | pppaul: yes |
| 11:45 | pppaul | booooo classpath |
| 11:45 | raek | lein is made for handling the classpath |
| 11:45 | pppaul | ok, time to fix slime |
| 11:46 | pppaul | is cake easier? |
| 11:46 | raek | https://github.com/technomancy/swank-clojure |
| 11:46 | raek | I would say it's fairy equivalent |
| 11:46 | raek | you use it the same way |
| 11:46 | pppaul | i don't know the difference |
| 11:47 | raek | it started as a separate project. lein and cake are now very similar for basic tasks |
| 11:47 | raek | the swank-clojure readme (see previous link) contains most that you need to use swank-clojure and slime |
| 11:49 | raek | if you use technomancy's emacs-starter-kit, installing slime is even more simpler, since you have package.el from the beginning |
| 11:50 | pppaul | ok, i didn't do the starter kit, i'll try that too |
| 11:50 | pppaul | i have problems installing slime or swank-clojure in emacs now |
| 11:50 | pppaul | troubleshooting time |
| 11:50 | raek | anyway, beware that the 'swank-clojure.el' emacs file (which used to let you start a swank server by running M-x slime) is deprecated |
| 11:51 | raek | don't install swank-clojure in emacs |
| 11:52 | raek | technomancy's Durendal project is a good replacement for it. it uses leiningen to do its tasks, but makes it easy to call from emacs |
| 11:55 | raek | there's two things called "swank-clojure": 1) the clojure library swank-clojure and 2) the deprecated emacs file "swank-clojure.el", which was used for starting 1) |
| 12:20 | no_mind | how do I include a clojure lib for use in repl / |
| 12:22 | markskilbeck | no_mind: http://clojure.org/libs |
| 12:22 | tomoj | how do you get at a public field with the same name as a public nullary method? |
| 12:23 | tomoj | need to read it I mean |
| 12:23 | raek | tomoj: does Foo/bar for the field and (Foo/bar) for the nullary method work? |
| 12:24 | tomoj | instance fields and methods, I should've said |
| 12:24 | raek | no_mind: use a build tool like leiningen or cake |
| 12:25 | raek | ,(.width (java.awt.Dimension. 1 2)) ; <-- instance field |
| 12:25 | clojurebot | 1 |
| 12:25 | raek | ,(.getWidth (java.awt.Dimension. 1 2)) ; <-- instance field |
| 12:25 | clojurebot | 1.0 |
| 12:25 | raek | s/field/method/ |
| 12:25 | sexpbot | <raek> ,(.getWidth (java.awt.Dimension. 1 2)) ; <-- instance method |
| 12:26 | raek | hrm. but what happens when they have the same name? |
| 12:26 | tomoj | exactly |
| 12:26 | tomoj | the method appears to be called |
| 12:26 | no_mind | markskilbeck: that doesnt solve the problem. I have downloaded congomongo in a dir and I can :use it in a program. My problem is, i want to use the congomongo in repl. From repl when I execute (:use somnium.congomongo), I get an error java.lang.ClassNotFoundException: somnium.congomongo (NO_SOURCE_FILE:1) |
| 12:26 | tomoj | haven't found a way to get the value of the fields |
| 12:27 | raek | tomoj: maybe you can use the . form directly... don't know if that would fix the problem though... |
| 12:27 | tomoj | (. d width) didn't |
| 12:28 | raek | no_mind: that means that you didn't start the repl with that jar on the classpath. leiningen handles that stuff automatically |
| 12:28 | no_mind | raek: I specified the classpath with -cp |
| 12:29 | raek | no_mind: did you list the jar in the classpath, or the directory containing it? |
| 12:29 | tomoj | "...the name of the field is the name of the symbol, and the value of the expression is the value of the field, unless there is a no argument public method of the same name, in which case it resolves to a call to the method." |
| 12:30 | raek | (also note that if you use the -jar option, -cp is silently ignored) |
| 12:30 | no_mind | raek: I used this java -cp "lib/*" -jar lib/clojure-1.1.0.jar |
| 12:31 | no_mind | raek: so how do I get congomongo in repl ? |
| 12:31 | raek | java -cp "lib/*" clojure.main |
| 12:32 | raek | the -jar option causes -cp to be ignored |
| 12:32 | raek | clojure.main is the main class of clojure.jar |
| 12:33 | tomoj | wall-hack-field appears to work :( |
| 12:33 | no_mind | raek: same error while :use-ing congomongo with your method |
| 12:34 | raek | no_mind: do you run (use 'somnium.congomongo) or (:use somnium.congomongo) at the repl? |
| 12:34 | no_mind | (:use somnium.congomongo) |
| 12:42 | raek | no_mind: you must use the (use 'somnium.congomongo) form at the repl. the other one is for use inside the ns macro |
| 12:42 | raek | you got the error because you accidentally tried to look up the :use key in the somnium.congomongo java class, which does not exist. |
| 14:34 | zvrba | hmm, is there a way to write just StreamTokenizer instead of java.io.StreamTokenizer ? |
| 14:35 | Chousuke | import it. |
| 14:45 | zvrba | how? |
| 14:45 | clojurebot | with style and grace |
| 14:46 | raek | in the ns form: (ns your.namespace (:import java.io.StreamTokenizer)), when playing in the repl: (import 'java.io.StreamTokenizer) |
| 14:48 | raek | ...either one, preferably, with style and grace ;-) |
| 14:49 | zvrba | thanks :) |
| 15:05 | brehaut | morning everyone |
| 15:06 | brehaut | morning __name__ |
| 15:06 | __name__ | hello brehaut |
| 15:06 | __name__ | brehaut: it's 9 pm over here :D |
| 15:06 | brehaut | clojurebot: UGT |
| 15:06 | clojurebot | ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html |
| 15:48 | svdberg | hi! |
| 15:48 | __name__ | hi! |
| 15:48 | xkb | what's the idiomatic way of creating lists? |
| 15:49 | brehaut | xkb: literals or programmatically? |
| 15:49 | xkb | '(1 2 3) or (list 1 2 3) |
| 15:49 | xkb | like that |
| 15:49 | xkb | like in for example a test |
| 15:49 | brehaut | i think the former is prefered |
| 15:49 | Chousuke | the former only works with literals |
| 15:50 | Chousuke | but most of the time you'd use lists in other lisps, you will use a vector in clojure |
| 15:51 | xkb | I ran into the problem defining the expected result of a function on seq's in a test |
| 15:51 | xkb | like (is (= expected_result (function))) |
| 15:52 | xkb | where function returns something like (1 2 3) |
| 15:52 | xkb | how would you define expected_result? |
| 15:52 | Chousuke | if it only has literals, '(1 2 3) |
| 15:52 | brehaut | xkb: as long as both expected_result and (function)'s return are both seq's (rather than maps or sets) |
| 15:52 | brehaut | they should be comparable |
| 15:52 | brehaut | ,(= '(1 2 3) [1 2 3]) |
| 15:52 | clojurebot | true |
| 15:53 | xkb | ok, that's how I defined expected_result now |
| 15:53 | brehaut | regardless of the implementation type |
| 15:53 | xkb | in for example the empty seq case: (is (= '() (function '())) |
| 15:54 | xkb | but the literals hint is good to think about |
| 15:55 | xkb | in this specific case the elements are always Strings, numbers or nil |
| 15:56 | brehaut | xkb have you actually encountered a problem or are you trying to prevent a potential problem? |
| 15:57 | xkb | brehaut: the latter |
| 15:57 | xkb | I tried to identify the error cases |
| 15:57 | xkb | like the empty seq |
| 15:58 | xkb | so rather the potential error cases |
| 15:58 | brehaut | then dont worry. as long as both sides are sequences (lists, vectors, lazy-seqs, etc) = will do the right thing |
| 15:58 | xkb | I got some comments from a friend of mine regarding the use of ' to define a list |
| 15:58 | brehaut | and keep in mind Chousukes comment about vectors being the idiomatic sequential type in clojure |
| 15:58 | xkb | that's what triggered me to ask here :) |
| 16:00 | xkb | perhaps I should define my testdata as vectors indeed. That avoids the "problem" alltogehter |
| 16:01 | xkb | and the actual test remains the same |
| 16:01 | xkb | thanks for the help. Always nice to get quick answers to these kind of questions |
| 16:01 | brehaut | no problem |
| 16:06 | fps | just following this tutorial http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html |
| 16:08 | fps | when setting up the test project in project.clj, I replaced the dependencies clojure with version 1.3.0-master-SNAPSHOT, which works. |
| 16:09 | fps | but for clojure-contrib I used "1.3.0-SNAPSHOT", which results in a maven error, where the clojure-contrib.jar could not be found... |
| 16:11 | fps | any tips? |
| 16:11 | brehaut | fps are you just getting started with clj? |
| 16:12 | fps | yep |
| 16:12 | brehaut | then stick with 1.2 |
| 16:12 | brehaut | clj 1.3 is still in alpha, i dont think contrib is following closely yet |
| 16:13 | fps | ok, will try. Thanks |
| 16:15 | raek | the syntax looks very clojure-inspired |
| 16:19 | Dranik | hi all! |
| 16:19 | Dranik | what web framework to choose for web application development on clojure? |
| 16:20 | brehaut | Dranik: there is only one 'web framework' |
| 16:20 | brehaut | but there is a range of good web libraries |
| 16:20 | brehaut | that work together |
| 16:20 | Dranik | brehaut, so what's the web framework? |
| 16:20 | brehaut | Dranik: everything is built ontop of 'ring' |
| 16:20 | raek | http://www.glenstampoultzis.net/blog/clojure-web-infrastructure/ |
| 16:21 | Dranik | raek, thanks |
| 16:21 | brehaut | (inc raek) |
| 16:21 | sexpbot | ⟹ 4 |
| 16:21 | Dranik | wow! it's really distributed... |
| 16:23 | brehaut | Dranik: common combinations to start with are Ring, (Moustache or Compojure), (Enlive or Hiccup) |
| 16:23 | Dranik | brehaut, seems like you have some practical experience? |
| 16:23 | Dranik | brehaut, do you blog about that? |
| 16:24 | brehaut | Dranik: ive built my own site/blog on ring, moustache and enlive |
| 16:24 | Dranik | wow! |
| 16:24 | brehaut | and ive written an xml-rpc library. my experience is a little limited |
| 16:24 | Dranik | where is it deployed? |
| 16:24 | brehaut | http://brehaut.net |
| 16:24 | brehaut | its nothing fancy |
| 16:24 | Dranik | brehaut, oh, looks great! |
| 16:24 | Dranik | really! |
| 16:25 | brehaut | thanks :) |
| 16:25 | Dranik | brehaut, do you share the sources? |
| 16:25 | brehaut | nope sorry |
| 16:25 | Dranik | :-( |
| 16:25 | brehaut | my site is always my 'learn stuff' project, so its a horrible mess |
| 16:26 | Dranik | brehaut, actually my clojure experience is so little that everything goes |
| 16:26 | brehaut | LauJensen does have an example site or two |
| 16:26 | brehaut | https://github.com/LauJensen/bestinclass.dk |
| 16:27 | Dranik | thanks! |
| 16:27 | brehaut | hes also blogged about building a social media site too http://www.bestinclass.dk/index.clj/2011/01/building-a-social-media-site.html |
| 16:28 | Dranik | https://github.com/LauJensen/bestinclass.dk -- his site looks lovely |
| 16:29 | brehaut | his code is real clean. note that it 'bakes' the site for him, rather than dynamic generation. nevertheless it should show you a good example of moustache and enlive |
| 16:29 | Dranik | bendlas, yep, thank you |
| 16:29 | fps | I am not familiar with ant, how would I build the clojure-contrib 1.2.0-SNAPSHOT? |
| 16:29 | Dranik | brehaut, and your post about monads is really interesting |
| 16:30 | brehaut | fps are you using leiningen or cake? |
| 16:30 | Dranik | brehaut, I guess I translate some to my blog. Its in russian |
| 16:30 | brehaut | Dranik: monads are not an approved method of solving problems in clojure. |
| 16:30 | fps | brehaut: leiningen |
| 16:31 | brehaut | fps dont use a snapshot then |
| 16:31 | fps | haha ok |
| 16:31 | brehaut | fps [org.clojure/clojure "1.2.0"] |
| 16:31 | brehaut | [org.clojure/clojure-contrib "1.2.0"] |
| 16:31 | brehaut | put those into your :dependancies in project.clj |
| 16:31 | Guest51521 | brehaut: what do you mean about monads not being approved? |
| 16:31 | Dranik | brehaut, yep, I thought so. But it's interesting bcs it is not idiomatic |
| 16:31 | fps | ok. thanks brehaut |
| 16:32 | Dranik | brehaut, I've just coped creating anaphoric macross with lexical variable capturing -- it was also not idiomatic but very interesting! |
| 16:32 | brehaut | Guest51521: clojure has a bunch of more specific tools to solve 95% of the problems monads solve, and they are more idiomatic |
| 16:33 | raek | fps: the tutorial you linked to uses a bit of an unusual approach to clojure development (compiling everything from source). it seems to be the norm to use pre-compiled jar files and let the build tool (lein/cake) handle the downloading and the classpath |
| 16:33 | brehaut | Guest51521: while they exists, rhickey has commented more than once that he doesnt think they are appropriate |
| 16:34 | fps | raek: ok, will remember |
| 16:34 | brehaut | Guest51521: here is teh appropriate logs http://clojure-log.n01se.net/date/2010-02-12.html#i70 |
| 16:34 | Guest51521 | brehaut: i'm no functional guru but from my novice perspective, they seem like a cleaner way to handle code that throws exceptions everywhere when doing interop with java |
| 16:34 | Guest51521 | thanks brehaut. i'll read |
| 16:34 | brehaut | Guest51521: Java exceptions arent idiomatic clojure either. |
| 16:35 | Guest51521 | brehaut: but you have no choice but to deal with them for java interop. the world isn't clojure on the jvm :) |
| 16:35 | Guest51521 | i guess that's one of the 5% |
| 16:36 | brehaut | Guest51521: correct. java interop is first class, so clojure provides exception handling when you need it |
| 16:36 | brehaut | but most clojure code wont throw exceptions |
| 16:36 | brehaut | Guest51521: ive used monads to make error handling cleaner for some of my code, only because it makes implementing the appropriate macros simpler, especially while prototyping. |
| 16:37 | raek | brehaut: looked at that article recently. very interesting! |
| 16:37 | brehaut | However, consumers of my code dont need to know that there are monads under the hood |
| 16:37 | brehaut | raek: cheers :) |
| 16:37 | brehaut | raek: hopefully with the changes to the colors scheme, you can read it without loosing your eyesight too |
| 16:38 | raek | yeah, saw that that you toned down the yellow a bit |
| 16:39 | raek | I think it's perfectly acceptable now |
| 16:39 | brehaut | raek: im a bit sad about that, but ive gotten such an overwhelm grumpy response i really couldnt not |
| 16:40 | raek | :( |
| 16:47 | Guest51521 | is this a good place to ask a question about ccw in eclipse? |
| 16:47 | brehaut | Guest51521: good as any |
| 16:48 | Guest51521 | i was using the stable version of teh plugin but am trying out 0.2.0.RC05 now and it doesn't give a prompt in the repl showing the namespace lke it used to. in fact there is no prompt at all in the repl, cursor is just all the way to the left. is that a bug or can i set some var to show the namespace prompt that i'm used to? |
| 16:50 | Guest51521 | everything seems to work fine but i don't like that it doesn't display the current namespace |
| 16:51 | brehaut | i never used the repl in ccw sorry |
| 16:55 | brehaut | Dranik: just done some reading on anaphoric macros; not kidding about non-idiomatic |
| 16:56 | Dranik | brehaut, sorry? |
| 16:56 | Dranik | didn't get it |
| 16:56 | brehaut | You mentioned that you had recently ported anaphoric macros to clojure? |
| 16:57 | Dranik | brehaut, yep. did you read about it from Paul Graham's On LIsp? |
| 16:57 | brehaut | apparently so |
| 16:57 | Dranik | the main point there was variable capture |
| 16:57 | Dranik | and that is not possible in clojure, isn't it? |
| 16:59 | brehaut | not out of the box at any rate |
| 17:00 | Dranik | that what I meant |
| 17:00 | Dranik | actually, everything I had to do -- creating my own version of gensym |
| 17:01 | Dranik | it looks like this |
| 17:01 | Dranik | (defn make-sym [name] (. clojure.lang.Symbol (intern (str name)))) |
| 17:01 | Dranik | it generates unqualified predictable names for variables |
| 17:01 | brehaut | why not just (symbol (str name)) |
| 17:01 | Dranik | and the rest was just translating from lisp to clojure |
| 17:02 | Dranik | brehaut, guess, intern is also needed here |
| 17:02 | Dranik | the function make-sym is just a simplified version of usual gensym |
| 17:29 | wjlroe | When I do (print "αβγ") from the REPL, it prints fine, but from a .clj file run from the terminal it prints "???" - why is this? |
| 17:30 | rlb | wjlroe: both from a terminal? |
| 17:30 | wjlroe | yep |
| 17:31 | rlb | wjlroe: I'd guess that clojure hooks up a fancier stream to the prompt then. |
| 17:31 | mjg123 | I'm having trouble using 3rd party library in the repl. Probably a real simple problem: http://pastebin.com/SzyWS89t |
| 17:31 | rlb | just a guess, though |
| 17:32 | wjlroe | mmm |
| 17:32 | rlb | wjlroe: or the stream encoding defaults are different |
| 17:32 | wjlroe | rlb: how would I find out? |
| 17:32 | rlb | i.e. utf-8 vs something-else |
| 17:32 | brehaut | mjg123: you need to wrap parents around your use |
| 17:33 | brehaut | s/nts/ns/ |
| 17:33 | sexpbot | <brehaut> mjg123: you need to wrap parens around your use |
| 17:33 | brehaut | eg (use 'somnium.congomongo) |
| 17:33 | mjg123 | brehaut: cheers |
| 17:33 | brehaut | mjg123: no worries. you can see the repl has evaluated both expressions (eg 'use |
| 17:34 | kjeldahl | Has anybody done simple "log to stderr" type logging from running a jetty/ring webserver with handlers from repl (with join? false)? I'm having some trouble figuring where output goes, if anywhere... |
| 17:34 | brehaut | and the quoted symbol 'somnium.congomongo) and printed them on the repl |
| 17:34 | rlb | relevant? http://jkndrkn.livejournal.com/264856.html |
| 17:35 | wjlroe | rlb: I get "MacRoman" for (.getEncoding *out*) from the REPL and from the script |
| 17:35 | rlb | wjlroe: try the -D |
| 17:35 | wjlroe | rlb: okey dokey |
| 17:35 | rlb | perhaps i.e. force utf-8 (assuming that's appropriate) |
| 17:36 | mjg123 | kjeldahl: stdout/stderr are usually into logfiles for jetty/tomcat/etc |
| 17:37 | brehaut | kjeldahl: my jetty in a repl just logs to is just printed the console running the repl |
| 17:37 | kjeldahl | mjg123: Ok, thanks. |
| 17:37 | kjeldahl | brehaut: How did you set jetty up to log to the console? Is that the log4j config or something? |
| 17:38 | wjlroe | rlb: this is -Dproperty=value right? what's the property I'm setting? |
| 17:38 | brehaut | i just start it in a seperate thread |
| 17:38 | brehaut | kjeldahl: (doto (Thread. #(run-jetty #'wendigo-app {:port 8000})) .start) |
| 17:39 | rlb | wjlroe: just from glancing at that web page, perhaps "java -server -Dfile.encoding=UTF-8 ..." |
| 17:39 | brehaut | kjeldahl: i wouldnt trust that approach as canonical |
| 17:39 | rlb | wjlroe: though I'm just guessing -- I haven't really investigated |
| 17:39 | wjlroe | rlb: ok, cheers |
| 17:40 | wjlroe | rlb: that worked |
| 17:40 | kjeldahl | brehaut: Ok, thanks. I guess it's running in a thread already, with the "run-jetty" join? false thingy. But I'll give your method a try. |
| 17:41 | brehaut | kjeldahl: i have no idea sorry. i cobbled that together ages ago. i actually need to work out a better way to run it |
| 17:44 | wjlroe | rlb: if you are a stackoverflower, feel free to add that as an answer to my question: http://stackoverflow.com/questions/4843976/unicode-clojure-unit-test-output |
| 17:45 | rlb | I'm not, but feel free to add it yourself if you like. |
| 17:45 | rlb | (if that helps) |
| 17:45 | wjlroe | rlb: ok thanks |
| 18:19 | Guest51521 | brehaut: regarding my earlier question about the namespace prompt in ccw... i see now that the namespace is displayed on the tab for the repl window. i didn't notice that at first. that is sufficient so i really don't care about the prompt then. |
| 18:19 | brehaut | Guest51521: oh true, cool |
| 18:43 | mjg123 | How to read an InputStream? I just want to be able to treat it as a string. |
| 18:48 | tonyl | I haven't use InputStream but have you taken a look in clojure.java.io http://clojuredocs.org/clojure_core/clojure.java.io/ |
| 18:52 | mjg123 | hmm they don't make this easy in Java either... |
| 18:52 | Raynes | Calling clojure.java.io/reader on an input stream will give you a buffered reader. You can't treat it as a string, but you can do stuff like .readLine on it to get a line at a time from it. |
| 19:00 | Guest51521 | mjg123: you can call read-lines from duck-streams and it will return a collection of strings |
| 19:01 | Guest51521 | mjg123: i should say a sequence of strings |
| 19:02 | Guest51521 | mjg123: oh sorry, you didn't say a file, just an inputstream. |
| 19:04 | Guest51521 | http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/line-seq |
| 19:04 | Guest51521 | combined with InputStreamReader |
| 19:09 | mjg123 | Yeah, it'd be nice to have something as easy as slurp, imho |
| 19:11 | Guest51521 | line-seq looks pretty nice. you just have to turn the inputstream into a reader first. no biggie |
| 19:14 | mjg123 | (concat (line-seq (reader *stream*))) |
| 19:15 | mjg123 | indeed |
| 19:17 | AWizzArd | hiredman: ping |
| 19:18 | AWizzArd | hiredman: just saw the msg you sent a while ago. Thanks for the info about declaring vars as dynamic explicitly. |
| 19:20 | AWizzArd | btw, anyone, why do I get warnings in Clojure 1.3 that a var is not marked as dynamic? The compiler then sets them dynamic for me, but I don't want them to be dynamic… |
| 19:58 | technomancy | AWizzArd: that will go away during the release |
| 20:56 | replaca | technomancy: did you get C-right and C-left working in tmux? That's the one part of paredit that's not working for me under tmux and I was wondering if anyone had gotten that going. |
| 21:23 | technomancy | replaca: I had to rebind those |
| 21:23 | technomancy | don't want to reach that far off the home row anyway |
| 22:33 | replaca | technomancy: what bindings worked well for you? |
| 22:33 | replaca | thanks! |
| 22:52 | technomancy | replaca: I use M-) |
| 23:24 | replaca | technomancy: (sorry, coming and going tonight) sounds like a good choice, thanks |