#clojure logs

2009-01-12

00:14durkadoes this function exist?
00:15durka(defn eval-in-ns [ns code] (binding [*ns* (the-ns ns)] (eval code)))
00:15durka(eval-in-ns 'kitchen '(make-coffee))
00:16hiredmanclojurebot: latest?
00:16clojurebotlatest is 1207
00:16hiredmansvn rev 1207
00:16clojurebotsvn rev 1207; intial import of streams stuff, Java side
00:16hiredmandurka: I don't think so
00:20Chouser'eval' is generally frowned on. It's there because it needs to be for repls and the system itself to work, but not much effort is made to make it convenient.
00:54dcnstrcthrm... I want parenscript for clojure.
00:55dhayadcnstrct: did you look at clojurescript in contrib?
00:55dcnstrctwhat ?! you're kidding me
00:55dcnstrctno I'll check it out
00:55burkelibbeyhttp://github.com/kevinoneill/clojure-contrib/tree/master/clojurescript
00:56dhayaI don't think it is complete yet though.
00:56burkelibbeyNope
00:57Chouserdcnstrct: what do you want out of it?
00:58dcnstrctI want to use it together with a web serverl ike Jetty and JCouchDB for my persistance layer
00:58dcnstrctand kind of roll my own all lisp web framework
00:58burkelibbeyObvious question is "have you looked at Compojure?" ;)
00:59Chouserand you want to be able to write ajaxy event handlers in clojure and have them work in the browser?
00:59dcnstrctactually no I hated the name so bad ;)
00:59dcnstrctI'll go check it out
00:59burkelibbeyhaha, that was my reason for not looking at Webjure.
00:59Chouseror what role would clojurescript play?
01:00dcnstrctChouser, well mainly I want to write a whole web app in lisp, so that means I'll want a DSL for generating XHTML and one for JS
01:00dcnstrctand hopefully the two would play nicely with eachother
01:01Chouserthere are probably dozen libs that convert some style of clojure s-expr or other to x/html.
01:01Chouserthere are even one or two clojure-to-json libs around
01:02danlarkinthere sure are!
01:02dcnstrctthat gets me pretty damn close then =]
01:02Chouserbut if you actually want to produce javascript *code* from clojure-like sources, clojurescript can do it.
01:03burkelibbeyWith regard to just the html DSL, compojure seems to have this: http://github.com/weavejester/compojure/tree/master/src/compojure/html.clj
01:03ChouserI was rather excited about it for a while, but I'm starting to wonder just exactly how narrow the use cases are.
01:05dcnstrctChouser, What I really want to do is I want to create a clojure DSL around a system called Open Laszlo. Open laszlo sources are just xhtml and JS, but they get compiled down to flash bytecode
01:05Chouserheh. clojure -> js -> flash?
01:05dcnstrctso that way I can write flash apps without having to endure ActionScript and or lots of pointy brackets
01:06dcnstrctclojure -> js/xml -> laszlo compiler -> flash=*OR*dhtml
01:06Chouserfascinating. I've heard of laszlo, but I wasn't aware it included js->flash
01:06dcnstrctyeah you program declaratively?sp? with an XML/JS based DSL
01:07dcnstrctand then the program can be compiled into either a JS app
01:07dcnstrctor a flash app
01:07burkelibbeyThat sounds really cool -- I may have to check that out.
01:07dcnstrctand it's all written in java too, so it may be clojure friendly
01:08dcnstrct=] thnx for the hep people.. checking out compujure and clojurescript. ttyl
02:28jomahmm coming back to python after using clojure just feels wrong
02:28jomaits like clojure and haskell are just above everything else
02:32banisterfiendjoma: yeah the local gay community has that as their slogan, are you sure you're not wearing a pink t-shirt and sitting on a dildo
02:37Lau_of_DKMorning all
02:38Chousukemorning
02:54Chouserclojure.main isn't pleasing me. I suppose I'll have to write up a whole thing as to why, if I want it to change.
02:55ChouserI feel bad I didn't test it and speak up earlier. :-/
02:55Lau_of_DKClojure.main ?
02:56Chouser,(keys (ns-publics 'clojure.main))
02:56clojurebotjava.lang.Exception: No namespace: clojure.main found
02:56Chouserhmph.
02:57Chouserit's meant to replace clojure.lang.Script and clojure.lang.Repl, I believe.
02:57ChouserI shouldn't be trying to talk -- it's too lat emand my brain's functioning quite as well as I think it is.
02:57ChouserI think I just replied to a google group post. I wonder if it made any sense.
03:54danleidoes anybody know, what the new equivalent of slime-redirect-inferior-output is?
05:18AWizzArdclojurebot: max people
05:18clojurebotmax people is 127
07:56grosourshi everybody
07:56Lau_of_DKHey hey
08:13vsthesquareshttp://adiumx.com/blog/2009/01/msn-rejecting-adium-132-connections/
09:42AWizzArdI have a 2 line clojure file: line1: (ns 'my.file (:gen-class)) and line2: (defn foo [bt text] (.setText bt text)). I (compile) this to .class files and would like to call foo from Java.
09:44AWizzArdHow can I load the contents of the .class files? And when this happened, how can I call foo?
09:46cooldude127AWizzArd: you can't call it from java
09:46cooldude127any functions defined on your class need to have a "0
09:46cooldude127"-" prefix
09:46cooldude127sorry typo
09:46cooldude127http://clojure.org/compilation
09:47AWizzArdoki
09:48cooldude127i'm not sure if or how you can define static methods on a class from clojure
09:51Chouseryou can can use clojure methods to call clojure fns from java
09:52ChouserI suppose you'd start with a call to 'require' to load the namespace, and then you could fetch the Var for foo and invoke it
09:53AWizzArdWhat is the function to call Clojure functions with Clojure from Java?
09:53ChouserInstances of Var are invokable.
09:55dhayaAWizzArd: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
09:56Chousertake a look at src/jvm/clojure/main.java
09:57AWizzArdgood, thanks
10:52danlarkinjava is like python, in that if I (catch Exception...) any exceptions that inherit from Exception will be caught, right?
10:52Chouseryes
10:53danlarkincool
10:53Chouserwhich is almost, but not quite, all of them.
10:53danlarkinof course
10:53danlarkinwhy wouldn't it be all
10:53danlarkinthat would be too convenient
10:54Chouserif you really want all of them, use Throwable. But that's generally discouraged
10:59danlarkinI was planning on using mmcgrana's clj-backtrace to display exceptions through a web browser, to do that I'm assuming I'll have to catch everything and then deal with printing it to the browser
10:59mmcgranadanlarking: Throwables are either Errors or Exceptions, Exceptions are meant to be recoverable, Errors are usually meant to be fatal.
10:59mmcgranadanlarkin: very exciting release this evening on that front!
11:00danlarkinOoo la la
11:02danlarkinOkay, so maybe it's better just to catch Exceptions then
11:03mmcgranabut yeah the basic idea would be to add a try/catch around the app, and when Exceptions bubbled out print the backtrace to your response body, using either (pst-str e) or a lower-level api to customize the output, as you'll see in the release.
11:05mmcgranadanlarking: yes Error = game over. subclasses are e.g. ThreadDeatha and VirtualMachineError
11:05mmcgranaack keeping mispelling your name
11:05mmcgrana* I keep
11:09danlarkinhaha everyone does
11:09danlarkinit's the "ing" muscle memory
11:09mmcgranao yeah good point
11:10Chousukeit sometimes appears when talking about python too
11:17mmcgranadanlarkin: btw have you seen the new colorizing in clj-backtrace? http://img.skitch.com/20090112-qu36c7p478nbkt1e2knt2hch1g.jpg
11:18danlarkinI have, it's super great, I hope I can make it work over the web
11:21danlarkinI'm sure I can, I just haven't tried yet
11:38Chouserhm, clojurescript compiler in an applet works.
11:38rhickeycool
11:39Chouserthis should make the browser-based repl more sane, since it won't have to ship code off to a server to be translated.
11:40rhickeyyes, very neat
11:41rhickeyso applets work ok in general?
11:41ChouserI've not gotten one to work on Mac yet, but that's hard for me to test.
11:41rhickeyI'd love to figure that out, since only Macs here
11:42Chouser:-)
11:43Chouserthere is a Mac in the house, but I don't get much time on it usually.
11:44ChouserSo I may be able to make an attempt to track it down at some point.
11:45rhickeymy cursory glance at the error makes me feel like it is just that when compiled something is protected/public, and thus wrapped by gen-class, that at runtime on the Mac JVM is less accessible
11:46rhickeyI wonder if an :only option for gen-class would be useful
11:46Chouserbut you got a trivial applet to load and init ok, right?
11:47Chouseroh, you only tried appletviewer, didn't you?
11:47rhickeyChouser: appletviewer
11:48ChouserI think durka was reporting my applets were working fine in the appletviewer even on Mac.
11:49rhickeyI know (way back in the '90s) some applets were confused when read from the file system vs over the net, in browser
11:49rhickeybut not the case here reading yours over the net
11:53Chouserat the moment I have the applet returning a PersistentArrayMap, but of course this is a different beast than clojurescript's PersistentArrayMap. This is weird to think about.
11:54rhickeyheh, yeah, now you have Java and js on same side of the fence
11:55ChouserI suppose the functions in rt.js (like 'first', 'seq', etc.) could be made to interoperate with the Java objects.
11:59rhickeyChouser: once you have full Clojure engine on that side, you could implement simple interpreter for Clojure on Clojure (just to make things more confusing)
11:59Chouseryes, I'd thought of writing a clojure interpreter in clojure.
11:59Chousukeso wait what.
12:00Chouserthat would at the very least be more fun than writing (and maintaining!) clojure.lang.RT in javascript.
12:00ChouserChousuke: you can't have a applet the provides a full clojure repl currently, because to do that you need to load dynamic bytecode, which applets (and android devices) won't allow.
12:01Chousukehm, right.
12:01Chousukeso you'd need an interpreter.
12:01Chouserbut if you were to write an interpreter that examined clojure s-exprs and called the appropriate Java functions, then you could have a repl.
12:01danlarkinthis is rife with opportunity for a "yo dawg I wrote clojure in clojure so you can eval while you eval"
12:02Chouserbut since clojure can now be compiled to classes, you could write this interpreter in clojure
12:02Chousukesuch an interpreter would be useful for the sandbox too I think.
12:03Chouseror go the route I started pursuing last night, which is to have the applet produce javascript and eval that in the browser.
12:03rhickeyChouser: a lot of simple expression support for an interpreter is done, given Compiler.Expression.eval()
12:03Chouserrhickey: is that used for anything currently? I've never quite understood why it's there.
12:04rhickeyChouser: some things at the repl still run through it - used to be a lot more, but now fast enough to rwap in fns/conmpile/run in order to ensure same semantics
12:04StartsWithKChouser: you mean you can't have dyamic bytcode in applet? like, clojure can't compile .clj on the fly inside the applet?
12:04Chouserhuh. ok.
12:04ChouserStartsWithK: right.
12:05StartsWithKHmm
12:05rhickeybut essentially, almost all of Clojure except fns can be eval'ed like that
12:05StartsWithKi had opengl gears demo in clojure running in applet like 4-5 months ago
12:06StartsWithKyou can denerate dynamic bytecode inside applet
12:06ChouserStartsWithK: ah, yes, I should be more specific. I'm talking about applets without lowered security barriers, that is, unsigned applets.
12:06StartsWithKgnerate*
12:22StartsWithKChousuke: what is the main problem? That you have to give AllPermissions to your applet? Could that be solved by using RuntimePermission and restricting your applet so it can only generate bytcode in safe packages?
12:23ChousukeI don't think it needs AllPermissions, but the problem is that it needs *any* permission
12:24Chousukeit would be useful to just be able to run unsigned clojure code in an applet.
12:25StartsWithKsorry, Chouser*
12:34ole3is there a mapping between namespaces?
12:35ole3I have a ns foo-bar and this seems to get mapped to foo_bar
12:35ole3when i load the package
12:36technomancyI think it's just the dash-underscore translation.
12:36technomancythat one allows you to work around a limitation of the JVM
12:37ole3hm, so i have to name my directories with underscores
12:37ole3to load it i mean?
12:37technomancyafaik the only rule is any dashes in namespace names need to be underscores on disk, yeah
12:38technomancybut that applies to files and directories
12:38ole3so it is better not to use dashes in namespaces?
12:38technomancyif you have two-word namespaces, you should separate them with dashes.
12:39technomancybut if you can use one-word for each part of the namespace, that's fine too. =)
12:39ole3thank you
13:18danlarkinOT but really good post, http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/6d61dbf80d6f0fb6
13:19ChouserI think rather than renaming rest to tail and adding a new function rest, it might be better to introduce a new fn to encapsulate the idiom: 'has-rest' or something.
13:19Lau_of_DKGood evening gents
13:20danlarkinAfternoon Lau
13:20danlarkinChouser: "rest?"
13:21Chouserdanlarkin: sure, something like that. I think it would be unnecessarily tricky to keep 'tail' and 'rest' straight.
13:21Lau_of_DKChouser: Was any decicision made on nil punning yesterday?
13:22ChouserLau_of_DK: not that I know of.
13:22Lau_of_DKOk
13:22danlarkinwouldn't it be most common to use rest, though? I mean to say that 'tail' would have limited usage in user code, right?
13:24gnuvince_,(time (dotimes [_ 10000] (last (sort (range 1000)))))
13:24clojurebot"Elapsed time: 5648.104 msecs"
13:24gnuvince_,(time (dotimes [_ 10000] (reduce max (range 1000))))
13:24clojurebot"Elapsed time: 322.303 msecs"
13:24cooldude127well then
13:24cooldude127that's good to know
13:25Chouserreduce max is linear vs nlogn for sort. But the real difference probably comes from sort putting the whole seq into an array and then calling Java's sort.
13:25gnuvince_There's a WTF on reddit about "how to find the largest element without looping" and some people are saying things like "well if the sort routine is written in C..."
13:26danlarkin,(time (dotimes [_ 10000] (first (sort > (range 1000)))))
13:26clojurebot"Elapsed time: 8490.771 msecs"
13:26cooldude127wow a big pile of suck
13:27danlarkinmax it is
13:27cooldude127lol
13:28danlarkingnuvince_: yeah I saw that thread... ridiculous
13:28Chouser,(time (dotimes [_ 10000] (apply max (range 1000))))
13:28clojurebot"Elapsed time: 799.461 msecs"
13:28gnuvince_danlarkin: yes.
13:28Chouser,(time (dotimes [_ 10000] (apply max (range 1000))))
13:28clojurebot"Elapsed time: 277.883 msecs"
13:28cooldude127wtf?
13:28Chouser,(time (dotimes [_ 10000] (apply max (range 1000))))
13:28clojurebot"Elapsed time: 297.532 msecs"
13:29Chousukemust've been some glitch :)
13:29danlarkinnah, second run is always way way faster
13:30danlarkinI'm thinking it's some jvm optimizing going on profiling the first run and using it on subsequent runs? but really I have no idea
13:30Chousermuch of the time 'apply foo' is essentially the same as 'reduce foo', but if one of them is going to be faster, it'll be 'apply foo'
13:30Chousukeespecially true for str I guess
13:31ChouserChousuke: right, that's the main example. but the point is that foo is control of the loop when you 'apply foo', so it can do the best/smartest thing
13:31Chousuke,(time (do (reduce str (range 1000)) nil))
13:31clojurebot"Elapsed time: 12.906 msecs"
13:31Chouserwith 'reduce foo' you're controlling the loop. 'foo' only sees 2 args at a time, and so can't do anything clever.
13:31Chousukehmm, quick?
13:32Chousukeor maybe it noticed the result is nil and skipped the reduce :)
13:32danlarkinbut try the apply :)
13:33danlarkin,(time (do (apply str (range 1000)) nil))
13:33clojurebot"Elapsed time: 2.027 msecs"
13:33ChouserI told you, Clojure's alrady too fast.
13:33Chousukeah right, maybe I should've added a dotimes to that :P
13:36rhickey__note that while it is true (apply foo x) let's foo decide the best course, (reduce foo x) let's x decide, if it has optimized reduce vs. seq navigation
13:36rhickey__lets
13:36rhickey__aargh
13:36rhickey__irc is destroying my English
13:36danlarkinclojure is destroying my python, serves you right!
13:37Lau_of_DKhmm... Clojure destroys Python... i like :)
13:37kotarakhehe :)
13:38danlarkinyou guys and your python hating... psh
13:42durkarhickey_: what do you mean by optimized reduce vs. seq navigation?
13:42durkado you mean if it is lazy?
13:44rhickey__durka: apply requires x be supplied to foo as a seq, reduce may hand foo to x for more efficient internal iteration
13:45Chouser,(let [x (map identity (range 1000000))] (time (reduce + x)))
13:45clojurebot499999500000
13:46clojurebot"Elapsed time: 1671.362 msecs"
13:46Chouser,(let [x (range 1000000)] (time (reduce + x)))
13:46clojurebot499999500000
13:46clojurebot"Elapsed time: 318.357 msecs"
13:47rhickey__Chouser: range may be a bad candidate as it optimizes both seq and reduce
13:47Chouser,(let [x (vec (range 1000000))] (time (reduce + x)))
13:47clojurebot499999500000
13:47clojurebot"Elapsed time: 238.569 msecs"
13:48rhickey__as a general rule I would say prefer reduce, except for str, as 1 str of n things is more efficient than n-1 strs of 2 things
13:48Chouserbut if you use 'apply +', + will turn around and use reduce so you're still covered.
13:50rhickey__Chouser: still, prefer reduce, it will engender good habits and ways of thinking about things, apply is just for when you have the args for a single call in a seq already
13:52Chouseryessir
13:55rhickey__Sorry, didn't mean to be pedantic, just working on lfe/streams stuff and wondering if people really get reduce, since they'll need to
13:59ChouserI guess I should have said "ok" if I didn't want to sound injured. No need to apologize.
13:59Chouseris reduce any harder to get than map?
14:00rhickey__I see lots of loop/recur where reduce would do
14:00Chouserah, I see.
14:01burkelibbeyPeople usually seem to have a little more trouble "getting" reduce.
14:02rhickey__for all those following yesterday's stream conversation, unification is definitely out. Just too much of a mismatch to have map be pure on seqs and mutating on streams
14:02burkelibbeySo that means... nil punning stays, right?
14:02ChouserI wonder if 'reduce' could be rolled into 'for' somehow. People unfamiliar with functional programming seem to be more comfortable with 'for' at least at first.
14:03Chouser(for [i (range 10) :reduce +] ?)
14:04rhickey__burkelibbey: nil punning safe for now, but as I said yesterday, fully lazy seqs are independent of streams, but unification would have allowed both
14:04Chouser(for [i (range 10) :reduce (+ i old-i?)] ?)
14:05rhickey__:)
14:06technomancywas a decision reached on whether streams would be in 1.0 or not?
14:07rhickey__technomancy: I need to figure out if they require any breaking changes
14:10technomancygotcha. just curious; I don't feel strongly either way.
14:10Chouser(for [i (range 10)] (+ i (previous i 0))) is so much easier to understand than (reductions + 0 (range 10)) :-P
14:13rhickey__Chouser: http://www.lispworks.com/documentation/HyperSpec/Body/06_ac.htm
14:15rhickey__http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm
14:15rhickey__when you're ready to go really crazy with for
14:15Lau_of_DKI miss that loop :)
14:15rhickey__Lau_of_DK: not coming any time soon, loop is probably more complex than all of Clojure!
14:16Chouserno thank you.
14:16Lau_of_DKhehe, really? thats surprising... I also remember using it while relying heavily on sideeffects
14:17technomancyit's a good example of how you can do pretty much anything in Lisp syntax, but it's also a good example of why restraint in such an endeavor is important.
14:17danlarkinisn't there a project on github implementing LOOP in clojure? I might be wrong though, since I can't find it..
14:17Lau_of_DKrhickey__: I think you made a really good point about nil punning yesterday, are you looking to implement the proposed changes anytime soon ?
14:18danlarkinoh, nevermind, I'm thinking of FORMAT :)
14:18ChouserLau_of_DK: 14:02 < rhickey__> for all those following yesterday's stream conversation, unification is definitely out. Just too much of a mismatch to have map be pure on seqs and mutating on streams
14:18rhickey__Lau_of_DK: there are no proposed changes yet, just wanted to see how people felt about it
14:18Lau_of_DKdanlarkin: If you ran loop in something like SBCL, and stored all the results and calculations in an SQL table, then technically ClojureQL could be the project your looking for :)
14:18Lau_of_DKrhickey__: ok... just sounded interesting
14:18Lau_of_DKChouser: thanks
14:19jomadeos clojure have arrays or I use ajava arrays then? if i wanted to write a matrix-lib in clojure(just for fun I kno there a re good java ones), what would I use? vectors of vectors? vectors dont have O(1) access right? would I use dicts?
14:19ChouserLau_of_DK: but there's a branch in svn for the streams stuff, if you want to play with it.
14:19Lau_of_DKcool
14:19gnuvince_joma: vectors have O(log32 n) random access
14:19gnuvince_Which is pretty good
14:20gnuvince_,(/ (Math/log 1e10) (Math/log 32))
14:20clojurebot6.643856189774725
14:20Chousukemaybe not acceptable for a matrix lib though
14:20Chouserhow big would your matrix be!?
14:21Chouservectors are more "fun" in clojure than java arrays are.
14:22rhickey__Chouser: streams branch not ready for use yet
14:22Chouserok
14:22rhickey__only about 1/3 is up
14:22rhickey__some Java stuff, no clj stuff
14:23ChousukeChouser: sometimes you have really huge matrices :)
14:24Chousukebut I'm sure there are plenty of high-performance java matrix packages
14:26rhickey__http://piotr.wendykier.googlepages.com/parallelcolt
14:26rhickey__http://acs.lbl.gov/~hoschek/colt/
14:27Lau_of_DKrhickey__: Since your so informed about anything relating to software developement, I need to ask: Do you have a favorite bug tracker? :)
14:28technomancythough of course that is hard to maintain. =)
14:28Lau_of_DKIts a little hard, yes :)
14:28rhickey__technomancy: I agree, and it was with trepidation I introduced: http://code.google.com/p/clojure/issues/list
14:29Lau_of_DKEspecially when a bug can be anything from "Your software ate my cat" to "This line needs to be moved up 1 pixel"
14:29technomancyman, if clojure could eat cats that would be awesome.
14:29Lau_of_DKhaha
14:29Lau_of_DKMy friend, I think you missed the point
14:30ChouserI think I've been proved wrong about the issues page being overrun, though.
14:30Chouserwhich is good.
14:30technomancyI do love how short the issue list is.
14:31technomancyseems like a good balance of bugs and enhancements
14:31technomancy"Clojure is the least-buggy lisp implementation ever! Only sixteen bugs."
14:32technomancyactually... none of the high-priority defects are even bugs.
14:33kotarakSome are also just documentation issues.
14:33kotarakWhich rules me out, I guess.
14:33Chouserand some are fixed, with patches waiting patiently to be applied. :-)
14:34Lau_of_DKCan we consider it a bug that ClojureQL is not included in Core yet, or do I need to post that somewhere else?
14:35Chouserheh
14:38Lau_of_DKehh.. I made a funny? Not intentional I assure you :)
14:46ChousukeLooking at the stream code makes me wish java had macros. and I'm not even writing that code :D
14:50jomathats interesting. for real only 16bugs? how many does a language normally have? take python for example, or sbcl or Java or C++?
14:52technomancyjoma: that's not really a good question to ask... for instance, many of Java's bugs will be inherited by Clojure, and C++ can't have any bugs since it's not an implementation, just a language standard.
14:52technomancyactually, I take that back, C++ has tons of bugs even without being software.
14:52technomancyarguably its entire existence
14:52danlarkinand python's been around for 18+ years, and clojure only ~3
14:53danlarkintwo of which were unreleased
14:53Chouseralso, that's a list of discovered but unfixed bugs. It says nothing about how many there were that have been fixed, and certainly not how many undiscovered bugs there may be.
15:08jomafor(r=0; r<rows; r++) { for(c=0; c<columns; c++) {mtrx[r][c] = new_matrix[r][c];}} , why is that not working?
15:08jomasorry wrong channel
16:03Lau_of_DKHow does if-let work ?
16:04drewrLau_of_DK: (if-let [foo true] foo :else) => true
16:04drewr(if-let [bar false] foo bar) => false
16:05Lau_of_DK(if-let [x (= 2 2)] x 5)
16:05Lau_of_DKso x will be true and the rest is like a normal if then..
16:06drewrIt binds the symbol if the value is true(-ish).
16:06kotarakLau_of_DK: it's more interesting for things like (if-let [rst (rest of-a-seq)] (map stuff rst) ["The seq did not have a rest"])
16:06drewrIt's the same as (if :foo (let [x :foo] ... ))
16:07drewrEr, (if :foo (let [x :foo] ... ) ...)
16:07drewrThe other one was more like when-let.
16:08Lau_of_DKok, thanks guys
16:23Chouserha! clojurescript destructuring works on java clojure vectors.
16:34danlarkinChouser: sweeeet
16:37Chouserit's goofy, but it was working already. vector destructuring calls clojure.nth
16:38Chouserclojurescript's nth looks to see if the object has an nth method. The Java vector object does. So it gets called, pulls the value from the java object, and returns it through the javascript.
16:38Chouserdestructuring that assigns that to a local javascript variable, and you're off and running.
16:50Chouserno new macros in a browser repl, though.
17:04herkelmaybe im stupid but ic ant figure out the damn classpath, i have it working in clojure but in java i dnt get it. C:/javaprogs/Matrix/ , in there I have Matrix.java and MatrixTest.java. what should MatrixTest inherit and what package name should Matrix.java be in? wht should I pass as classpath when I compile?
17:05kotarakIf C:/javaprogs is in your classpath, I would suspect Matrix to be in the package matrix.
17:05kotarakpackage matrix;
17:05kotarakpublic class Matrix ......
17:06kotarakIt's similar to Clojure. The package is the path to the file. The class (or in clojure: the last part of the namespace) is the file.
17:07kotarakpackage foo.bar; class Baz ... <=> foo/bar/Baz.java
17:09RaynesI wish I could find an open source pastebin that supported clojure =\
17:11RaynesOh.
17:11RaynesFound one.
17:11Raynes:D
17:20kotarakRaynes: would you share your success?
17:23Rayneskotarak: Lodgeit is open source.
17:23RaynesIt also supports Haskell, just what I needed.
17:23Rayneshttp://dev.pocoo.org/projects/lodgeit/
17:24Raynespaste.pocoo.org
17:24kotarakIndeed. Clojure support available...
17:25RaynesI knew about Lodgeit, but I didn't know it was open source.
17:26Chousukethat's pretty nice.
17:26RaynesAgreed.
17:26RaynesI'm going to slap it on my site :>
17:27Chousukethe rest of the utils look nice too
17:28kotarakAnd there is a Vim plugin for pasting...
17:28danlarkinI use werkzeug with django, it's very helpful
17:30RaynesDirty vimmers.
17:30craigmarshall9:-D
17:38durkais (in-ns (ns-name ns)) the same as (set! *ns* ns) ?
17:39durkaand (binding [*ns* ns] ...)?
17:41FibAre "symbols" in Clojure/LISP just another name for "identifier", or is there a difference? I have a feeling there is but I've not been able to pin it down from what little I know of LISPs.
17:41durkathe documentation of in-ns seems to suggest that it would be, and i can't find an implementation, except one in java that seems to just call (set! *ns*)
17:42durkaFib: there is a difference, but i think there is also a difference between a clojure symbol and a lisp symbol
17:42durkabut i am fuzzy on all three definitions as well
17:43ChouserFib: My common lisp knowledge is weak, but I think there a "symbol" may have storage, so it's more like a variable.
17:43technomancyFib: they're used *mostly* for identifiers, yes
17:44technomancysymbols are usually bound to a value, but sometimes they're used by themselves to just be disconnected names
17:44ChouserFib: In Clojure a symbol is an object -- it has data members for namespace and name, each of which is a string. It's essentially a special kind of string.
17:44rhickey__More naming fn, given bifurcation, what suffix for stream versions of fns like map/filter/reduce? Candidates are map! and map$
17:44rhickey__fun
17:45Chouser'map!' doesn't change the value of the stream it's consuming, right? just generates a stream that's doing mutation internally?
17:46rhickey__Chouser: it does change the state of the stream, streams are inherently stateful, each call to next! eats a value
17:47rhickey__that's the main reason not to unify with map of seqs
17:47Chouserok, right, sorry.
17:48Chousukehmm, you have many edits to clojure.core in your clojurescript compatibility patch :/
17:48Chouseryou don't want to consider a suffix of "+"?
17:48rhickey__sometimes it will be a "real", io type mutation, like a file based stream, other times a weaker mutation of a cursor on a persistent data structure
17:48ChouserChousuke: yes, and also RT.java
17:48rhickey__would consider anything, throwing it out for suggestions
17:49rhickey__a benefit of non-alpha is that you could stick it on any existing name
17:50ChouserI like the idea of a new suffix that does already mean more generally "mutate" like "!", but I find $ rather unattractive.
17:50durkai kind of like $ because it suggests S for stream
17:50durkaon the other hand it has an overloaded java meaning
17:50kotarakwhy not mapS, then?
17:50rhickey__durka: right, that's the argument for it
17:50kotarak$ is ugly
17:50Chouserlook, a stream between two rocks: %
17:50rhickey__but people hate $
17:51rhickey__Chouser: heh
17:51danlarkinmap?
17:51kotarakmaps
17:51kotarakmapEUR ;)
17:51Chousuke:P
17:52rhickey__ascii please :)
17:52ChousukeI guess map: would be too unnoticeable.
17:52kotarakmap>
17:52kotarakmap<
17:52Chousukeand looks like a keyword or some kind of label anyway
17:52Chouser(reduce% #(- %2 %) strm)
17:53kotarakWe are approaching Haskell, eh?
17:53rhickey__kotarak: not even close
17:53durkaweren't you considering map* earlier?
17:54durka* seems to be the historical lisp character for "subtly different version"
17:54kotarakmap�, but not ascii....
17:54Chousukemap|, but a bit difficult to type :/
17:54Chousuke(needs alt on my keyboard)
17:55kotarakmap-
17:55danlarkinthere's no good answer :-/
17:55rhickey__just FYI, all of these versions will curry, so that hairy Haskell LFE stuff becomes something like this:
17:56rhickey__(line-streamer rdr (comp-> (map! inc) (filter! even?) (reduce! + 10)))
17:56rhickey__not that it makes sense reduce lines with + :)
17:56rhickey__comp-> is like comp in reverse order
17:57rhickey__so something like line-streamer can fully encapsulate the use of its resource-based stream
17:57Chousukeis it required that they curry like that? or just optional?
17:57kotarakWasn't there a longer discussion about currying before?
17:57ChousukeI guess it's just adding an overload without the seq/stream argument
17:58rhickey__Chousuke: you want to say partial a lot?
17:58Chousukenot really.
17:58Chousukethat looks good.
17:58rhickey__Chousuke: right, just an arity overload
17:58karmazilladid you also change your mind on currying for normal map, filter, reduce?
17:59rhickey__karmazilla: nope, these might actually be used curried more often than not
18:00Chousukewould it break anything to add similar overloads for the regular seq functions though?
18:01rhickey__I would like not to get distracted by that now
18:01Chousukeokay, so back to naming... hm.
18:02ChousukeI think I find ! the least offensive. maybe users could be re-educated to just think it means "pay attention!"
18:02Chousukesince streams are lossy.
18:02danlarkinso there's set! (which means side effect) and map! (which means consumes-a-stream)
18:03danlarkinwhich I guess are similar ideas
18:03rhickey__danlarkin: yes, because it consumes a stream by side-effect
18:03danlarkinyeah
18:04rhickey__the thing is, when you package them up as in the line-streamer call above, they become safe(r)
18:06danlarkinsee this is where haskell is nice, because with the type system you can say hey! you can't use these things where you're not expecting side effects
18:06danlarkinthat's my understanding, anyway
18:06rhickey__danlarkin: yeah, by tainting your entire call chain
18:07karmazillaas Erik Meijer would have said; "but it's the truth!" :)
18:08rhickey__right now I've got it so io! blocks and transactions can't overlap, will be interesting to see how far that gets us
18:08rhickey__karmazilla: its a straightjacket that keeps you from painting outside the lines (and makes it difficult to play tennis)
18:09karmazillahehe yeah. He also said he liked dynamic languages because if the type system tells you nothing, then it can't lie
18:10rhickey__karmazilla: there you go
18:11technomancyI don't see how the type system enforcing safety is any safer than using io! blocks.
18:11technomancyfor side-effects, I mean
18:11rhickey__technomancy: type system can prove things at compile-time, all I can do is throw at runtime
18:12technomancyah, so it just encourages you to spend less time on your test suite then... awesome. =)
18:13karmazillaand more time trying to get your code to compile
18:13technomancyif you've got a codebase that could sneak an io! block into a transaction without getting caught by your test suite, retrying side-effects is the least of your worries.
18:13danlarkinI think we can all agree that clojure should remain dynamically typed :)
18:14technomancydanlarkin: sometimes the choir enjoys a good sermon. =)
18:15rhickey__so, map!, map-> ???
18:16danlarkinmap<- is too ugly I guess...
18:16kotarakjust map<
18:17danlarkinyeah map< might do
18:17karmazillaI like map!
18:17rhickey__(comp (reduce<< + 10) (filter<< even?) (map<< inc))
18:17Chousukereminds me of C++ :P
18:18durkai think that's too many characters
18:18technomancymap! appeals to /me
18:18rhickey__<< implies motion that < does not, for me
18:19kotarakwe also have :>> in condp
18:19rhickey__that's right
18:20danlarkinnaming is always the hardest part of programming... the rest is, what'd Chouser call it? SMOP?
18:20technomancyheh; my IRC client wraps nicks in <>s, so that makes this even more punctuationtastic.
18:20technomancyemoticon-oriented-programming
18:26rhickey__gotta run - thanks for the feedback
18:32jomaI like ! like in Scheme I already use it myself
19:26rhickey__My slot at ILC 2009 has been confirmed - a full-day tutorial: Clojure in Depth
19:27technomancywhat's ILC?
19:27technomancyInternational Lisp Conference?
19:27rhickey__yup
19:28technomancycool!
19:28rhickey__http://www.international-lisp-conference.org/2009/index
19:29technomancyis it in cambridge every year?
19:29rhickey__no, moves around, and every 2 years
19:30technomancyI'll have to wait for a west coast one. Sounds like fun though.
19:30rhickey__I'll also be on a panel at ILC
19:30rhickey__2 slots at QCon London
19:31rhickey__And 2 irons in the fire for Java One, one talk and one panel, don't know on those yet
19:34durkawill these be videotaped?
19:35rhickey__durka: I don't know, QCon seems very good about that, I'm also doing an interview with InfoQ while I'm there
19:39Chouserbleh. FnExpr.parse() calls compile, which demands a dynamic classloader.
19:41durkawhoops... i tried to install enclojure, and now i have an unbootable netbeans
19:58danlarkinHmmm
19:58danlarkinboston for a weekend
20:00danlarkinis there a cost for attending?
20:11rhickey__danlarkin: they do charge for the conference, I think in the past you could pay per day
20:14technomancywhat's ballpark range on the cost?
20:15danlarkinoh gosh, in 2007 per diem was �150
20:16technomancywhat city?
20:16danlarkinCambridge, MA -- across the river from boston
20:17danlarkinor is it a bay at that point... I don't know
20:18danlarkinhere's what I'm looking at http://www.international-lisp-conference.org/2007/price-list
20:19technomancy~USD500 for a weekend is not too horrible for a big event like that
20:20technomancythat's only slightly higher than RubyConf, which is pretty small.
20:20technomancyand not in Cambridge
20:20danlarkinmuch higher than pycon :-/
20:21technomancywell, I suspect they don't have a lot of big sponsors.
20:21technomancyITA can only throw so many dollars at Lisp; someone else needs to step up. =)
20:23danlarkinyeahhh, pycon was a little sponsor-heavy last year
20:50duderdoHello!
20:51duderdoHow do I add entries to my classpath?
20:53durkadepends on operating system
20:54durkagenerally has to do with the environment variable $CLASSPATH
20:54durkaor you can use command line args to java
20:54duderdoI see, I'm using linux so I just need to make an environment variable?
20:58durkayeah
20:58durkaif you want to make it permanent put it in your ~/.bashrc
20:58durka$CLASSPATH is directories separated by :
20:58duderdoSo I need to update it each time I want to add a library I guess...?
21:04durkasorry i wasn't paying attention
21:04durkagenerally yes
21:04durkaunless you can put the libraries in the same directory and just put the directory on the classpath
21:05duderdoNo worries. Thanks man.
21:06durkaif you're looking for references, you can find tons of classpath advice for java, and it all applies
21:10duderdoah that's a good point
21:10duderdowill do. thanks again
21:21herkelim doing compressions algorithms for sparce matrices(seminoobish as i am dont count one smething revolutionary :) ). I ws thinking how dynamic typing can save a lot of memoery it seems. since you can choose freely how to represent while a static language(at least the ones that exist) forces you to organize ina certain way. is this correct?
21:47herkelim doing compressions algorithms for sparce matrices(seminoobish as i am dont count one smething revolutionary :) ). I ws thinking how dynamic typing can save a lot of memoery it seems. since you can choose freely how to represent while a static language(at least the ones that exist) forces you to organize ina certain way. is this correct?
21:49ChouserI don't think that's a valid generalization.