#clojure logs

2009-12-22

00:00arohnerthe way you can tell a new feature is good: when you want it everywhere
00:00arohnerI want pre and post conditions on multimethods now
00:15chouserarohner: I believe they're planned for protocols
00:33chouseranyone up for a pop quiz?
00:33scgilardiand how!
00:34chouserok! where, in legal clojure code, does # by itself indicate a comment until the end of the line?
00:34scgilardi*raises my hand*
00:34chouserhm, maybe more of a riddle than a quiz.
00:35chouseryes, Mr. Gilardi?
00:35scgilardiOn the first line of a file to be loaded
00:36scgilardiWe support the shebang
00:37chouserah, but I specifically said "# by itself" You're right that #! is a comment to the end of the line.
00:37scgilardid'oh!
00:37chouserthis is too hard.
00:38_msthm, does #_ fail for the same reason then?
00:38chouserIt's not really fair to ask such questions when I just stumbled on an answer that I didn't know myself.
00:38scgilardilet's keep the floor open for a while
00:38chouser_mst: right. #_ requires the _ and is also only to the end of the form, not the end of the line.
00:39chouserI have a couple hints that I think wouldn't give it completely away.
00:39_mstright, yep
00:39scgilardifair enough
00:39chouserhint now, or wait a bit?
00:40scgilardiI'd say wait a bit
00:48chouserok, first hint:
00:49chouserthough the comment extends until the end of a line according to the applicable docs, there is actually one other character than can end the comment early.
00:51scgilardiyep, that didn't give it away. :-)
00:51danlarkinscgilardi loves his quizzes
00:54chouser:-)
00:55scgilardiis this behavior present in the 1.1 release candidate?
00:55chouseryes. Also 1.0 and 'new'
00:56chouseryou're all going to hate me.
00:56chouserok! thanks!
00:57chouserah well
00:57chousersecond hint:
00:58chouserI very much doubt Rich would be able to answer this.
00:58scgilardinow there's an intriguing hint
00:59tomojI can't even see how you can have a # by itself at all
01:00danlarkindoes this work? #\n(comment ...)
01:00chousertomoj: oh? do go on...
01:01chouserdanlarkin: you get "No dispatch macro for:" ... either \ or an actual newline char, depending on how you meant that.
01:01chouser...which is I suppose what tomoj is referring to.
01:02chouserThe only other hint I can think of is to say what the "other character" is in the first hint.
01:06scgilardiwhat kinds of reads bypass the normal reader?
01:06chouserexcellen question!
01:06chouserexcellent, even.
01:07scgilardiregex springs to mind...
01:08danlarkinthis is tricky, I'm running out of ideas
01:10scgilardihehe
01:10chouserscgilardi: you found it?
01:11scgilardiI think so. checking
01:12scgilardiwhen compiling a Pattern using #", with COMMENTS mode on: In this mode, whitespace is ignored, and embedded comments starting with # are ignored until the end of a line.
01:12scgilardinot sure exactly how to construct that yet
01:13chouserscgilardi: ha! beautiful!
01:13lisppaste8Chouser pasted "Where in Clojure code # by itself indicates a comment to the end of the line" at http://paste.lisp.org/display/92465
01:14scgilardivery nice1
01:14scgilardiand very nice! too!
01:15chouserscgilardi: quite impressive. I really don't think I could have done it from your end.
01:16chouserI needed a comment in my regex and had to go look it up when my first guess of /* comment */ failed. :-P
01:17scgilardi:) thanks!
01:17scgilardiI had no idea the pattern compiler supported humans.
01:17scgilardiThe Rich Hickey hint was a good one.
01:18chouserlearned about the "x" flag when doing very evil perl things.
01:19scgilardiso the "other character" is &quote ?
01:20scgilardi(spelled the usual single character way...)
01:20chouserscgilardi: right
01:20scgilardivery cool. time to sleep while I'm ahead. Thanks for the fun.
01:20chouser,(re-find #"(?x)foo # comment until the quote" "foobar")
01:21clojurebot"foo"
01:21replaca_ato: are you in channel?
01:21chouserscgilardi: good night, thanks for playing. -)
01:21scgilardi:)
01:21chouser:-)
03:36hiredmanya'll wanna see something cool?
03:36hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Clojure.png
03:36piccolinoSo if I have multiple threads working and I want to serialize their writes to a file, the way to do that is with a regular Java lock?
03:36hiredmanpiccolino: seems like most people would use an agent
03:36piccolinoAh, that was my first thought, but the agent docs said that the functions should be side-ffect free.
03:37hiredmanI think I would use a linkedblockingqueue
03:38piccolinoHow so?
03:38hiredmanpiccolino: that doesn't seem to stop people from using agents for that kind of thing
03:39piccolinoI see. Don't agents have the possibility of re-trying?
03:39hiredmanpiccolino: not that I recall
03:40hoeckhiredman: which toolkit is this, SWT?
03:42piccolinoLooks like Dr Scheme.
03:46hiredmanswing
03:52hiredman1ugh
03:55piccolinoAh, I see, their state should be an immutable object, but they don't need to be side-effect free.
03:57replacapiccolino: you might want to take a look at cloure.comtrib.seq-utils/fill-queue
03:58replacapiccolino: mmm, that probably doesn't do exactly what you want, but you might get a good idea from it
04:01hiredman~ping
04:01clojurebotPONG!
04:05piccolinoHm, yeah, I'm afraid I'm not quite sure how to use this for what I want to do.
04:08scottjhiredman: what I think would be cool in a graphical repl is displaying sql query results in a sortable table
04:12carkhiredman : you're going for a "lisp machine style" repl ?
04:13carkor CLIM style
04:24johnmn3hiredman: looks cool!
04:26johnmn3some of the boxes look a little awkward, but that can probably be fixed.
04:27hiredmanit is very awkward
04:28carkyou need inspectable return values now =)
04:29ordnungswidrigwhat did I miss? Graphical Repl?
04:29johnmn3yea, looks cool
04:33hiredmancark: that sounds painful
04:33johnmn3hiredman: are you going to leave the gray background on there?
04:33hiredmanjohnmn3: I don't know
04:34johnmn3embed JTrees. Could Rich's inspector work?
04:34carkhiredman : http://en.wikipedia.org/wiki/File:Listener.png
04:35hiredmanhttp://gist.github.com/261648
04:36johnmn3yea, that's a little more advanced.
04:36carkwew i'm trying to find ome pictures of a clim repl with inspectable content, and google already has my last sentenses int here
04:36carkthat's scary =/
04:38carkanyways what i mean is : you get a textual response from your repl, but you may click it to get an inspector
04:38carkthat would aleviate the infinite sequence printing problem
04:39johnmn3what's with the *->ops convention you use? what does that mean?
04:40johnmn3does bq stand for Blocking Queue?
04:47hiredmanyes
04:47hiredmanblockingqueu to outputstream
04:48hiredmanack, the code I gisted is broken
04:48hiredmanI was adding scaling to images
04:49johnmn3pretty sweet. I like how short your programs are (that you've listed here). after a little bit I can understand it.. useful learning examples.
04:51hiredman:)
04:51johnmn3and they're actually useful too.
05:22alexotti have short question - how i can create instance of java class, that is internal in other java class?
05:22alexottso for example, in java it created as M.Class(), but how i can create it in clojure?
05:23cark(new M$Class) i think
05:25alexottcark: thanks, I'll try
05:27alexottcark: hmm, doesn't work
05:27carktry fully qualifying your outer class
05:28alexottcark: ok, with fully qualified name it works. thank you
05:29ordnungswidrigI shouldn't try (repeat 1) in the graphical repl, though...
05:29carkthe thing is : you need to import the inner class the same way you do for the outer one
05:30carkthen you can use the short hand version
05:32alexottcark: ok, thank you... I'm not java programmer, so i don't know much details :-(
05:34carkme neither =)
05:57johnmn3this trick:
05:57johnmn3 (future
05:57johnmn3 (while true
05:57johnmn3never would have guessed I could do that.
05:58johnmn3does that spawn a thread?
05:58Chousukeyes.
05:59johnmn3hmm
05:59Chousukeyou might want to include some way to stop the thread :P
05:59Chousuke(while @*running* ...) is one way
05:59Chousukewhere *running* is a global atom
06:00johnmn3ok
06:00johnmn3in this instance, it's a repl running on a gui.. hiredman's gui repl
06:02johnmn3illustrative use of a defmulti in there.
08:09prhlavahello, I have solved one usage scenario for usage of gridgain and clojure, the modification: Var.intern(CLOJURE_NS, Symbol.create("*use-context-classloader*"), F) in RT.java made peer class loading work under gridgain. Is class loading in clojure due to overhaul at some time?
08:10Jules_How would you represent algebraic data types in Clojure? For example regular expressions like type regex = Char of char | Comp of regex * regex | Alt of regex * regex | Star of regex
08:11Jules_Should I use maps with a :type field that is :char, :comp, :alt or :star?
08:13interferonis there a way to start clojure with *print-level* set to 2?
08:13interferonuser.clj doesn't let me set! variables
08:14prhlavainterferon: put it into "init.clj" file and call clojure with --init argument.
08:15interferonactually, is there a way to do it just from slime?
08:15rhickeyjava -cp clojure.jar clojure.main -e "(set! *print-level* 2)" -r
08:17ilowryHello! Could anybody help me with Emacs clojure-mode & slime please?
08:18ilowryI've just intalled them, but every time I try to execute any expression in slime it just hungs.
08:18ilowryIn the same time I able to execute the same form from *inferior-lisp* buffer
08:19prhlavailowry: i did this (under debian and arch linuxen): http://riddell.us/tutorial/slime_swank/slime_swank.html
08:20interferonrhickey: thanks
08:24ilowryprhlava: thanks. I suppose I've done something similar. My config is here: http://paste.org/pastebin/view/13408. I use separately installed slime
08:26prhlavailowry: what happens (in emacs) when you do?: M-x slime
08:26prhlavailowry: do you get clojure prompt?
08:27ilowryprhlava: Yes I get clojure prompt and able to type something there. But nothing happens when I hit Enter.
08:29ilowrybtw, swank-clojure I've got gave me WARNINGS about deprecated ^ macro, until I patched it to use (meta ..) instead
08:30prhlavailowry: one thing - i use the latest repository versions for all: clojure-mode, slime, swank-clojure . Emacs is: GNU Emacs 23.1.1 . Is it possible that slime would be too old (they develop rapidly)?
08:32prhlavailowry: I get the same warning about ^ but it works. But I do not use paredit...
08:34ilowryprhlava: yes, I've got the latest versions of the all from repositories.
08:35prhlavailowry: :-/
08:35ilowryprhlava: the problem appeared before I added paredit
08:36prhlavailowry: :-/ :-/ is this clojure 1.0 or 1.1? I am using 1.1 snapshot at the moment (but could try with 1.0 easily)....
08:37ilowryprhlava: it is 1.1. got it from github
08:37ilowryprhlava: built it with 'ant clean jar' and just 'ant'
08:40prhlavailowry: pretty much what I did. For me, I pretty much followed the short guide (in the above link) and it just worked. I do update clojure-mode, slime, swank-clojure regularly and so far it just works. One thing I noticed that you do not use absolute paths in your config...
08:40prhlavailowry: but it starts, so :-/
08:41ilowryprhlava: I'm under Mac OS X 10.5 and emacs (23.1.90) is from http://emacsformacosx.com/
08:45ilowryprhlava: it maybe that something in my Emacs init file interferes with swank clojure. I need to look at it more carefully. Thanks for your help
08:45prhlavailowry: my work os is linux (debian or archlinux). Both work. My experience with macs is close to zero... But as far as I understand slime works over network socket, so maybe some security/firewall thing?
08:45prhlavailowry: you are welcome....
08:47prhlavaI would need to do (def clojure.core/*use-context-classloader* false) from code, but this does not work from user name space) Do I have to switch to clojure.core namespace or there is a way to set this symbol?
08:48ilowryprhlava: not sure this is a socket problem, as the other slime clients (sbcl, clozure CL) work fine, but I'll check
08:49prhlavailowry: aha, then I am still puzzled. Good luck.
08:49ilowryprhlava: thanks
08:51prhlavahave to go
08:53Xenon1ilowry: Maybe you could try this : http://github.com/citizen428/ClojureX It installs everything you need for using clojure with Emacs and TextMate. It worked flawlessly for me (both with Aquamacs and Emacs for MacOSX)
08:55ilowryXenon1: Thanks for the link. I'll look it. But I just can not understand what is wrong with my current setup
08:58Xenon1ilowry: Well, if you install ClojureX you might compare the two setups and spot the problem ;)
08:59ilowryXenon1: it maybe. thanks :)
09:29LauJensenWas ForkJoin included in JDK7 ?
09:35LauJensen~ google forkjoin included in jdk 7
09:35clojurebotFirst, out of 819 results is:
09:35clojurebotfahd.blog: JDK 7 - Fork-join and ParallelArrays
09:35clojurebothttp://fahdshariff.blogspot.com/2008/04/jdk-7-fork-join-and-parallelarrays.html
09:43ilowrypuff! Just solved the hung problem with closure-mode & swank-closure in Emacs. The reason seemed to be in slime-fancy module. After I removed it from the list given to (slime-setup ...) function in my Emacs init file, I was able to interact with clojure in slime. Just in case it can help somebody else.
10:14chouserwith the same pride as one might reinvent the wheel
10:14chouserperhaps I should read about it a bit first
10:23cburroughsFollowing java practices I have namspaces that look like tld.company.foo.bar.bax.qux.partIactuallyCareAbout. This looks really annoying in the repl. Is there any way to shorten that in general (or just in slime)?
10:27chouserthere are some advocating abandoning the Java conventions and going for more of a uniquepackage.PartThatMatters
10:27chouserand you can use 'import' -- that's about it, I'm afraid.
10:30cburroughsAs someone working with lots of java people, I think the convention is for the best. I just want a way to mitigate the pain of a 60+ character promt
10:33chouseroh, just in the prompt?
10:33chouserI think there's a way to fix that.
10:44rhickeypackage aliases are a possibility
10:45chouserI would love package (and class) aliases.
10:45rhickeychouser: which?
10:46chouserhm? both!
10:47rhickeysounds complicated
10:47cemerickclass aliases sound like trouble
10:48chouserfor inner classes especially would be useful.
10:48rhickeychouser: these are inner classes with statics or enums, where you need to use the classname often?
10:49rhickeysince you could always make an encapsulating ctor function
10:49harrisonhm. does reify not support [& rest] methods, or am i just messing it up somewhere?
10:50rhickeyharrison: does not
10:50cemerickyeah, I can see that. I've typed Field$Store/YES too much.
10:52cemerickstill, just def-ing those constants seems like a better option than classname aliasing
10:53rhickeyare we ready for RC2 ? or 1.1?
10:53cburroughsSo in summary there is no in clojure solution now, but chouser thinks there might be some sort of slime magic?
10:53chouserrhickey: right, class names used as value (enums, constants) and type hints
11:14chousercburroughs: in a normal terminal you can launch a repl with a custom :prompt set. I dunno if slime can leverage that or perhaps has something similar.
11:15cburroughschouser, Thanks, I'll look into it
11:26fliebelWhy doesn't await(-for) return the agent? I was surprised when I found out it did not. It's as simple as adding agent to the last line, isn't it? Can't hurt, in my opinion…
11:29fliebelalexyk: How is clojure-twitter doing?
11:30alexykfliebel: fine, oauth works
11:30fliebelcool
11:38chouserfliebel: await takes any number of agents args. you want it to return a seq of those same agents?
11:39fliebelchouser: Hmmm, in that case it would not be logical to do so, but I think that most of the time you only use one.
11:40fliebelBut in this case it would be a nice thing (pritnln (await (some-agent-returning-function)))
11:41fliebelNow I had to do (let [thing (function] (await thing) (println thing))
11:42notostracaI am new to Clojure, and I have no idea how to package an executable jar -- how do the fine people of #clojure do it?
11:42chouser(doto (return-agent) await println)
11:43akingnotostraca: I've started using leiningen - works well. To make a jar, you just type 'lein uberjar'
11:44akingnotostraca: details at: http://github.com/technomancy/leiningen/
11:44notostracaI couldn't figure out how to get it to work on windows
11:44fliebelchouser: would it be very confusing to add this to the end of await? (when (= (count agents) 1) (first agents))
11:44akingnotostraca: I'm not on windows, sorry - but I believe they are working on windows support - check the maillist
11:45notostracaah
11:45chouserfliebel: you saw my doto idea?
11:47fliebelchouser: yea… it's better, but… It's just not what I expected it to do, just an idea to make Clojure more intuitive or confusing… because I agree that it's not a good thing to return a seq of them.
11:48chouserfliebel: yeah, I'm not sure. fortuately for me my opinion doesn't matter, just rhickey's. :-)
11:48lpetitdoes anybody have experience with Eclipse RAP ?
11:49lpetitTrying to choose between alternatives to extend our current desktop application to enterprise intranet (low number of users)
11:49lpetitGWT is an option, but would require us to rewrite the whole UI part,and make it more difficult to share existing stuff too
11:50lpetitBut GWT would refrain us from adding clojure eventually (or just in the server part)
11:50notostracahi lpetit, tommy.ettinger here
11:50lpetitnotostraca: Hi tommy. Haven't forgotten you, but my "hacking night" is tuesday, so it's tonight :-)
11:51notostracayay for hacking night :-)
11:51lpetitnotostraca: but still at work currently
11:51notostracaah, can you use clojure there?
11:54lpetitnope
11:54lpetitnot yet ;-)
11:54lpetitbut thinking about it very har
11:54lpetitd
11:57fliebelchouser: Your doto doesn't work for me for some reason… I tried using an anonymous function, but nothing happened.
12:00pdkhm, what could be wrong with this syntax: (doseq [x enables] (. GL11 glEnable x))
12:00pdk"unable to resolve symbol: x in this context"
12:01pdkthough could it be cause i used into-array to construct enables
12:01chouser,(doto (agent 6) (send inc) await)
12:01clojurebot#<Agent@5df3c5: 7>
12:02fliebelchouser: hey, the thing returned the agent, so I could put my own function outside the doto.
12:03chouseryes, doto returns it's first arg
12:03fliebelnice...
12:06chouserpdk: that's weird.
12:12lpetitpdk: shouldn't it be (doseq [x enables] (. GL11 (glEnable x))) or even better (doseq [x enables] (.glEnable GL11 x)) ?
12:12chouserprobably (GL11/glEnable x)
12:13chouseranything starting with dot and a space should be avoided except perhaps when emiting code
12:13pdkhm changed it around a bit
12:13chouserbut that doesn't explain the x error
12:13pdk(doseq [x (range (alength enables))] (. GL11 glEnable (aget enables x))) seems to run now
12:14pdkis this a known issue with doseq's handling of java arrays
12:14chouserno
12:14lpetit,(doseq [x ["a"]] (. (java.util.ArrayList.) add x)
12:14clojurebotEOF while reading
12:14lpetit,(doseq [x ["a"]] (. (java.util.ArrayList.) add x))
12:14clojurebotnil
12:15chouser,(let [enables (into-array ["1" "2" "3"])] (doseq [x enables] (prn (Integer/parseInt x))))
12:15clojurebot1 2 3
12:16chouserthere shouldn't be any way to be inside (doseq [x anything] ...) and have x be undefined
12:32jneira, (reduce + 1 '(1 2 3))
12:32clojurebot7
12:33jneira@src reduce
12:33jneirajum
12:36pdk,(doseq [x (range 3) y (range 4)] (print (str "x: " x "; y: " y " -- ")))
12:36clojurebotx: 0; y: 0 -- x: 0; y: 1 -- x: 0; y: 2 -- x: 0; y: 3 -- x: 1; y: 0 -- x: 1; y: 1 -- x: 1; y: 2 -- x: 1; y: 3 -- x: 2; y: 0 -- x: 2; y: 1 -- x: 2; y: 2 -- x: 2; y: 3 --
12:37chouserI'm scared.
12:37chouserI think point-free style is starting to become more attractive to me.
12:37chousersomeone help me quick!
12:37pdkpoint-free as in
12:38chouser(partial deliver p) instead of #(deliver p %)
12:39jneira, (source map)
12:39clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
12:39chouser~def map
12:39pdkhm
12:39jneirathnxs chouser
12:39pdkis bitwise-right-shift implemented in terms of java >> or >>>
12:39jneiramy snd time in irc channel
12:40chouserjneira: except it doesn't seem to work. :-/
12:40chouserhiredman: I think github changed their line ids. it's #LID1705 now instead of #L1705
12:40pdker bit-shift-right that is
12:40jneirathe link goes to map definition
12:41chouserjneira: hm, didn't for me. glad it worked for you. :-)
12:41powr-tocchouser: any word on textjure? :-)
12:41chouserpowr-toc: dead dead dead
12:42chouseror at least indefinitely abandoned. I just don't have time for it right now.
12:42Chousukechouser: point-free style is just fine as long as you don't overdo it :P
12:42Chousukefortunately, it's pretty easy to tell when you are overdoing it.
12:42powr-tocchouser: how far did you get with it?
12:43jneira, (clone chouser)
12:43clojurebotjava.lang.Exception: Unable to resolve symbol: clone in this context
12:43jneirajum
12:43chouserpowr-toc: a pretty simple swing-based repl with careful output handling
12:43devlinsf,(let [c (transient {})]
12:43clojurebotEOF while reading
12:43devlinsf (do
12:43devlinsf (assoc! c :a 1)
12:43devlinsf (assoc! c :b 2)
12:43devlinsf (assoc! c :c 3)
12:43devlinsf (persistent! c)))
12:43devlinsfHmmm...
12:43powr-tocchouser: what do you mean by careful output handling?
12:44chouserpowr-toc: errors, printed output, and return values are all colored differently. missing eol's are flagged but formatted nicely anyway.
12:45chouserdevlinsf: stop abusing the transient!
12:45devlinsfchouser: Oh Yeah?
12:45devlinsf,(let [c (transient {})] (assoc! c :a 1) (persistent! c)))
12:45clojurebot{:a 1}
12:45chouserpowr-toc: I started working on a flexible keybinding system to support both emacs and vim-style bindings, but got bogged down and distracted.
12:46chouserdevlinsf: right, don't do that.
12:46powr-tocchouser: missing eols?
12:46devlinsfchouser: Seriously?
12:46chouserdevlinsf: seriously.
12:46devlinsfchouser: what's going on I don't see?
12:46devlinsfchouser: Sorry, I'm trying to check some of the docs
12:47chouserI'm trying to come up with a breaking example.
12:47hiredmanchouser: gah
12:47devlinsfchouser: for transients?
12:47Chousuke,(let [a (transient {})] (dotimes [i 20] (assoc! a i)) (persistent a))
12:47clojurebotjava.lang.Exception: Unable to resolve symbol: persistent in this context
12:48Chousuke,(let [a (transient {})] (dotimes [i 20] (assoc! a i)) (persistent! a))
12:48clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc-BANG-
12:48Chousukehm
12:48Chousukegah
12:48Chousuke,(let [a (transient {})] (dotimes [i 20] (assoc! a i i)) (persistent! a))
12:48clojurebot{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7}
12:48Chousukesee
12:48devlinsfRiht
12:48devlinsfRight
12:48devlinsfanyone: There's a statement in the transient docs I don't get
12:49devlinsfFrom the transient page, at the bottom : "Can't use after returning a persistent version"
12:49devlinsf,(let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c)))
12:49clojurebot{:a 1, :b 2}
12:49devlinsfIs that right?
12:50Chousukehmm. I thought that would throw an exception :/
12:50chouserme too
12:50devlinsfSo did I
12:50devlinsfIs this a bug?
12:50chouserdevlinsf: do you understand the earlier point though? it's important.
12:50devlinsfNo
12:51chouserdevlinsf: you have to use the return value of assoc!, just like you do with the return value of assoc
12:51devlinsfI see that only 7 items were read
12:51devlinsfAh
12:51hiredmanchouser: #L111 and #LID111 both seem to work
12:51Chousukedevlinsf: transients can't be used to write imperative algorithms
12:51devlinsfYeah, I know that's what you want
12:51Chousukedevlinsf: they are not quite mutable :)
12:51devlinsfIt's not how they behave
12:51chouserhiredman: #L1705 didn't for me in firefox 3.0. *shrug*
12:52powr-tocchouser: what did you mean by missing eols are flagged but formated?
12:52devlinsfHmmm... oh
12:52devlinsfI now see you example about dotimes
12:52hiredmanchouser: firefox and github don't play nice
12:53hiredmanat work on windows with firefox 3.5 the line numbers never work for core.clj
12:53chouserpowr-toc: I mean at a regular terminal repl, if you do (print "hi"), you actually see "hinil". textjure breaks them onto separate lines but sticks a different-colored marker after hi to indicate there was no newline.
12:53devlinsfAnyway, is my post persistent! modification a bug?
12:53chouserhiredman: ok. sorry for the noise. :-)
12:54rhickeydevlinsf: correct use of transients is simple - write it without them, then add transient ,!s and persistent!
12:54hiredmanI changed it to #LID anyway
12:54chouserdevlinsf: I think so.
12:54chouser,(let [c (transient [])] (persistent! c) (conj! c :x))
12:54clojurebotjava.lang.IllegalAccessError: Mutable used after immutable call
12:54chouserlooks like hash-maps forgot to implement it
12:54powr-tocchouser: ahhh gotcha... I've just fired it up now... Is there a way to eval expressions from the text area in the repl?
12:55devlinsfrhickey: See my assoc! exmple, though?
12:55chouserpowr-toc: no, the top text-area is dead.
12:55rhickeydevlinsf: which one?
12:55devlinsf(let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c)))
12:56hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Clojure.png :D
12:56devlinsf,(let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c)))
12:56clojurebot{:a 1, :b 2}
12:56devlinsfgranted, I'm misusing transients
12:56rhickeydevlinsf: how would that have bee ncorrect without transient stuff?
12:56chouserpowr-toc: someone forked it on github and hooked up the text area to real files (though without my keybinding stuff). But the repo seems to be gone? :-(
12:56powr-tocchouser: ok... so right now the only features it has that seperate it from the standard repl, are that it's swing based and has some fancy(ish) output handling
12:57devlinsfrhickey I'm modifying the map after psersistent!
12:57chouserhiredman: nice!
12:57chouserpowr-toc: right. hardly even worth existing. :-/
12:57devlinsf,(let [c (transient {})] (-> c (assoc! :a 1) (persistent!) (assoc! :b 2) (persistent!)))
12:57clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.ITransientAssociative
12:57devlinsfThat works right, though
12:58powr-tocchouser: Well... maybe not :-)
12:58devlinsfSo I guess my question is that does my misused behavior constitute a bug?
12:58chouserpowr-toc: but keybindings without a repl would have been equally useless. Maybe I should have started with the hard part. -)
12:58hiredmanhttp://gist.github.com/261648
12:59chouserI do think this is meant to throw an exception. Not sure how important it is.
12:59chouser,(let [c (transient {})] (persistent! c) (assoc! c :x :y))
12:59clojurebot#<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@104a681>
12:59devlinsfYup
13:00devlinsfchouser: Saw the same thing this morning at my REPL
13:00powr-tocchouser: I'm a bit tired of not having a good clojure project to get stuck into so I can really learn this lisp and this damn language I find so interesting... anyway I was thinking a paredit style structure editor of somesort might be interesting
13:00rhickeychouser: yes, patch welcome
13:01defnanyone have any better ideas on writing this: http://gist.github.com/261911
13:02defnquick note: sort-ns doesn't sort anything anymore :)
13:03chouserpowr-toc: would love to have that. Though it requires discipline to keep GUIs from ruining the rest of your Clojure code.
13:03chouserrhickey: against 1.1.x? I guess the patch will probably apply fine either way.
13:04rhickeychouser: no, master
13:06rhickeyI'd like to cut a 1.1 release soon
13:06chouserwhat's it blocking on if not bugs?
13:06chouserworse bugs than we're finding?
13:07rhickeyyes
13:07defnhttp://gist.github.com/261913 <---is that indentation correct?
13:07rhickeycorrectly formed transient code would never create that last bug
13:09chouseryes of course. It's just one of the checks built it to make transients safer to have in the language.
13:12rhickeychouser: the bigger issue is I'm unable to enforce serial usage (as distinct from same-thread) - I'm working on ideas for this. That's one reason I marked transients as alpha
13:14chouserto prevent bashing in place?
13:18pdk,(print (bit-shift-right -1))
13:18clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$bit-shift-right
13:18pdk,(print (bit-shift-right -1 1))
13:18clojurebot-1
13:19pdk,(print (bit-shift-right -255 1))
13:19clojurebot-128
13:19pdkso >>
13:20pdkthat indentation appears correct defn
13:20pdkthough emacs can reindent a line to where it should be if you press tab on the line
13:35alexykHow do you declare map parameters in defns so that you can call like (f :where a :only b) ?
13:36hiredman:(
13:37hiredmanapply hash-map
13:38hiredman,((fn [& a] (let [{:keys [x y]} (apply hash-map a)] [x y])) :x 1 :y 2)
13:38clojurebot[1 2]
13:44alexykok! why sour face?
13:44chouserhiredman doesn't like keyword arguments. He wishes people just passed in maps.
13:46chouserdon't we?
13:47devlinsfI don't think so
13:47stuartsierraThere's a defnk in contrib, haven't looked at it in a while.
13:47devlinsfThe use of &variadic-args and &&keyword-args everywhere is awesome
13:48devlinsfI've had this discussion many times with a Python buddy of mine, and I'm convinced it's more straightforward
13:48devlinsf(or is it * and ** ?)
13:48chouser*args **keyargs
13:48devlinsfAh
13:49pdkchouser's got it
13:49devlinsfAnyway, I think it's the price we pay for being a lisp
13:49chouserhm.
13:49pdkthough in python keyargs would become a dictionary and you could supply as many as you wanted
13:49chouseror being compatible with JVM calling conventions.
13:49devlinsfYeah, not sure which
13:50devlinsfAnyway, the point is keyword args is one of many areas Python handles well
13:51devlinsfGranted, I'm not going to trade parens for whitespace anytime soon.
13:51devlinsf:)
13:51fliebelQuite a lot Python references around here… both pro- and anti-python...
13:51devlinsfIf I had to go back to a normal language, it'd be Python
13:52devlinsfI'm coming from a Rails background, too
13:52devlinsfAnyway
13:52fliebel"normal", that sound like Clojure agains the rest of the world...
13:52stuartsierraLisp always feels embattled.
13:52jneira, (doc pos?)
13:52clojurebot"([x]); Returns true if num is greater than zero, else false"
13:53chouserno longer finding mutable collections or local variable acceptible, the number of languages to choose from has been reduced dramatically for me.
13:53devlinsfWell, right
13:53stuartsierrachouser: basically Clojure, Erlang, and Haskell, right?
13:54chousernareshov: interesting, isn't it? Wouldn't it be great if the author of the blog would write whole book about Clojure?
13:54jneirascala is out...
13:54chouserer
13:54hiredmannow you are unaffected by the paradox of choice
13:54chouserjneira: I meant you, not nareshov.
13:54chouserhiredman: and happy!
13:55fliebelIs there a, well… normal way to add lines to the end of a function in vim? At the moment that involves moving some parens around.
13:55jneirajeje but not alone :-P
13:56pdk,(doseq [x (into-array [1 2 3])] (print (str x " ")))
13:56clojurebot1 2 3
13:56chouserfliebel: (defn f [] ....), put cursor on opening paren, type %i<CR>
13:56chouserfliebel: is that what you mean?
13:57alexykscala can be easily used in immutable way. Default List and Map is immutable, and so are val's. You have to ask for trouble and import mutable maps explicitly, and even rename themn is you still want to use immutable ones.
13:57chouserI learned immutable locals, collections, and lazy seqs (streams) in scala before picking up Clojure.
13:58jneiraval x = new ...
13:58alexykchouser: ah! a fellow polyglot :)
13:58chouseralexyk: I'm more of a serial polyglot. I leave my old langs behind.
13:58chouserwhen I can, anyway.
13:59chousercan't shake off this C++
13:59alexykchouser: the beauty of JVM is, neighbors don't go away and it's tempting to share.
14:00alexykchouser: so how did you let go if static typing? :)
14:00alexykof
14:00stuartsierraSometimes I wish there were a JVM language with C-like semantics.
14:00pdkc++ reminds me of that old "lose the beer gut" weight loss ad where a guy is getting chased around town by a giant rolling gut
14:00chouserScala's a pretty good cure for that, actually. "Oh, you want static types? Here take all THIS"
14:00alexykstuartsierra: C-like means *
14:01stuartsierraC-like means tight control over the size of objects in memory.
14:01alexykchouser: 2.8.0 is coming along nicely. Growth pains. I bet you jumped ship in a moment of befuddlement. :)
14:01alexykstuartsierra: which means * :)
14:02stuartsierraalexyk: which means memory locality, more cache hits, better performance, ...
14:02chouserstuartsierra: I'm looking forward to small-vm targets for Clojure. Not sure what that means exactly -- maybe C or C++ with simple GC or maybe just reference counting.
14:02jneirammm i talked about a clojure implementation in c
14:03stuartsierrachouser: That would definitely be interesting.
14:03jneirawith (malloc .. )
14:03jneira:_P
14:03chouserstuartsierra: I think alexyk means the literal C syntax * for pointers, not asking you to fill in blanks.
14:03ieureArgh. I read a piece on Hacker News last week about a dude who implemented Wide Finder in Clojure and had it running in eight minutes, but I can’t find the link now. Anyone have it handy?
14:03alexykchouser: anyhow, Scala is a lure for Haskell crowd. And Clojure for Lisp one. So now they coexist, which is fun. I was pondering of a clojure/scala/jruby flow even.
14:03chouserjneira: no, not quite. The immutable collestions fall over if you have to manage memory explicitly.
14:03alexykstuartsierra: yeah, I mean C is opinter-based, and JVM makes it moot.
14:03alexykpointer
14:03jneirajava = c - -
14:04stuartsierraalexyk: Oh, now I get it.
14:04piccolinohttp://meshy.org/2009/12/13/widefinder-2-with-clojure.html
14:04alexykieure: clojurebot: google concur next
14:04ieurepiccolino, Thanks so much.
14:04alexykmember:clojurebot: google concur next
14:05slashus2What about doing Clojure in the parrot vm?
14:05alexykclojurebot: google concur next
14:05clojurebotFirst, out of 500000 results is:
14:05clojurebotongoing · Concur.next
14:05clojurebothttp://www.tbray.org/ongoing/When/200x/2009/09/27/Concur-dot-next
14:05cemerickalexyk: not sure about scala being a lure for the haskell crowd. Those I know that like haskell distinctly dislike scala.
14:05foguschouser: Creating a small C gc shouldn't be too bad, there are probably dozens laying around the internet for the taking
14:05chouserfogus: right.
14:05stuartsierraDoing GC efficiently is hard, I don't think anything can keep up with the JVM.
14:05alexykcemerick: #scala presents real practitioners who do both with blue-collar monads (called gonads).
14:06chouserno, the benefits would have to target specifically areas that JVM is weak
14:06chouserstartup time, memory footprint
14:06stuartsierrabit-twiddling, multi-dim arrays, ...
14:06jneiraand why not in python vm?
14:06chouserstuartsierra: yes, but native libs + jvm can mitigate a lot of that.
14:06pdk"scala coders got balls man"
14:06chouserjneira: sure!
14:07alexyki.e., haskell people who don't have to do any real-world work (e.g. JVM) have a luxury to not like anything else; if, however, reality dawns, they start liking Scala real fast.
14:07stuartsierrachouser: true
14:07fogusstuartsierra: Probably right; but it would be a nice experiment to create a small C target geared toward Clojure
14:07jneiradysinger siad that python vm isnt mature ...
14:07jneirajum
14:07stuartsierraIt's certainly more mature than Ruby, but not on par with the JVM.
14:07cemerickalexyk: from what I hear, F# is a more attractive target there, but that's complete heresay
14:08cemerickhearsay*
14:08chouserperl5 as a vm?
14:08jneirajuass
14:08jneiraclojure vm?
14:08chouserjneira: you mean write a new one from scratch? :-/
14:08cemerickchouser: I know a fellow who wrote a scheme in perl5, put it into production @ his company :-)
14:08chouserha!
14:09chouserbeautiful
14:09stuartsierraOne certainly can't complain that perl5 isn't mature.
14:09jneirait's a joke..jvm is a god choose
14:09cemerickhe's trying to convince the bosses to let him open source it.
14:09jneira*good
14:09alexykcemerick: I tried to love MS for F#, but it's too much. PowerShell instead of zsh? Instead of all Mac goodies, like, mine sweeper and solitaire? If there's a business need, though, F# is something special, and with all the VS support and task parallel library is finally a viable MS choice.
14:09stuartsierraEver looked at the source code to Perl 5, though? Scary stuff, man.
14:10chouserjvm is brilliant as a first target platform. I'm looking forward to having other options. C, Objective-C, lua, JavaScript, etc.
14:10chousergolang
14:10fogusI'm looking forward to Clj-in-Clj... can we draw target platforms out of a hat?
14:11chouser:-)
14:11pdkclj for commodore 64 please
14:11jneirammm .net is the snd platform ...
14:11cemerickjs first, then cocoa/objc for some fun UI stuff
14:11chouserthe first few will be hard as we run headlong into the kind of stuff Clojure .NET is already starting to deal with.
14:11fliebelfogus: what is the status of clj-in-clj?
14:12chouserOnce those issues are resolved, I think the backends will be relatively straightforward to crank out.
14:12fogusfliebel: Don't quote me, but I think the seeds are being planted with reify, types, protocols. I'm not the person to ask
14:14harrisonhmm. i was looking at MultiFn. looks like it could be made persistent quite easily.
14:24jan__I'm trying to set up slime with clojure, but when I start slime in emacs, the embedded clojure can't find swank.clj on it's classpath
14:24jan__can anyone tell me where I tell slime where it can find swank?
14:25grantmichaelsjan__ at the brothel
14:25polypus:)
14:25jan__ah, doubt that will work :)
14:25pdkhttp://riddell.us/tutorial/slime_swank/slime_swank.html step to "configure emacs" i think
14:26pdkthough if you're on windows you could dl clojure in a box
14:26jan__running on linux
14:26jan__tried that "configure emacs" step, but it doesn't work
14:26grantmichaelsjan__ you're here for MVCC, i know how you are =)
14:26alexykback to our sheep
14:27alexyk,((fn [& a] (let [{:keys [x y]} (apply hash-map a)] [x y])) :x 1 :y 2)
14:27clojurebot[1 2]
14:27alexyknow, if I want default values for x and y, what's the most gorges way to di them? :)
14:27alexykdo
14:28cemerickalexyk: you can provide defaults in map destructuring via :or
14:28pdk,(let [x (into-array [[(int 1) 2] [3 4]])] (print (str (aget x 1) "; " (aget x 2) "; " (aget x 1 1) "; " (aget x 2 1) "; " x)))
14:28clojurebotjava.lang.ArrayIndexOutOfBoundsException
14:28pdk,(let [x (into-array [[(int 1) 2] [3 4]])] (print (str (aget x 0) "; " (aget x 1) "; " (aget x 0 0) "; " (aget x 1 0) "; " x)))
14:28clojurebotjava.lang.IllegalArgumentException: Argument is not an array
14:28alexykcemerick: where do I stick :or again?
14:30pdk,(let [x (Integer[][].)] x)
14:30clojurebotjava.lang.Exception: Expecting var, but Integer is mapped to class java.lang.Integer
14:30jan__slime says Clojure 1.0.0--SNAPSHOT
14:30jan__user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
14:30jan__user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:3)
14:30jan__user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:5)
14:30jan__user=> user=>
14:30fliebelWhat is a good way to learn all the functions that keep me from using loop? Like reduce, map, doseq, etc. It's not very easy to browse the whole api every time I need to write a loop.
14:31dysingerjan__: ! what the heck are you doing in here ? :P
14:31chouserMaybe the bottom half of http://clojure.org/sequences
14:31chouserfliebel: Maybe the bottom half of http://clojure.org/sequences ?
14:31pdkhttp://java.ociweb.com/mark/clojure/article.html has code examples of various looping constructs
14:32fliebelchouser: hmmmm, I'll look at that, although not very informative it does group them.
14:32pdk,(let [x (into-array [(ints [1 2]) (ints [3 4])])] (print (str (aget x 0) "; " (aget x 1) "; " (aget x 0 0) "; " (aget x 1 0) "; " x)))
14:32clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [I
14:33jan__dysinger: trying to see if someone could shed some light on what I'm doing wrong
14:36alexykwhen testing destructuring, I currently do it like: ((fn [{k :k :or 10 v :v}] (print k v)) {:k 1 :v 2})
14:36alexykdoes (binding ...) do that too or only vars?
14:37alexykis there a shorter way to test-destructure?
14:40grantmichaelsdysinger: he saw the MVCC sign ...
14:40pdkok what types can you pass to ints/floats/etc
14:40mebaran151anybody here use enclojure with the latest clojure plugin
14:40fliebelWhat is a good implicit loop for going through a list and for every item verify a condition, and if it's true return that item.
14:40mebaran151*clojure version, 1.1.0 master
14:40mebaran151fliebel, filter?
14:41mebaran151(filter verifier list)
14:41lpetitMr Ettinger ?
14:41fogusfliebel: Are you building a list of the results? If so, then probably `for`
14:41chouser,((fn [{k :k v :v :or {v 10}}] (print k v)) {:k 1})
14:41clojurebot1 10
14:42fliebelmebaran151: no, I want to return the first match only, not all that match. I might do first on the result, but that seems like a waste of recourses.
14:42fliebelfogus: no, only the first matching item
14:43chouserfliebel: no waste using 'first' -- filter is lazy!
14:44mebaran151yeah I thought filter was lazy
14:44chouseryou could also make 'some' work, though it may be awkward depending on your exact case.
14:44fliebelchouser: so it's going to filter until it finds one match?
14:44fliebelI'll check out some
14:44mebaran151more like, when you ask for the first element, it'll run through the list until it finds one that matches
14:45fogus,(some #{3} [1 2 3 4])
14:45clojurebot3
14:45chouserfliebel: not until you call 'first' on it, but yeah.
14:45fogusthis is a special case though
14:46piccolinoDoes send-off create a new thread every time you call it on the same agent?
14:47chouserpiccolino: good question! Pretty sure it doesn't, but I'll check.
14:48chouserpiccolino: no, it does not.
14:48fliebelThere is one problem with filter and some… I need to have state, I need to check if a file exists in a directory, if it does not, move on directory up and try again.
14:48piccolinochouser, OK, thanks for checking. It was a bit difficult to tell from the docs.
14:48DeusExPikachuis parenthesis balancing handled by the reader?
14:49johnmn3reading that blog (blog.fogus.me).. that usage of :post and :pre.. Might be useful for some kind of input validation template system?
14:49johnmn3erm
14:49johnmn3I'm not trying to be cheeky
14:50fogusfliebel: Why is state needed?
14:50fliebelfogus: because I can't think functional I guess… :$
14:51stuartsierrajohnmn3: I think :pre/:post are meant more for code assertions; since they're disabled by default outside the REPL
14:51fliebelfogus: I'll have to rethink my approach I think...
14:51johnmn3stuartsierra: oh
14:55johnmn3fliebel: what's the basic algorithm you have in your head for checking for the files existence?
14:55mebaran151anybody here use enclojure
14:55mebaran151I can't get the repl to work with 1.1 master
14:55mitchellhSimple question: What is the general method people use to run the clojure program JARs? I mean, if the JAR has 11 other JAR dependencies, how does one setup the class paths? Just setup a bash script for the user and list the deps?
14:56mebaran151mitchellh, you could just make an uberjar use lein
14:56mebaran151and then it gets run like a normal jar with main, all dep included
14:57fliebeljohnmn3: I'm not sure… but what I want to do is use the most "detailed" file. so first I check for a file in the current directory with a specific name, else I want to have the closest general file.
14:58fliebeljohnmn3: I'm now trying to make a seq from a path that goes like a/b/c a/b a
14:58mitchellhmebaran151: Some googling lein = Leiningen ?
14:58mitchellhI'm reading about it now
15:00mebaran151yeah
15:00mebaran151it's a nifty buiild tool
15:00mebaran151someone decided to finally make Maven sane
15:00mitchellhmebaran151: This is great, but what if I'm writing a lib? It would make sense to not make the uberjar there to keep the lib clean.
15:01mebaran151you can declare dependencies in the lein buildfile
15:01mebaran151and then make a pom.xml
15:01mebaran151using lein pom
15:01mebaran151people who use your library with maven will automagically fetch the required dependencies
15:01mitchellhFantastic
15:02johnmn3fliebel: well I'm pretty noob at this, but I'd do that, then get the contents of each of those directories, filter each with regex, stopping at the first one should get you the most "detailed," right?
15:02mitchellhmebaran151: Well, before I ask any other noobish quetsions, I'm going to go read about this and play around with it :) Thanks
15:02mebaran151yeah
15:02mebaran151they made it way to easy to install
15:02mebaran151are you on windows or UNIXy?
15:02mitchellhmebaran151: unix
15:02fliebeljohnmn3: yea, that's what I'm aiming at
15:02mebaran151it's supposed to be broken on windows unfortunately, due to some assumptions about scripting
15:03mebaran151yeah, then you're set
15:03mitchellhSupporting windows [easily] is something I'm not worried about
15:03mitchellhThanks
15:03fliebeljohnmn3: not sure how to make that seq...
15:03johnmn3fliebel: ok.. I'm thinking you should be able to do that pretty functionally
15:03pdkthe simplest working way i've found so far to create say a java int[][] is basically: (into-array (into-array [1 2]) (into-array [3 4]))
15:04pdkthere's probably better eh
15:04mebaran151mitchellh, the jars will work, the build process will not
15:04fliebeljohnmn3: I agree… but how? :D
15:04mebaran151though I suppose if they don't edit your pom.xml, maven should work on windows
15:04mebaran151it's mostly interacting with lein itself that would get problematic
15:04johnmn3fliebel: not sure off the top of my head.. what's java's getPath method?
15:06johnmn3fliebel: or do you just want to work with the string "a\b\c" ?
15:06fogusstuartsierra: "Disabled outside the REPL"... what do you mean?
15:06stuartsierrafogus: I think *assert* is false by default, except in the REPL
15:07fliebeljohnmn3: I don't care, as long as it works...
15:07fogusstuartsierra: I always assumed that was for `(assert)`
15:08johnmn3fliebel: well this is a start
15:08johnmn3,(apply str (drop-last "/a/b/c"))
15:08clojurebot"/a/b/"
15:08fogusIf I compile my blog example, it still throws the :post exception
15:08fogusstuartsierra: If I compile my blog example, it still throws the :post exception
15:09stuartsierrasomeone said that, maybe it's wrong
15:10fliebeljohnmn3: the point is that filenames are not 1 char in the real world
15:10lisppaste8fogus pasted ":pre :post aot" at http://paste.lisp.org/display/92494
15:11defnHow do you get an environmental variable like $HOME into clojure?
15:12johnmn3fliebel: ah, right
15:13fliebeljohnmn3: I'm nearly there...
15:13fliebel,(seq (.split "abc/def/ghi "/"))
15:13clojurebotEOF while reading string
15:13fogus,(System/getenv "HOME")
15:13clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.HOME)
15:13fliebel,(seq (.split "a/b/c" "/"))
15:13clojurebot("a" "b" "c")
15:14fogusdefn: ^^ doesn't work here but should work on your box
15:14defnfogus: thanks
15:15fogusdefn: np
15:15fliebelis there something like map that gives me access to the previous item?
15:15mebaran151i wish there were a way to associate an agent with a given security context
15:15stuartsierra$HOME is also (System/getProperty "user.home")
15:16defnstuartsierra: is one preferred?
15:16mebaran151I'm sure it exists, but it seems like the threadpool forkjoin clojure uses might not agree with the thread context model
15:16defnover the other i mean...
15:16defnfliebel: sorry for not replying to your email yet, im busy with some work stuff until the holidays
15:16stuartsierradefn: The System property is more portable.
15:16johnmn3,(re-split #"/" "/a/b/c")
15:16clojurebotjava.lang.Exception: Unable to resolve symbol: re-split in this context
15:16johnmn3mmm
15:17defn,(use 'clojure.contrib.str-utils)
15:17clojurebotnil
15:17defn,(re-split #"/" "a/b/c")
15:17clojurebot("a" "b" "c")
15:17johnmn3oh
15:17johnmn3is there a way to split without losing the delimiter?
15:18fliebeldefn: it's fine
15:18johnmn3you could just add the / back onto it afterwords
15:18defnfliebel: nice parser though :)
15:19defnjohnmn3: split-with i believe
15:19defn,(split-with #"/" "a/b/c")
15:19clojurebotjava.lang.ClassCastException: java.util.regex.Pattern cannot be cast to clojure.lang.IFn
15:19fliebeldefn: I'm now working on the template stuff
15:19johnmn3fliebel: oh. didn't see that you'd already split it up there.
15:19twbray,(. #"/" split "a/b/c")
15:19clojurebot#<String[] [Ljava.lang.String;@1e3d80c>
15:20defnfliebel: cool im excited to see where you're at :)
15:20twbray,(prn (. #"/" split "a/b/c"))
15:20clojurebot#<String[] [Ljava.lang.String;@f55759>
15:20defn(doc prn)
15:20clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
15:20the-kenny,(seq (. #"/" split "a/b/c"))
15:20clojurebot("a" "b" "c")
15:20defn(doc pr)
15:20clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
15:21defnah, cool
15:21defntwbray: ?
15:22mtm_hmm, leiningen is having trouble resolving a dependency of [org.clojure/clojure "1.1.0-rc1"]. Has 1.1.0-rc1 been added to clojars?
15:22fogus,(seq (. #"/" split "a/b/c"))
15:22clojurebot("a" "b" "c")
15:22fogustwbray: ^^
15:23fliebelis there any looping function that gives me the previous item?
15:23hiredmanreduce
15:24fliebelhiredman: like that, but not ending up with one item, but rather using the previous item for computing the present.
15:24fliebelhiredman: like fibonacci…
15:25mtm_bah, looks like rc1 is not on any of leiningen's default repos. Anyone have any maven coordinates for rc1?
15:25fliebelhiredman: I think I'll use this: http://github.com/richhickey/clojure-contrib/blob/master/src/clojure/contrib/lazy_seqs.clj#L78
15:25stuartsierramtm_: I don't think it's been pushed anywhere, but you can download the ZIP and run "ant ci-build"
15:26mtm_stuartsierra: I'll give it a shot
15:26stuartsierraThat will install in your local maven repo.
15:27mtm_I guess with 1.1.0 final imminent it doesn't make sense to push an rc at this point
15:27johnmn3,(use 'clojure.contrib.seq-utils)
15:27clojurebotnil
15:27johnmn3,(partition-by #(= \/ %) (seq "/hi/by/my"))
15:27clojurebot((\/) (\h \i) (\/) (\b \y) (\/) (\m \y))
15:27stuartsierra,(map str (partition-by #(= \/ %) (seq "/hi/by/my")))
15:27clojurebot("(\\/)" "(\\h \\i)" "(\\/)" "(\\b \\y)" "(\\/)" "(\\m \\y)")
15:27stuartsierra ,(map #(apply str %) (partition-by #(= \/ %) (seq "/hi/by/my")))
15:28johnmn3fliebel: I think for allows you to hold on to more than one value of a seq at a time.
15:29stuartsierramtm_: You'll need to download maven-ant-tasks too.
15:30johnmn3stuartsierra: my repl says that works just fine.
15:30mtm_stuartsierra: thanks (hopefully I already have them)
15:30fliebel,(take 5 (iterate butlast [:a :b :c :d :e])) ; johnmn3: this should do, now only the joining part.
15:30clojurebot([:a :b :c :d :e] (:a :b :c :d) (:a :b :c) (:a :b) (:a))
15:31johnmn3ah-hkha! very nice
15:32hiredmanhttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci
15:32mtm_is the latest rc on origin/master or origin/1.1.x ?
15:32stuartsierra1.1.x
15:32mtm_thx
15:32mebaran151does 1.1 have the local cleaning fix?
15:32johnmn3,(for [x (take 5 (iterate butlast "/ab/cd/ef"))] (apply str x))
15:32clojurebot("/ab/cd/ef" "/ab/cd/e" "/ab/cd/" "/ab/cd" "/ab/c")
15:33mebaran151where holding on to the head won't be the headache it currently is
15:33johnmn3still have to wordify it.
15:33fliebeljohnmn3: I can handle it now, thanks for your help.
15:34johnmn3np
15:34stuartsierramebaran151: no
15:37defn,(use 'clojure.contrib.shell-out)
15:37clojurebotnil
15:40hiredmanhttp://www.technologyreview.com/blog/arxiv/24497/ <-- function of the past, eh?
15:40johnmn3,(System/getProperty "user.home")
15:40clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
15:40mtm_stuartsierra: spiffy, that worked
15:41joshua-choiHey, is there an easy way to compose two predicates f and g into #(or (apply f %&) (apply g %&))?
15:42defnim trying to get the project root from a nested directory... "/my/project/root/is/not/here" -- I want "/my/project/root/"
15:42fliebel,(take 5 (map #(apply str (interleave % (repeat "/"))) (iterate butlast (seq (.split "abc/def/ghi/jkl/mno" "/"))))) ; johnmn3
15:42clojurebot("abc/def/ghi/jkl/mno/" "abc/def/ghi/jkl/" "abc/def/ghi/" "abc/def/" "abc/")
15:42johnmn3fliebel: there it is
15:43defni was thinking something like:
15:43johnmn3gratifying, isn't it?
15:43defn,(reverse (drop 2 (reverse (re-split #"/" (sh "pwd")))))
15:43clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
15:43fliebelyea
15:43lpetithello, could someone help me find where emacs lisp (check-parens) definition is in a standard emacs distribution ? (which file ? generally under which folder layout ?)
15:44lpetitit seems it's not part of paredit, probably of some other "mode" ...
15:44johnmn3i love it when it works.. yea, clojurebot is locked down.
15:44fliebeldefn: I'm just fighting paths as well. How is root defined? the dir called root? the nth item form either sides?
15:45_atodefn: use (System/getProperty "user.dir") for pwd
15:45defn_ato: thanks
15:45mebaran151that's not pwd
15:45defnerr so it isnt
15:46_atomebaran151: ?
15:46defnerr it is
15:46mebaran151user.home isn't
15:46johnmn3its the home dir
15:46mebaran151pwd is in Runtime I think
15:46defnuser.dir for me works
15:46_atouser.dir, not user.home
15:46defnit's the same as pwd
15:46defnwithout the ugly \n
15:47_atohttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()
15:47defn_ato: how would you get two directories above "user.dir"?
15:47mebaran151I think though it gets something weird like Application Support in windows
15:47defnlike /my/current/working/dir/is/this
15:47defnbut i want /my/current/working/dir/
15:48hiredman(-> (File. (System/getProperty "user.dir")) .getParent .getParent)
15:48mebaran151oh
15:48mebaran151much easier way would be
15:48hiredmanit may not be called getParent
15:48defnhiredman: awesome, thank you
15:48hiredmanbut look at the javadoc for File
15:48defnill figure it out, thanks
15:48mebaran151(.getCanonicalPath (File. "../../"))
15:48mebaran151,(.getCanonicalPath (File. "../../"))
15:48clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
15:49_ato,(.getCanonicalPath (java.io.File. "../../"))
15:49clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
15:49_atoheh
15:49mebaran151yeah user.dir maps someplace strange
15:50_atoif it does then "." in java.io.File is also going to map someplace strange ;-)
15:50mebaran151ah, I think I lied
15:50_atocause File uses user.dir as the above access exception shows
15:51mebaran151I would have thought it the other way around, but so is the ways of Java
15:52mebaran151I thought it mapped to the like where the jar actually was
15:52robwolfelpetit: C-h f check-parens: check-parens is an interactive compiled Lisp function in `lisp.el'.
15:54lpetitrobwolfe: thanks very much. I'm beginning a port of paredit.el to clojure, but I'm a noob with emacs so your help is very much appreciated (I prefer spend my little spare time hacking on paredit.clj than on enhancing my emacs skills :-) )
15:56defnthere we go
15:56defn,(.. (File. (System/getProperty "user.dir")) getParentFile getParentFile)
15:56clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
15:57hiredman(-> "user.dir" System/getProperty File. .getParentFile .getParentFile)
15:58fliebeldefn: shouldn't that be java.io.File.?
15:58_ato,(-> "/home/defn/src/myproject/src/myproject" java.io.File. .getParentFile .getParentFile)
15:58clojurebot#<File /home/defn/src/myproject>
15:59defn_ato: that's nicer, thanks
15:59mebaran151then arrow macro has made my life much easier
15:59mebaran151some things are so much clearer with it
15:59defnit's cheating!
15:59defn;)
16:00hiredman~clojure
16:00clojurebotclojure is the best way to learn java
16:01somniumhiredman: how did you end up getting auto-complete to start on all .clj files?
16:02hiredmanah
16:02somniumhiredman: I even use it at the repl now
16:02hiredmanI don't have my .emacs.el on hand
16:02somniumok, maybe later
16:03somniumbtw, did you get rainbow parens working?
16:03hiredmanand I don't know much emacs, but I think ac is a major mode? so you can't just add it to the hooks
16:03hiredmansomnium: nope :/
16:03somniumhiredman: highlight-parens.el, its on elpa!
16:03hiredmanthere is a var called, maybe ac-modes? and you make it a list of modes you want ac to work with
16:03somniumhiredman: you can customize the faces for each level
16:04somniumhiredman: nice, thanks
16:04hiredmanyeah, I have hlp, but I haven't looked at customizing
16:11somniumhttp://tinypic.com/view.php?pic=2urqmgl&amp;s=6
16:13hiredmanooo
16:13somniumcustomize-group -> highlight-parentheses
16:14somnium:)
16:15hiredmanthe weird part is I don't have a dog
16:15the-kennyI want a "my other car is a cdr" sticker
16:15lpetitok maybe I'm a little bit tired tonight. Is (cadr x) equivalent to (rest (first x)) in clojure, or the exact inverse ?
16:15somniuma t-shirt with a minified clojure.core would be cool
16:16somniumlike _why's camping
16:17chouser((fn [{k :k (-> (or 10) v) :v}] (print k v)) {:k 1})
16:17pdkiirc clojure ditches car/cdr etc
16:18robwolfelpetit: (first (rest x))
16:18robwolfe;)
16:18hiredmanpdk: he is porting some code
16:18lpetitrobwolfe: so I was reading it in the wrong sense ... it composes as it reads a -> first, d -> rest => (first (rest x)), ok thanks !
16:19chouseralexyk, but he's gone
16:19robwolfeexactly: cdr = rest
16:20chouser(doc fnext)
16:20clojurebot"([x]); Same as (first (next x))"
16:20lpetitchouser: even better, thx
16:20LauJensenIs the funding graph on /funders out-dated, or did the funding stop at about 60% ?
16:20lpetit(doc nnext)
16:20clojurebot"([x]); Same as (next (next x))"
16:20lpetitcool
16:20triyoI have functions that all need to return a result in json form. What the most idiomatic way to reuse this common pattern so that results of all my functions are wrapped in json-str?
16:21hiredmantriyo: write a macro
16:21stuartsierraOr just wrap all your functions in json-str.
16:21lpetitchouser: or should it be frest , rrest now ?
16:21lpetit(doc frest)
16:21clojurebotPardon?
16:21lpetitchouser: or nrest :-)
16:22fliebelAnother I-should-know-that question: How can I test if a vector contains a value?
16:22triyohiredman: macro is what I had in mind thx
16:22chousernext is closer to cdr than rest is
16:23chouser,(rest '(1))
16:23clojurebot()
16:23triyostuartsierra: thats how I have it right now. Its just that I saw that I could abstract the content type away from the actual functions that deal with logic
16:23lpetit,(next '(1))
16:23clojurebotnil
16:23lpetitok
16:24chouserfliebel: if you have a container that you're mostly using to test to see if things are in it, consider using a set instead of a vector.
16:24chouserfliebel: otherwise you have to use an O(n) scan like 'some' or '.contains'
16:25fliebelchouser: It's returned by Java: http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#listFiles()
16:25lpetitrobwolfe: is emacs lisp a lisp-1 or a lisp-2 ?
16:25stuartsierralisp-1
16:25fliebelchouser: It's a File[], should I just call set on that?
16:26the-kenny,(set (make-array Object [(Object.)]))
16:26clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Character
16:26the-kennyCharacter? huh?
16:26chouserfliebel: 'some' is probably what you want.
16:27lpetitstuartsierra: oh. so I don't understand this code from paredit.el :
16:27the-kenny,(doc make-array)
16:27clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
16:27chouserfliebel: you've the name of the think you're looking for?
16:27the-kenny,(set (make-array Object 1))
16:27clojurebot#{nil}
16:27hiredmanthat is bizzare
16:28fliebelchouser: I'm looking for default.clj for now
16:28lpetitstuartsierra: http://paste.lisp.org/+1ZDE . could you explain what the put does ?
16:28stuartsierralpetit: no, I'm only casually familiar with elisp
16:29lpetit,(make-array Object 1)
16:29clojurebot#<Object[] [Ljava.lang.Object;@1f88953>
16:29the-kenny,(set (make-array Object 10))
16:29clojurebot#{nil}
16:29chouserfliebel: (some #(= (.getName %) "default.clj") (.listFiles (java.io.File. ".")))
16:29the-kenny,(set (seq (make-array Object 10)))
16:29clojurebot#{nil}
16:29chouserthat'll return true or nil
16:29stuartsierralpetit: I'm guessing (put coll x n) places x in coll at position n
16:29hiredmanman
16:29hiredmanelisp is old
16:29hiredmanput is for manipulating property lists
16:29hiredmanhttp://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_8.html#SEC97
16:30fliebelchouser: thanks
16:30lpetithiredman: oh, so it's somehow like placing a metadata on the symbol that's used for the macro ?
16:31lpetithiredman: I think I now remember this from CL
16:31hiredmanyeah
16:32lpetitseems weird now that I'm accustomed to clojure, but I understand, thx
16:34hiredmanproperty lists where a big point of contention durring the common lisp standizing effort
16:34hiredmanI forget exactly how and why
16:36lpetitoddly enough, I see the property lisp-indent-function set to 2 in the property list of the paredit-do-commands macro, and it's not used anywhere else in the paredit code ... some black magic beyond my powers is at use I guess ... :-(
16:36hiredmanlpetit: possibly telling emacs how to indent the code
16:36stuartsierrayes
16:37lpetithiredman: yes. I thought paredit code was maybe in isolation from the rest, but it's certainly more tightly integrated with emacs than I would like ... we'll see
16:38hiredmanI don't think paredit bothers with indentation
16:40johnmn3I always wondered how a indentation tool would handle all situations, if it had full control over all indentations.
16:41johnmn3indedit
16:41lpetitit is said in the comments that it tries not to, though it does it sometimes "very locally"
16:42lpetitjohnmn3: pprint already does a good job of that I think, albeit working on clojure data structures as code, not on text string as code (thus not preserving user comments, etc.)
16:42johnmn3I'd imagine a full on indentation tool would make things unwieldly, with fragments extending far to the right
16:42johnmn3hm
16:42stuartsierrajohnmn3: "Vietnamization"
16:43chouserI wonder if comments and spacing could be tucked into metadata in a way that would allow exact reconstruction of the original sources.
16:44johnmn3couldn't the whole original code string be stored in metadata?
16:44hiredmanchouser: where would the metadata go?
16:45johnmn3seems like a :source metadata string makes sense
16:45chouserI guess I'm thinking at read time so that editors could deal with the data structures at that level.
16:45stuartsierra"Vietnamization: The tendency of Lisp code to wander off to the right, then eventually back to the left, until it resembles the map of Vietnam."
16:45johnmn3stuartsierra: ah
16:45stuartsierra-YTools docs www.cs.yale.edu/homes/dvm/papers/ytdoc.pdf
16:46lpetitjohnmn3: that's what pprint tries to do
16:46johnmn3I had a hunch it'd be along those lines.
16:46chouserhiredman: since many scalars don't support metadata, it'd have to go in an enclosing collection.
16:46lpetitchouser: allowing exact reconstruction would be great, and allow one to just rely on a unique reader ! :-)
16:47johnmn3mm.. but because (comment ..) is not evaled, even macro time tools can't store the string?
16:47_atoyou would need a different reader
16:47_ato(comment ...) is jsut a macro so you can find that
16:47chouseryes, but it could be a backward-compatible reader
16:47_atobut what you can't find is the whitespace and reader-macro symbols like #_
16:47stuartsierraEven in Lisp, it's hard to draw a 1-to-1 correspondence between characters and code structures.
16:48chouserthat is, this new reader would produce data that all existing tools (esp. the Compiler) could work with.
16:48lpetit#_ is a reader macro too ...
16:48stuartsierraIt would be much more fun to have a real structural editor.
16:48lpetit_ato: sorry for the repetition
16:48chouserstuartsierra: this would enable that.
16:48stuartsierraIF it could be written.
16:48chouserallow a real structural editor to edit things like comments, #_foo, etc.
16:48chouserright.
16:49chouserit wouldn't be pretty.
16:49stuartsierraI think it would be much easier to write a structural editor from scratch than to try to recover structure from characters.
16:49johnmn3yea, I've always wanted work with a structural editor, without having to learn emacs or vi (though I suppose those aren't real structural editors...)
16:50lpetitchouser: the classical problem of structural editors ... certainly too rigid for writing source code incrementally ... I guess adding paredit to ccw will suffice to users just as it seems to suffice to emacs users (at least it will for a while :-) )
16:50stuartsierraEven paredit is just scanning for matching delimiters.
16:51stuartsierraI took a stab at a structural Lisp editor in Javascript, found it very hard to break away from the code-as-text habit.
16:51chouserstuartsierra: you still need a way to handle comments, don't you?
16:51_atoprobably simplifying the model to would help implementation: don't allow custom indentation, don't allow arbitrary spaces between list element (just comma or no-comma), don't allow trailing whitespace. Then it becomes basically a question of where you put line breaks. But perhaps that's simplifying too far ?
16:51hiredmanchouser: if only we had a reader written in clojure
16:52stuartsierrachouser: I never got that far.
16:53johnmn3heh
16:53chousermaybe docstrings are sufficient
16:53hiredmanmy gui repl thing just counts the parens and does (zero? (mod x 2))
16:55johnmn3I wounder what the default would be? for any given function that takes three arguments, do you put the first argument on the same line and the next two on the following lines? and what if the first argument is a function which takes three arguments? Now you have it's first argument on the same first line... and so forth until you have 50 arguments and parens on one line? where do you draw the line?
16:55lpetithttp://www.osenkov.com/diplom/contents/1/5/
16:55johnmn3hiredman: yea, just a bit cleaner than my 70 some line parens counter.. with 5 closed over atoms :)
16:55lpetit~gui repl
16:55clojurebotthe repl is holding onto the head of sequences when printing them.
16:56lpetithiredman: where's your gui repl ?
16:56_atoit depends a lot on the function and the context. "if" you often want to split into 3 lines, but occasioanlly it reads better as 1-liner (if foo? 2 5)
16:56_atoa structural editor doesn't have to make that sort of decision for you though, let the programmer deicde
16:56_atoit'd annoy me to no end if it did ;-)
16:56hiredmanjohnmn3: :P
16:57hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Clojure.png http://gist.github.com/261648
16:57hiredman_ato: you get all kinds of heuristics
16:58lpetit_ato: the indenter I intend to add to ccw will just correctly reindent the start of the lines. And it will do so in a totally predictable manner : 2 spaces for each argument that's not on the first line when parens, 1 space for every element of literal vectors, sets or maps (at least at first)
16:58fliebeldefn: I'm done! http://github.com/pepijndevos/utterson/blob/master/test/template_test/template_test.clj calling template invokes the last function in the appropriate template file, supplying the used page, for body, title, etc. and the other pages for menus, blog pages, etc.
16:58hiredmanbased on the number and "size" of earch argument
17:00lpetithiredman: thanks for the screenshot. Interesting stuff !
17:01johnmn3hiredman: I messed with it for a minuted.. couldn't get the background to go white! .setBackground on the JPanel and the JScrollPane was no help.
17:01johnmn3*minute
17:02chouserswing is pure joy
17:02hiredmanjohnmn3: because of how stuff is rendered it can be difficult to figure out where to type, so I'm leaning towards accenting the different more instead of toning it down
17:02hiredmanchouser: :P
17:03fliebelAre functions relying on the file system considered functional? I guess not, but calling them multiple times with the same input on the same file should give the same output, right?
17:04johnmn3yea.. could try to set up mouse listeners for the whole window and have them redirect focus on the input box
17:04hiredmanjohnmn3: good idea
17:04johnmn3you don't want the mouse anywhere else, anyway.. at least, I can't think of a good usage of having them anywhere else.
17:05hiredmanjohnmn3: might want to go clicky
17:05johnmn3perhaps on a menubar, but every where else could redirect.
17:05hiredmanclick on a datastructure to get an exploded view
17:05johnmn3hmm?
17:05johnmn3ah
17:05hiredmanfile explorer in repl
17:07johnmn3well, I'd imagine the most intuitive thing then.. would be that where a not obviously clickable object/region within the repl is, have it listening and redirecting to the input box.
17:08lpetitfliebel: you said it yourself, "pre-requisites" that are not part of the function arguments: the current status of the file, for one. And also, you can get an I/O exception, so no, definitely not purely functional they are
17:08johnmn3like if a collapsed tree is presented, allowing the user to delve into the data structure.. but it is collapsed as one node, then only the small expand dot should be outside of the "redirect to input" listening region.
17:09johnmn3intuitively then, one would just click in the whitespace to begin writing again.
17:10hiredmanyou can just create some kind of JCompenent at the repl and call $ on it, and it will render
17:10hiredmanso that is pretty cool
17:11johnmn3hiredman: does that many anything will render? like, even an embedded browser?
17:12johnmn3typing (show menubar) and a menu bar pops up within the repl would be cool.
17:12hiredmanjohnmn3: if it's a JComponent, there might be some focus issues and such
17:13patrkriscan anyone tell me why (binding [inc (fn [n] (+ n 2))] (inc 1)) doesn't return 3?
17:13hiredman($ (JLabel. "Foo"))
17:13johnmn3i've also been toying with the idea of a contextual repl.. has anyone ever worked with cisco switches or routers?
17:13hiredmaninc might inline
17:13hiredman(meta #'inc)
17:14hiredman,(meta #'inc)
17:14clojurebot{:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 618, :arglists ([x]), :inline #<core$fn__4729 clojure.core$fn__4729@1724852>, :doc "Returns a number one greater than num."}
17:14lpetit,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1))
17:14clojurebot2
17:14hiredmanyeah, so the body of inc is inlined at compile time
17:14patrkrishiredman: aha... I guess there is nothing I can do then?
17:14patrkrisI'm just using it as an illustration of binding
17:15hiredman,(alter-meta! #'inc dissoc :inline)
17:15clojurebot{:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 618, :arglists ([x]), :doc "Returns a number one greater than num."}
17:15hiredman,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1))
17:15clojurebot3
17:15lpetit,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1))
17:15clojurebot3
17:16patrkrishiredman: much too complex for my illustrative example... I'll redesign it. Thanks for the help.
17:16hiredman+ is inline for the two arg case
17:16hiredman,(binding [+ *] (+ 2 3))
17:16clojurebot5
17:16hiredman,(binding [+ *] (+ 2 3 1))
17:16clojurebot6
17:17hiredman,(binding [+ *] (+ 2 3 2))
17:17clojurebot12
17:17johnmn3in a cisco switch, you type "conf t" (short for "configure terminal") to get into the configuration mode. which changes the prompt to: hostname(config)
17:17johnmn3then you type "int fa0/1" to get into Interface FastEthernet 0/1: hostname(if-config), etc
17:18johnmn3I thought having a repl to configure a program (or your repl) using a contextual interface would be pretty neet.
17:19johnmn3the great thing is that you can do a <tab> or an <?> in any given context to find out what available commands there are.. it's very easy to go into a switch you've never been in before and figure out your way around.
17:20johnmn3So I was wondering, would that kind of thing be possible with a namespace at the repl?
17:21johnmn3like, a repl.config namespace? where I could save configuration, load configuration, turn on and off properties
17:22somniumjohnmn3: putting a user.clj on the classpath kind of works like that now
17:23johnmn3true
17:24johnmn3you could probably get by with a ,config {:background-color ..}
17:25johnmn3just thought it'd be neet, you could drop down into a context with a whole DSL for a certain job.
17:26johnmn3I guess DrScheme has something like that, with different levels of easiness (for noobs)
17:26hiredmanI really need to namespace the code and do a proper repo, I got history working last night too
17:26johnmn3*neat
17:26johnmn3really?
17:26johnmn3nice 1
17:27hiredmanyeah, there are some issues with enter
17:27hiredmanI need to find a way to catch "enter" keypresses and selectively let them through
17:27somniumwhen you type (fn ...) at the repl does the runtime store a .class file in memory?
17:28hiredmanyes
17:28johnmn3rendering issues? those boxes.. I have a dark GTK theme in ubuntu and it looks a little funny with the white boxes on dark dark brown.
17:28somniumis there a way to get a handle on those files?
17:29hiredmansomnium: they aren't files
17:29hiredmanthey are bytecode in ram
17:29johnmn3serialization?
17:29somniumso if you serialized it, != .class file?
17:31johnmn3hiredman: ah, you mean stop the enter key from actually making a \newline in the textarea?
17:31hiredmanyeah
17:31hiredmansomnium: actually you might be able to recover the byte arrays
17:32johnmn3somnium: not in the java -cp my.class sense, I don't think.
17:32somniumwould be nice to have (save-image!) or something like in smalltalk
17:33johnmn3I don't see why that wouldn't be possible.
17:34johnmn3in fact, I think a performance trick for faster start up is to pre-cache, or pre-.. pre-something which pretty much suspends the running code.
17:35johnmn3hiredman: if you set the text area only one row in length, pressing enter doesn't do anything.
17:35johnmn3you could then decide to add another row to the text area selectively, when you get an enter key press?
17:36hiredmanI was thinking there was a method on ClassLoader that return the bytes for a class
17:36johnmn3iirc
17:36hiredmanbut there isn't
17:36somniumhiredman: wall-hack into c.l.Compiler maybe?
17:37hiredmanClasses are serializable, but I am not sure if the serialized form can just be written to a class file
17:38johnmn3hiredman: how about setting the text area to only one row in length?
17:38hiredman"serializing java.lang.Class instance does not really write the content of the class file in to the stream. It only write a class descriptor. At the read end it will try to locate the class file locally and validate the class file with the information in the descriptor.
17:39hiredmanjohnmn3: I don't think that will effect the underlying issue
17:39somniumhmm, headius might have some input, doesn't appear to be around though
17:39headiusinput on what
17:40somniumheadius: trying to serialize bytecode in the runtime to .class files
17:40johnmn3hiredman: I'll have to check again, but I think pressing enter on a one row TA doesn't do anything, which would allow you to catch the enter without the new line. Then selectively add rows.
17:42pdkhow's the current state of clojure-eclipse
17:42headiussomnium: once you've classloaded it you can't get at the bytecode anymore as far as I know
17:43headiusis this for serializing a function or something?
17:44somniumyeah, like at irb typing: a = lambda {|x| x * x}, save-image!, restart irb and a is there
17:44somniumheadius: conceivable?
17:45headiusclosures are hard, and I think all functions in clojure qualify as closures, right?
17:45headiusthe problem is not getting the code across as much as getting the surrounding state across
17:46headiusthe context in which it runs
17:46headiusyour best bet in both cases would be to reverse it to code and re-evaluate/compile it on the other side in a new appropriate context
17:46headiusthat's theoretically possible in JRuby but there's no API for it
17:46somniumhmm, maybe once we get metadata on fns
17:47technomancyserializing a single closure might actually be more difficult than serializing the whole state of the VM
17:47somniumheadius: the env of blocks is accessible in ruby, right?
17:48headiustechnomancy: yes
17:48headiussomnium: indirectly, yes
17:48hiredmanclojurebot: fn minus
17:48clojurebotant clean and rebuild contrib
17:48headiusyou can evaluate code against that context (use it as a binding) but you can't really poke it directly
17:49headiusinteresting fact: this is also why define_method is slower than real methods, because it has to maintain a closure environment for every call
17:49headiusin either ruby or clojure cases, though, the code is the least of your problems
17:50hiredmanhttp://paste.lisp.org/display/91148
17:50technomancyheadius: is that the only reason define_method is slower? interesting.
17:51hiredmanclosed over locals are fields in the resulting fn class
17:51headiustechnomancy: that's the main reason
17:51somniumheadius: does it make a new class for every new method?
17:51hiredmanso if you don't use any closed over locals it's not a problem
17:51headiusa secondary reason is because it uses block arguments, which are using masgn, which is slower in most rubies
17:51johnmn3hiredman: I just tested it, setting (.setRows 1) on a JTextArea makes it not able to expand on <enter>
17:51headiussomnium: impl detail
17:51somniumok
17:51headiusin JRuby everything interprets for a while, but once they jit there's a class per body of code in memory
17:52headiusbecause that's the granularity on which we jit
17:52hiredmanjohnmn3: the expansion is not the problem
17:52hiredmanI like the expansion
17:52johnmn3what's the problem?
17:53johnmn3the problem is that _sometimes_ you don't want it to expand, right?
17:56hiredman,(let [x 1 y (fn [] x)] (wall-hack-field (class y) :x Object))
17:56clojurebotjava.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
17:57lpetitpdk: usable. But I'm biased, I'm for a great part the author :-)
17:58somnium,(doc wall-hack-field)
17:58clojurebot"([class-name field-name obj]); Access to private or protected field."
17:58hiredmanfrom java-utils
18:02somniumI get: Can not set java.lang.Object field user$eval__3708$y__3710.x to java.lang.Class
18:07defnwhat's an easy way to strip the first line of a block of text?
18:07defn1234\nasdf\n => asdf\n
18:08defnthis reminds me of _why's what_method? -- it'd be cool to build one of those in clojure
18:08headiusback
18:08defn(what-makes "abc" "ABC")
18:08defnsomething like that
18:08defnhiya headius
18:08defnwhat's an easy way to strip the first line of a block of text?
18:09arohner_defn: you can probably line-seq then rest
18:09hiredman,(let [x (fn [] 1)] (-> x class .getFields first (.get x)))
18:09clojurebot1
18:09hiredman,(let [y 1 x (fn [] y)] (-> x class .getFields first (.get x)))
18:09clojurebotnil
18:10somnium,(apply str (drop-while #(not (= \newline %)) "foo bar\n baz"))
18:10clojurebot"\n baz"
18:11defnhm, specifically i have the output from (print-doc form)
18:12defnim using with-out-writer to print the output of print-doc form
18:12somnium,(alias 's2 'clojure.contrib.str-utils2)
18:12clojurebotjava.lang.NullPointerException: Expecting Symbol + Namespace
18:15somnium,(require '(clojure.contrib [str-utils2 :as s2]))
18:15clojurebotnil
18:17somnium,(s2/replace "foo bar baz\nbar konk\boom" #"^.*[\n]{1}" "")
18:17clojurebot"bar konk\boom"
18:18somnium,(rest (s2/split "foo bar baz\nbar konk\nboom" #"\n"))
18:18clojurebot("bar konk" "boom")
18:19somnium^^ maybe less ugly?
18:19johnmn3hiredman: so why were you wanting to intercept the enter key?
18:22defnhow can i intercept (print-doc #'and) before it gets handled by with-out-writer?
18:24somnium,(source print-doc)
18:24clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
18:24somnium,(use 'clojure.contrib.repl-utils)
18:24clojurebotjava.lang.ExceptionInInitializerError
18:25somniumdefn: well, if you check the source to print-doc it just gets the meta data off the var
18:25_mstemacs rainbow paren hideousness if anyone wants to try it: http://dishevelled.net/elisp/rainbow-parens.el. I don't actually want to use this--just wanted to see if it was possible :P
18:25defnsomnium: yeah, that actually is fantastic
18:26defnthank you :)
18:26defnwhat is ^v?
18:28mitchellhdefn: "^" is a reader macro for metadata, but its deprecated in 1.1.0
18:28mitchellhdefn: It does the same thing as the "meta" function
18:28defnmitchellh: what is it replaced by?
18:29defnah
18:29mitchellhdefn: It was always shorthand for "meta"
18:29mitchellhyep
18:29defnso now it will always be (meta v)
18:29defninstead of ^v?
18:29mitchellhYep
18:30mitchellhI'm not sure why, I'm fairly new to clojure, perhaps readability? I'm unsure
18:30mitchellhI just read the messages the 1.1 RC1 is giving me :)
18:30hiredmanrich wants to use ^ for type hinting
18:30defn:)
18:30mitchellhhiredman: thanks!
18:32mitchellhI have a question about "leiningen" if anyone is savvy: I'm trying to write a lib which uses HtmlUnit but HtmlUnit 2.6 isn't in maven central so "lein deps" doesn't work with it. What other options do I have to specify it as a dependency?
18:32defn,(str "*" (ns-name (:ns (meta #'and)) "*")
18:32clojurebotEOF while reading
18:32defn,(str "*" (ns-name (:ns (meta #'and))) "*")
18:32clojurebot"*clojure.core*"
18:32neotykhiredman: I'm trying to run clojurebot and have some issues getting it to run, can you help?
18:33neotykhiredman: or do you have some instructions on how to run it
18:34hiredmannow is not a good time
18:34hiredmanclojurebot () { rlwrap java -server -Djava.security.manager -cp $CLASSPATH:./clojurebot/ clojure.main -i clojurebot/hiredman/clojurebot.clj -r
18:34hiredman}
18:35hiredmanthat's how I start it
18:37neotykhiredman: what version of clojureql bot depends on? one I got from http://www.gitorious.org/clojureql/ is using different name space
18:40neotykhiredman: what is in $CLASSPATH ?
18:45defn,(re-gsub #"\n" "" "hello world\n testing\n")
18:45clojurebot"hello world testing"
18:47neotykhiredman: thanks anyway, will let you know if I manage to run it
18:49defnwhat is pr-on in (source pr)?
18:49defn,(source pr)
18:49clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
18:52defnthe source for pr shows: (defn pr ([] nil) ([x] (pr-on x *out*))...)
18:52defnbut i can't find pr-on anywhere
18:53q1hi
18:56q1any ideas on how to build a list of all defs defined in a particular library? (using clojure.contrib.repl-utils)
18:56defnq1: (vals (ns-publics 'clojure.core))
18:56defnthat gets you closer
18:57q1yup looks like just a parsing problem now
18:57defnq1: whatcha building if i may ask?
18:57q1slickedit module for clojure
18:58q1i'd like to color code a list of common defs for example
18:58defnah, neat
18:59somniumq1: I think you mean vars (not to be that guy, just because symbols/vars can lead to confusion)
19:05q1somnium: yes guess im interested in public vars bound to functions in commonly used libs
19:05q1this does the trick: (keys (ns-publics 'clojure.core))
19:07defnq1: yeah, i used keys at first
19:07defnbut then switched to vals
19:07defnsince you'll probably be inspecting the #' versions
19:08ubiistarting to dig into clojure and am looking for recommendations on what the best clojure development platform is for linux
19:08the-kennyubii: Emacs + Slime
19:08defnubii: it's painful at first, but you will learn to love it
19:09defni learned emacs while i started learning clojure
19:09defnubii: basically you need to get ELPA, then M-x package-install clojure-mode, swank-clojure, slime-repl, and slime
19:09defnand you're off to the races
19:11ubiithat is what I am currently using, but being a vi guy for ever and a day, emacs takes a bit to get use to
19:11the-kennyIt takes some time, but it's the best lisp editor out there.
19:12defnubii: yeah, it takes time, you can get vimclojure setup and all, but i had nothing but trouble with it, you will learn some of the SLIME tricks and you'll be hacking like a pro in no time
19:12the-kenny(paredit is a must-have)
19:12somnium+ emacs 23 even looks good by default now
19:12defnwhen i found M-. -- that was awesome
19:12defnyeah, with xft
19:12somniumI love the adjust opacity feature
19:12defnparedit-mode quick guide: M-s, M-r, C-)
19:12ubiiagreed, v23 looks way better than v22
19:14kwertiiWhat's the most efficient and idiomatic way to make a per-thread spinner (i.e. a function that returns true or nil in strictly alternating sequence each call) in Clojure? a var? a closure?
19:15ubiiI currently am running v23 with clojure-mode, slime, swank-clojure and have paredit installed
19:15kylesmith,(take 4 (iterate not true))
19:15clojurebot(true false true false)
19:15ubiijust trying to get use to emacs and was wondering if there were any other comparable options that had less of a learning curve
19:16kwertiikylesmith: I don't know in advance how many times it will be called
19:16ubiibut I agree emacs is the way to go, so I guess I just need man up and dig in
19:16somniumubii: if you're not set in your emacs ways yet I would encourage trying ergoemacs too, the standard key-bindings are way saner than emacs defaults (pretty close to vi actually)
19:16kylesmithkwertii: so just omit the call to take. iterate returns an infinite seq
19:19ubiihmm, looking at http://ergoemacs.org, it appears that it is windows only
19:19defnubii: one tip -- it's like quitting smoking, you need to change your $EDITOR, alias vim to emacs, etc.
19:19somniumubii: no, its an elisp package
19:19kwertiikylesmith: interesting, so something like (let [spinner (iterate not true)] .... (foo data (fnext spinner))) ?
19:19defnwhat the heck is ergoemacs
19:20somniumubii: theres a zip file under the windows download
19:22somniumhttp://code.google.com/p/ergoemacs/wiki/DeveloperIntro
19:23ubiidefn: yeah, I thought about just trying to go cold turkey and only using emacs, but I use vi so much for work that I have simply not been able to make the switch yet
19:24somniumubii: viper mode?
19:24defncan (def)'s have a docstring?
19:24defn(def abc "docstring")
19:25somnium,(doc defvar)
19:25clojurebot"clojure.contrib.def/defvar;[[name] [name init] [name init doc]]; Defines a var with an optional intializer and doc string"
19:25ubiiI use to do all of my development in vi, now I have wussed out as I sometimes use gedit or textmate when I am feeling lazy
19:25defnthanks somnium
19:25ubiiemacs is way more powerful than vi, so I just need to start forcing myself to use it more
19:26defnubii: yeah, like i said, just remove your other editors, make them map to emacs, it will be painful for about a week, and then you will start to enjoy yourself
19:26defnit's a hoot once you get over the first few bumps
19:27ubiias part of my original 12-step plan on migrating to emacs, I am now using emacs as my irc client instead of xchat :)
19:28defnhehe, use C-h a
19:28ubiidefn: yeah, I just need to get my balls out of my momma's purse and start using emacs exclusively
19:29ubiithat would be very helpful
19:29ubiiI need Emacs for the impatient :)
19:29somniumhttp://xahlee.org/emacs/emacs.html << is pretty good
19:29ubiithx, I will check it out
19:30defnI don't have a lot of information, not a book, just like 20 things that i slowly learned that i wish i would have knew right away
19:30defnthere's just so damn much...
19:31the-kennyC-h t ftw :)
19:32ubiiwow, just caught myself doing "vi .emacs" to check a config setting
19:32kwertiiwhy does this not work? (let [spinner (iterate not true)] (list (fnext spinner) (fnext spinner))) ;; (false false)
19:32ubiiis that bad or what? :)
19:33somniumhttp://xahlee.org/emacs/emacs_kb_shortcuts_pain.html
19:33the-kennyubii: put alias vi=emacs in your .bashrc or so
19:33somniumthe-kenny: :-)
19:33ubiiyep, that would resolve the problem, wouldn't it
19:35kylesmithkwertii: you're not re-binding spinner.
19:36kylesmithso you can't just bash it in place
19:36kwertiiis there anything like pop that works on sequences?
19:37pdkwhat is the deal with this
19:37pdkafter installing counterclockwise eclipse flips and gives a null pointer exception trying to load a clj file
19:39somnium,(butlast (range 5))
19:39clojurebot(0 1 2 3)
19:39ubiihmm, had forgotten about the emacs screencast out on peepcode
19:40ubiisweet, there is jQuery screencast as well, guess I know what I will be watching tonight :)
19:41kylesmithkwertii: (let [a (atom true)] (defn spinner [] (swap! a not)))
19:41ubiipizza is here, so I need bail, thx for everyones recommendations
19:41defnarray element type mismatch... any ideas?
19:41kwertiikylesmith: interesting, thanks
19:41kylesmithkwertii: but you should really learn how to work with immutable data
19:41kwertiikylesmith: I'm working on that :)
19:43kwertiiclojure.org/lazy says "A seq is like a logical cursor". doesn't that imply that you can iterate through an infinite sequence without using atoms? I'm not seeing anything in the API that does that.
19:43defn(defn apply-markdown [path] (doseq [f (file-seq (java.io.File. path))] (sh "/usr/local/bin/markdown" f "-f" (str f ".html") "-x codehilite")))
19:43defni get an array element type mismatch
19:45ubiisweet, the Emacs screencast is now part of my O'reilly Safari subscription, so I don't have to buy it
19:45defnnevermind, needed to coerce f to (str f)
19:45ubiiso is the Functional Programming with Clojure screencast, which I already watched
19:46ubiifinally, this damn scription is starting to pay off :)
19:46ubiilater all
19:53defnoh my god that is slow
19:54defnrunning that above apply-markdown function on 1007 files :(
19:55q1question. can anyone explain the NIL next of the lines that REPL is printing: (map #(println %) (keys (ns-publics 'clojure.core)))
19:56arohnerq1: println returns nil
19:56q1ah ok lol
19:56q1thought i was going nuts
19:57arohneralso, map creates a new seq of the return values of the function
19:57arohnerif you want to use side effects, doseq is a better option
19:57q1filter seems most applicable here
19:57arohnermap is lazy, because it's assumed that 'f' is pure
19:57q1just wanted a printout
19:58q1you are right about doseq. thanks!
20:03pdkok stupid q, how do you go about uninstalling eclipse plugins
20:08kylesmithkwertii: if you have a loop/recur algorithm (for example), just pass (next spinner) on each recur.
20:09pdkq1 everything in clojure returns something or another even if it's nil
20:16q1pdk: yeah. just not used to the REPL output. thanks.
20:28polypusyou guys have an opinion on jquery vs dojo?
20:30polypusi'm trying to pick a js lib to front a clojure app
20:31pdkguess i should just reinstall eclipse since counterclockwise left its mark
20:43somniumpolypus: dojo is my preference for writing new javascript, but jquery usually wins for instant functionality.
20:58johnmn3and now I embark on a week long mission home from afghanistan.
20:59johnmn3hopefully, I'll be able to sign in to irc from Bagram, like did a year ago. later
21:39pdkso is counterclockwise for eclipse supposed to not work
21:42polypussomnium: ty, i'm going to go with jquery. knock on wood
23:07technomancyis the azul JVM free software?
23:09danlarkinha!
23:11technomancywell they sell hardware, don't they?
23:12danlarkinand they want you to want their jvm
23:14danlarkinin this inspired by cliff click's latest post? pretty interesting read
23:14technomancyso they found some loophole in Sun's application of the JVM
23:14technomancywell I was about to be interested in it until I realized it was about stuff I'll never use.
23:15technomancy*loophole in Sun's application of the GPL, that is
23:15pdkwhat's the gist of it
23:16danlarkinthere's this mention on wikipedia, don't know if it's relevant, http://en.wikipedia.org/wiki/Azul_Systems#Legal_issues
23:16technomancydanlarkin: nah; that's patent fluff
23:17technomancythey've been around since before the relicensing of the codebase though, so they must have some grandfather clause
23:17danlarkinit'd be fun to work on azul boxes instead of ec2, that's for sure :-D
23:18technomancyboxes? you need more than one? =)
23:20pdkhe's going to construct skynet you see
23:23technomancyhah; a Lua implementation on the JVM called Kahlua: http://code.google.com/p/kahlua/
23:23technomancywell played, Brazil.
23:54defnnevermind! M-x hs-minor-mode, C-c @ C-h
23:55technomancylousy binding though
23:55defnyeah, terrible
23:55defnwhat do you bind to tech?
23:55defnor do you not use it?
23:55technomancyI just keep my files short
23:56technomancyunfortunately now that I switched to a widescreen I'm keeping them shorter than before
23:56defnyeah good call -- im really new to this whole structuring in nested directories and all that
23:56technomancystupid aspect ratio
23:56defnso ive been building these massive source files
23:56defnand then splitting it up
23:56technomancyevery time I open my old laptop I just get so jealous of the 4x3 display
23:56defn:)
23:57technomancythen I think to myself, "I should turn the brightness up--oh wait; it is all the way up. stupid non-LED display." =(
23:57defnyeah man, i know the feeling -- i have 4 displays at work with my emmaculate xmonad setup
23:57defni get home and i have one big display, very different feeling
23:57somniumdefn: do you run xmonad on top of gnome?
23:57defnyes
23:58technomancyI should just go get one of those portrait-oriented displays
23:58technomancyunfortunately they don't make laptops like that
23:58defnthat's an interesting idea...
23:59defnportrait laptop display, the keyboard rotates once you open the laptop
23:59technomancythe Alto was portrait-oriented
23:59technomancyahead of its time
23:59defntechnomancy: could i have your opinion for a moment on some code ive been fiddling with?