#clojure log - Nov 03 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

7:38 AWizzArd: Do you also have this? When you are chatting with other programmers and want to talk about closures you accidently write "clojures"?

8:22 duck1123: is there a BNF grammar for Clojure anywhere?

8:34 rhickey: duck1123: I don't have one - there might be something in the enclojure project

8:40 duck1123: ok, I was looking info what it would take for semantic to recognize parts of Clojure code in clojure-mode, and it looks like we would need a BNF

8:40 stuthulhu: rhickey: did you get my email Friday with book & sample code?

8:41 gnuvince: Good morning everyone.

9:12 lisppaste8: gnuvince pasted "Short Clojure history" at http://paste.lisp.org/display/69627

9:12 gnuvince: rhickey: can you look at that paste I just made and tell me if this is accurate?

9:14 Chouser: gnuvince: s/where/were/

9:14 solkis: developing has one "p" and you have "where" instead of were

9:14 gnuvince: Chouser: this is going to be in French anyway :)_

9:14 Chouser: heh, ok.

9:15 gnuvince: Weirdly enough, I find it harder to write in French than in English.

9:57 rhickey: gnuvince: technically correct, although I would say writing and maintaining correct imperative programs, concurrent or not, is too difficult

9:59 gnuvince: rhickey: OK, I'll correct it.

10:02 lisppaste8: gnuvince annotated #69627 with "take #2" at http://paste.lisp.org/display/69627#1

10:07 rhickey: gnuvince: looks fine

10:07 gnuvince: Thanks.

10:50 Chouser: If I've got a stack of java.io things (somethingStream, StreamReader, BufferedReader), do I need to close each of them, or just one? Which one?

10:52 stuthulhu: Chouser: no easy answer

10:52 for the JDK ones, you could review the code and see which ones close contained things

10:52 but for the interfaces in general you may not be able to count on wrappers closing their innards

10:53 I'd be happy to be proven wrong on that, but such was the case the last time I looked (years ago)

10:53 Chouser: bleh

10:53 thanks. :-/

10:54 the javadocs don't seem to address the question at all

11:02 * drewr is still confused by the packaging subdirs

11:03 drewr: If I have foo/foo.clj and foo/bar.clj, how do I reference foo.bar?

11:04 Clojure wants foo/bar/bar.clj, which defeats the purpose of having the subdirectory.

11:04 Chouser: not entirely, but it does reduce the purposes.

11:05 if you want something at namespace foo.bar, put it in foo/bar/bar.clj

11:05 drewr: Yep. It just bugs me.

11:06 Chouser: there are rumbling that might chagne with AOTC

11:06 drewr: Awesome. I wish we would just copy Python's module system.

11:11 * Chouser doesn't go there.

11:11 drewr: We're half-way there...

11:14 duck1123: personally, I'd like it to search foo/bar.clj then foo/bar/bar.clj

11:14 danlarkin: drewr: I'm with you, the java packaging directory requirements are annoying

11:14 duck1123: but the current way isn't that bad once you resign yourself to having a lot of directories

11:15 wwmorgan: I believe the rationale is that there's a one-to-one correspondence between directories and namespaces

11:17 cemerick: Chouser: Readers and Writers in the stdlib have been closing whatever they're wrapping for a long while now

11:18 Chouser: wwmorgan: I think that's right. And the reason that's desirable is that it's normal in Java.

11:18 cemerick: I think JDK 1.3 was the last revision where there was any issue regarding cascading flushing/closing.

11:18 Chouser: cemerick: oh, ok. so close the top-level thing?

11:19 cemerick: Chouser: Yeah. I never keep separate references to nested streams/writers/readers. Stuff like this is very idiomatic: Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(blah), "UTF8")));

11:19 Chouser: ok, great.

11:20 I mean, it's not great I need a half-dozen objects to read a file, but you know what I mean... :-)

11:20 cemerick: Sure. Yeah, it's verbose, but on the other hand, it's very transparent, easy to understand, and easy to compose.

11:21 Chouser: heh, I disagree with the first two, but it's not worth arguing over. It's what we've got. And I must say, I appreciate duck-streams.

11:22 cemerick: yeah, maybe I'm just used to it :-P

11:45 lisppaste8: Chouser pasted "get-source" at http://paste.lisp.org/display/69638

11:47 Chouser: I know the implementation is ugly, but does that work for you guys/

11:47 that was prompted by a recent post on the google group.

11:48 duck1123: looks good, need to try it

11:49 sohail: Chouser, what is the ^(...) syntax

11:49 Chouser: sohail: short for (meta (...))

11:49 sohail: oh yeah, duh

11:49 thanks :-)

11:49 Chouser: :-) np

11:50 sohail: so anyone know why blip.tv insists on saturating my connection

11:50 AWizzArd: Chouser: what will happen when AOT is available? Will the source go into the .class files?

11:50 duck1123: Chouser: will this work if the source is in a non-standard location or entered via the repl?

11:51 AWizzArd: duck1123: you can paste the code into your repl and see if it works for repl code

11:51 Chouser: AWizzArd: I don't know. I would be surprised if the source will travel with the compiled code by default.

11:52 cemerick: AWizzArd: no, no clojure source will be filtering into the AOT-compiled classfiles (at least, based on what rhickey has said so far)

11:52 duck1123: NPE if I try to source code entered in the repl

11:52 Chouser: duck1123: nope, this is relying on meta-data currently provided by clojure, which does not include the full path to the file nor runtime access to the actual source of the def.

11:53 hm, I guess I could handle error conditions better. :-)

11:59 lisppaste8: Chouser annotated #69638 with "get-source with better error handling" at http://paste.lisp.org/display/69638#1

12:00 gnuvince: sohail: saturating your connection?

12:01 sohail: gnuvince, whenever I try to watch a clojure video on blip.tv, I can't do anything else on the net

12:03 cemerick, is AOT still in someone's mind at the moment or is rich actually implementing it?

12:04 gnuvince: sohail: that's not a blip.tv thing

12:04 sohail: they just have a really good upload speed

12:04 cemerick: sohail: I gather that it's in progress now.

12:04 gnuvince: It's your OS that takes all it can.

12:05 sohail: gnuvince, ah, so I have to limit on my side :-(

12:05 my network meter is showing "100% network usage"!

12:06 Drakeson: can I "compile" a project written in clojure?

12:06 (to bytecode, etc.)

12:07 solkis: sohail: you could download the presentation and then launch it locally

12:07 sohail: solkis, oh, didn't know I could do that

12:08 Drakeson: sohail: you can even download the original format (most of the are .mov), so you can read the text on the screen easily.

12:08 solkis: sohail: Download Playing link at the bottom of the page

12:09 sohail: very strange, I don't see this

12:09 do I need internet exploder for that?

12:09 Drakeson: no

12:10 jkantz: is there a way to escape spaces in symbol names in the spirit of :foo\ bar ?

12:11 Drakeson: oh, that's ugly

12:11 solkis: sohail: there is a grey bar under the comments area titled Quick Links

12:12 sohail: solkis, I don't have a comments section.. Obviously there is a PEBKAC somewhere

12:12 ReplRat: sohail: you can subscribe to clojure.blip.tv in iTunes. There's an RSS feed. I'm on a mac, and it downloaded about 1.4G. Well worth it in my opinion. Rich is a good speaker. I've listened to Clojure for Java Programmers and for Lisp Programmers so far.

12:13 wwmorgan: jkantz: you could do (symbol "foo bar") and (keyword "foo bar"). But such practices are not recommended

12:14 jkantz: is there a restriction on characters allowed in symbols?

12:15 (with-in-str (with-out-str (pr (keyword "foo bar")))

12:15 (read *in*))

12:15 doesn't play nice

12:15 sohail: solkis, I'm obviously having a problem with computers today... I can't even figure out how to add the rss feed to google reader anymore!

12:16 kotarak: jkantz: obviously whitespace is not allowed in symbol names.

12:16 solkis: sohail: try this link in firefox: http://blip.tv/?s=search;topic_name=clojure&skin=rss

12:17 sohail: solkis, I think I fail today

12:18 Drakeson: sohail: wget -c 'http://blip.tv/file/get/Richhickey-ClojureSequences284.mov' ?

12:20 kotarak: jkantz: http://clojure.org/reader have a look at the reader forms

12:25 lisppaste8: Drakeson pasted "get clojure screencasts" at http://paste.lisp.org/display/69641

12:26 Drakeson: sohail: that was for you

12:31 gnuvince: What do you guys think of this definition of integer exponentiation: (defn pow [n m] (reduce * (replicate m n)))

12:31 Drakeson: (pow 2 0.5)

12:31 wwmorgan: (pow 2 0)

12:32 gnuvince: Drakeson: integer exponentiation

12:32 wwmorgan: although replacing reduce with apply will fix that I think

12:33 gnuvince: wwmorgan: return 1; (reduce * []) is 1.

12:33 Drakeson: gnuvince: is -1 integer?

12:33 wwmorgan: ah. You're right

12:33 gnuvince: Drakeson: yes.

12:34 Although I don't the think the result is.

12:34 Drakeson: (pow 1 -1)

12:34 sohail: Drakeson, thanks!

12:34 gnuvince: Drakeson: yeah, that won't work.

12:34 sohail: I guess it isn't a handicap to be slightly retarded in #clojure

12:35 gnuvince: Drakeson: actually, for this particular case, it will

12:35 Drakeson: gnuvince: oops, yeah!

12:35 gnuvince: But (pow 2 -1) will return 1 and not 0.5

12:36 wwmorgan: gnuvince: I'm seeing better performance with Math/pow (about 4x faster), but your approach does arbitrary precision

12:37 gnuvince: wwmorgan: I'm guessing Math/pow is optimized a lot more than my attempt here.

12:37 And my concern was indeed bigints

12:37 Doing the "sum all the 2^1000 digits" from Euler

12:53 Chousuke: don't java bigints have a .pow() method or anything similar?

12:54 gnuvince: Chousuke: I don't know, I never wrote any Java (except for one semester in school)

12:54 Chousuke: well you should check

12:55 though if it's 2^1000 you need you don't need a generic exponentiation function. just bit-shift 1 a thousand times.

12:55 gnuvince: Chousuke: yes, they do

12:55 http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html#pow(int)

12:56 yeah, much faster

12:57 ivan: is there a bare-bones clojure syntax highlighter for IDEA 7 or 8?

12:59 gnuvince: The difference:

12:59 user=> (time (dotimes n 10000 (pow 2 1000)))

12:59 "Elapsed time: 18820.92753 msecs"

12:59 user=> (time (dotimes n 10000 (.pow (BigInteger. "2") 1000)))

12:59 "Elapsed time: 158.838221 msecs"

13:14 danlarkin: bet it'd be faster if you tried (time (let [bi (BigInteger. "2")] (dotimes n 10000 (.pow bi 1000))))

13:14 so you don't construct a BigInteger for each iteration

13:16 gnuvince: danlarkin: 129 ms

13:16 danlarkin: my runs vary between 90ms and 140ms

13:20 gnuvince: I was surprised that a there was no way to build a BigInteger from an Integer.

13:21 Ah

13:21 (BigInteger/valueOf 2)

13:41 lau_: Good evening gents

13:42 Chouser: hi, Lau_of_DK.

13:43 kotarak: hi lau

14:03 Lau_of_DK: Im on my new work PC, therefore this weird question: Anybody here got my .emacs? :)

14:04 kotarak: yepp.

14:07 Lau_of_DK: kotarak, saves the day! :) The Emacs master! :)

14:08 kotarak: hahaha! More Vim grokker. ;)

14:38 Since there were some questions on the list concerning macros, I thought it might be a good idea to have a tutorial in the wiki. Feel free comment, modify, improve: http://tinyurl.com/6y8857

14:40 * Lau_of_DK is connecting to Frankfurt

14:41 kotarak: so you have diner, eg? ;)

14:49 Lau_of_DK: kotarak, as far as I can see it looks very good, and its definately needed on the site. I wonder though if the text could be shortned a bit to ease the reading?

14:50 kotarak: possibly, I'm not a good writer. It's also kind of chaotic, because I just started writing....

14:50 feel free to do any changes!

14:52 I tried to point out some of the caveats and pitfalls...

14:52 Lau_of_DK: Yea that cant be emphasized enough with Macros

14:52 RadioApeShot: Question - is there a clojure function which will return to me the current classpath?

14:52 Lau_of_DK: Imagine the power of macros in the hands of a Chouser... its destined for catastophy

14:52 (System/getProperty "java.class.path") I think

14:53 @ RadioApeShot

14:53 kib2: kotarak: I've installed Chimp (on Windows with cygwin) but that does not seems to work.

14:54 RadioApeShot: Lau_of_DK: Thanks

14:55 Chouser: kib2: people have reported success there -- what's failing?

14:56 kib2: Chouser : this http://clojurepastebin.appspot.com/6

14:56 kotarak: kib2: chimp.sh your-clojure-start-script.sh

14:57 * Lau_of_DK wont say anything about emacs...

14:58 kotarak: Lau_of_DK: shhhh....

14:58 kib2: kotarak: but my clojure start script is already a .bat file. Do I have to install clojure on my cygwin drive directory or just make a new bash script ?

14:59 kotarak: I suppose: chimp.sh foo.bat should also work

15:00 kib2: ok, I try

15:02 ...idem ~(

15:03 Chouser: I usually need: chimp.sh -- your-clojure-start-script.sh

15:03 kotarak: try giving it the full path.

15:03 Chouser: double-dash

15:05 kotarak: since we have a few vimmers here now, again the teaser for the Chimp successor: Gorilla - http://tinyurl.com/5ma9d8

15:07 abrooks: kotarak: Is there a quick summary? I'm currently a Chimp user.

15:08 kotarak: abrooks: a summary for what?

15:08 abrooks: kotarak: Summary of the Gorilla vs Chimp differences.

15:09 kotarak: abrooks: there functionality is mostly equivalent. However Gorilla has no dependency on screen.

15:09 abrooks: so everything works from inside vim. eg. a Repl in a vim buffer

15:09 abrooks: kotarak: Ah. Does it provide it's own repl wrapping?

15:10 kotarak: abrooks: it's still pre-pre-pre-alpha, but I hope to get out a first version soon

15:10 abrooks: kotarak: Are the sources anywhere public yet? I'm interested. :)

15:10 kotarak: abrooks: yes. Via network. So it's also easy to do remote Repling.

15:10 abrooks: no. the sources are not public, yet.

15:11 abrooks: I hope to release a first version tomorrow or sometime this week.

15:11 Lau_of_DK: kotarak, what would you say inspired you the most to write Gorilla?

15:12 abrooks: kotarak: Very cool. I'll keep an eye out.

15:12 kotarak: Now that we get info back into vim, there are things possible, like omni completion with arglist, dynamic docstring lookup, etc...

15:13 Lau_of_DK: the little green ghost from the Ghostbusters movie ;)

15:13 Lau_of_DK: Haha

15:13 You mean Slimy Emacs ? :) Thats his full name btw

15:13 abrooks: Slimer

15:14 kotarak: abrooks: there is a dependency on Ruby however, but I can leave with it for the advantages it brings over Chimp

15:14 s/leave/live/

15:15 abrooks: kotarak: Ruby for the Vim bindings or stand-alone Ruby?

15:15 kotarak: ruby-enabled vim

15:16 that is +ruby in the :version output

15:16 abrooks: Perl Vim bindings are pobably the most common for portability sake.

15:17 kotarak: abrooks: but I don't Perl at my work, Ruby is available however.... (you see the point ;))

15:18 * abrooks always has +python +ruby +perl +tcl turned on anyways

15:18 kib2: kotarak: sorry, I had my baby crying. Yes, I have ruby inside Vim.

15:19 abrooks: We really just need Clojure bindings in Vim... :-p

15:20 I don't think I'd suffer the JVM + compile + byteload overhead for each Vim startup.

15:20 kib2: oopps sorry : I don't have Ruby inside because I've compiled myself and forgot to do so.

15:20 Lau_of_DK: Can I ask a serious question abrooks? On one hand you have Vim, for which you basically need to write a small OS for it to have any function. On the other hand you have emacs, swift and powerfull, abounding in features. Why not just use emacs ?

15:20 Chouser: abrooks: but a clojure-client in vim would work nicely.

15:21 abrooks: Chouser: True.

15:21 kotarak: kib2: no problem.... for now, but Gorilla, the Chimp successor, will need it.

15:21 kib2: kotarak: Chimp does not need Ruby at the moment right ?

15:21 kotarak: kib2: no

15:21 kib2: only screen (and Cygwin for Windows...)

15:22 I think Ruby is the more tolerable dependency compared to Cygwin...

15:22 abrooks: Lau_of_DK: It really comes down to modal editing which doesn't require laying on CTRL/META, etc. and some amount of infrastructural inertial. I highly respect Emacs and semi-regularly consider switching.

15:22 kib2: kotarak: in cygwin I had to install getopt too

15:22 kotarak: kib2: yes, sorry, needed for chimp.sh

15:22 kib2: no problem

15:22 Lau_of_DK: abrooks, but have you heard of Vim-mode for Emacs? :)

15:22 abrooks: Lau_of_DK: I've considered Viper/Vile/etc. and have even tried them out.

15:23 Vile wasn't really enough. Viper was better but wasn't being supported (having been superceeded by something else).

15:23 kotarak: Lau_of_DK: you are quite in a missionary mood for someone who was willing to try vim a week ago.... ;)

15:24 Lau_of_DK: kotarak, Im just asking the question, because Im curious. If people have good arguments for prefering Vim I'd like to hear them. Personally Im quite happy no matter what people use :)

15:24 kib2: kotarak: when do Gorilla be released ?

15:24 abrooks: Chouser and I keep joking about writing textjure, an Emacs implementation which has an included Vim binding base.

15:24 Lau_of_DK: --^

15:24 kotarak: kib2: sometime this week, it's still unstable

15:25 kib2: kotarak: ok, thanks

15:25 kotarak: abrooks: there are also plans for clomacs

15:25 Lau_of_DK: clomacs :)~~

15:26 abrooks: Lau_of_DK: gnuvince wrote this interesting Vim/Emacs comparison: http://gnuvince.wordpress.com

15:26 /2007/02/24/emacs-and-vim/

15:26 Arg.

15:26 Lau_of_DK: I think you pasted that out of Vim

15:26 abrooks: http://gnuvince.wordpress.com/2007/02/24/emacs-and-vim/

15:26 Lau_of_DK: Thanks :)

15:26 gnuvince: Another post of interest is my "5 things I hate about Emacs and Vim"

15:26 kib2: abrooks: every try to make a vim/emacs clone had poor success. There's even tries in Haskell and Python.

15:26 abrooks: Lau_of_DK: Cheap shot... no. GNU screen sometimes wraps and sometimes splits. I haven't tracked down yet...

15:26 gnuvince: http://gnuvince.wordpress.com/2007/03/28/five-things-i-hate-about-emacs-and-vim/

15:27 Lau_of_DK: abrooks :) Alright, you dont need to explain, I understand

15:28 abrooks: gnuvince: BTW, I enjoyed both of those posts.

15:28 gnuvince: abrooks: thanks.

15:29 kib2: I'll probably need your help later this week to proof read a French blog post about Clojure.

15:29 kib2: gnuvince : Emacs has line numbers :)

15:29 abrooks: gnuvince: This weekend I added you to my Google Reader list. :)

15:30 gnuvince: kib2: a good one or a lousy .el script with the problems I described?

15:30 abrooks: thanks :)

15:30 kib2: gnuvince : no problem, I'll read it : same topic as before ?

15:30 gnuvince: kib2: It's a general introduction to Clojure, a bird's eye view.

15:30 Chouser: abrooks: ah! you gave away the name!

15:31 gnuvince: It will take longer than I expected, because apparently I suck at writing directly in French ;)

15:31 kib2: gnuvince : so for sure I'll read because I need this :)

15:32 gnuvince : I was refering to http://www.emacsblog.org/2007/03/29/quick-tip-line-numbering/

15:32 nice blog about EMacs indeed

15:32 gnuvince: kib2: yeah, that's the one I tried. Notice how the 54 is the wrong color?

15:33 kib2: yes, first time I see this : I must be blind !

16:46 drewr: I feel like I'm missing a built-in macro for this pattern:

16:46 (map foo (map bar (map baz quux)))

16:47 Does one exist?

16:47 rhickey: (map (comp foo bar baz) quux)

16:48 sh10151: sorry to bungee-question here

16:48 is there a pretty-printer for Clojure?

16:48 drewr: rhickey: Ah, composition. Thanks.

16:48 rhickey: sh10151: not yet

16:48 Chouser: sh10151: nope, but there's an open request to add one. go for it!

16:48 :-)

16:48 sh10151: awesome

16:48 that was my project to learn clojure

16:48 :)

17:01 drewr: ericthor, rhickey: How you guys feeling about tomorrow?

17:02 rhickey: drewr: busy

17:02 :)

17:02 drewr: Hope everything goes well!

17:03 rhickey: thanks

17:06 Chouser: rhickey: substantial amounts of clojure code involved, or not really?

17:07 rhickey: Chouser: I absolutely cannot discuss, sorry

17:07 AWizzArd: when I (defn foo [..] ...) can I then attach meta data to foo?

17:07 Chouser: rhickey: :-) ok, np.

17:08 wwmorgan: AWizzard: you could do (.setMeta #'foo {:bar :baz})

17:09 alt. (.setMeta #'foo (assoc ^#'foo k v))

17:09 AWizzArd: wwmorgan: thanks

17:09 why is it not possible to do something like (with-meta (var foo) my-data-here)?

17:10 rhickey: AWizzArd: with-meta returns a new value, and vars aren't values, can't have same semantics

17:11 AWizzArd: So, does with-meta do this at read time?

17:11 rhickey: AWizzArd: no

17:11 it's a regular function

17:27 danlarkin: re: tomorrow, I hope everything goes well too... heh heh *nervous chuckle*

18:02 lisppaste8: AWizzArd annotated #69638 with "Keep the code even in presence of AOT" at http://paste.lisp.org/display/69638#2

18:04 wwmorgan: AWizzArd: You don't need setMeta for that. Just have the macro emit a (defn ~name ~args {:code '~body} ~@body)

18:05 AWizzArd: yeah right, I am doing this right now, thanks

18:17 rhickey: Clojure group passes 800 members...

18:18 AWizzArd: yeah, that's great

18:18 but it's nothing compared to what we will have soon

18:18 When the real break through comes then hundreds of new users will come daily

18:20 sohail: what's the real breakthrough then AWizzArd ?

18:20 AWizzArd: I remember what happened to lighttpd. My ex class mate programmed it, and it had just a few thousand user. But at some day there were like 5k new users every day. Today it's one of the most used webservers. I hope Clojure will also have a nice break through.

18:20 sohail: I see

18:21 AWizzArd: it was very chaotic and no obvious reason was there.. it simply happened and the users came

18:24 Just let an IDE like Enclojure be in place.. some more bloggers (also non-english blogs), some first success stories...

18:24 rhickey: The group is just an indicator of size, certainly not all users sign up, as they don't need to to read the list (can read via browser or RSS). For instance there were 3000 downloads and 56000 SVN reads in the past 2 months

18:26 AWizzArd: rhickey: I think the group is a very nice indicator. I am looking at these numbers also daily, and also see how many hits google returns

18:28 It's also fortunate that you (rhickey) are such a good speaker, as we can see in the videos. Components like these really help.

18:29 sohail: is it planned to move to git or do you guys just use git svn?

18:33 AWizzArd: sohail: why do you think that it may be planned to move to git? (not meant critical, I am just curious if this was mentioned somewhere in irc or GG)

18:34 sohail: AWizzArd, oh just because its a PITA to use svn and patch clojure if necessary

18:34 AWizzArd: What about darcs?

18:35 sohail: darcs is not very nice to me..

18:35 well, neither is git really but it's the latest fad to use git (/me prefers bzr)

18:38 AWizzArd: rhickey: what are the fine differences between lazy-cat and concat? As in:

18:38 (def fibs (lazy-cat [0 1] (map + fibs (drop 1 fibs))))

18:38 which could also use concat instead... both do the same when we say (take 15 fibs)

18:40 oh I see... it accepts concat only if the var was defined before with lazy-cat

18:41 wwmorgan: lisppaste8: url

18:41 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

18:42 wwmorgan pasted "lazy-cat vs concat" at http://paste.lisp.org/display/69663

18:43 wwmorgan: you can also think about in terms of their implementations: concat is a function and lazy-cat is a macro

18:44 Chouser: wwmorgan: fantastic. I'd been wondering that myself. great answer.

18:57 AWizzArd: wwmorgan: my repl gives me a different result

18:58 your version with lazy-cat prints foo and returns (1)

18:59 In my repl it looks different. It prints foo but then writes, splitted on two lines: (bar 1) where "(bar" is in the first line and "1)" in the second.

18:59 wwmorgan: are you taking 1 from it?

18:59 AWizzArd: yes

19:00 I copy-pasted your example

19:00 wwmorgan: try it in java -jar clojure.jar and see if you get the same result

19:00 AWizzArd: let me see if I can post a picture online somewhere

19:02 yes, I get this in pure clojure in the shell, I get it in emacs+slime and in Enclojure

19:03 lisppaste8: wwmorgan annotated #69663 with "lazy-cat as it's defined for me" at http://paste.lisp.org/display/69663#1

19:03 AWizzArd: http://img221.imageshack.us/img221/9004/zwischenablage02lr9.png

19:03 This is a picture from within Enclojure. But I get the same in Emacs and in the shell

19:04 wwmorgan: oh I think I know what it is

19:04 lisppaste8: AWizzArd annotated #69663 with "And this is my lazy-cat" at http://paste.lisp.org/display/69663#2

19:05 wwmorgan: it's your take, I bet

19:06 lisppaste8: wwmorgan annotated #69663 with "my take" at http://paste.lisp.org/display/69663#3

19:07 wwmorgan: older implementations of take computed (seq coll) eagerly

19:08 lisppaste8: AWizzArd annotated #69663 with "Yes, my take is different" at http://paste.lisp.org/display/69663#4

19:08 wwmorgan: you can update to svn head or just edit your boot.clj

19:09 AWizzArd: This difference is good, because I had a hard time to understand how the result could contain the symbol bar as println does not return it's string argument to symbols

19:10 wwmorgan: the old implementation of take evaluates one more element than it appears to need to, for certain kinds of collections

19:10 AWizzArd: Now I realize that it is not me that bends, but it's the spoon.

19:14 Hun: (boundp spoon) => nil

19:16 AWizzArd: ;-)

20:59 bradbev: when I try to run Clojure's inspector (or any Swing window) from Slime on Windows, I get the window up & then it won't respond to any input, and I have to kill the VM to unstick it. The same things work on OS X. Am I missing something?

22:05 danlarkin: Oooo I got an exotic error, java.lang.reflect.InvocationTargetException

22:13 sohail: danlarkin, you haven't been using clojure enough then ;-)

22:35 bradbev: I asked a question & had to dash, sorry. Here is the question again.when I try to run Clojure's inspector (or any Swing window) from Slime on Windows, I get the window up & then it won't respond to any input, and I have to kill the VM to unstick it. The same things work on OS X. Am I missing something?

22:50 danlarkin: I'm trying to find a more memory-efficient way to do clojure.contrib.str-utils/str-join

22:54 because (str-utils/str-join "," (range 10e6)) overflows the heap

22:55 so I need some way of lazily consuming it but still making a string with the same effect as str-join has

22:56 I believe it's that str-join uses apply that ruins the laziness of the list

22:58 bradbev: Surely it's having to convert to a string is the issue? I'd guess strings can't be lazy

23:04 Chouser: is that like an 80MB string?

23:05 danlarkin: So perhaps I need to use a StringWriter instead of just java.lang.Strings

23:05 Chouser: danlarkin: you want that as a string, or in a file?

23:05 (apply str (interpose "," (range 10e6))) is cranking away here, no overflow yet.

23:06 danlarkin: Chouser: it'll get there

23:07 I suppose I'd like a string

23:08 bradbev: Chouser: 80Mb? (reduce + (map #(inc (count (str %))) (range 10e6))) How did you do it?

23:10 danlarkin: in python I can run >>> len(",".join((str(x) for x in range(10e6)))) in a few seconds

23:10 78888889 is the result

23:22 Chouser: bradbev: that produces 78888890 which is 80MB, right?

23:22 bradbev: yeah, just wondered if you'd done the calculation in the same way

23:23 Chouser: oh, no, I just guestimated

23:23 bradbev: :)

23:24 Chouser: largest number is 8 digits, times 10000000 is about 80MB

23:26 danlarkin: I don't think str is the problem, it's that apply keeps a reference to the head of the list

23:26 bradbev: I can't even do it using a StringWriter: (let [w (StringWriter.)]

23:26 (doall

23:26 (doseq n (range 10e6)

23:26 (.. w (write (str n)))))

23:26 w)

23:30 Chouser: I can make an array of the right size almost instantly.

23:30 (make-array Character/TYPE 78888889)

23:31 maybe you could dump your digits directly into the array and then construct a String from that.

23:31 ...but I'm off to bed. good luck.

23:32 danlarkin: Chouser: thanks, I will think about that

Logging service provided by n01se.net