#clojure logs

2009-08-06

00:00hiredmananyway, read the docs for set! on the special forms page
00:00Carkhbinding would require that i go all over the place and establish that binding
00:00Carkhi did
00:00Carkhlooks like i first nit to use bindings, then i can set!
00:01hiredmanhttp://clojure.org/vars#set
00:02Carkhohwell i'll make it an atom and a function to check the value
00:02hiredman:(
00:02hiredmanglobal state
00:02Carkhwell the use case it pretty good
00:03Carkhi would use conditional compilation in a static language for this
00:09CarkhAOT compilation is slowwww
00:10Carkhback to the c++ age
00:11hiredmanreally?
00:11Carkhnot _that_ bad ... but yes 1:30 min to build a fairly small web app
00:13Carkhand 3sec to just load the source files and start the application from emacs
00:13hiredmanI imagine most of that is jvm start up time
00:14Carkhi first start the jvm, then compile the file that starts the app
00:14Carkhonly the second part is 3 secs
00:15Carkhanyways no big deal, that's not like i'm AOT compiling every minute
00:19Carkhi'm within a couple days of deploying my second "commercial" clojure project to a customer
00:19Carkhstarted quite a while back .. still using pre 1.0 clojure
00:25hiredmanlisppaste8: url
00:25lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
01:12mebaran151_Carkh, have you tried using something like nailgun to keep the jvm live
01:12mebaran151_I used to use it for dev'ing with Jruby
01:15Carkhno i didn't
01:15Carkhi'm not worried about the start times ... i usually develop with the repl ...
01:30mudphonedoes anyone know how to give the compiler a type hint for byte[]
01:31hiredman#^bytes
01:31mudphonehiredman:thanks you rock
01:32hiredmanso they tell me
02:05mudphonehiredman: who are you that are so wise in the ways of science?
02:06hiredmansome dude
02:14jwhitlarkso, (org.enclojure.repl.main/run-repl-server 11345) works in the repl, but not as part of a script. I get the error: Caused by: java.lang.IllegalArgumentException: No matching method: run-repl-server
02:15jwhitlarkanyone seen something like that before?
02:15hiredmanhmmm
02:15jwhitlarkI'd have thought it was a classpath problem, but it's finding org.enclojure.repl.main without problems.
02:15jwhitlarkjava -cp $CLOJURE_DIR/*:$CLOJURE_JAR \
02:15jwhitlark jline.ConsoleRunner clojure.lang.Repl
02:15jwhitlarkThat's my bash script for the repl...
02:16jwhitlarkscriptname=$1
02:16jwhitlark java -cp $CLOJURE_DIR/*: clojure.lang.Script $scriptname -- $*
02:16Jomyootwe need an all-inclusive web-framework like rails?
02:16Jomyootbut all written with clojure
02:16hiredmanuse clojure.main instead of clojure.lang.Repl
02:16jwhitlarkand that's mine for running a script. I don't see any difference.
02:16jwhitlarkk. just a sec.
02:16hiredmanI doubt that it'll fix things
02:16hiredmanbut clojure.lang.Repl is depricated
02:17hiredmanand Script
02:17jwhitlarkclojure.main for both?
02:17hiredmanyep
02:17hiredmanjava clojure.main --help will tell you all about it
02:19hiredmando you know what kind of number the method takes
02:19hiredman?
02:19jwhitlarkshould be just an int, it's a port #
02:20jwhitlarkoh! That's interesting, now it's failing in the repl too.
02:20hiredmanmaybe try wrapping it in (int …)
02:20hiredmanare you sure the method only takes one parameter?
02:22jwhitlarkcopied it right out of: http://www.enclojure.org/REPLSupport
02:22jwhitlarkone page down.
02:22jwhitlarkinteresting. it worked for me *once* in slime, and that's it.
02:23hiredmanare you using enclojure/
02:23hiredman?
02:23jwhitlarktrying to.
02:23jwhitlarkoh, no. not for an ide.
02:24jwhitlarkjust to embed a repl in an application. I asked earlier today if http://clojure101.blogspot.com/2009/05/creating-clojure-repl-in-your.html was still the way to go and was told it was still good to go.
02:26hiredmanI think the problem is the enclojure namespace is gen-classed
02:27hiredmanso clojure is treating a reference to it like that as a static method call
02:27hiredmanmaybe if you (require '[yadda.yadda :as enclojure])
02:28hiredmanand (enclojure/something-something 43242)
02:30jwhitlarkjava.lang.Exception: lib names inside prefix lists must not contain periods
02:30hiredmanhttp://gist.github.com/163140 makes a repl you can telnet to
02:30jwhitlarkoh!
02:31jwhitlarkthat's what I wanted.
02:31jwhitlarkand it works just fine.
02:32jwhitlarkthanks for the help.
02:32hiredmansure
02:34jwhitlarkI saw somewhere that you could configure slime to connect to an application, but that's a task for another day.
03:27Anniepoois there a jira for Clojure?
03:32LauJensenFrom Google definitions: "Jira is a Thai given name. Notable people bearing the name include: * Jira Boonpojanasoontorn, Justice of the Constitutional Court"
03:32AnniepooLOL
03:32LauJensenSo in a sense, yes there is JiraAnniepoo
03:32Anniepoook, more to the point, I've found a small bug in clojure.contrib
03:32mudphonethese aren't the droids you're looking for
03:32Anniepoowhere should I report it
03:32LauJensenthese arent the droids?
03:33LauJensenAnyway - I think all project details are handled on Assembla now, you should report there
03:33Anniepoook
03:34Anniepoowhat and where is an Assembla?
03:34LauJensen~assembla
03:34clojurebotassembla is http://www.assembla.com/spaces/clojure
03:34AnniepooAssembla is what system pah-rogramma's use in gah-ga
03:34Anniepoothanks
03:34LauJensennp
03:37AnniepooI submit a 'ticket'?
03:38jdzwell, are you sure it's a bug?
03:38jdzhave you asked here or in the mailing list?
03:38Anniepoook, there's a note to say put it on the mailing list first
03:38AnniepooI'll do that
03:38AnniepooI'm quite sure it's a bug
03:38LauJensenAnniepoo: Yes, a Support Ticket
03:39mebaran151_what's the bug?
03:39lisppaste8Anniepoo pasted "untitled" at http://paste.lisp.org/display/84890
03:39Anniepooit's putting Unix newlines in the file in this code
03:40Anniepoowhen run on XP Tablet
03:40AnniepooI'll try to characterize it better before submitting
03:40LauJensenBest to demonstrate by a very simple case :)
03:41Anniepoothat's what I meant
03:41LauJensenOk
03:45jdzye, it's right there, the newline function
03:46jdzalthough i think outputting DOS line endings is a braindamage
03:47jdzand if you want to do it, you just use print and add whatever you want at the end
03:47Anniepoothe newline function puts out a newline
03:47Anniepoo,(doc newline)
03:47clojurebot"([]); Writes a newline to the output stream that is the current value of *out*"
03:47Anniepoosorry, that's not enlightening me
03:47jdz,(int \newline)
03:47clojurebot10
03:48jdznewline function outputs this character
03:48Anniepooand I'm not a huge whoppign fan of DOS line endings either
03:48Anniepooyah, that's excluding 2/3rds of the world
03:49tomojmost of those people aren't coding in clojure :P
03:49Anniepooand if you make it difficult for them to do so they will continue to not do so
03:49jdzAnniepoo: your calculations are wrong
03:49Anniepoook, if you count by users it's 95% or something
03:49jdznothing close to 2/3rds of computer users read plain text files
03:49jdzin notepad
03:50jdzall other text editors can deal with single newline character
03:51Anniepoobut 100% of C# input streams are confused by the things
03:51mebaran151_I think the JVM makes it simple to figure these things out...
03:51mebaran151_what kind of newline
03:51tomojI see java uses a system property to decide what the line separator is
03:51mebaran151_yeah
03:51jdzAnniepoo: using DOS line endings is not gonna fix the problem you know
03:51mebaran151_exactly
03:51Anniepoocause I'm writing a file to be interpreted by a program
03:52Anniepooand at the very least, *I* need to be able to read the thing without manually changing the line endings
03:52jdzAnniepoo: so you should output your file in a format that is expected by the other program
03:52Anniepoook, it expects dos line endings
03:53jdzAnniepoo: and you should not expect that some function will figure out what the other program expects magically
03:53tomojPrintStream.println will use DOS endings, though
03:53tomojdoes seem a bit strange that clojure's println isn't consistent with java's
03:53Anniepoobut I do expect it to put out the line endings that system.properties says to use
03:53jdzAnniepoo: what i'm trying to tell you is that if you write your program, and then somebody runs it on, say, OSX, the output will be wrong, anyway
03:54tomojnot if it uses line.separator...
03:54tomojoh, yes, I see
03:55tomojso the solution in that case is to specifically ask for dos endings, I suppose
03:55jdzyes
03:55mebaran151_sigh, the line ending wars
03:55tomojis rebinding newline a bad way to do that
03:55tomojjust curious
03:56jdzso the real problem is that pr*l?n functions don't respect the system property mentioned above
03:58AnniepooI'm with tomoj, I think the correct behavior here is to respect line.separator
03:58jdzAnniepoo: that would be the correct behaviour of println function, but you should not use it
03:59Anniepooso yes, my program will break on OSX only if the C# program it's interacting with doesn't respect the system line separator
03:59Anniepooand, while I wrote the program it's interacting with, it's the only thing I've ever written in C#, I have no idea
03:59jdzand, btw, i'm pretty sure C# can deal with single-character line endings with no problems
03:59Anniepoowhat it does with line endings
04:00Anniepooyah, I'm actually unit testing, and the test is failing.
04:00jdzrelying on magic defaults in cross-platform cross-language communication is a way of asking for big trouble
04:02Anniepooit's not as bad as 'cross platform means fsck off if you're not a cool linux user'
04:02Anniepoocertainly the different line endings are a stupidity that needn't have happened
04:07LauJensenIts quite amazing that in 1980's we were anticipating flying cars etc in the new millenium, and here we are in 2009 discussing newline formats..
04:08AnniepooI referred to EBCDIC the other day 8cD
04:09Anniepoohey, get on a network hardware forum, you'll hear about mark and space all the time
04:09Anniepoothe terms are from telegraphy
04:09Anniepoosoon after telegraphy was invented, they realized people could send it faster than someone could copy it down
04:10Anniepooso they made a clockwork gizmo that pulled paper tape through a holder
04:10Anniepooand attached a goose quill pen to the sounder of a telegraph
04:10Anniepoodown is mark, up is space
04:10clojurebotmark is 1
04:10mebaran151_mark is 1?
04:10Anniepooah, come on! I bet this is the first time we've discussed mark on this forum!
04:11mebaran151_no I was just confused about the clojurebot
04:11mebaran151_I want to know what mark it thinks is 1
04:11Anniepoomark wrote a cool clojure program (see if it does it again)
04:11Anniepooso did marky mark
04:12mebaran151_I wonder if we still use any of the old telegraph lines, repurposed for digital communication
04:12mebaran151_esp the the cross the atlantic ones
04:12Anniepoodoes it mean Mark Mark, the lead rapper of Marky Mark and the Funky Bunch, or Marky Mark the wrestler
04:13mebaran151_this beginning to resemble a Markov
04:13mebaran151_chain
04:13AnniepooI believe they've all been replaced with more modern stuff
04:13mebaran151yeah, that's too bad
04:13Anniepoobut the hard part of laying a cable is laying the first one
04:13wtetznerwhat is mark
04:13Anniepooso in a sense we still use them
04:13wtetznermark is
04:13wtetznerhmm
04:14Anniepoojust as there's probably none of the original rails, spikes, or ties from the transcontinental RR still out there
04:14Anniepoobut the track is still there.
04:15Anniepoomany houses in San Francisco were converted to electric light after the quake,
04:15Anniepooand have the old tube and post wiring still in them
04:16mebaran151gotta avoid the sea monsters
04:16mebaran151well the clojurebot has declare mark is 1
04:17AnniepooI was dating a guy who was a diver for a while. He had a video of an octopus attacking the ROV he was operating
04:20wtetznerclojurebot: mark
04:20clojurebotmark is 1
04:20wtetznerclojurebot: XML
04:20clojurebotXML is like violence; if it doesn't solve your problems, you're not using enough of it.
04:21Anniepooclojurebot: space
04:21clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
04:22Anniepooanybody know how clojurebot works?
04:22wtetznerclojurebot: math
04:22clojurebotmath is hard.
04:22wtetznerclojurebot: brain dump
04:22clojurebotbrain dump is http://clj.thelastcitadel.com/clojurebot
04:23wtetznerAnniepoo: look here ^
04:23Anniepooah, fun
04:31AnniepooI'm about to write my first loop because I can't find a good map/reduce form for this
04:31AnniepooI have two seq's a and b. I want to create a modified a by looking through the elements of a
04:32LauJensen~paste
04:32clojurebotlisppaste8, url
04:32lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
04:38lisppaste8Anniepoo pasted "untitled" at http://paste.lisp.org/display/84892
04:42mebaran151there's usually a better way
04:42mebaran151are a and b the same length?
04:42eevar2anniepoo: (defn myfun [pred foo a b] (let [filtered-a (filter pred a)] (map foo a b))))))) .--- or something?
04:43Anniepoono, a and b are NOT the same length
04:43eevar2probably can't use map like that, but ;)
04:43mebaran151there is almost always a map reduce form that is better than a loop recur form
04:43mebaran151I assume you have something function of b that you want to apply to a
04:43Chousuke(fn f [foo pred [a & as] [b & bs]] (lazy-seq (when a (cons (if (pred a) (foo a b) a) (f as bs)))))
04:43Anniepooyes
04:44Chousukesomthing like that?
04:44Anniepooyes mebaran
04:44eevar2,(doc map)
04:44clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
04:44mebaran151so if pred a is true apply a to b
04:44mebaran151the way I'd do it
04:44mebaran151first match up all your a and b's
04:45Chousukehmm, right
04:45mebaran151then filter by a
04:45mebaran151(which will probably be something like (first blah)
04:45Anniepooyes, but Chousuke, isn't that tail recursion?
04:45ChousukeAnniepoo: it's a lazy seq
04:45mebaran151then finally with the filtered form apply your foo
04:46ChousukeAnniepoo: they *need* to be done using recursion, and take care not to blow up the stack
04:46mebaran151then you get all your laziness, which is a huge boon
04:46Chousukebut hmm
04:46mebaran151so how do you match up a and b
04:46mebaran151that's a little confusing
04:46mebaran151does a always go with the next b
04:46mebaran151so if a is at place 0 you want b to be 1?
04:47Anniepoosuppose you have a class of students who always line up in the same order
04:47mebaran151or do you want to use b like a stack of operands to be applied to a successive line of a's
04:47Anniepoowhat mebaran said
04:47mebaran151so on your filtered a's, you'd take b0 b1 b2
04:48mebaran151oh that's pretty simple
04:48mebaran151first filter a
04:48Anniepoosure, but I need to have the unfiltered a's back at the end
04:48mebaran151what do you mean?
04:48Anniepoosuppose you're working on a farm
04:49Anniepoothe farmer tells you to go paint the fenceposts that aren't currently painted
04:49mebaran151is this for some job queueing system
04:49Anniepoo(ok, ignroe the farmer) I have a list of objects in my system
04:49mebaran151yeah
04:50mebaran151so why do the unfiltered ones need to go to the back
04:50mebaran151I mean you can get that
04:50Anniepoono, they're ordered, don't rearrange them
04:50mebaran151okay
04:50Anniepoothese objects represent objects on another system
04:50mebaran151so you need to record their position
04:50mebaran151probably
04:51mebaran151maybe as a tuple
04:51mebaran151[a pos-a]
04:51Anniepoothose that are dirty, I add their info to some list
04:52Anniepoorun some external process that does the transfer
04:52Anniepooand it returns the ID's I use to reference them on the other system
04:52mebaran151so why can't you filter by a
04:52mebaran151then map over b
04:53Anniepoobecause at the end, I need to preserve the ordering on my end
04:53mebaran151keep an index with each a
04:53mebaran151so first map each a to its index
04:53mebaran151in a vector
04:53mebaran151then filter that vector by its first element
04:54AnniepooI need to (assoc ) the ones I updated to get the other system's UUID into their map
04:54mebaran151then map b to apply to the first element of each of yours a's and remap it back in
04:54Anniepoothen sort
04:54mebaran151actually, this might be a perfect use for metadata
04:54mebaran151to maintain your position information
04:55mebaran151assuming a is some sort of clojure thing
04:55mebaran151so you have a bunch of a's whose uuid's you need to get
04:55Anniepoooh, sure, the a's are maps. It's a GUI editor
04:56mebaran151but some a's come with uuid's already
04:56Anniepooyes
04:56Anniepoosome already have UUID's
04:57Anniepooand the spawned process takes some info from the ones that need UUID's
04:57Anniepooas lines in a file
04:57mebaran151so why is mainting order so important?
04:57Anniepooand returns lines in a file with the UUID
04:58Anniepoobecause that establishes Z order for the objects in the virtual world that is the other end
04:58mebaran151it always seems ugly and imperative to rely on absolute ordering
04:58Anniepooyes, maybe that's my problem
04:58Chousukehttp://gist.github.com/163202
04:58mebaran151this order attribute sounds like it belong as another attribute in your map
04:58AnniepooI shouldn't be depending on it
04:59mebaran151well Chousuke just made the right loop
05:00Anniepoo,(doc gen)
05:00clojurebot"/;nil; "
05:00Anniepoowhat's gen?
05:00Chousukegen is the name of the fn
05:00Anniepooah, I see
05:01mebaran151I still think we could be a little more functional than rolling our own lazy-seqs
05:01mebaran151lazy-seqs are always a little more brittle
05:01mebaran151for this sort of thing, I think you can map and reduce your way out yet
05:01Chousukehmm
05:01mebaran151Anniepoo, what do you have recording the position in the map?
05:01mebaran151*have against
05:02mebaran151the position seems to be an instrinsic attribute of a: maybe it deserves its own key
05:02Anniepooyes, I'm beginning to think so
05:02mebaran151that way you could even uses sets if you wanted and not lose any data, or resort them and always have a way out
05:02Chousuke,(for [a [1 2 3 4] b [1 2 3 4] :when (even? a)] [a b])
05:02clojurebot([2 1] [2 2] [2 3] [2 4] [4 1] [4 2] [4 3] [4 4])
05:02Anniepoothough it's nice that it stays a compact set
05:02mebaran151then you have a simple path for filtering map and reducing
05:03mebaran151compact set?
05:04Anniepooyes, the objects are 'stacked' in 3D in the virtual world that's at the other end
05:04Anniepooso a3 is always up a constant amount from a2
05:04Anniepooif I delete a2 in the set a3 should move down
05:05mebaran151that wouldn't be true though in a vector either (they don't automagically compact themselves)
05:06Anniepoofirst/rest does
05:06mebaran151I might be lying :)
05:06Anniepoothe data's really a list, not a set
05:06mebaran151I see
05:07mebaran151so essentially for each a that the pred is true
05:07mebaran151you want to pop a b off the stack
05:07Chousukehmm
05:07Anniepooyes
05:08Chousuke,(merge-with + #{1 2 3 4} #{10 2 30 4})
05:08clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry
05:08Chousukedamn :)
05:08mebaran151but you have to remember where a came from at the same time
05:09Anniepooanother way to look at it is that my architectural error is in using the order to map the external process's I/O
05:10Anniepoothat is, I have to give it a list of filenames (that's what I get out of the a's) and I get back a same length list of UUID's
05:11Anniepooso I should wrap this very imperitive nastiness with making a map
05:11Anniepoothat maps filename to UUID
05:12Anniepoothen look through all of the a's, and if it's got a filename that's in my map, remap it
05:12Anniepoothat's the correct thing, I think
05:12Anniepoo,(doc merge-with)
05:12clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
05:13Chousuke(merge old-map (zipmap filenames uuids))
05:13Anniepoo,(doc zipmap)
05:13clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
05:14Chousukemerge is basically (merge-with (fn [x y] y) ...)
05:14Anniepooyes, this is the architecturally clean thing
05:14Anniepoomake the structure I need
05:16mebaran151it's all about datastructures
05:17Anniepoook, gimme a minit to try this
05:23Anniepoois there a way to start with (:foo :bar) (1 2) and get {:foo 1 :bar 2}?
05:23Anniepooah, zipmap
05:23Anniepoosorry,
05:32Anniepoook, this looks a lot saner
05:35mebaran151yeah
06:00tomojis there a reason ns-reload! needs to be a macro here? http://bc.tech.coop/blog/docs/user.clj
06:35Chousuketomoj: not as far as I can tell.
06:35tomojme neither, strange
06:35Chousukeprobably just convenience
06:36Chousukeas you can white (ns-reload! your.namespace) instead of (ns-reload! 'your.namespace)
06:36Chousukewrite* :P
06:39Chousukedoes the repl automatically load user.clj btw? :/
07:09Jomyoothi man
07:09Jomyootyo
07:09Jomyootis there a better way than clojure.org/api to find the functions in eed
07:09Jomyooti need?
07:10Jomyootthe good thing about object oriented is that i can always look at the right class to find the right method for what i need
07:10Jomyootbut now all functions are listed alphabetically. i can never find the right ones i need
08:26LauJensenhehe, seriously?
08:26rhickeyyes
08:26LauJensenoh... :)
08:28LauJensenI thought proxy was quite good in terms of naming
08:58Jomyoothi
08:58LauJensenYo
08:58Jomyootsup dude
08:58Jomyootwoder if anyone actually has a job that uses clojure
08:59LauJensenSure they do
08:59Jomyootlike what kind? research?
08:59Jomyootai ?
08:59LauJensenNumber crunching and data parsing
09:02cemerickJomyoot: 95% of the new code we write is in clojure
09:02Jomyootcamerick what kind of project?
09:02cemerickwhen we're hiring next, I'm sure we'll make it well-known here and on the group
09:03cemerickJomyoot: there's lots of moving pieces. In the first place, v3.0 of PDFTextStream
09:03cemerickhttp://snowtide.com/PDFTextStream
09:03Jomyootcan't wait to see a web project
09:03alinphi
09:04Jomyootreplacement of rails but with clojure
09:04cemerickWe have a far more ambitious project running in parallel.
09:04alinpis there any "power of" function in clojure ?
09:04fffejalinp: use Math/pow?
09:04alinpbeside of that, of course :)
09:05alinpthat's why I asked: in clojure
09:05alinpnot in java
09:05Chousukethen, no :P
09:05fffejalinp: my bad
09:05Chousukeexcept maybe in contrib somewhere.
09:05alinpok, thanks
09:06fffejalinp: clojure.contrib.math has (expt x y)
09:06alinpoh, pretty cool
09:06alinpthanks
09:09rhickeycemerick: I missed you yesterday, but I think reify makes sense as a concrete realization of an (otherwise non-instantiable) interface abstraction
09:16cemerickrhickey: Yeah, I guess that makes sense.
09:17rhickeyand it makes sense as a realization both as code and as an object
09:18cemericknaming things is so fuzzy -- so much about 'feel'...
09:20cemerickI'm all for the pedagogical utility of naming it 'reify', but we'll have to be prepared for even more q's about 'how do I implement an interface...'
09:20rhickeycemerick: people found proxy even though it's not a great name
09:21cemerickheh, I thought it made perfect sense because of j.l.r.Proxy
09:22rhickeythat's what's fun about this conversation, I think we are thinking about this feature completely differently :)
09:23cemerickyup -- I just don't have the CS chops to think about it outside of its actual utility for too long :-)
09:23rhickeycemerick: I don't think it's a matter of CS chops, I'm just looking out for ClojureScript :)
09:24cemerickrhickey: oh, that. I thought you were referring to your line of thought from yesterday, about how newnew's impl shows that the typical lambda construct is a specialization, etc.
09:24ChousukeWhat happens if you actually subclass a concrete class with newnew? Will the code look at you in a condescending manner?
09:25cemerickI have moments of clarity when I enter those waters, but that's about it. :-(
09:25rhickeycemerick: there is that, but here I'm just trying not to depend on Javaisms
09:25rhickeyChousuke: definitely
09:26cemerickChousuke: you'll softly hear, 'tsk, tsk, tsk', but you won't be able to tell where it's coming from.
09:27cemerickrhickey: a good thing, definitely
09:28cemerickOn my drive in this morning, I was daydreaming about a couple of macros to implement something like traits using newnew. Surely that's a sign of some kind of illness?
09:29rhickeycemerick: at your suggestion I looked at Scala traits. They really frightened me.
09:30cemerickconcept, or implementation?
09:30cemerick(I found them to be pretty pleasant to use, as long as you stayed away from the loftier bits of type mumbo-jumbo.)
09:30rhickeycomplexity, ordering rules, cascading dependent definitions... seems fraught
09:33cemerickI just want to be able to program to (for example) NetBeans' APIs in clojure in some rational way, which would ideally involve having default implementations of certain interfaces and abstract classes here and there, combining them as desired.
09:34cemerickThe general case is surely far more complex.
09:34cemerickRight now, UI / NetBeans dev is our #1 cluster of Java development, thus the attention.
09:35rhickeyI think, in my ideal world, nothing would ever be isa some concrete thing from which it inherited, e.g. if you could derive from an abstract superclass but not be instanceof it, only an instance of interfaces it implements
09:37rhickeyi.e. we inherit things from our fathers but are not our fathers
09:37rhickeyI'm not opposed to mixins in general, but it is so easy to design a mess-making system
09:38cemerickit seems like your ideal world *is* mixins
09:38rhickeyhow you do mixins matters
09:39cemerickah -- so your concern with scala traits really are related to implementation complexity?
09:39rhickeycemerick: no, user complexity
09:40cemerickHuh. When I used them, I found them pleasant enough.
09:40cemerickThough, I wasn't trying to dig myself a hole :-)
09:43cemerickyeah, I can see how you could really spin a web with them.
09:43rhickeycemerick: but you could still find yourself in the bottom of one, cursing your shovel
09:45cemerickrhickey: oh, I ended up in a very deep hole, and I cursed scala for it, but it was the type system (or, my application of it, others might say) that got me there.
09:46cemerickI seem to remember having come to the conclusion that I would have had to build a whole new type hierarchy, rooted at Any, with my own datastructures, in order to get things to line up properly. Don't remember the specifics though.
09:48rhickeyI smiled also (in recognition) at the lack of ctor args for traits
09:54rhickey(musing here) what if I let you specify multiple ctor-less classes but the resulting object would not be isa any of them, only the interfaces they implement?
09:55cemerickThat sounds like the ideal.
09:56cemerickWouldn't work for libs that have a dependency on an abstract class, but in that case, the interface is semi-worthless anyway.
09:56rhickeythat's one of the problems I have with traits, they're the substitute for interfaces, but, then you put in concrete code and have left yourself without an interface
09:56cemerickwell, the interface is there, just name-mangled
09:57LauJensenGuys, if its impossible thats ok, but I'd like to understand what youre talking about. Where do I go to read some background info which will let me understand the implications of your propositions?
09:57rhickeycemerick: I'm determined not to try to fix bad Java designs
09:57rhickeycemerick: but not part of the program design
09:59cemerickrhickey: yes, definitely quarantine those vectors
09:59cemerickLauJensen: I generally barely keep up myself :-)
10:00LauJensenGood to know :)
10:00rhickeyme too!
10:02cemerickrhickey: you'll understand if we all collectively roll our eyes, right? :-)
10:02cemerickprogramming is one of those fields where, the more you learn, the more you realize you don't understand a damn thing.
10:02rhickeycemerick: I had to read the Scala book to follow up on your suggestion
10:03rhickeyit works both ways
10:03cemerickrhickey: oh, I'm so sorry.
10:03rhickeyre-read the traits section I mean
10:04cemerickjeez, back when I started learning scala, all there was were the tutorial PDF and the language spec PDF (with the former consistently being out of date/sync with the latest version). That was brutal.
10:04LauJensenReminds me of when I picked up Clojure... All I had was Chouser :)
10:05cemerickYeah, Chouser_'s been here "forever".
10:05cemerickLikely off coding some hairy C++ right now. :-/
10:06LauJensenYea he loves that stuff
10:06cemerickChouser_: come back to the fold, buddy! :-D
10:06cp2_feels good man
10:07LauJensenrhickey: What happend to that virtual study session you were considering at one point?
10:10rhickeyLauJensen: right now we're putting together a NYC Clojure meetup
10:10ChousukeHm
10:10LauJensenrhickey: How can I benefit from that ?
10:11LauJensen( I realize Im being very selfish )
10:11ChousukeI wonder why an exception from my reader got wrapped in ~eleventy billion RuntimeExceptions :/
10:11LauJensenChousuke: Sounds like you've gotten into 'state'
10:13Chousukemy reader does not "consume" its source.
10:14ChousukeI can (def source whatever) and then try to read it multiple times.
10:14Chousukebut still, I get this: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Expected token, got nothing. (line 10, character 7)
10:14Chousuke(It's just an unimplemented reader macro, but the runtimeexceptions are puzzling)
10:18LauJensenrhickey: I meant it seriously. Will you put out some info from those meetings, videos, docs, etc ?
10:18Chousukehm, maybe I should do this work in the newnew branch
10:18ChousukeI could use a "/dev/null" right now.
10:18rhickeyLauJensen: no plans right now
10:18LauJensenok
10:18Chousukesomething that discards the item if you conj on to it.
10:19ChousukeI suppose proxy would work too
10:22cemerickrhickey: any idea of the schedule yet? I/we would try to make it.
10:23rhickeycemerick: you can sign up here for notices: http://www.meetup.com/Clojure-NYC/
10:39lisppaste8cgrand pasted "clojure on par with java?" at http://paste.lisp.org/display/84909
10:40Chousukehmm
10:40rhickeycgrand: looks pretty good!
10:41ChousukeI have a println statement in a defmethod accompanied by a flush, but I'm not seeing it anywhere. :/
10:41cgrandrhickey: I'm really surprised by these results
10:42rhickeyin what way?
10:42cgrandthey are too good
10:42rhickey:) that's the point, no more need for Java!
10:43rhickeyI presume ISetNode is because no non-reflective helpers yet?
10:44cgrandcan reify declare new methods?
10:44rhickeyyes
10:44cemerickcgrand: those benchmarks are using transients in the reduce?
10:44Chousukedurr
10:44rhickeybut right now calls to them are reflective
10:45ChousukeI didn't even have a bug. D:
10:45rhickeyself-calls will be non-reflective, will always be reflective from outside the class
10:45ChousukeI just had mismatching parentheses in a *comment*
10:45LauJensenrhickey: is 'reify' the decided name? Am I the only one to whom it really sticks out in a bad way?
10:45cgrandcemerick: no transients on sets yet plus I'm in the "new" branch
10:46rhickeyLauJensen: you are the only public complainant at the moment, maybe everyone else is just cringing in private :)
10:46cemerickwell, goodness, lots of potential yet :-)
10:46LauJensenhehe, I just earned a bad title then
10:47rhickeycgrand: I love how few #^s
10:47rhickeyalthough it begs for #^objects akin to #^doubles etc
10:48cemerickrhickey: LauJensen may find some friends on the group. It's not a bad name, but it's certainly unusual and uncommon.
10:48rhickeycemerick: not bad traits for a new special op, in terms of conflicts
10:48clojurebotfor is not used often enough.
10:49cemerickoh, I don't disagree. There will definitely be some groaning and muttering, though.
10:49rhickeycgrand: so, with high-perf helper methods, ISetNodes/Utils could go away and I SetNode could be defined with gen-interface?
10:49cgrandyup
10:50rhickeycool
10:50rhickeycgrand: this is a terrific validation, thanks for tackling it
10:52AWizzArdrhickey: btw, do you expect this InvokeDynamic bytecode instruction from Java 7 to speed up Clojure here and there even more?
10:53cgrandrhickey: I'm not sure to understand how non-reflective self-calls will help to remove the need for an explicit interface
10:53rhickeyAWizzArd: perhaps, but it would mean bifurcating the code to deal with older VMs. One of the design constraints for Clojure was to work well on the JVMs people are using right now
10:54rhickeycgrand: they don't remove the need for ISetNode, but for ISetNode/Utils, and the former we can write with gen-interface
10:55rhickeyin order to make your solution Java-free
10:57cgrandbut this benchmark is unfair: no dummy map and slightly different algorithms (half-full bitmap nodes become array-nodes, no leaf-node)
10:59AWizzArdrhickey: will I be able to build my own abstraction over newnew which can give me something like defstruct, but with faster instantiation (under the hood I would build a simple Java class, to which I can't add k/v pairs of course)
10:59rhickeyAWizzArd: you have to stop asking me about that
11:00rhickeycgrand: true, but still shows an (almost) all-clojure data structure with speed akin to the Java-written ones
11:04cgrandrhickey: can't we have non-reflective method calls to a reified object (a "reclausa"? :-) ) in the whole lexical scope? Is this impossible or hard?
11:04AWizzArdi see
11:05rhickeycgrand: oh yes, by self-calls I meant only from within any of the methods, on a target of "this"
11:07rhickeycgrand: or do you mean on another instance of the same anonymous class?
11:07rhickey(of course your helpers don't use "this")
11:10cgrandI was thinking about something like that: (let [o (new [] (foo [x] (str "bar" x)))] (.foo o "baz"))
11:12rhickeycgrand: ah, I'm not there yet, I need to think about it, my inclination is no, I'm trying to encourage programming to interfaces
11:12cemerickall such calls would always be reflective though, right?
11:13rhickeyalso, if they move that body into a helper, they'll get reflection warnings they can't remove
11:13rhickeycemerick: if I let them be public at all, that style of programming is really icky
11:13tomojdamn. this site uses multiple cookie headers, spelled "Set-cookie" instead of "Set-Cookie". clojure-http-client supports neither
11:14rhickeyright now the intended use for additional methods is private high-perf helpers
11:14cemerickis that even necessary? You can just close over some 'bare' helper fns, right?
11:15cemerick(that's totally aside from convenience, clarity, etc)
11:15rhickeycemerick: methods can have fully primitive args/returns
11:15rhickeyfns can't
11:15cemerickah-ha, right
11:15rhickeyplus fns need to be allocated
11:15rhickeyeverything in a reify is one allocation
11:16rhickeyonly non-closing helper fns could be one-time allocated
11:16rhickeyand fns don't have access to the other members except through a public interfaces
11:17rhickeyso there's a good argument for additional helper methods, and no really good ones for leaking them out
11:18cgrandok
11:18cemerickrhickey: I'll just keep asking naive questions so you can fully examine your reasoning :-P
11:25cgrandrhickey: btw, on thie "new" branch, lazy-primes3 (see here http://clj-me.blogspot.com/2009/07/everybody-loves-sieve-of-eratosthenes.html ) throws an IllegalAccessError when called
11:43cemerickgawd, trying to get NetBeans folks to understand that there is a world outside of big-J Java is proving nigh-impossible.
11:43cemerickodd, since they've got the best JRuby IDE impl out there.
11:58AWizzArdcemerick: so currently they don't see enough critical mass behind Clojure to provide more support in NetBeans?
11:58tomojdo dan larkin or phil hagelberg ever come around here?
11:59cemericktomoj: danlarkin is over there :-)
11:59cemerickAWizzArd: not a matter of support or critical mass -- they just don't seem to recognize that there's a universe outside of Java
12:00tomojdanlarkin: hey, got some issues with clojure-http-client. I'll try to figure out the patch needed. should I put them in github's issue tracker?
12:00cemerickThere are a couple of things they could do that would simplify things for other jvm language users, and introduce zero breakage for Java devs, but they don't see the point.
12:01AWizzArdhmm
12:01cemerickwe'll see, I'm swinging for it :-)
12:02danlarkintomoj: sure! You might also check out contrib's http library. It was added after we started clojure-http-client, and I haven't used it yet. Not sure how much parallel functionality there is between the two
12:03tomojdanlarkin: ah, will check that out. just ran into a few problems with cookies (two of which are probably my university's fault for not strictly following HTTP)
12:06tomojlooks like clojure-http-client has more of the features I need. currently fixed it with an ugly hack. I'll try to figure out a proper patch soon
12:06danlarkintomoj: cool :)
12:08Chousukeooh, progress! reader.clj is able to read itself without exceptions now. (though the results of the read are not usable, due to missing support for complex character escapes and such... )
12:09Chousuke\newline gets read as ewline :p
12:35ChousukeI still wonder why I get so many RuntimeException wrappers :/
12:36mebaran151yeah, I've always wondered that too
12:43tomojwhat's like reduce but operates on one element at a time, rather than two?
12:44Chousukethat doesn't make sense?
12:44Chousukeor do you mean map? :P
12:44tomojhrmm
12:44tomojOH
12:44tomojI was confused
12:44tomojreduce is exactly what I want
12:47angermancan I split a large clojure file into many smaller ones using (use and (in-ns ?
12:47Chousukeuse load-file
12:47Chousukeor subnamespaces
12:49tomojhmm
12:50tomojI have a function which takes a pred and a seq, and returns a map where the keys are the seq elements for which pred is true, and each value is a vector of the elements after that and up to the next element for which pred returns true
12:50tomojI wonder what to call it
12:51angermanfilter?
12:52Chousuke"group" :P
12:52angermangroup-filter or filter-to-group?
12:52tomojlike (my-function number? '(5 a b 7 c d e)) returns {5 [a b], 7 [c d e]}
12:52angermangrouped-filter, maybe
12:53Chousukethere's a similar function "group-by" in contrib I think
12:53Chousuke(doc group-by)
12:53clojurebot"([f coll]); Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
12:53Chousukehmm, not quite.
12:54Chousukegroup-by-delimiter
12:54tomojthat's exactly what it does!
12:54tomoj:)
13:00cemerickargh, just got caught by the fact that clojure in the same ns as a class with a package-private method can't invoke that method.
13:03gkoIs there some macro for such destructuring: instead of (defn f [{a :a b :b c :c ...}] ...) => (defn f [XXX] ...) and the XXX would magically becomes {a: a b: b ...} etc?
13:04Chousukegko: {:keys [a b c]}
13:04Chousukeor hm
13:05Chousukesomething like that works in let anyway. I always forget the exact syntax :P
13:07gkoChousuke: oh... right, I must still explicitely say a, b, c, etc... otherwise I'll have compiler error...
13:08gkoChousuke: OK, working. Thanks.
13:10rhickeycgrand: thanks, fixed letfn on new branch
13:14gkodo you use different faces (in SLIME) for (), [], {}, #{}, @..., ^..., ^#'..., #', etc.?
13:19LauJensenBtw - For those interested in Github: I contacted their support to ask about the slowness of their site. They said that they have been working on a solution since april (sounds like a c++ thing), and that things will be changing very soon
13:21Chousukeooh. good news.
13:21Chousukebecause github is *slow*
13:22gkoWhen is it slow? Always? Morning? Evening?
13:23Chousukeevery time I use it :
13:25rhickeyis there a way to get a link to a particular source line on github, like we used to be able to do with gcode?
13:26Chousukehmm
13:27ChousukeI think clojurebot does it somehow
13:27rhickeyah, looks like #LCnnn
13:27LauJensenThere is
13:27LauJensenI think you just prepend #150 to get line 150, but lemme check
13:28rhickeyLauJensen: #LCnnn works
13:28LauJensenk
13:29Chousukerhickey: btw, do you have any idea what could cause my exceptions to get wrapped in multiple RuntimeExceptions? I'm writing a recursive reader for clojure and all exceptions it throws are rather well "packaged" :P
13:31lpetitChousuke: a beginning of explanation in the "recursive" nature of your reader ?
13:31ChousukeI suppose it could be just slime being weird.
13:32Chousukelpetit: what do you mean? :P
13:34lpetitChousuke: maybe a totally idiotic idea of mine, but could exceptions be catched an rethrow (wrapped in a fresh one) at each level of the recursion ?
13:34Chousukethat's possible, but it didn't happen with a regular recursive function
13:34Chousukehmm
13:34lpetitChousuke: I'm interesting in knowing what you're pursuing by writing a recursive clojure reader. Is it as an exercise, or with other goal in mind
13:35lpetitChousuke: %s/interesting/interested/g
13:35Chousukelpetit: well, if it turns out good enough I'm all for including it in Clojure. But if not, then at least it's been fun to write
13:36Chousukeas it is now, it's not as resistant to stack overflows as the java reader, and is a fair bit slower too I guess
13:36Chousukebut at least it doesn't contain mutable state
13:37lpetitChousuke: oh yes, less java, more clojure. I see :-). If you came up with a reader that could have a "working mode" that would not throw anything that it reads (including comments, raw textual representation of the element, spaces) that would be great too !
13:39tomojpossible to get a map sorted by insertion order?
13:40Chousuketomoj: not without having the information in the key.
13:40tomojah
13:40tomojjust thought up a way around needing it anyway
13:41Chousukelpetit: it's not quite that flexible at the moment, but... it might not be impossible.
13:43Chousukefirst, I need to get in a state that produces eval'able code :P
13:45Chousukesyntax-quote is going to be interesting to implement in Clojure.
13:46ChousukeCurrently I just call the java method that syntax-quotes a form. :P
13:46lpetitChousuke: do you do this all by hand, or a helper library such as fn-parse ?
13:46Chousukelpetit: pure clojure.core
13:46Chousukefnparse would make it much easier I suppose.
13:47Chousukebut it would make it impossible to use my reader with clojure :)
13:49tomojthere has to be a better way to do this: https://gist.github.com/a625a6edd5824bfc4c81
13:51Chousuketomoj: curious: why are you using lists instead of vectors? :/
13:51tomojrandom choice
13:51tomojI dunno when one or the other is better yet
13:51Chousukewell vectors are easier to type. :)
13:51tomojwill switch to vectors, but still seems ugly
13:51tomojah, and easier to read too I suppose
13:53tomojupdated gist
13:53Chousuketake-while could help you I suppose.
13:54Chousukeor hm.
13:54tomojah, then I wouldn't have to pass around the current delimiter, I suppose
13:54tomojsince I could just grab the delimiter's group all in one
13:55tomojoh, except I'm reducing
13:55Chousukeyour current implementation is probably better.
13:55tomojmaybe it just seems ugly to me because I'm not used to functional programming yet
13:59tomojdestructuring is fucking awesome
14:00cemerickthat's a pretty good tshirt slogan :-P
14:01tomojthe clojure logo looks good for tshirts
14:01cemerickI think they're already on cafepress?
14:01cemerick~tshirts
14:01clojurebotHuh?
14:01cemerickhrm
14:01cemerick~shirts
14:01clojurebotTitim gan éirí ort.
14:01tomojfound a few on zazzle
14:01cemerickah, zazzle
14:02tomojhttp://www.zazzle.com/clojure+tshirts
14:02cemerickclojurebot: tshirts is <reply>Check 'em out: http://www.zazzle.com/clojure+tshirts
14:02clojurebotIn Ordnung
14:02cemerick~tshirts
14:02clojurebotCheck 'em out: http://www.zazzle.com/clojure+tshirts
14:02tomojnice
14:04tomojlogo buttons are only $1.45
14:20lisppaste8cemerick pasted "group-by-pred alternatives" at http://paste.lisp.org/display/84926
14:20cemericktomoj: ^^
14:21cemerickthe second one is (perhaps) a clearer way of doing what you did, but some will not like reducing of a vector for this purpose
14:22tomojI was just about to update my gist
14:22cemericksplit-groups-with is more general, and returns a seq of vectors that can be turned into map with (into {} (split-groups-with number? ...))
14:22tomojI also need to transform the keys and values of the final map with different functions
14:23tomojended up rolling it into my previous function like this: https://gist.github.com/a625a6edd5824bfc4c81
14:23tomojwhich I don't like at all
14:24cemerickyeah...you should definitely break things up there a little bit
14:25cemericklots of stuff going on in the * fn
14:25tomojthe problem is, after the map functions are applied, there's no way to distinguish delimiters from values
14:25tomoj(in my case)
14:25cemerickaren't the delimiters always the keys?
14:26tomojyeah, I just mean I can't transform the elements of the seq before grouping them
14:26tomojperhaps I could group, then transform the keys and values of the resulting map
14:26cemerickthat's a far better approach
14:27tomojactually, now that I think about it a bit more, I don't even want a map at all
14:27cemerickheh
14:27tomojI want each element of the result to be a map with one pair for the delim and another pair for the grouped elements
14:28tomojand doing that I can transform after grouping easily
14:29cemericktomoj: I'm a little confused, but mostly because there are no pairs in clojure :-)
14:29cemerickyou mean two-element seq / vector?
14:29tomojI meant one key-value pair
14:29cemerickah
14:29tomojlike each element will look like {:name <delimeter transformed> :children <group, each element transformed>}
14:30cemerickI thought you meant a dotted pair, which I don't even remember well from CL
14:30tomojno dotted pairs in clojure?
14:30tomojoh, no conses really, I guess
14:31tomojeven though we have "cons" :)
14:31rhickey,(class (cons 1 nil))
14:31clojurebotclojure.lang.PersistentList
14:31tomojI'm too noob to understand your examples quickly, but thanks, I'll step through them
14:32cemerickThere is a cons (clojure.lang.Cons) data structure, but the cdr is always a seq.
14:32rhickey,(class (cons 1 [2 3]))
14:32clojurebotclojure.lang.Cons
14:33tomojempty seq for the last element?
14:34cemerickempty seq for rest
14:34cemerick,(cons 1 2)
14:34clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
14:34cemerick,(cons 1 [2])
14:34clojurebot(1 2)
14:34cemerick,(rest (cons 1 [2]))
14:34clojurebot(2)
14:35tomoj,(cons 1 nil)
14:35clojurebot(1)
14:35cemerickcontrast with:
14:35cemerick,(list 1 2)
14:35clojurebot(1 2)
14:35cemerick,(list 1 nil)
14:35clojurebot(1 nil)
14:36tomojthose two behave just like CL
14:36rhickeyClojure cons cells are not arbitrary pairs
14:36tomojthe ones with nils i mean
14:37tomojbut (cons 1 2) is different
14:37cemerickyeah. You can't do (1 . 2)
14:37rhickeyand most ops prefer PersistentList
14:37rhickey,(counted? (cons 1 nil))
14:37clojurebottrue
14:38rhickey,(counted? (cons 1 [2 3]))
14:38clojurebotfalse
14:38rhickeyso the cons function has polymorphic return values, it is not a constructor for a particular structure
14:47angermanhow would I translate something like "sha.new(str(random.random())).hexdigest()[:5]" from python to clojure?
14:49cgrandrhickey: ok now I think it's worthy to rework PersistentHashMap (and TransientHashMap), do I get your green light?
14:49tomojangerman: probably mostly with java I'd think
14:50rhickeycgrand: rework how, the leaf-less and not-packed ideas
14:50rhickey?
14:50cgrandyup
14:50rhickeyyou think that due to the set work?
14:50clojurebotthat is not what I wanted
14:51cgrandyup (btw I forgot two or three #^"[Object" this makes things slightly faster)
14:51rhickeycgrand: this reworking in the Java version?
14:53cgrandrhickey: rewriting collections in clojure is a short term goal?
14:54rhickeycgrand: there is a problem with using them before cinc in that there are bootstrapping issues, e.g. the implementation of Clojure uses maps
14:54rhickeybut we might be able to bootstrap what we've got and swap in Clojure versions as we go
14:55cgrandso yes, I was talking abour reworking the java versions, I think TransientHashMap ca be way faster
14:55rhickeygo for it then
14:55cgrandmust run
14:55cgrandok
15:02angerman tomoj thanks
15:04tomojangerman: i.e. java.security.MessageDigest
15:07angermanhmm another question, how would I loop over something that I want to stop once it's done
15:08angermane.g. I want to try to create something it might fail...
15:08angermanso I'll retry for x times
15:08wtetzner_is there a way to check if something is named?
15:09wtetzner_like with symbols and keywords, you can do (name :keyword) or (name 'symbol)
15:11tomoj(or (symbol? x) (keyword? x)) ?
15:12wtetzner_hmm
15:12wtetzner_ok
15:16tomojangerman: I suppose you could recur in a catch, passing along a counter counting up to the max number of tries
15:16tomojthere's probably a better way
15:17tomojbetter to count down from max tries
15:19Chousukehm
15:20tomojeshell? or what?
15:20ChousukeAt least I found a third terminal emulator for OS X.
15:20Chousukejust terminal, running bash
15:20Chousukeinside emacs...
15:20angermanhow about my faculty implementation? (defn fac [n] (loop [x n acc 1] (if (> x 1) (recur (- x 1) (* x acc)) acc)))
15:21tomojthere are no loops in clojure
15:21clojurebotclojure is the best way to learn java
15:21Chousuketomoj: loop is there :p
15:21tomojnot like you'd think, anyway
15:21Chousukebut it's a functional loop.
15:21tomojloop is misleadingly named for noobs
15:22Chousukeyeah, it's basically just a shortcut for ((fn [foo bar] (dostuff foo bar) (recur something else)) init vals)
15:23Chousukethough I don't know if it *really* is that.
15:23tomojoh, but I forgot about loop-recur
15:25tomojhow about (defn fac [n] (reduce * (take n (iterate inc 1))))
15:27tomojangerman: yours is faster
15:31tomojwhy in the world isn't there a time which returns the msecs
15:32tomojbut mine doesn't even do any recursion anyway :(
15:32Chousukethe laziness overhead matters some.
15:34tomojhow do you run bash inside emacs anyway?
15:34ChousukeM-x shell or M-x term
15:34ChousukeI'm not just running bash inside emacs. I'm running ssh inside that bash, and screen, and finally irssi
15:34Chousukeand it works just fine
15:35ChousukeI bet I could run emacs inside emacs.
15:35tomojhaha
15:35tomojI've got irssi and emacs in a screen through ssh
15:35tomojbut not nested in emacs :)
15:36Chousukehm
15:36ChousukeI ran emacs in emacs :P
15:36Chousukeit works too
15:36tomojI can even get screen up
15:36tomoj"clear screen capability required"
15:36Chousukeyou probably need M-x term for that
15:36ChousukeM-x shell is just for shell interaction
15:37Chousukebut I think if I ran a terminal inside emacs inside emacs then the keybindings would conflict.
15:37tomojwow this is nice
15:37tomoj(irssi in emacs)
15:38Chousukeyou can switch buffers with C-c b (C-c is the "escape" from terminal mode into emacs)
15:39tomojcan't get other minor modes in here?
15:39tomoje.g. paredit for typing to #clojure :)
15:40tomojdunno how to get something like M-x starting with C-c = C-x
15:41tomojoh, easy. but paredit doesn't like this buffer
15:42fridim_tomoj, do you have a screenshot ? :)
15:42fridim_emacs is Lisp enabled, so I guess you guys use it.
15:43fridim_would be logical. So if some of you use vim, that prooves the superiority of it.
15:43fridim_:-O
15:43tomojnot a very interesting sshot
15:44fridim_I know
15:44tomojhmm
15:44fridim_ah I thought you mean my attempt.
15:44tomojhttp://skitch.com/tomoj/b4ptn/terminal
15:44Chousuketomoj: maybe you need to enable line mode for the terminal hmm
15:44tomojfor some reason I can't send that url in irssi-in-screen-in-ssh-in-term-in-emacs
15:44Chousukewooh
15:45Chousukeokay
15:45Chousukescreen does not like line mode :P
15:45tomojhad to switch back to Terminal.app to send that url
15:46Chousukehmm
15:46ChousukeI wonder how to get back to character mode
15:46Chousukeline mode is a lot faster though.
15:46tomojhere's my clojure http://skitch.com/tomoj/b4ptw/users-thomasjack-code-clojure-utscheduler-src-com-tomojack-utscheduler.clj
15:47tomojC-c C-k and the repl has the updated code
15:47tomojvim probably has something similar
15:48ChousukeGorilla, but it's not as good as slime. :p
15:48tomojslime <3
15:48tomojI still have not achieved paredit zen
15:48Chousukevim simply sucks at interacting with things that are not vim
15:50Chousukewhich is one of the reasons I consider emacs superior. though I like vim's modal interface.
15:50Chousukebut for that, there's viper.el
15:50tomojfor some reason phil hagelberg's starter kit forces paredit 20 to load even though it bundles 21
15:50tomojand 20 sucks at clojure
15:54fridim_Chouser_, I totally agree
15:55fridim_Chouser_, I'm definetly a vim person, and I want this kind of feature available in Emacs. I tried the VIPER mode but it sucks compared to the original vim ;(
15:55ChousukeI wish I could make emacs somehow able to differentiate between left and right apple key.
15:55Chousukebut I don't think OS X does that, so little hope for emacs being able to do it...
15:56Chousukeif it could, I could keep one as cmd and the other as meta
15:56tomojlooks like ukelele can't do it either
15:57tomojagreed, though, I sortof got used to cmd-as-meta while x forwarding to arch linux
15:57angermanis there any tutorial on project file layout?
15:58tomojnow i'm on aquamacs and alt is such a small key
15:58tomojangerman: technomancy mentions it in http://technomancy.us/126
15:58tomojbriefly
15:58tomojand specifically in relation to clojure-mode's clojure-project (emacs)
15:59technomancytomoj: sorry; didn't notice that (paredit problem) since I'm running from trunk.
15:59technomancywill try to get that fixed
15:59technomancybut the version of 20 that is bundled is patched to support clojure IIRC
16:00tomojI was able to just remove paredit from the list of elpa projects to force download
16:00tomojtechnomancy: what's "trunk" ?
16:00tomojthe problem i had was clojure-mode does special fixes for paredit, but only if 21 is loaded
16:00technomancytomoj: upstream paredit; I think it's in darcs
16:01tomojand deleting paredit in elpa didn't help since it would just be reloaded next time emacs starts.
16:01technomancyalso, you should try rcirc instead of irissi-in-emacs
16:01tomojso didn't you have to take paredit out of the list of elpa projects to download?
16:01technomancyanyway, thanks for the heads-up
16:01technomancytomoj: I manually load-file'd it after ELPA had loaded
16:01tomojah, I see
16:02tomojrcirc looks interesting, I'll give it a shot
16:03tomojtechnomancy: thanks, by the way. starter kit and http://technomancy.us/126 have helped me a lot
16:03technomancygreat!
16:03tomojgreatly speeding up my weaning myself off textmate :)
16:04duncanmit's possible to run irssi in emacs? in term-mode?
16:04tomojwasn't pretty for me, but yeah
16:04Neronusyou can even run mutt if you don't like gnus
16:04Neronusor rmail
16:04Neronusor whatever
16:04tomoj+termtter
16:04duncanmi use rcirc, it's pretty good
16:05tomojit makes me happy there are more than a few emacsers here
16:05tomojI'm vastly outnumbered by vim people in the other channels I frequent
16:06NeronusThat's because the world is full of people who don't have a good taste. There are even people who don't like lisp
16:07tomojyup
16:07tomojmostly rubyists who haven't seen the light yet
16:08tomojtechnomancy: looks like the fix is to just delete line 12 of starter-kit-elpa.el
16:09technomancytomoj: temporary fix, anyway. go for it.
16:09tomojis the real fix to get 21 into elpa?
16:10technomancy22, if we're lucky
16:10technomancyI've been talking with the author, it seems it's right around the corner.
16:10technomancy22 allows you to use paredit with nonlisps too.
16:11tomojhuh.
16:21wwmorganIf a class has a public field foo and a nullary function foo, how do I access the field from clojure?
16:26gkoWhat's the most effective way to remove a map from a set in an alter?
16:32tomojdisj?
16:32tomojwhat other way is there?
16:33Chousukewwmorgan: good question. :P
16:34duncanmheh, interesting
16:34duncanmwhat's the lookup order, it gets the method before the field?
16:42cemerickwwmorgan: in a pinch, there's always Reflector.getInstanceField
16:42gkotomoj: yes, disj is what I wanted. Thanks!
17:02Chousukehmm
17:02Chousukeegg makes using git a lot more pleasant once you get used to it.
17:03Chousukenow if I only had the skills and patience to provide viper-y bindings for it...
17:04Chousuken/p for going up/down the hunks is not bad, but I am used to j/k
17:04clojurebotfor is not used often enough.
17:04duncanmwhat's viper?
17:04Chousukemodal editing for emacs
17:04duncanmoh
17:04duncanmyou like using that?
17:04Chousukeyeah
17:05ChousukeIt's what I like about vim the most
17:05Chousukethe editor itself is clearly inferior to emacs.
17:09duncanmbut you like modal editing
17:09ChousukeI also did what I never could figure out how to do in vim and made C-ö equal "exit insert mode" (ö being to the left of l and right under my pinky on this keyboard layout
17:10Chousukeleft... right!
17:10Chousukeand yeah, I like modal editing
17:10ChousukeI also like modal browsing, with vimperator. ;p
17:11triddell1technomancy: question: when you use clojure-install from the starter kit, what versions of clojure and contrib are installed? and how are these typically updated/changed... using git commands in the src directories?
17:12LauJensentriddell1: As I recall it pulls all the latests using Git, updating is manually done by Git pull. I could be wrong
17:13ChousukeI think it takes 1.0 by default
17:13Chousukeand the compat branch in contrib
17:13triddell1LauJensen: that's what it looks like but I didn't see any mention, thx
17:17triddell1Chousuke: ok, I'll pull new versions if necessary
17:25triddell1I usually use egg for git in emacs but I only see magit in the package-list-packages list... what do some of you use?
17:26technomancytriddell1: it should use clojure 1.0 and the 1.0-compatible branch of contrib
17:27technomancyI've got a plan to make it optional to use the master branch of git, but haven't gotten around to that since I only use 1.0 myself
17:28technomancysee the clojure-last-known-good-revisions var
17:28triddell1technomancy: ok, thanks... so do you use magit then... which in in the list of installable applications
17:29technomancydefinitely; magit is one of my favourite tools.
17:30triddell1I'll have to give it a try
17:30technomancytriddell1: check out the screencast; it's really helpful: http://alexvollmer.com/index.php/2009/01/18/meet-magit/
17:31triddell1technomancy: cool, starting it now
17:32Chousuketechnomancy: are you aware of egg?
17:32Chousukeit's like magit, except user-friendly.
17:32Chousuke(it uses *colour*)
17:33technomancymagit is pretty colourful
17:33Chousukenot mine :P
17:33triddell1technomancy: so if I want to use something like egg I just make those changes in my local username.el file then?
17:33technomancytriddell1: sure
17:33Chousukesuppose I never saw the colourful screens :)
17:40Chousuketechnomancy: hm, how do I stage individual chunks with magit? :/
17:41technomancyChousuke: it's just "s"
17:41technomancyyou need to expand the file first with tab then put the point on the chunk
17:42drewrkotarak: is there an idiomatic way to provide lexicals inside of an execute-sql macro call?
17:42Chousuketechnomancy: hm, and how do you narrow down the hunk? :/
17:43kotarakdrewr: do you have example, what you want to do?
17:43technomancyChousuke: you mean splitting an existing chunk into smaller pieces? not sure.
17:44Chousukehmm, it only shows me one chunk in the first place.
17:44kotarakdrewr: you mean something like (let [x 5] (query some-table [foo bar baz] (>= foo ~x)))
17:46lisppaste8drewr pasted "variable in execute-sql expansion" at http://paste.lisp.org/display/84943
17:48drewrah, an unquote, of course
17:48kotarakdrewr: unquote work normally. You can also use query*, but be sure to quote all symbols then or use strings. keywords are broken at the moment. *coughcough*
17:49kotarakChousuke: be ripping of the syntax-quote algorithm from core and remove all the resolution stuff. It becomes what is known as "quasiquote" eg. in Scheme.
17:50kotarakI posted that to the google group if you are interested.
17:50drewrthe expansion looks right though, doesn't it?
17:50drewrwhy wouldn't that work?
17:50Chousukekotarak: I'm looking at it
17:50drewrahh, I didn't expand execute-sql
17:51kotarakexactly.
17:51Chousukekotarak: I might end up implementing syntax-quote outside the reader
17:52drewractually it was insert-into that hid the quasiquote
17:53kotarakChousuke: http://www.mail-archive.com/clojure@googlegroups.com/msg04500.html <--- here's the original thread, but don't ask me how to find that on google groups....
17:53Chousukekotarak: does your quasi-quote handle nesting though?
17:54kotarakChousuke: not sure, never tried.
17:54kotarakIt also doesn't handle ~@ at the moment, which is sort of annoying.
17:57ChousukeI suppose checking for a (quasi-quote ...) and then just returning the list completely quoted would handle nesting.
17:57Chousukethe clojure reader is pretty weird about it.
17:58Chousuke,(let [x 5] `(do ~x `(foo bar ~x)))
17:58clojurebot(do 5 (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/foo)) (clojure.core/list (quote sandbox/bar)) (clojure.core/list sandbox/x))))
17:59kotarakYes. I wonder whether this is really necessary. It looks at least scary.
17:59Chousukeit's because syntax-quote is completely read time
17:59Chousukeand the inner ones are expanded first
18:01Chousukebut I think returning '(do 5 (c.c/syntax-quote (foo bar (unquote x)))) should suffice
18:01Chousukeassuming syntax-quote as a macro
18:03JAS415you can seperate it out into two parts
18:09kotarakChousuke: Hmmm.. Dunno. I found nesting to be very rare and when I needed it, it didn't solve my problem... ;p
18:12JAS415clojure bot is being weird
18:12JAS415ah i'm mistaken
18:13JAS415,(let [x 5 inner `(foo bar ~x)] (list 'do x inner))
18:13clojurebot(do 5 (sandbox/foo sandbox/bar 5))
18:14JAS415,(let [x 5 inner `(foo bar ~x)] `(do ~x ~inner))
18:14clojurebot(do 5 (sandbox/foo sandbox/bar 5))
18:15JAS415(let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner))
18:15JAS415,(let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner))
18:15clojurebot(do 5 (foo bar 5))
18:27drewrkotarak: I didn't see any support for LIMIT/OFFSET; any plans for that?
18:27alrex021if I have a list of maps, what is an easiest way to find a map that case a specific value for a given key?
18:27clojurebotmaps are functions
18:27alrex021*case = has
18:28kotarakdrewr: yes. there was a patch already a while back, but we noticed, that it somehow got lost. I will check to see whether it still applies.
18:29kotarakalrex021: (first (filter #(= (:key %) value) list-of-maps))
18:31Chousukehm
18:32Chousukesurprisingly easy.
18:32kotarak:)
18:32ChousukeI just had to wrap stuff in lists, add a concat and then NOT wrap the spliced stuff in an extra list)
19:05hiredmanhttp://clj-me.blogspot.com/2009/08/what-warn-on-reflection-didnt-tell-you.html
19:45wavisterit seems like when one has a function with a variable argument list, and a collection which could serve as those arguments, there should be a way to use the collection as the argument list. I've looked around for it, and I'm not finding. Is it right under my nose?
19:45dreishapply
19:45wavisterin ruby it's called splatting
19:45dreish,(doc apply)
19:45clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
19:45dreish,(apply + [1 2 3 4])
19:45clojurebot10
19:46wavisterokay thanks! i'll work with that
20:43tomojhmm.. how come I can't barf out the body of a defn?
20:43durka42say again?
20:43tomojoh, kill/yank works fine for that
20:43dreishReferring to paredit mode?
20:43tomojyeah
20:43durka42oh :)
20:43dreishOr expecting to vomit Lisp?
20:43tomojhehe
20:44dreishparedit-forward-barf-sexp works for me, with the cursor right before the body of the defn.
20:47MakoryuIs it possible to interactively define functions on the console, and then dump them to a file?
20:48dreishYou could if you coded your own repl that did that.
20:50dreishOr you could redefine defn to add the source code as metadata on the var.
20:50cemerickis there a shortcut to ensure that a dispatch value should always have some lowest priority?
20:50cemerickbasically, another level of default?
20:51cemerick(I suppose I could just have a :default dispatch, and go from there)
20:52tomojdreish: what version of paredit?
20:52dreishtomoj: 22
20:52tomojforward-barf-sexp just moves to after the defn for me on 21
20:52tomojaha
20:53tomojguess I should figure out how to upgrade
20:59tomojhmm, actually I can't barf anything
20:59tomojthis is odd
21:08tomoj./facepalm. I was using M-{ etc instead of C-{ etc
21:17ataggartwhat is the effect of adding :refer-clojure to the ns?
22:19cemerick,(doc ns)
22:19clojurebot"([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo
22:19cemerickeh, not enough
22:19cemerickataggart: see http://clojure.org/api#ns
22:19cemerick:refer-clojure is only used when you need to exclude or rename some vars in clojure.core
22:20cemericksame options as http://clojure.org/api#refer
22:20JAS415,(doc refer)
22:20clojurebot"([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current nam
22:20JAS415woowoo
22:34ataggartcemerik: thanks
22:34ataggartcemerick
22:35ataggartbah, I forot about the BAC tonight
22:36mebaran151the BAC?
23:41JAS415is there a place to announce clojure libraries?
23:41carkthere is a thread on the mailing list
23:42carkhttp://groups.google.com/group/clojure/browse_thread/thread/affb08d66c048c7f
23:42JAS415cool
23:42JAS415i made this: http://github.com/JonathanSmith/CRIB/tree/89a3f4d9c797ef6f4e4f456001ff6a4c5c050064
23:43tomojdo clojure people use mocks/stubs?
23:43tomojnot sure how those would fit into clojure's paradigm
23:43JAS415http://github.com/JonathanSmith/CRIB/tree/master
23:43JAS415this rather
23:43JAS415what are mocks/stubs?
23:43tomojwell.. mock objects for testing. the objects part doesn't really make sense
23:44tomojbut say I'm testing a function that makes an http request
23:44hiredmanyou can use binding to alter function behaviour
23:44tomojI suppose I could just rebind the function to return a fake http response
23:45hiredman,(binding [+ *] (+ 2 3))
23:45clojurebot5
23:45hiredmangrr
23:46hiredmanoh
23:46hiredmanof course, inlined math op
23:46hiredman,(binding [+ *] (+ 2 3 4))
23:46clojurebot24
23:46hiredman,(* 2 3 4)
23:46clojurebot24
23:46JAS415weird
23:47JAS415probably because + gets inlined
23:47JAS415?
23:47carkmhh
23:47carkthat's a bug isn't it ?
23:47tomojfrom my ruby perspective I would want to rebind the http request function to make sure it was passed the right args
23:47JAS415depends on your perspective i guess
23:47tomojand fail the test if not (or if it's not called)
23:47carkmock functions =)
23:48JAS415really need in-lining levels like in CL
23:48tomojbut I get the feeling that's not the right idea for clojure
23:48JAS415well tom
23:48tomojI mean, rhickey doesn't do any testing at all, right?
23:48carktomoj: when doing pure functional, you know what goes in and check what goes out
23:48JAS415ideally it would be decomposed so that the http-function and the function calling it are composable
23:49JAS415if that is the really important part
23:49tomojoh, I see. so does binding the http request method to return a fake http request sound reasonable?
23:50tomojproblematic there because http request = not pure functional
23:50JAS415well clojure isn't pure functional because its running on java :-P
23:50JAS415but you can write code purely functional?
23:51tomojsure, but not code that does http requests
23:51JAS415but anyway, i think that sounds reasonable
23:57tomojI think I'm just hoping TDD will magically make my code pretty
23:58tomojI'm just going to delete it all and start over :)