#clojure logs

2009-08-23

00:48elbenI'm confused by the apply function. Why does (apply + [1 2]) return 3, but (apply print [1 2]) return "1 2nil"? Aren't we applying the function + and print to each item in the given vector? Then, why did the first example add up 1 and 2?
00:49carkit prints 1 and 2 ...then returns nil
00:50carkyou get the same result with (print 1 2)
00:50cark,(print 1 2)
00:50clojurebot1 2
00:50carkhum clojurebot refuses to show it =/
00:50elbeni see it
00:51elbenso what does apply actually do? calls the function on each item in the given arg right?
00:51replaca__I think clojurebot special cases print
00:52lowlycodergl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
00:52lowlycoderhow do I get bit or in clojure?
00:52cark(apply + [1 2 3 4]) is the same thing as (+ 1 2 3 4)
00:52tomoj,(bit-or 1 2)
00:52clojurebot3
00:53elbencark: I see.. kinda. My experinece w/ functional langs are virtually nil (a tiny bit of haskell is all ;)
00:54tomojelben: (apply print [1 2]) returns only nil
00:54lowlycodertomoj: thanks
00:54tomojit prints "1 2", but because there's no newline, the return value is shown immediately afterward on the repl
00:54clojurebotthanks; that was delicious. (nom nom nom)
00:55elbentomoj: yes that makes sense, thanks
00:55carkyou'll get used to apply =)
00:56replaca__elben: compare apply to map. Map calls the function on each element of the sequence and returns a (lazy) sequence of the results
00:57replaca__apply call 1 func with n args, map calls the func n times with 1 arg (unless you give it multiple sequences)
00:57replaca__*apply calls ...
00:58elbenreplaca__: I just started learning clojure, and I haven't gotten to map yet =P
00:59elbenbut i assume it's the same as other languages
00:59elbenor similar
00:59replaca__elben: yup, pretty much
00:59replaca__as is apply (or at least other lisps)
01:00replaca__clojure's laziness is a little different, though. Not as pervasive as Haskell, but more aggressive than most langs
01:01elbeni'm sure i'll get to all that fun stuff eventually =)
01:01replaca__yup, it's all cool!
01:02elbengoing through pragmatic's book right now. I wished it went into more detail (for the benefit of those that do not know a lisp), but I suppose it will work for now
01:16lowlycoderuser=> (import '(javax.media.opengl GLDrawableFactory))
01:16lowlycodernil
01:16lowlycoderuser=> (show GLDrawableFactory)
01:16lowlycoderjava.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:17)
01:16lowlycoderhow do I get clojure to show me all the functions of GLDrawableFactory ?
01:20lowlycoderuser=> (import 'java.util.HashMap)
01:20lowlycodernil
01:20lowlycoderuser=> (show java.util.HashMap)
01:20lowlycoderjava.lang.Exception: Unable to resolve symbol: show in this context (NO_SOURCE_FILE:22)
01:21lowlycoderwhy does the above not work?
01:24replaca__lowlycoder: you've gotta use c.c.repl-utils
01:24lowlycoderclojure.contrib ?
01:25replaca__yah
01:25replaca__http://richhickey.github.com/clojure-contrib/repl-utils-api.html#repl-utils/show
01:27tomojlowlycoder: are you using slime?
01:27lowlycoderno
01:27lowlycodervim user
01:28tomojoh well
01:28tomojin slime you can do C-c I, then type the class (or it guesses it if you're pointing at it), and you can browse all the methods/fields
01:29tomojdoesn't work too well for clojure stuff yet but gives you the signatures for java methods
01:29lowlycoderuser=> GLDrawableFactory/getFactory
01:29lowlycoderjava.lang.Exception: Unable to find static field: getFactory in class javax.media.opengl.GLDrawableFactory (NO_SOURCE_FILE:0)
01:29lowlycoderhowever, I also have:
01:29lowlycoderuser=> (show GLDrawableFactory)
01:29lowlycoder=== public abstract javax.media.opengl.GLDrawableFactory ===
01:29lowlycoder[ 0] static getFactory : GLDrawableFactory ()
01:29lowlycoderso why can't I go GLDrawableFactory/getFactory ?
01:29tomojgetFactory is a method
01:29tomoj(GLDrawableFactory/getFactory)
01:29lowlycoderuser=> (GLDrawableFactory/getFactory)
01:29lowlycoder#<X11GLDrawableFactory com.sun.opengl.impl.x11.X11GLDrawableFactory@45b34126>
01:29lowlycodernice
01:29lowlycoderthanks
01:29tomojhttp://clojure.org/java_interop
01:30lowlycoderyeah, it just confuses me that if (f) evalutes the function,
01:31lowlycoderf # won't give me "hey, this is a function"
01:31tomojnormally it would
01:31tomojbut the java interop is a bit different
01:31tomojGLDrawableFactory/getFactory looks for a static field
01:53lowlycoderhow can a function refer to itself?
01:54lowlycoder(let [my-fun (fn [] .... i want to refer to my-fun from in here)])
01:57tomojlowlycoder: refer? for calling?
01:57lowlycoderyes
01:57tomojyou should use recur
01:57lowlycoderso this function my-fun does some stuff then stuffs itself into a callback function
01:57lowlycoderthe last line of my-fun is:
01:58tomojoh, then no
01:58lowlycoder(. display asyncExec my-fun)
01:58tomojfn is hygienic I believe
01:59tomojso it won't bind a special variable to refer to the function itself
01:59lowlycoderhow do I express these idioms?
02:00tomojare you doing continuation passing?
02:00tomojjust curious
02:00lowlycoderno, converint a swt/jogl app into clojure
02:00tomojhaving a function that refers to itself seems pretty odd to me
02:01lowlycodersupose you have a timer function
02:01lowlycoderthat wants to add itself to the callback at the end of the timer
02:01tomojI think you might be able to do it with letfn though
02:01tomoj,(letfn [(foo [] foo)] (foo))
02:01clojurebot#<sandbox$eval__2562$foo__2564 sandbox$eval__2562$foo__2564@169baee>
02:03lowlycodertomoj: nice; thanks
02:05tomojthat function just keeps returning copies of itself I think
02:06tomojyup
02:06tomojpretty bizarre
02:41lowlycoderdoes clojure have it's own timer classes, or do i need to use java's?
02:41lowlycoderbasically i want to create a thread and have it run at 30fps
02:41lowlycodererr, a function called at 30 fps
02:43tomojthe way the ants demo does it is by sending off to an agent that runs the thread
02:43tomojand then within that, create a new thread that just sleeps for however many ms
02:45lowlycoderdo agents / clojure automatically create threads behind my back, or do I manually create / manage threads?
02:47tomojnormally you manually create/manage threads
02:47tomojagents can make their own though
03:22lowlycoderuser=> Thread/NORM_PRIORITY
03:22lowlycoder5
03:22lowlycoderdoes this change per jvm run, or is iit failry static?
03:32tomojit's always 5
03:32tomojexcept maybe if you switch jvm versions
03:32lowlycoderso reading the java dos, is I have two threads, one of priority 6, one of priority 5, on a single CPU machine
03:32tomojnot sure if there are any historical differences or differences in other implementations
03:32lowlycoderand the priority 6 thread is while(1) { };
03:33lowlycoderthen the priority 5 thread just starves?
03:33lowlycoder(assuming the JIT doesn't optimize that out)
03:45tomojI suppose so
08:43angermanis there a fn that does ['a' 'b' 'c'] [1 2 3] -> ['a' 1 'b' 2 'c' 3] ?
08:44mikem`_angerman: isn't that zip?
08:44mikem`_,(doc zip)
08:44clojurebotIt's greek to me.
08:45mikem`_,(find-doc zip*)
08:45clojurebotjava.lang.Exception: Unable to resolve symbol: zip* in this context
08:45mikem`_,(find-doc zip)
08:45clojurebotjava.lang.Exception: Unable to resolve symbol: zip in this context
08:45angerman,(zip ['a' 'b' 'c'] [1 2 3])
08:45clojurebotUnmatched delimiter: ]
08:46angermanhmm
08:46angerman,(zipmap ['a' 'b' 'c'] [1 2 3])
08:46clojurebotUnmatched delimiter: ]
08:46mikem`_,(doc interleave)
08:46clojurebot"([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."
08:47mikem`_,(interleave ['a' 'b' 'c'] [1 2 3])
08:47clojurebotUnmatched delimiter: ]
08:47kotarak,(zipmap ["a" "b" "c"] [1 2 3])
08:47clojurebot{"c" 3, "b" 2, "a" 1}
08:48mikem`_,(interleave ["a" "b" "c"] [1 2 3])
08:48clojurebot("a" 1 "b" 2 "c" 3)
08:48angermanahh. thanks
08:48mikem`_haha, took a few tries
08:50kotarakthe correct delimiter for string is " not '
08:50kotarak,(macroexpand-1 ''x)
08:50clojurebot(quote x)
08:50kotarak,(macroexpand-1 '"x")
08:51clojurebot"x"
09:30hamzahey guys, if i create a file containing [ 1 2 3 ] and read this in to string is it possible to turn this into a vector?
09:31cark,(read-string "[1 2 3]")
09:31clojurebot[1 2 3]
09:31hamza,(doc read-string)
09:31clojurebot"([s]); Reads one object from the string s"
09:32hamzathank you can i use this to read a while snippet of code and execute it?
09:32cark,(eval (read-string "(println \"hello\")"))
09:32clojurebotDENIED
09:32carkeval denied =/
09:32carkbut yes it works
09:33hamzathanks you.
09:33hamza*thank
09:33carkadd a read and a loop, and you have your very own repl !
09:35hamzai was thinking to store state i would just write the object to disk as lisp statements and read them back to restore state is this good/bad practice?
09:36carki do this as well
09:36carkbut don't eval if you do this
09:36carkthere is a limit to the size of what you can eval
09:36carkwhile reading has no size limitation
09:37carkprudence would also require you to disable read-eval
09:37hamzakk
09:37carki mean *read-eval*
09:38carkmhhh let's see if we can cheat with clojurebot =P
09:38cark,(read-string "#=(eval (def x 3))")
09:38clojurebot#'sandbox/x
09:38carkhehe
09:38cark,x
09:38clojurebot3
09:39carkhiredmaaaan !
09:39hamzahehe
11:36Licenser__hmmm hmmm what is a good thing to start of with clojure
11:37Chouser_projecteuler
11:38Licenser__Chouser: my favourite channel user ^^. And that is a nice ida
11:38Licenser__*idea
11:38Chouser:-)
11:51carkmhh if i want to avoid too many side effects due to retries in a function in a dosync, would it be ok to temporarily memoize that function ?
11:51carkor should i avoid side effects alltogether ?
11:52carksometimes you need to check the state of a ref, depending on it maybe do side effects, then update the ref
11:53carkor is it bad architecture ?
12:01ChouserI'd be suspicious of the desire to put any kind of side-effect in a transaction.
12:07carkyes =/
12:07carkbut there are different kind of ..huh ... side effect severity
12:08LauJensenI would recommend you try, as far as humanly possible, to code without sideeffects. Its not hard to go back from, but its hard to get there.
12:09carkopening a database connection is side effect, and there's no way around it =)
12:09Chousercark: yeah. don't do that in a transaction. :-)
12:09carkwell
12:10carkif the function that returns the connection is memoized for the duration of the dosync
12:10carki mean memoized around it
12:10carkthen i get at worst one connection created
12:11carkor the transaction might fail, and then my connection is up for garbage collection
12:12carkthat sounds hacky doesn't it ?
12:12Chouserwhy not open the connection before the dosync, use it inside, and close it after?
12:12carkthe whole point is about creating connections, that's a connection pool i'm trying to do
12:12Chouseroh
12:13Chouserare you coordinating with other refs, or is there just the one pool?
12:14carkthat's another thing i'm not sure about
12:14carki'd like to have a count of in-use connections
12:14carkso that i can gracefully exit, waiting for all connections to be returned
12:14cark(to th pool)
12:15carkactually this last part is the reason why i need coordination, and risk problems if i'm not creating the connection inside the dosync
12:17Chouserjust musing aloud here, but I wonder if it would help to have new connections be created by a lazy seq
12:17carkmhh
12:18carkit is truely some kind of memoization
12:18Chouserin your dosync you'd (alter connection-seq rest)
12:19Chouserif the transaction retries, you'll keep reusing the first of the connection-seq
12:20carkright this makes sense
12:20carkthough the connection might become unavailable in the mean-time
12:20Chouserwhen it succeeds and commits that alter, your next transaction will cause the next new connection to be created when it callse (first connection-seq)
12:20Chouserhm
12:21Chouserwell, connections can become unavailable at any point, couldn't they?
12:21Chouserthat's just a general real-world failure case.
12:21carkright
12:21carkconnetions are checked before handing these out to the caller
12:22carkand a new one might be recreated on failure
12:22carkso i guess that's a non-issue
12:23carkwell thanks, i might go this direction =)
12:24Chouserit's still a side-effect in a transaction, I guess, but packaged up sufficiently safely. I hope. :-)
12:24Licenser__hmm I like this ^^
12:27rhickeyhttp://dobbscodetalk.com/index.php?option=com_myblog&amp;show=Clojure-vs.-Scala.html&amp;Itemid=29
12:27Chousernot dramatically different than your memoization idea, since that's what lazy seqs do for you anyway, but this allows the consumer to indicate when it wants to reuse the old one (on retry) vs. getting a new one (after commit)
12:29carki think both memoization and lazy-seq are overkill, memoization has this hash-table stuff that i don't need for a no-parameter function, and lazy-seq all the lazy-stuff for a one-off
12:30carkrhickey : hey i'm working in telecoms ! i'm in the fortune 1bazillon bracket
12:31Chousercark: (repeatedly create-connection) ; that's it
12:31carkchouser : right but i need to maintain a reference to the sequence
12:32woodzrhickey: interesting article, although I'm not sure about the "I think Scala's got the edge because I've never grokked Lisp" line of thinking.
12:32woodzAlthough I can imagine moving from Java to Scala being a gentler experience than Clojure.
12:33rhickeywoodz: probably, I'm not too keen on the whole 'vs' way of thinking - the Java market is positively huge and has more than enough room for Clojure and Scala
12:33woodzAgreed. Language wars tend not to go anywhere.
12:35Licenser__I found the article pretty empty. It's a prefference there are hardly any facts at all presentet :/
12:35Licenser__Ruby isn't better then Clojure because I am more used to it either :P
12:37rhickeyI think the fact that it is a question - whether or not a mostly functional Lisp will be a contender, that is most interesting
12:38rhickeyUltimately tools get adopted because people accomplish things with them, not due to any arguments for/against
12:38rhickeye.g. PHP gets not much love as a language in and of itself
12:39cark~paste?
12:39clojurebotlisppaste8, url
12:39lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:40lisppaste8cark pasted "once" at http://paste.lisp.org/display/85905
12:40carkchouser : there !
12:41LauJensenrhickey: Hows newnew coming along ?
12:47Licenser__rhickey: PHP is a horrible language :/
12:47rhickeyLauJensen: I hope to get back to it this week - only 2 things left - fabrication of bridge methods and non-reflective self calls
12:47LauJensengreat
12:51jwr7Is there anything that would prohibit a dosync block inside a watch function?
12:52jwr7I have a watch function (added to an agent via add-watch) and I'd like it to update some refs. But it seems as though my dosync just quietly does nothing...
12:53LauJensenIt can be tough to catch errors in threads, but dosync should work fine
12:53jwr7LauJensen: you mean there could be exceptions thrown without them being visible to me?
13:11Licenser__hrm clojugre gives errors that are about as helpfull as Java exception :/
13:11Licenser__what is this meaning: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Boolean (NO_SOURCE_FILE:0)
13:11Licenser__?
13:14Licenser__The code that caiuses it is: http://pastie.org/592293
13:15woodz(true) on line 10 doesn't look right.
13:15Licenser__never mind I found it ^^
13:15Licenser__woodz: yes exactly
13:15Licenser__I had the impression that I need to put everything in ()
13:16woodzToo many parentheses in a Lisp... Who'd have thought..? ;-)
13:16Licenser__:P
13:19alinphi
13:19Licenser__hi alinp
13:20alinpsomething weird is happening here when using memoize function
13:20alinp(def x (memoize reduce))
13:21alinpand running (x + (range 0 99999999))
13:21alinpno improvement
13:21alinpI mean, running it for few times
13:22alinpwhen used for ... fib function for instance, everything is ok
13:24LauJensen jwr7: I appologize for the delay. Yes - I dont remeber ever seeing exceptions from threads in my lisp buffers
13:24luisalinp: how do you test for equality between two sequences?
13:24jwr7LauJensen: it seems you're right -- removing some println statements cured the issue.
13:24alinpluis: yeah ... now I'm starting to figure it out :)
13:25alinp(range 0 9999) will yield each time other object :)
13:25alinpso, different param
13:25LauJensenjwr7: k, cool. The one certain debug instance you have is (javax.swing.JOptionPane/showMessageDialog nil "foo")
13:25alinptrue
13:25alinpthanks luis
13:25luisalinp: it wasn't a rethorical question, but glad I could help. :)
13:25alinp:)
13:26alinpluis: eq between 2 seq ... are eq if all elements are in the same order and the same elements
13:26alinpsome naive comparator .. it would sould like this
13:26alinpright ?
13:26luisit would what?
13:27alinps/sould/sound/g
13:27alinp:D
13:28luis,(== (range 0 1) (range 0 1))
13:28clojurebotfalse
13:28alinpso, it's using the java approach ? :)
13:28alinpcomparing hashCode ?
13:29luisalinp: IIUC, == calls the equal() method.
13:29Chouser== is for numbers
13:29Chouser,(= (range 0 1) (range 0 1))
13:29clojurebottrue
13:29alinpso, Chouser why my memoization doesn't work ?
13:30alinp(def x (memoize reduce))
13:30alinp(x + (range 0 99999999))
13:31alinprunning it for few times -> no improvement
13:31alinpfor sure I'm missing something, but don't know what
13:32jwr7I'm curious -- why do the watch functions (see add-watch) take a reference argument? You're not supposed to deref it anyway, and you are definitely not supposed to mutate it. So what is it for?
13:32luisalinp: see, I told you I didn't know how test for equality. :)
13:32alinp:)
13:33Chouseralinp: (hash (range 0 1e7)) takes a long time -- that has to be done even to get a cache hit
13:33alinpoh, I see
13:34Chouserit's probably taking almost as long to get the hash in order to do a lookup as it does to sum them
13:34Chouserhm
13:34alinpyeah
13:34alinptrue
13:34alinpit seems so
13:35alinp,(time (hash (range 0 9999999)))
13:35clojurebotExecution Timed Out
13:35Chouseroh, neat -- the assoc of a big range on a small map is fast because it's an array map and doesn't have to hash to insert
13:35alinpok Chouser, it makes sense now
13:38alinpthanks also for hash function, didn't know about it
13:38alinpI used (. xxxx hashCode) :)
13:39alinpin fact, range returns a lazy seq ... ok
13:39alinpand .... in order to get the hash code, you need to evaluate all of it's elements
13:39alinpso, that's why I think it takes so long
13:40Licenser__hmm clojure is really nice for such nifty things as the problems on the project thing
13:43luisLicenser_: project euler?
13:44Licenser_http://projecteuler.net/ <- this one. Chouser was so nice to remind me of it, it's nice to get used a bit to the way you deal with things in clojure
13:44Licenser_I love how you can create a lazy sequence of prime numbers ^^
13:55jwr7java.util.concurrent.RejectedExecutionException -- hints, anyone?
13:56Licenser_Java feels rejected?
13:58Chouserneed a stack trace
13:58ChouserI think thread pools throw that when you try to queue something after they've been stopped
13:59jwr7Chouser: are there any limits to the number of actions I can enqueue?
13:59Chouserdunno
14:00jwr7Chouser: I'm sending lots of agent actions (well, in the thousands) and there is something wrong with the code, so they might get queued somewhere...
14:08LauJensenjwr7: I think you should keep it below 2000 as a general rule of thumb
14:09jwr7LauJensen: uh-oh, then I might have a problem.
14:10jwr7Any reasons for this limit? I would love to be able to enqueue more, as this means less data structures in my application.
14:11jwr7ok, I think the exception was caused by bugs in the code and my testing session. Restarting clojure made it go away.
14:11LauJensenjwr7: Check out James Reeves reply in this post, his first one: http://groups.google.com/group/compojure/browse_thread/thread/1f0df9d6656fa069
14:11LauJensenAccording to him - And I've learned not to question what he says - Its a limitation of Java
14:12Chouserthat's number of simultaneous threads, isn't it? That's not the same as number of agents or number of actions.
14:12jwr7LauJensen: oh, but he's talking about threads, and I mean actions.
14:13jwr7The thread pool is CPUs+2, from what I know. It's just that I expect to enqueue lots of agent actions.
14:13LauJensenI'm talking about threads as well.
14:13Chouser,(let [a (agent 0)] (send a #(do (Thread/sleep 3000) %)) (dotimes [i 1e4] (send a inc)) (await a) @a)
14:13clojurebot10000
14:13Chouser10000 actions, no problem.
14:13jwr7Chouser: oh, cool. I should be fine, then.
14:14Chouser,(let [a (agent 0)] (dotimes [i 4] (send a #(do (Thread/sleep 2000) %))) (dotimes [i 1e4] (send a inc)) (println "awaiting") (await a) @a)
14:14clojurebotExecution Timed Out
14:15Chouser,(let [a (agent 0)] (dotimes [i 4] (send a #(do (Thread/sleep 1000) %))) (dotimes [i 1e4] (send a inc)) (println "awaiting") (await a) @a)
14:15clojurebot10000
14:15clojurebotawaiting
14:15Chouseryou can't see the timing of it there, but if you run it yourself you'll see
14:16Chouserthere I'm clogging up the send queue so that all the inc actions will queue up. You'll see "awaiting" almost instantly.
14:16Chouseroh, I didn't need that -- this is one agent, so my first example was sufficient.
14:22stuarthallowayam I crazy, or didn't somebody start writing seq-utils tests? Don't see them in contrib...
14:22clojurebotcontrib is http://github.com/richhickey/clojure-contrib/tree/master
14:23stuarthallowaydid I just accidentally invoke the clojurebot...
14:24Licenser_How is the regexp support in clojure?
14:27ChouserLicenser_: stellar
14:27Chouserstuarthalloway: he just chimes in on his own at times.
14:27ChouserLicenser_: er, I just meant that clojure has fantastic regex support.
14:27Licenser_oops oh okay
14:28Chousuke,(class #"foo")
14:28clojurebotjava.util.regex.Pattern
14:28Chousukelike that.
14:28Licenser_Good start
14:28Chousercontrib str-utils2 has nice helper functions if what's in core is insufficient.
14:28Licenser_*nods*
14:29ChousukeIt'd be really neat if regexps could be used as functions though :/
14:29ChouserChousuke: would they act like re-seq or re-find or something else?
14:30Licenser_yes it would be nice if you could use them as functions something like: (/"/'/s string)
14:31Chouser(str2/replace string #"\"" "'")
14:31Chousernot quite as succinct as perl, I suppose
14:31Licenser_Chouser: yes but the other one would be nicer :P
14:32Licenser_I love how nice ruby (sorry I love the language) handles regexp's :P
14:32ChousukeChouser: probably just returning the match or nil if none. could be used as a filter. hmm.
14:32ChouserChousuke: both re-find and re-seq do that
14:33Licenser_hmm you could actually give back a lazs seq that gives all matches peace for peace if possible ^^
14:33ChouserLicenser_: that's re-seq
14:33Chouser:-)
14:33Licenser_ow
14:33Licenser_that is incredible nice
14:35Licenser_hmmm I really really like the lazy sequence idea is really really great
14:37ChouserI've done some experiments mmaping a large text file, then using re-seq on it to load and search only as much as needed until I have the matches I need.
14:37Chouserpretty fast
14:38Chouser(take 3 (re-seq #"this.*stuff" mmaped-file))
14:38Licenser_like the further thingy
14:39Chouserseque will do that for you.
14:39Chouserit allows a lazy-seq producer to, in another thread, get ahead of the consumer by however much you want to allow
14:39Licenser_neat
14:50Chouserchunking 'for' just passed all the regression tests. Now to see if it's actually any faster...
14:51Chouseroh, whoops, no it didn't...
14:51Licenser_I wonder why did they made up a new regexp syntax?
14:51ChouserLicenser_: who?
14:51Licenser_why not use /<regexp>/ but #"<regexp>"
14:51Chouseroh
14:51Licenser_clojure
14:52Licenser_I think that isn't a good step, it will scare some people
14:53Chouserit's hard to tell at read time if / foo / is a regex or the / symbol twice and the symbol foo in between
14:53Chouserin clojure # always indicates special reader behavior, the exact sort indicated by the following char
14:54ChousukeLicenser_: / would have complicated things a LOT.
14:54Licenser_hmmm but it would be nicer .p
14:54Chouser#^ is metadata, #_ a comment, #( an anonymous fn, #" a regex
14:54ChouserI guess one could make a case for #/regex/
14:54Chousukethough #/foo/ would perhaps have been a better... yeah.
14:54Licenser_I was about to say that
14:55Licenser_get out of my head :P
14:55Licenser_it's getting crowded in here
14:55Chouserheh
14:55Licenser_I think using // would be possible but I understand that it would make stuff a lot harder
14:55Chousukefor the reader, anyway :P
14:56Licenser_yes
14:56Licenser_I think people would understand stuff
14:56Chouserand there are always lots of readers. rhickey is wary of making up new parsing rules that make it hard for syntax coloring tools, etc.
14:56Licenser_and who would write if( / foo /)
14:56Licenser_I'm not even sur eif that would make any sense
14:56Licenser_or even be conform syntax
14:57Licenser_it is good syntax but it makes little to no sense
14:57Licenser_who would ever want to test /?
14:58Chousukehmm
14:58Chousuke,/
14:58clojurebot#<core$_SLASH___4112 clojure.core$_SLASH___4112@9830bc>
14:58Chousukethat's actually the only symbol allowed to contain / :P
14:58Chousuke,foo/
14:58clojurebotInvalid token: foo/
14:58Licenser_so it is special
14:59Licenser_well you use it to seperate namespace and thing
14:59Chouserright
14:59Chousukeyeah. normally / is the namespace separator
14:59Chousuke,'core/foo/bar
14:59clojurebotcore/foo/bar
14:59Chousukehmm.
14:59Chousuke,'core/foo/
14:59clojurebotInvalid token: core/foo/
15:00Chouser,(namespace 'core/foo/bar)
15:00Chousukeapparently it's only forbidden at the end :/
15:00clojurebot"core/foo"
15:00Licenser_(ns/bla /) still would be non confusable since you can't call a namespace
15:00Licenser_you can use / within namespaces o.O
15:00Licenser_,(namespace 'core/fooµbar)
15:00clojurebot"core"
15:01Licenser_he does not like that :P
15:01Chousukewell, you can but I don't think it's supported :P
15:01Licenser_no unicode namespaces?
15:01Chousukeyour namespace is core in that symbol
15:02Chousuke,(namespace 'cœre/foo)
15:02clojurebot"cœre"
15:02Chousergah
15:02Licenser_heh
15:02Chousukebut I think that might not work when actually creating a namespace :P
15:02Licenser_nice
15:03Licenser_(ns µbla)
15:03Licenser_nil
15:03Licenser_1:48 µbla=>
15:03Licenser_weeh I can use µ as a namespace
15:04Chousuke,(namespace ' / )
15:04clojurebotnil
15:04Licenser_I wonder if the rhickey here is the guy who started the whole thingy?
15:05Chousukehe is.
15:05Licenser_so we can pester him to make #" #/? *dodges and hides*
15:05ChousukeWell, you can but you'll probably fail :P
15:05Chousukeand I don't recommend trying.
15:06gkoHello: In SLIME, how do you interrupt a stuck REPL because of socket problem?
15:06Licenser_Oh apple will be happy:
15:06Licenser_,(ns )
15:06clojurebotnil
15:07Licenser_I like that you can make funky namespaces this way :D
15:07ChousukeI think most of unicode works.
15:07ChousukeThough I'm not sure if things beyond the BMP will
15:07Licenser_No idea
15:10Licenser_Hmm okay another question, clojure is really nice for one machine pralelism, but is there a build in way to utilize more then one system?
15:11Chouserit can take advantage of any of the several systems for spreading java work across multiple machines.
15:11LauJensengko: slime-abort-connection
15:11Licenser_so nothing clojure intern thingy
15:11Chouserpeople are working to make several of them play as nicely with clojure as possible.
15:11Chouserright, nothing internal.
15:12Licenser_something like
15:12Chouserthough the print/read stuff may be a nice way to send data around.
15:13Licenser_(register <ip>) or so would be nice when it then connects to a clojure on the other end and pmap or so automatically uses the second host
15:13rathore_chouser: i'm using print/read to send data between requesters and workers in swarmiji
15:13iceyso... I've recently cocked up my emacs installation... who currently has the best dox on getting emacs + clojure up and running from scratch (on a mac if it makes a difference) technomancy is the one I used previously, I think
15:13Chouserrathore_: I've heard good things about swarmiji, but I haven't looked at it yet.
15:13gkoLauJensen: Thanks!
15:13Licenser_what is swarmiji? (googeling for it too)
15:13rathore_chouser: thanks, maybe u will need it some day :)
15:14rathore_licenser_: swarmiji is a parallel, distributed computing framework for Clojure
15:14Licenser_Ah neatisch
15:14rathore_we use it at runa.com to split up computations in real-time
15:14rathore_http://swarmiji.org
15:16Licenser_ah neat
15:17Licenser_looks cool
15:18Licenser_it's nice how good clojure seems to be for paralelism
15:18Chouserhmph. chunked 'for' is right except it does an extra 'seq' in some cases.
15:19rathore_licenser_: it absolutely is... and with swarmiji you can go across jvms on different machines also
15:19Licenser_Yes that is like a perfectish thing
15:19psmyth_I'm trying to implement a Java interface using (proxy <class...> <args..> & <fns>)
15:20psmyth_sets up ok but some callbacks don't seem to get tripped
15:21psmyth_anybody have experience with this? maybe there are threading issues?
15:22StartsWithKwhat part of clojure.contrib.expect depends on 'immigrate'?
15:23Chouserpsmyth_: threading shouldn't be an issue unless you're using proxy-super
15:25psmyth_almost like the API I am coding against isn't "grabbing" the callback methods.
15:25Chouserif you misspell a method, no error is generated
15:26Licenser_why is this happening:
15:26Licenser_,((first '(+)) 1 2)
15:26clojurebot2
15:26Chouser,(class (first '(+)))
15:26clojurebotclojure.lang.Symbol
15:26psmyth_gotcha
15:26Licenser_,(class +)
15:26clojurebotclojure.core$_PLUS___4094
15:27Chouser('+ {:a 1, :b 2, '+ 3})
15:27Chouser,('+ {:a 1, :b 2, '+ 3})
15:27clojurebot3
15:28Licenser_hmm how could I get this to work o.O
15:28Chousukeyou want the function from the symbol?
15:28Licenser_yap
15:28Chousuke,(resolve '+)
15:28clojurebot#'clojure.core/+
15:28Licenser_ah nice
15:28Chousukethat way you get the var
15:28Chousukewhich just forwards to the function
15:29Licenser_:D thanks
15:32danleialso (class (first (list +))), ' quotes
15:33danlei(or: (class (first [+])))
15:33Licenser_dankthanks
17:21dave[csc]Anyone suggest a good tutorial/howto on tearing apart a file in Clojure? What I've found so far isn't so helpful...
17:26Chousermostly you use normal Java libs for IO
17:27Chouserthere are a couple helpers, suchs line-seq and contrib's duck-streams, but it's still all built on Java libs.
17:34dave[csc]Chouser: I've looked in to duck-streams a bit... I guess I'll just have to stumble through. Thanks though
17:36octewhye does this: http://pastebin.ca/1540870 cause an infinite loop?
17:36octei presume, because i get an outofmemory error..
17:38Chouseriterate creates an infinite seq
17:38Chousukenext returns a seq. :)
17:38octeyes. what does next to do a seq when it's trying to return a seq?
17:38Chouserall of which is fine, but the repl then tries to print that still infinite seq that 'next' returns
17:39Chouser,(next '(1 2 3 4 5))
17:39clojurebot(2 3 4 5)
17:39octeah
17:39clojurebotPaul Graham is the creator of the other new lisp
17:39octei see
17:39ChousukeClojurebot's sudden interjection made me laugh :P
17:40Chousukeapparently "ah" matches graham :P
17:40octei want to create a sequence that generates numbers like for example: 1,3,5,7,9,1,3,5,7 and so on
17:40octei guess a sequence is what i'd want?
17:40Chouser,(take 20 (cycle [1 3 5 7 9]))
17:40clojurebot(1 3 5 7 9 1 3 5 7 9 1 3 5 7 9 1 3 5 7 9)
17:41octenice
17:42Chousukethough remember that seqs are persistent, so if you have a reference to the head, you'll end up keeping all the generated numbers in memory.
17:42octehmm
17:42dave[csc]clojurebot: Are you open source?
17:42clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
17:42Chousukeso doing (def foo (cycle [1 2 3])) is not recommended, because then foo will always hold onto the entire seq
17:42dave[csc]Outstanding ^_^
17:42octewell, that's bad
17:43Chousukeocte: but you can do (defn foo [] (cycle [1 2 3])) to have a function that returns a new seq
17:43Chousukethen pass that onto whatever needs it.
17:44Chousukeeg. (dostuff (foo))
17:44Chousukethen the dostuff code can avoid holding onto the entire seq
17:44octecool
17:46dmixis there a function to check if a string contains another string or regex?
17:47Chouser,(re-find #"needle" "There is a needle in the haystack")
17:47clojurebot"needle"
17:47Chousukethere are regex functions. most string stuff is directly from java.
17:47dmixty
17:53krumholthow can i check if clojure.contrib is loaded correctly?
17:55danlei(find-ns 'clojure.contrib) would be an indicator
17:55danleibut "loaded correctly" is a rather broad term
17:57krumholtok that returns nil so i guess no it's not loaded
17:57tomojyeah... e.g. I've been using stuff from it fine for weeks, but just realized my clojure.contrib.pprint is broken
17:58danleikrumholt: yes. for example: (find-ns 'clojure.contrib.monads) -> nil (require 'clojure.contrib.monads) -> nil (find-ns 'clojure.contrib.monads) -> #<Namespace clojure.contrib.monads>
18:00dmixhas anyone found not knowing any java to be a significant drawback while using clojure?
18:00krumholtdanlei, thanks
18:00krumholtdanlei, no i know it found the jar files and added them to the classpath
18:01krumholtno/now
18:01danleikrumholt: but beware that it will still return nil for (find-ns 'clojure.contrib) after (require 'clojure.contrib.monads)
18:02krumholtdanlei, yes i just wanted to check if the additional jar files are added to the class-path. i am trying to use the lightweight java gaming library
18:02danleikrumholt: there is something for this in contrib
18:03krumholtdanlei, really? that would be nice
18:03danleikrumholt: clojure.contrib.classpath/classpath.jarfiles
18:03danleikrumholt: clojure.contrib.classpath/classpath-jarfiles
18:03krumholtdanlei, thanks i look into that
18:03danleiyou're welcome
18:16cow-orkerdmix: I'd say so.... I don't know Java, what I know of it (the language that is) I don't line. I know common lisp well enough, but I find "learning clojure" (mostly the std java libs) fairly unpleasant. I wish more was wrapped in std libs :-)
18:17cow-orker/line/like
18:23danleicow-orker: I somehow feel the same way, but wrapping is seen as against the "embraces the jvm" philosophy
18:28cow-orkeryes, I guess... although I feel it should be possible to wrap more in std clojure libs and still embrace the JVM (but to a lesser extent the Java language). But thats just me!
18:30ikitatis anyone having problems getting clojure-mode + slime + clojure-swank working property in cocoa emacs 23? I can't seem to get my clojure results to echo in the REPL window, though they seem to compile.
18:30danleiatm I'm just using a little toolbox in which I collect my own little wrappers. In general I agree with you, but we're a minority. ;) (another thing I really didn't like was dropping nil-punning, but that's another story)
18:30ChousukeI think there aren't so many wrappers because it's still extra work.
18:31Chousukeand mostly redundant.
18:31danleiChousuke: well, I pointed out a few things which really should be wrapped (for my taste at least) but there was not much positive response to that
18:32Chousukeit might be good to include some wrappers in contrib.
18:32danleiredundant, yes, if you are willing to "use java". it's more a personal taste thing I guess
18:32tomojdanlei: "nil-punning" means nil=='() ?
18:32Chousukethen it'd be easier to make a case for moving them to core :P
18:32danleitomoj: (rest []) used to be nil
18:33tomojdon't like using next instead?
18:33ChousukeI don't miss nil punning, really. the (if (seq foo) ...) idiom is good enough.
18:34tomojis (seq [...]) linear?
18:34danleitomoj: no, because that only holds for restish things, not, e.g. ... map, or things like (filter zero? [1 2 3]). younow have to wrap them in seq. again, maybe it's only taste
18:34clojurebotfor is not used often enough.
18:34Chousuketomoj: seq is constant time.
18:34tomojChousuke: great
18:35tomojdanlei: ah yeah I see what you mean I think
18:35danleiChousuke: it feels awkward to me. as I said, it's a taste thing, I guess. It just doesn't feel "right" to me (maybe because of CL background)
18:36danleiChousuke: It's not a real show-stopper, just a change I didn't like
18:39dmixsimilar to re-find, is there a function to check if a string contains any values in a collection? (not exact match) for ex "cat in craddle" contains? ["cat" "dog" "bird"] equals true
18:40dmixor should I just write one? :)
18:40Chousukehm
18:40tomojdmix: you can use "some" in addition to whatever string thing you're using
18:41tomoje.g.
18:41tomoj,(some #(.contains "cat in craddle" %) ["cat" "dog" "bird"])
18:41clojurebottrue
18:42Chousukehmm
18:43Chousuke~def contains?
18:43ChousukeWonder if that will work on strings. /:
18:44tomojif you're looking for indexes, yeah :)
18:44tomoj,(contains? "foo" 1)
18:44clojurebottrue
18:44Chousukeright.
18:44dmixthanks tomoj
18:44dmixwhy does that bot use tinyurl?
18:44Chousukethe urls are long :P
18:45dmixah github, true
18:58danleihm
18:59danlei(xxx 'bar '(foo bar baz)) -> true (or bar)?
19:00Chousuke(some '#{bar} '[foo bar baz])
19:00Chousuke,(some '#{bar} '[foo bar baz])
19:01clojurebotbar
19:01danleiI see, or (.contains 'bar '[foo bar baz])
19:01Chousukeyeah.
19:01danleiso, thats a good example, where I would add "member" or "find"(taken) to my wrappers
19:02tomojconfused... you can't call .contains on a symbol
19:02danleiand that's pretty close to what I discussed a while ago. such things, in my opinion, should be in core, or at least contrib
19:03danleitomoj: oh, you're right, sorry
19:03danleitomoj: thaught it'd work
19:03danleiI mean, that's not something exotic
19:03tomojI still don't understand what you're looking for
19:04danleicl's MEMBER or FIND
19:04danlei(find 'foo '(foo)) -> foo
19:04danlei(member 'foo '(foo bar)) -> (foo bar)
19:05danleiJust wanted to show an example of (to my feelings) missing things in the core
19:05clojurebotshow is clojure.contrib.repl-utils/show
19:05tomojah, I think I see what you mean
19:05tomojcontains? promises to be constant/log time so it can't do that
19:05tomojyou want a function that wraps the "some" idiom?
19:06danleisome is 2 steps more general
19:07danleiand it doesn't feel nice to have (some #{bla} '[bla]) to me
19:07danlei*just have
19:07tomoj(defn find-member [coll x] (some #{x} coll))
19:07tomoj:)
19:07tomojbut yeah I see what you mean
19:07danleiif I looked for this functionality, the first thing I would look for would be someting like find, or member
19:07Chousuke,(drop-while (complement '#{bar}) '(foo bar zonk)) the member equivalent is a bit less nice.
19:07clojurebot(bar zonk)
19:08danleioh, thanks, but that I could have done myself
19:08danleiIt's not about member specifically
19:08Chousukeusing sets is a clojure idiom though so I think teaching people to use them is better than introducing a function for it. :)
19:08tomojwell, hmm
19:08danleiIt's just that I often have to search java documentation on some classes for things I just except in a languages core
19:08danleithat's what I wanted to point out
19:09danleimaybe it was not the best example
19:09tomoj,(.contains '[foo bar] 'foo)
19:09clojurebottrue
19:09danleihehe
19:09tomojoh, but that's boolean
19:09danleiyes, but it's ok
19:09Chousukedanlei: well, that's half-intended for clojure.
19:09danleiChousuke: yes, I know
19:09danleiChousuke: I'm always free to write my own toolbox of wrappers (and I do so)
19:10danleibut somehow it just ... sometimes really gets on my nervers ;)
19:10danlei*nerves
19:10ChousukeIt might be possible to get these things into core through contrib though.
19:10ChousukeI doubt anyone would object to some more utility functions in contrib.
19:10clojurebotfunctions are maps
19:11danleiand, what's really bad about that: In some point in time, no other clojure user will understand my code, without knowing my whole wrapper toolbox
19:11danleithat's why I'd like this stuff at least in contrib
19:11Chousukewell, all you need is a CA and then a post to the mailing list for discussion :/
19:11danleiChousuke: well, I'd surely appreciate that
19:11danleiah, yes. that CA thingie
19:11danleishould maybe really do that
19:12danleionce I had some snipped I felt belonged in core
19:12danleibut thought it wasn't worth the CA
19:12ChousukeIt doesn't take much, really.
19:12danleis/core/contrib
19:12danleiyes, It's just a minor inconvenience, you're right
19:13danleiIf I understand you right, even for contrib I'd have to "pass" some kind of "vote"(?)
19:13danleiI mean, you don't get an CA and can add what you want, can you?
19:14Chousukedanlei: well, yeah. contrib is not a dump for random things.
19:14danleisure, but how exactly does it work?
19:14Chousukebut if enough people show interest in your library I think it'll get in. :P
19:14danleiso it's not clearly defined how you get things in?
19:14ChousukeI guess that's right.
19:14danleihm, I see
19:15Chousukeyou just need one of the committers to support you I guess.
19:15danleiyou have that CA?
19:15danlei*done
19:15Chousukeyeah, though I'm not a contrib committere
19:15Chousuke-e
19:17danleihttp://paste.lisp.org/+1UAQ is what I had in mind
19:17danleiI think there's nothing like that in contrib right now (last time I checked)
19:17danleinothing earth-shaking but I sometimes have use for it
19:17Chousukethat would do fine in repl-utils I think.
19:18danleiI think I should just do that CA and try to convince at the list about my thoughts about wrappers
19:18danleimaybe some people would support that idea
19:19tomojI get worried about old mappings left in my namespace when using slime
19:19tomojthat would be neat
19:19ChousukeI've been bitten by that a few times :P
19:19Chousukeonce I had all the needed functions in my code, but in the wrong order :)
19:19tomojjeez I hadn't even thought about order
19:20Chousukethen it broke when I "rebooted"
19:20dmixtomoj, in the code earlier (some #(.contains "cat in craddle" %) ["cat" "dog" "bird"]) is there a way to return which value it was? (cat) or is it limited to true/false because of some
19:20tomojit's limited to true/false because of .contains
19:20danleithere we go :) cl:find is needed ;)
19:20tomojbut you could use find-first from contrib
19:21dmixthanks ill try it
19:21tomoj,find-first
19:21clojurebotjava.lang.Exception: Unable to resolve symbol: find-first in this context
19:22Chousuke(doc find-first)
19:22clojurebot"clojure.contrib.seq-utils/find-first;[[pred coll]]; Returns the first item of coll for which (pred item) returns logical true. Consumes sequences up to the first match, will consume the entire sequence and return nil if no match is found."
19:22tomoj,clojure.contrib.seq-utils/find-first
19:22clojurebotjava.lang.ClassNotFoundException: clojure.contrib.seq-utils
19:22tomoj:(
19:22danleiah, and there it is ;)
19:22tomojhe has the docs but can't use the functions?
19:22Chousukeclojurebot's doc is a bit specia.
19:22Chousukel
19:23Chousuke,(refer 'clojure.contrib.seq-utils)
19:23clojurebotjava.lang.Exception: No namespace: clojure.contrib.seq-utils
19:23danlei,(require 'clojure.contrib.seq-utils)
19:23clojurebotnil
19:23danlei,(refer 'clojure.contrib.seq-utils)
19:23clojurebotnil
19:24tomoj,(find-first #(.contains "cat craddle" %) ["foo" "cat"])
19:24clojurebot"cat"
19:24dmixyeah it works :)
19:24danlei:)
19:24tomojweird.. is clojurebot polluted with seq-utils now until it dies?
19:24Chousukeyes :P
19:25Chousukethough I suppose hiredman can always unmap the stuff.
19:25tomojoh, there's a contains? for strings in str-utils2
19:26tomojheh, http://is.gd/2vuhh
19:26tomoj(contains? s substr) == (.contains s substr)
19:26tomojapparently someone agrees with you, danlei :)
19:27danlei:)
19:27tomojalso, there's includes? in seq-utils too
19:27tomoj,(includes? '(foo bar baz) 'bar)
19:27clojurebottrue
19:28Chousukehmm :/
19:28danleibit confusing that they all share names. should maybe be generic functions, or someting
19:28tomojwonder why it uses (fn [y] (= y x)) instead of #{y}
19:29lowlycodersince Thread/stop is being deprecated, what's the clojure way to stop a thread?
19:29lowlycoderto have the thread share a global ref with the main program? to use agents? ....
19:30tomojants.clj uses agents that check a global var
19:33ikitatuhg. Does anyone know why I can't get *slime-repl clojure* to display anything useful?
19:34ikitatit's just the user> prompt
19:34ikitat(+ 1 1) C-c C-c
19:34ikitatminibuffer says compilation finished 0 errors 0 warnings 0 notes
19:34ikitatREPL doesn't blink
19:34danleiyou mean, (+ 1 1) <return> doesn't evaluate and print the result?
19:35ikitatdanlei, I'm using clojure-mode in emacs and I'm C-c C-c'ing in a s ource file
19:35ikitatbut it doesn't show the result in the repl
19:35tomojthe repl doesn't do anything when you compile..
19:35ikitathow can I get the code to show up in the repl?
19:36tomojgo over there and type it in :)
19:36danleitry C-c C-c'ing a defn and use it in the repl
19:36tomojyou can see the result in the minibuffer with C-x C-e
19:36ikitatheh.. oh, I swore I've seen videos of people just executing in the repl from their clojure buffer
19:36tomojor C-M-x
19:36ikitatand though.. danm, that's cool
19:37tomojI saw a trick someone had for that somewhere
19:37tomojbut afaik it's not built-in
19:37ikitatactually, I think it even did that for me in aqua emacs, but I've been stuck since going to cocoa emacs 23
19:38tomojikitat: http://bc.tech.coop/blog/070424.html
19:38tomojthat's old, maybe slime has something for it now
19:38tomojI'm in aquamacs emacs, and it doesn't do that
19:39tomoj(by default)
19:41tomojI've never really noticed because I don't usually have top-level forms in source files for which I want to see the result
19:41danleiso, no member in seq-utils. should get that CA and add something like (defn member [thing coll] (drop-while #(not= 'bar %) coll)) in there
19:41AnniepooIs there a way I can run a clojure script from within a java program?
19:41tomojI'd vote for a less CL-like name :)
19:42tomoj"member" doesn't really make sense to me as a name for that function
19:42Chousukeikitat: the result of a C-x C-e is shown in the minibuffer.
19:42ikitatheh.. ok, you are all right, I must have been seeing things... :)
19:42danleiwell, ... it looks for a member, but is restartable. what would you prefer?
19:42ikitatI just checked it in aquamacs again
19:43ikitatoverall I'm pretty excited about emacs, I've used vim for over 10 years... I was probably hallucinating from excitement ;)
19:43Chousukeheh :P
19:43danleibtw, that's just a toy member function, it should also take test and key keyword args, to come close
19:43danlei:)
19:43ChousukeI used viper some when I went to emacs, but it doesn't play well with paredit so I'm using it less and less...
19:43danleiikitat: was the same for me :)
19:44danleibtw, chosuke: you know a convenient way in paredit to "close all sexps"?
19:44Chousukehmm :/
19:44Chousukeno.
19:45tomojdanlei: good point, I can't think of another name
19:45ikitatChousuke, yeah, viper just doesn't cut it... I'd rather go cold turkey.. though it's hard I have a lot of built up vim knowledge. I'm still trying to pick up the things that I absolutely need to do a lot
19:45Chousukethe sexps should always stay closed though. But that's not what often happens
19:46ikitatremapping my brain is harder than it used to be
19:46Anniepoodanlei continues to rock for having gotten noobie me up on slime, swank, paredit, emacs, etc stack the other nite
19:46danleiChousuke: well, in my case it's more that I used to close-all-sexp's before I started using paredit, I'm just looking for a convenient way to get to the end of a form quickly
19:46danleiAnniepoo: you're welcome
19:47danleiC-M-e would be a candidate, I guess
19:47danleibut it's not quite the same
19:48danleiAnniepoo: you like it?
19:48Chousukedanlei: end of a form? ctrl-k?
19:48danleiChousuke: bound to paredit-kill for me, what is it bound to normally?
19:49Chousukeisn't paredit-kill what you want?
19:49Chousukeit kills whatever comes after point, but keeps the sexp structure intact.
19:49danleino, I want to move point after the form I just entered
19:49Anniepooso far I'm still in the 'I get all tangled up and eventually ctrl-alt-del kill it' stage
19:49danleis/after/behind/
19:49Chousukedanlei: ah, I misunderstood you then. hmm.
19:49Anniepoobut am still willing to believe some day I'll love it
19:49danleiAnniepoo: :)
19:50Chousukedanlei: actually, it looks like ) should do that :/
19:50danleiAnniepoo: It'll take some time, but (for me) it was worth it
19:50danleiChousuke: yes, what I want is like ) but it goes behind ALL closed parens
19:51Chousukeno idea then :/
19:51Anniepoook
19:51danleiChousuke: atm I'm doing something like end-of-defun paredit-forward
19:51danleiChousuke: thanks anyway
19:52AnniepooI'm skeptical now because I don't see any ez way of navigating from file to file within it
19:52ChousukeAnniepoo: within emacs?
19:52danleiAnniepoo: C-x b in ido-mode is quite comfortable
19:52Anniepooyes
19:52danleiAnniepoo: and did you check out M-.?
19:53Anniepoono, but if it's got those tools, cool
19:53danleiM-. and M-, actually
19:53Anniepoo8cD
19:53danleifor quick buffer switching i recommend ido-mode
19:53Anniepoook
19:53danleialso helps for opening files
19:53Chousukeheh, yeah
19:53danleiit's build in, just try M-x ido-mode and switch buffers or open a file
19:54tomoj(or get the starter kit)
19:54AnniepooI'm going to have to find a day and write some totally toy project where I can just focus on learning the dev env
19:54Chousukemost of the time I just type some part of the file name and emacs somehow magically finds it for me.
19:54Chousukeeven if the path part is completely wrong.
19:54danleithat's what I do, too ;)
19:54tomojsometimes I hate that
19:54tomojI try to make a new file and emacs says, "hey, are you looking for this file in that other project?"
19:55danleitomoj: maybe you don't like the fuzzy part of it
19:55danleitomoj: ah :)
19:55Anniepooquestion about JVM's - I'm running a java program, I want to execute some clojure within it and have them share the JVM
19:55Chousuketomoj: heh, you don't type fast enough ;)
19:55danleitomoj: you have to be quicker :)
19:55danleipretty sure you can tweak the time, though
19:56tomojI usually just switch to regular old find-file at that poit
19:56Anniepooif I go clojure.main("path/to/myclojure.clj") will that be in the same jvm?
19:56danleito make sure everyone knows about it: try C-SPACE to narrow search in ido, really convenient
19:57Chousukehm, what an unconvenient keybinding
19:57danleiwhy unconvenient?
19:57ChousukeI have cmd acting as control and cmd-space is captured by OS X before emacs gets to it :P
19:57danleiaaah
19:58danleithat search function, innit?
19:58tomojcaps lock ctrl ftw
19:58Anniepoonot to mention that it's what initiates autocomplete in IntelliJ
19:58Chousukedanlei: it changes the input method for me, actually.
19:58danleiChousuke: ah, ok
19:58Chousuketomoj: I decided that caps lock is better as meta.
19:59lowlycoderhow does send and send-off differ? send uses from a thread pool, wheras send-off creates its own thread?
19:59danlei(meta-right shift)
19:59tomojlowlycoder: exactly
19:59danlei*left
19:59lowlycodertomoj: in practice, why do I care about this difference?
19:59tomojif the function you're sending blocks, you could lock up all the threads in the thread pool
20:00dmixhow come when you press up in repl (in osx term) it doesnt bring up the last command?
20:00dmixI seem to do a lot of copy/pasting
20:01tomojyou probably need JLine or something
20:01ikitatdmix you need to set up rlwrap or jline
20:01tomoj(but really, switch to a real repl :))
20:01dmixreal repl, like in emacs?
20:01tomojyeah
20:02dmixi wad putting that off :)
20:02dmixi spend too much time playing around with my .emac file
20:02ikitattomoj how do you pull up recent expressions in the repl on emacs?
20:02tomojM-p/M-n
20:03tomojand if you type a bit and hit M-p, it'll search for recent expressions starting with that
20:03lowlycoderis there a way in clojure to break on currenct function call w/o killing clojure; C-c tends to kill clojure as well
20:04ikitathrm... is there a way to get it to do the search without anchoring it with a ^?
20:04ikitateg
20:04ikitatuser> (factorial 10)
20:04ikitatuser> facM-p
20:04ikitatthat doesn't find the previous expression
20:06tomojhmm
20:06tomojM-r lets you type in a regexp
20:07tomojand then you can use M-p/M-n to navigate the results
20:07ikitatthat works :)
20:09tomojI think you'd have to write a new function to use the current input as the regexp
20:10lowlycoder(def blah (agent 3)) (send blah (fn [val] 4))
20:10lowlycoder(await blah) (println @blah)
20:10lowlycoderwhy do I get an error on the await?
20:12tomojwhat's the error?
20:13krumholthow should i do an infinite loop in clojure?
20:16tomoj(while true ..) is an infinite loop
20:16Chousukethere is a while macro
20:16Chousukeyou'll need some kind of a side-effect to break out of it, obviously.
20:16Chousukean atom or a ref
20:16lowlycoderanyone actually have an example of how to use 'await' in clojure?
20:16tomojlowlycoder: what's the error?
20:17lowlycoderjava.lang.IllegalStateException: await in transaction
20:17lowlycoder(def blah (agent 3)) (send blah (fn [val] 4))
20:17lowlycoder(await 100 blah) (println @blah)
20:17lowlycoderis the code ... i don't see where the transation is
20:17tomojwhat is "(await 100 blah)" ?
20:18Chousuke(doc await)
20:18clojurebot"([& agents]); Blocks the current thread (indefinitely!) until all actions dispatched thus far, from this thread or agent, to the agent(s) have occurred."
20:18lowlycodererr, sorry, let's retry this:
20:18lowlycoder(def blah (agent 3)) (send blah (fn [val] 4))
20:18lowlycoder(await blah) (println @blah)
20:18lowlycodergives me: java.lang.IllegalStateException: await in transaction
20:19tomojworks fine for me
20:19tomojyou're doing that at the repl?
20:19Chousukeare you sure it's not in a dosync block? :/
20:20lowlycoder~/tmp:$ cat t3.clj
20:20lowlycoder(ns t3) (def blah (agent 3)) (send blah (fn [val] 4)) (await blah)
20:20clojurebotNo entiendo
20:20lowlycoderuser=> (use :reload-all 't3)
20:20lowlycoderjava.lang.IllegalStateException: await in transaction (t3.clj:0)
20:22tomoj~def use
20:23lowlycoderah, the problem is that (use ...) is in a transaction?
20:24tomojdoesn't appear to be to me
20:24tomojbut that's what I guess
20:24tomojs/guess/guessed/
20:25tomojbut what you're doing looks strange to me anyway
20:26lowlycoderwhat i' doing is pointless; just trying to learn how agent works
20:26tomojtry putting it in a function and use then call the function
20:27tomojoh, refer calls out to java stuff looks like, maybe the transaction is in there
20:35lowlycodereturns nil if returning due to timeout, non-nil otherwise.
20:35lowlycoderso is returning 'false' fair game for this function?
20:37tomojI think it's safe to assume "non-nil" means truthy
20:37lowlycodertomoj: i'm getting false ... somehow
20:38tomojweird
20:38tomojare you awaiting-for your send there that just replaces it with 4?
20:38lowlycoderyes
20:38lowlycoderhere, let me get a complete demo
20:40lowlycoder(ns t3) (def blah (agent 3)) (send blah (fn [val] 4))
20:40lowlycoder(defn mytest [] (println (await-for 0 blah)) (println @blah))
20:40lowlycoderuser=> (mytest)
20:40lowlycoderfalse
20:40lowlycoder4
20:40lowlycodernil
20:40lowlycoderthe false is surprising :-)
20:40tomojwell.. why are you awaiting for 0ms ??
20:40lowlycoderbecause i want to just check if it's ready
20:41lowlycoderif it's ready, great; if not, i want it to return immediately
20:42tomojwell, await-for 1 then I guess
20:43tomojthe docs are wrong there, I think
20:43tomojawait-for returns _false_ if it times out
20:44tomojotherwise it returns true
20:44tomojbut (await-for 0 ...) always times out
20:45lowlycoderlthat's too bad
20:45lowlycoderin erlang, the wait for 0 seconds is a non-wating way to check "is there data?"
20:46Chouseran agent always has data, doesn't it? though it can be nil
20:46Chouserjust deref the agent to instantly see what its value is
20:47tomojI think lowlycoder wants to get the data only if it's been updated
20:48tomojbut not sleep (even for 1ms) if it hasn't
20:48Chouseryes, so never sleep, just fetch the value, right?
20:49tomojbut then you get a value back even if the send-off hasn't completed
20:50lowlycoderhttp://paste.lisp.org/+1UAU <-- why does this continue to print out true 4
20:50tomojI think it's an imaginary problem :)
20:51lowlycoderi was under the impressession that @ or deref would 'consume' a value ... if not; waht's the point of await?
20:51tomojconsume??
20:52Chouserno, an agent hold a value. That's what it does.
20:52tomojderef doesn't change anything, that would break clojure
20:52Chouserit always has exactly one current value
20:52lowlycoderi'm completely misunderstanding agents
20:52tomojsend says "hey agent, use this function to update your value"
20:53tomojawait says "wait until the agent's done doing that"
20:53lowlycoderyeah; this looks very different from mailboxes
20:53clojurebotthis is not a bug
20:54tomojagents are not actors
20:54Chouseronce upon a time I think Clojure called them actors, but rhickey changed it to help reduce the expectation that they would behave like erlang actors.
20:56rhickeyChouser: they were never called actors once implemented
20:57Chouserrenamed Actor to IRef Dec 2 16:17:12 2007 -- That's just the interface then?
20:58lowlycoderrhickey: why aren't there continuations in clojure? not caputing java stack frames i understand, but being able t have continuations for just clojure code seems feasible
20:59Chouserlowlycoder: Someone wrote some macro stuff to do something like continuations for Clojure code.
21:00lowlycoderChouser: have a link? :-)
21:00lowlycoderi would just write all my code in continuation passing style, ... but clojure doesnt have tail call optimiation either :-)
21:00rhickeyChouser: no one was supposed to use them prior to 1203/2007 :)
21:01rhickey12/03
21:01rhickeylowlycoder: when/if the JVM gets continuations Clojure will too, not before
21:02Chouserlowlycoder: I haven't looked at this beyond the description: http://github.com/swannodette/clj-cont/
21:02lowlycoderare trampolines expensive?
21:12rhickeyooh, much better group search via: http://groups.google.com/advanced_search?q=&amp;
21:12rhickeyselect google groups radio button and specify clojure as the group
21:13Chousereven message id. nice.
21:13carkchhouser : after much thinging about this database ocnnection thing, i'll go with neither solution, agents instead of refs, and a blocking queue to make these actors
21:14Chousercark: ok, that sounds sane.
21:14carkthe side effect the clue
21:14carkwas the clue
21:14Chouserok, *now* 'for' passes all tests.
21:19Chouserhuh, the timing is all over the place. but the average for chunked for is definitely better.
21:20rhickeyChouser: cool!
21:33Chouserseriously subsequent runs after plenty of warm up can still vary but about 2x
21:39Chouserok, chunked concat and for are at http://www.assembla.com/spaces/clojure/tickets/1