#clojure logs

2009-08-19

00:00konrI want to learn how to use swing and clojure, but I'm wondering where I should start. Almost everything writter for swing is in java
00:01hiredmando you know java?
00:01hiredmando you know clojure?
00:03konrI don't know java
00:03arbscht_doesn't Programming Clojure cover basic Swing usage from Clojure?
00:03konrI now know a bit of clojure
00:03hiredmanwell, in order to translate java to clojure you will need to know some java
00:03hiredmanso I would start with a java tutorial or two
00:04tomojhmm.. what's a good way to generate all the n-tuples of natural numbers that add up to x?
00:06tomojright now I'm using selections from contrib.combinatorics to generate all possible n-tuples selecting from 0 to x, and then filtering by checking the sum
00:06tomoj(which is obviously not a good way)
00:07Anniepoohey, clojurebot's been rescued from the Scala people!
00:07Anniepooclojurebot: paste
00:07clojurebotlisppaste8, url
00:07lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:08tomojoh, this reminds me of the donut problem
00:08tomojI could have a vector of n 1's, then pick all possible ways to partition the vector and sum the subvectors
00:08lisppaste8Anniepoo pasted "mapping def" at http://paste.lisp.org/display/85630
00:09Anniepoocan anybody suggest a clean way to do this without the ugly list of def calls
00:09arbschtmultimethods?
00:09hiredmansounds good
00:10hiredmanor write a macro
00:10Anniepoook, it'd have to be a macro, wouldn't it?
00:10tomojwhy?
00:11hiredmanit looks like you writing a switch statement
00:11hiredmanyou are
00:11hiredmanso use a multimethod
00:11Anniepoono (map #(def % not-handled) ('key-up 'mouse-down...)
00:11Anniepooyah, good idea
00:11hiredman
00:12AnniepooI'm just trying to get out of all the swing ceremony
00:13tomojoh, I see
00:13tomojdef is not a function..
00:13hiredmanwell, you just created your own ceremony
00:13Anniepooso it seems
00:14tomojI don't understand how you could use multimethods there
00:15hiredmanyou have a handler multimethod
00:15hiredmanit dispatches on the type of event passed in, the default method does nothing
00:16arbschthttp://gist.github.com/170156
00:16tomojah, I see
00:16arbschtsort of like that
00:16Anniepoook, but the java class of event isn't sufficient to know, for example, if it's mouse up or mouse down
00:16Anniepooso I suppose you have to mark it with a keyword or something
00:17tomojcertainly java gives you some indication of the type of the event?
00:17hiredmanAnniepoo: you just write a dispatch function that contains the logic needed
00:17arbschtyes, just pass it as an argument for the dispatch fn to use
00:17hiredmanby type I did not mean java class
00:17Anniepoook, sounds good
00:17Anniepooit's a nice use of a multimethod
00:18AnniepooI'm making a little starter shell for a clojure hack meetup
00:18hiredmanmultimethods are pretty dope
00:18AnniepooI'll pass out a shell for a game and everybody can fill it in
00:18tomojI wish there were clojure meetups here
00:19Anniepooanybody in SF bay area who wants info, we'd love to have more clojure types at this
00:19Anniepoobunch of Java programmers 'in the wild' are interested, but nobody knows anything
00:19Anniepoolovely, it's in SF tomorrow evening,
00:20Anniepoogetting the info now
00:20arbschtI mean I'm in the south pacific :)
00:20arbschtthe really, really far side
00:20AnniepooLOL
00:20hiredmanI'm going to be in sacramento next weekend, but I don't think I have enough time for anything
00:20Anniepootoo bad
00:21hiredmanyeah
00:21Anniepoohttp://www.ebig.org/index.cfm?fuseaction=Page.ViewPage&PageID=481
00:21hiredmanI should get off my butt and go to seafunc sometime
00:29Anniepoono docstring for defmethod?
00:29hiredmanhow would you lookup the docstring for a specific method?
00:30Anniepoogood point
01:08Anniepoohmm... I can't nest destructuring?
01:08tomojsure you can
01:08Anniepoothe single arg to this function is something liek [[1 2] [3 4]]
01:09hiredman,((fn []) [[1 2] [3 4]]
01:09clojurebotEOF while reading
01:09hiredmaner
01:09Anniepoook, never mind
01:09hiredman,((fn [[[a b] c]] a) [[1 2] [3 4]])
01:09clojurebot1
01:09Anniepoook, cool, sorry, it's my mistake
02:47konrstrange... awt seems to be missing but I've used it before. Any idea on what is going on?
02:49hiredmanuh
02:49hiredmanwhat makes you say that?
02:50konr#<CompilerException java.lang.NoClassDefFoundError: java.awt.Container (imagem.clj:1)>
02:51konrhmmm, actually this is a different error message
02:52hiredmanweird
02:52konranyway, I've solved it removing sun's jdk and installing open jdk... go figure
02:52konrhaha, and netbeans doesn't install with openjdk :(
03:05Fossihi
03:08RaynesYo.
04:25carkDan Weinreb having a couple good words for clojure during the last 10 minutes of his google talk http://www.youtube.com/watch?v=xquJvmHF3S8
04:35Fossihmm C-M-Backspace is not 'backward-kill-sexp' ;D
05:40hamzahey guys, how can i extend one class and implement other two i need to extend DefaultTableCellRenderer and implement MouseListener MouseMotionListener
05:41dhayacheck out "proxy"
05:42hamzai know proxy but i can't get the synxtax right
05:42hamzai tried (proxy [DefaultTableCellRenderer MouseListener MouseMotionListener] []...
05:42hamzaand (proxy [DefaultTableCellRenderer ] [ MouseListener MouseMotionListener]...
05:43hamzaboth did not work
05:43carkthe first vector should have class and interfaces
05:44carkcould you paste your code somwhere ?
05:46lisppaste8hamza pasted "extend" at http://paste.lisp.org/display/85641
05:47carklooks ok at first glance
05:47carkwhat error do you get ?
05:48dhayayou
05:48hamzait works but mouseClicked never gets called.
05:48dhayaoops.
05:49carkare you sure about that ? *out* might not be bound in the event thread
05:51dhaya*out* defaults to System/out in any case, i think.
05:52carkit has been a while since i did swing stuff, but i remember having problems with it ... might be wrong tho
05:53carkmaybe try throwing in there, you'll be sure then =)
06:19alinphi
06:19alinpwe have dosync macro
06:19alinpwhat if I want to make an alias or something ... call it transaction, for instance
06:19alinphow this can be done ?
06:19alinpusing defmacro ?
06:20carkye
06:20carks
06:20alinpthat's the only way ? there is no alias concept for clojure ?\
06:20carkuntested : (defmacro transaction [& params] `(dosync ~@params))
06:20alinpsince I don't want to do much stuff ... just to change the name of dosync with transaction
06:20alinpok, thanks cark
06:21carkusually you can "alias" any var
06:21cark(def plus +)
06:21AWizzArdalinp: you should use a macro for that. It would look like the one that cark suggested, or very similar.
06:21alinpcark: your example worked
06:22alinpso you can consider it tested :D
06:22tomoj(refer-clojure :only '(dosync) :rename '{dosync transaction})
06:22carkgreat =)
06:23alinptomoj: thanks
06:23alinpbut keeping the spirit of lisp, I think macros are the most elegant way to do it
06:23Chousukethe ns macro can do it :P
06:24alinpbtw, why dosync and not transaction ? :)
06:24tomojrefer-clojure is a macro :P
06:24Chousukerefer-clojure is a function.
06:24tomojmine isn't
06:24Chousuke,refer-clojure
06:24clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/refer-clojure
06:24Chousukeoh. hmm.
06:24carkit's a macro here =)
06:24tomojjust a thin wrapper around the refer function
06:25Chousukeah, I was thinking of require etc
06:25carkwouldn't tomoj solution hide the rest of core ?
06:26tomojnot if you've already got it (like in user)
06:26carkok interesting
06:26tomojbut yeah if it's in your ns I guess you'd want to take out the only
06:27carkas for the naming, i guess rhickey didn't want a name clash with database stuff
06:35AWizzArdalso one can think of the operations inside a dosync block happen all synchronous
06:58tomojI wonder what the point of the first argument to sync is
07:27cp2has anyone seen http://www.youtube.com/watch?v=xquJvmHF3S8 yet?
07:27cp2they talk about clojure apparently
07:29Fossithey do? i thought it was implemented in common lisp
07:29cp2well, from the description:
07:29cp2I will also talk about the future of Lisp, which has three tracks: Common Lisp, Scheme, and Clojure.
07:29cp2i just started watching it
07:29Fossiah, ok
07:30Fossibut i'm definitely bookmarking that to watch it later
07:30Fossithose guys have some serious mojo down
07:30cp2heh
07:32mtdcp2: I like the "CONFIDENTIAL" stamp in the bottom right of the presentation
07:32cp2haha
07:33cp2quick, download the flv before they delete it!
07:42tomojthe clojure mention is like 10 minutes before the end
07:43tomojaround 50:00
07:44cp2ok
07:52ole3hi, i need loggin in my application, so is println thread save?
07:59Fossieh, pimping your theatre group on a world wide broadcasted tech talk is funny ;D
08:02Chousukeole3: send logging actions to an agent if you want to ensure that they're serialised.
08:02Chousukeole3: you might also want to take a look at the logging library in contrib
08:05ole3Chousuke: thank you.
08:26cp2interesting talk
08:27mtdcp2: very - weinreb saying CL is "on life support" and clojure is "amazing" seems to me a big (new) deal.
08:28cp2hehe
08:28cp2cl is very much alive still
08:28cp2but i do agree
08:28cp2clojure is amazing
08:28cp2=P
08:28mtdcp2: "life support" != dead :)
08:28cp2well
08:28cp2i meant alive as in
08:28cp2alive and kicking
08:28cp2not needing life support
08:29Fossiyeah, but imho i can't see many areas where it's much superior to clojure
08:29arbschtI gathered he said it would eventually be on life support if the library distribution situation wasn't resolved soon
08:29Fossiexcept maybe for having hardware support on obscure plattforms :)
08:29Fossiwhich is awesome
08:29ChousukeFossi: Performance, at least for now :p
08:30cp2mhm
08:30cp2im waiting for my tail calls!
08:30cp2and a *real* compiler
08:31FossiChousuke: well, i guess that depends a whole lot on the job
08:31ChousukeThe java compiler is pretty lazy I guess.
08:31Chousukeit just does the bare minimum of optimisations and leaves the rest to hotspot :)
08:31cp2yeah
08:31Chousukebut since it's written in java that's understandable. :P
08:32cp2hehe
08:32cp2has the development on the clojure clojure compiler started yet?
08:32mtdarbscht: "There is a lot of other interest [in library support and] doing things that will improve Common Lisp, but I mostly think that's life support. It can stay alive as a good language for another 5 years, or 10 years or something".
08:32ChousukeChouser did start something in March but I think that work won't be used.
08:33cp2yeah thats about what i last heard of it
08:33mtdarbscht: "...but it's not really the way to go in the long run because there's just a lot of stuff in it that's old, that has to be that way for compatibility..."
08:33ChousukeI'm writing a reader, but it's not as important as the compiler :)
08:33Chousukeit's also a lot easier. :P
08:33mtdarbscht: that's not "eventually on life support" that is "[on] life support".
08:33cp2you must be written in java =P
08:34Chousercompiler is two parts: analyzer and bytecode emitter
08:35cp2i almost thought you were Chousuke
08:35cp2(almost)
08:35cp2for like the 50000th time
08:35Chouseryeah. :-/
08:35ChousukeWe're used to that :P
08:35ChousukeSometimes I get called Chouser and it doesn't even faze me anymore.
08:35FossiChousuke: is that bad? leaving the optimisations to the runtime?
08:35cp2heh
08:36cp2well, usually whenever that happens it means i need more coffee
08:36cp2brb
08:36ChousukeFossi: Nah, but I'm quite sure there are some optimisations the compiler could more efficiently do before runtime.
08:36Fossimight be. then again, it seems to turn out quite well
08:37Fossii guess they would've improved the compiler by now otherwise
08:37ChousukeFor example, the issue with locals getting cleared only on tail calls
08:37Chousukeand not upon last use.
08:38Fossi*shrug* i don't actually *know* anything about shit. just loosely interested ;)
08:38ChouserI think some of the optimisations the compiler does are actually un-done by the vm before it does its own.
08:42cp2mmm
08:47raphinou_hi
08:51raphinou_I'm trying to compile a class, but I don't see how I can implement its constructor
08:52Fossiwhat's not-empty for? i thought (seq coll) was idiomatic
08:53Fossiactually, i can't figure out what value it adds at all
08:54Fossiand since you need a pred for test-is/is, is there a better way than (not (nil? stuff))?
08:54Chouserraphinou_: using proxy or gen-class or ... ?
08:54raphinou_Chouser: I'm using gen-class
08:54raphinou_it extends another existing class
08:55Chouserraphinou_: look at :init and :post-init -- those are your constructor hooks
08:56Chouser:init names a function that takes constructor args and feeds values into the base class constructor
08:57raphinou_but :init returns a vector with args and state
08:57Chouser:post-init gets run after the object has been created but before the object is returned to the client
08:57Chouserraphinou_: yes
08:57raphinou_what's the state exactly?
08:58Chouserraphinou_: it's the one instance field you get with gen-class, described in the doc under :state
08:59raphinou_Chouser: is it possible I do not need to use the state?
09:01Chouseryes
09:01Chouseresp. when extending an existing class that may store whatever state you need.
09:02Chouserbtw, I'd recommend using proxy instead, unless you know you need gen-class features that proxy doesn't support.
09:02raphinou_well, I started with proxy, but have read the gen-class is better if you need to specify the constructor
09:03Chouserraphinou_: yes, if absolutely need your own constructor and a clojure "factory" function won't suffice, then you need gen-class.
09:04raphinou_Chouser: might be a stupid question: is there an example of a clojure factory function somewhere? I don't understand what you mean
09:04Chousernot a stupid question -- the way clojure does these things can be a bit tricky to get your head around at first.
09:05raphinou_btw, I'm trying to translate this java code in clojure: http://www.webtoolkit.eu/jwt#/src/hello
09:06raphinou_I did the HelloMain with proxy
09:06Chouser(defn make-thing [ctor-arg] (proxy [Object] [] (toString [] (str "my arg was: " ctor-arg))))
09:06raphinou_thanks! I'll take the time to study it :-)
09:06Chouserthere's a short example. its a fn that takes an arg, which is then used inside a proxy method
09:07Chouserso then you can say (def x (make-thing "foo")) and when you call (.toString foo) later, it can still access ctor-arg
09:08raphinou_ok, I see
09:08raphinou_but here I think I really need the constructor
09:09AWizzArdhttp://www.google.com/insights/search/#q=clojure&amp;cmpt=q
09:14Chouserraphinou_: why? All the code in HelloApplication's constructor could be in a make-hello-app fn that HelloMain would call.
09:15Chouserif you want to use gen-class, that's fine, it just tends to demand a more complicated environment (AOT compilation, specific directories set up with specific classpath requirements, etc.)
09:15AWizzArdI want to slurp a file with a specific encoding, other than the default one (which is UTF-8 I think). What is the best way to do that? slurp inside some binding?
09:16Chouser,(doc slurp)
09:16clojurebot"([f] [f enc]); Reads the file named by f using the encoding enc into a string and returns it."
09:16raphinou_Chouser: I'll try with proxy, I'm not pushing for gen-class (though I have everything set up now :-)
09:16AWizzArdoh good, is that new?
09:17ChouserAWizzArd: new-ish. June 19 http://www.assembla.com/spaces/clojure/tickets/125
09:18AWizzArdthanks Chouser, this is useful
09:21ChouserI always forget how to have clojurebot look up a ticket
09:29raphinou_Chouser: here's what I thought to do:
09:29raphinou_(defn make-hello-app [] (proxy [WApplication] [env] (setup-application [] (setTitle self "HelloWorld"))))
09:30raphinou_but it complains it doesn't know env, though from an example online this seems fine
09:30Chouserenv would have to be a value you're passing in to WApplication's constructor
09:31raphinou_ok
09:33raphinou_so I should defn make-hello-app where env is available, which is in the createApplication from HelloMain... /me is trying
09:34Chouseryou can pass the env into make-hello-app
09:34Chouser(defn make-hello-app [env] (proxy [WApplication] [env] ...))
09:37raphinou_I seem to have valid code chouser. Now I'll see if it runs as hoped!
09:38Chouser:-)
09:44rottcoddis make-thing a more idiomatic name than new-thing or create-thing ?
09:53Chousermost of the built-in fns that create a foo are just named foo. symbol, keyword, atom, agent, etc.
09:55raphinou_chouser: the code runs fine, serves a page, but the elements I added to the page in the make-hello-app don't appear in page served
09:55raphinou_I put the code at http://pastebin.org/10239
09:56raphinou_if you have the time to look...
09:56raphinou_I might have missed something obvious
09:56Chouserdefn's don't belong nested like that. Let me see how it should be re-arranged...
09:57raphinou_Chouser: yes, I put it there to have access to env
10:00Chouserok, you can't create new methods with proxy, only override ones defined in a class you're extending or an interface you're implementing
10:01raphinou_hmm, does that mean gen-class should be used. I like the proxy better in the end :-)
10:01ChouserI'm looking; just a sec.
10:01ChouserI don't know anything about WApplications...
10:02raphinou_I don't know much more actually :-D
10:02ChouserI don't think you need to proxy WApplication at all, at least not yet.
10:03Chouserhm, unless getRoot is private or protected.
10:04raphinou_getRoot seems public
10:04raphinou_in case this helps, javadocs are here: http://www.webtoolkit.eu/jwt/latest/doc/javadoc/
10:05Chouseryes, thanks.
10:06Chouserthe pages on their site work very inconsistently for me.
10:06raphinou_do some pages not load you mean?
10:07Chouserright, they come up blank.
10:07raphinou_telle me your brower/os combination, I'll let them know
10:08lisppaste8Chouser pasted "raphinou_: try this?" at http://paste.lisp.org/display/85659
10:09Chouserthis is often what you have to do when translating Java examples. They put all their code in classes, constructors, etc. when such are rarely needed in Clojure.
10:09Chouserhm, I'm missing a close paren in there.
10:10raphinou_yes, there was a paren misplaced ;)
10:13raphinou_I still get a blank page. I'll look further to get it working. Thanks a lot Chouser!
10:14Chouserhmph.
10:14Chouserok
10:14raphinou_I learnt a lot today, thanks for your time!
10:14Chouseryou're welcome. hope you figure it out.
10:15raphinou_I'll post it in the google group if I get it working
10:22raphinou_btw, what's your brower/os combination?
10:23ChouserI was getting similar behavior in firefox 3.0.13 and nightly chromium-browser for ubuntu.
10:24Chouserno page failed consistently -- browsing around or reloading would sometimes cause a working page to fail or vice-versa
10:48jweissi have a macro that takes 2 args, when i call the macro, it doesn't seem to evaluate the args I pass it. it just passes the forms straight into the macro
10:49jweissor maybe this only happens using macroexpand-1
10:51stuartsierramacros never evaluate their arguments
10:57jweissstuartsierra: you mean if i have a macro blah and i do (blah (str "abc" "123")) the macro receives the form (str ...) rather than "abc123"?
10:57liwpjweiss: that's right
10:58AWizzArd(.foo #^ClassA (.bar #^ClassB *some-object*)) ==> gives me a reflection warning.
10:58AWizzArd(let [x #^ClassA (.bar #^ClassB *some-object*)] (.foo x) ==> gives me a reflection warning.
10:58AWizzArd(let [#^ClassA x (.bar #^ClassB *some-object*)] (.foo x) ==> works, no reflection warning. Why does only this last version work?
10:58jweissliwp: stuartsierra: wow, i did not know that
10:58jweisshow do i get around this?
11:01jweissi want to pass in a deref'd atom like @myatom, but the macro receives a IPersistentList, oddly which is what you get when you do
11:01cemerickjweiss: that's a pretty definitional characteristic of macros
11:02jweisshm, maybe the fn that calls my macro also needs to be a macro
11:03liwpcan you show the macro?
11:03lisppaste8jweiss pasted "untitled" at http://paste.lisp.org/display/85666
11:03liwpand have a look at the clojure documentation at http://clojure.org/reader
11:03jweissapologies for the tabs
11:03liwpspecifically the syntax-quote bit
11:03jweissit's the macro define-all-methods
11:04jweissand it's called by define-all-tasks immediately below it
11:05liwpshouldn't you have ~obj in the get-methods call?
11:06jweissliwp, yeah, i was just grasping at straws trying to figure out what's wrong, but the problem is that the define-all-methods macro receives '@task-obj as teh 2nd arg
11:06jweisswhich is an IPersistentList. i want just @task-obj
11:07liwpyeah you'll have to pass in a value rather than a ref
11:07liwpyou can let-bind the value before the call to the macro
11:07jweissliwp: but isn't @task-obj a value?
11:07Chousukejweiss: @ is a reader macro. there's no way to pass it to anything as is.
11:08jweissChousuke: ah ok
11:08Chousuke@foo is equivalent with (deref foo)
11:08Chouserjweiss: you can probably do all this with no macro
11:09jweissChouser: yeah, that is starting to occur to me
11:09Chouserdefine-all-methods could be a fn that iterates through the obj and uses 'intern' to create the fn vars in the given namespace
11:10jweissi'm so used to java that i assume doing defn's in a loop has to be in a macro, but that's not the case
11:10jweissi based this on lancet, and lancet uses macros to do something similar
11:12jweissChouser: the part i am unsure about is doing a defn with a number of arguments not determined until runtime
11:13Chouserdefn is a macro, so you can't pass in a variable name.
11:13ChouserI'd try using intern instead.
11:13Chouser(doc intern)
11:13clojurebotDENIED
11:13Chouser,(doc intern)
11:13clojurebotDENIED
11:14Chousersheesh
11:14stuartsierraYes, you can do (intern *ns* symbol-name (fn ...))
11:15jweissyeah, but can i pass intern a fn that has 3 args one time thru the loop, and 2 the next, 4 the next, etc
11:15jweissi don't know how to take a number and create a fn with that number of args
11:16Chouser(fn [& x] ...) takes any number of args.
11:17Chouseroh.
11:17Chouseryou want to turn around and call a method with those same args
11:17jweissyeah
11:18stuartsierrajweiss: I think you need to name your arguments.
11:18Chouserwell, since you won't know the actual types of the args at compile time, Clojure's going to have to use runtime reflection anyway, so you could use reflection manually in your fn.
11:19Chouserare you sure you want to do this?
11:19jweissChouser: pretty sure, i want to be able to call methods on a my java object using clojure fns, not the java interop syntax
11:20Chouserjweiss: but why?
11:20jweissthis isn't for me, it's for people who don't have a clue about clojure
11:20Chouserhm.
11:20Chouserhttp://paste.lisp.org/display/67182
11:20Chouseryou can use jfn to create the fns you need
11:21jweissChouser: cool, i'll try that, thanks
11:21Chouserby bouncing every method call through a fn you're going to lose a lot of runtime performance -- no primitive args, no primitive return values, reflection on every call.
11:22jweissChouser: performance is not an issue here. it's an interactive console, so 1/100th of a second to do reflection is no biggie
11:23stuartsierra"Most Clojure programmers go through an arc.  First they think 'eww, Java' and try to hide all the Java.  Then they think 'ooh, Java' and realize that Clojure is a powerful way to write Java code." -quoting rhickey at http://stuartsierra.com/2008/08/08/clojure-for-the-semantic-web
11:23jweissstuartsierra: like i said, this isn't for me :)
11:23jweissi am fine with using java :)
11:23jweissbut lisp syntax is scary enough for my audience without adding java interop syntax to it
11:24jweissthis would be the rest of the people on my qa team who i'm hoping will use this tool
11:25jweissno primitive args *could* be a problem, but if unboxing won't work, i can just change those method sigs to take Integer, Boolean etc. the java calling code will do autoboxing
11:27stuartsierrajweiss: Clojure can call methods with primitive args, they're automatically un-boxed.
11:30ChousukeMakoryu: :P
11:33ChousukeIf you really want comments, I think it's mostly drivel
11:33carksounds like the guy didn't give a try to clojure
11:34cark(beyond hello world)
11:34cemerickMakoryu: link?
11:34ChousukeIt's fine to talk about purity and all, but a pure system that does not exist is not very useful for real-world problems. :/
11:34carkhttp://jng.imagine27.com/articles/2009-08-19-011225_clojure_the_false_lisp.html
11:35cemerickheh, even the URL is funny
11:36cark"Clojure epitomizes everything that's mediocre about modern computing"
11:36carkright
11:36ChousukeAnd I hate the starting disclaimer. If there is a word that describes it better than "hubris", educate me, please. :P
11:37cark"Look at the sequences that wrap some of Java's collection types."
11:37carki guess he didn't try it at all actually
11:37stuartsierra"For years I've had problems with Clojure being called a Lisp," seems a bit extreme in that Clojure has existed for barely two years.
11:38MakoryuLet's see. His disclaimer is full of enterprise-quality hubris, and he was too impatient to actually learn Clojure, and too lazy to actually make any supporting arguments.... He should learn Perl!
11:38ChousukeThe "you're sheep because you're not thinking BIG THOUGHTS like I am!" kind of attitude just offends me.
11:38carkstuart : some are doing 100years languages, other are doing 100years blog posts
11:38stuartsierraheh
11:39Chousukecark: he tells you to look at the classes wrapping sequences, but... what about it? :/
11:39Chousukeit's as if looking at them is going to prove his point.
11:39ChouserI think that's meant to demonstrate the clash between java idioms and clojure idioms.
11:40rhickeySuccess is the best revenge - just write great things with Clojure and don't worry about it :)
11:40Chouserbut I'm only guessing at that, because to me it demonstrates the beauty of the clojure idiom, that a lot of existing stuff can be packed into the same kind of box.
11:41stuartsierraI've tried to emphasize in my presentations that there are really only three viable platforms around right now: C/Unix, JVM, and .NET, and you've got to choose one if you want to get anything done.
11:41ChousukeI wonder where he got the idea that clojure is a pure functional programming language :/
11:41ChousukeQuote from him on reddit comments: "It's Clojure thats pushing pure functional programming. I for one am glad that Lisp does not do that."
11:42Chouserwell, I tried to write something great, but ran out of time. So I wrote this instead: http://www.sunlightlabs.com/contests/appsforamerica2/apps/jobless/
11:44carkchouser : hum it crashed here =)
11:44cark Unparseable date: "1976 Jan"
11:44Chouseryikes
11:44Chouserlovely
11:44carki may have some french settings here
11:45stuartsierraChouser: cool, clever
11:45Chouserhuh. I thought Java was write once, run anywhere... :-)
11:46carkanywhere in USA =)
11:46stuartsierraOh, no, we meant "anywhere in the lower 48 states, not including the District of Columbia."
11:47carkwant a full stacvk trace ?
11:47Chouser"SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner" sure enough, documented right there.
11:47Chousercark: nope, thanks. Bad assumption on my part.
11:48carkallright, you better fix that because i want to see it !
11:48ChouserI don't know what they do if you change the app after the submission date.
11:48carkoh ok, bah no big deal
11:50Chouseroh, I bet it still breaks on Macs
11:50ChouserI keep forgetting that.
11:50Fossihmm. won't work for me on gentoo
11:51Fossiprolly i haven't set the java plugin right though
11:51Chouserapplets are apparently fragile. you can try downloading the jar and running it locally
11:51Chousermight work around some of the issues.
11:52ChouserI need to get a good place to host clojure web apps so I can stop messing with applets.
11:52Fossi"Unparseable date: "1976 Mar"" for me as well
11:53cark1976 was a bad year for parsing
11:53Chouserheh
11:53ChouserFossi: you also have non-english locale?
11:53Fosside_DE
11:54Fossisetting it to something else helped
11:55ole3hi, is there a standard way to read a string of length n from a stream?
11:56Fossinice though
11:56Fossiole3: i'd guess reader and take n
11:57stuartsierraNo, reader won't work. You'd have to use the Java IO classes like InputStreamReader.
11:57stuartsierraI mean clojure.core/read won't work.
12:01Fossioh i would've thought that there is a lazy seq wrapper for streams around already
12:03stuartsierraonly if you're reading a line at a time
12:03Chouserthere is line-seq
12:04ole3thanks, i have written a loop.
12:13cemerickI figured he'd prefer some offal. :-P
12:13cemerickugh, maven
12:14Chouseryay more ticket approvals.
12:16Chouserclojure already came alive once this week... came right into the channel and started talking
12:16cemerickrhickey: the mixed metaphor is funnier, though
12:17rhickeytrue
12:21stuartsierraQuoth the maven, "Nevermore."
12:21cemerickheh
12:21cemerickQuite the macabre channel today.
12:22cemerickMore Poe references re: maven though, please. :-)
12:22Chouserquoththemaven.com
12:23Chouseralso http://www.amazon.com/Quoth-Maven-William-Safire/dp/0679423249
12:23Chouserjust in case your google isn't working.
12:23stuartsierrahttp://www.shades-of-night.com/aviary/maven.html
12:27Fossiaaaand: i did it again. C-M-Backspace ftw \o/
12:31stuartsierraFossi: you can disable that in X
12:32stuartsierrahttp://www.assembla.com/spaces/clojure-contrib/tickets/18-java-utils-as-str-could-be-variadic
12:33ole3how do i make a forward declaration?
12:34Fossistuartsierra: and i should
12:34stuartsierra(declare foo bar)
12:34Fossiobviously
12:36Fossiole3: it *is* an emacs command
12:36Fossiat least more or less
12:36Fossiyou can ESC-C-Backspace
12:37ole3Fossi: thanks
12:41ChouserInteresting. whitespace-sensetive clojure: http://github.com/onyin/pleajure/tree/master
12:43Chousersensitive
12:44Fossigiven the number of sexp, i guess that could be highly confusing
12:44Fossithen again you can prolly still use parenthesesis (sp?) for some things
12:44cemerickcute, but painful
12:45Fossii'd love to see some source
12:48Fossistuartsierra: great. i have been waiting for it :)
12:48Fossiand the other bad key combo :\
12:49stuartsierraFossi: thx
12:49technomancywhat's awesome about str-utils2?
12:49technomancyother than being twice as good as str-utils, obviously...
12:50stuartsierraSpeed. It's much faster than doing the equivalent with sequences over strings.
12:50technomancycool
12:50stuartsierraThat, and a much more complete, organized API.
12:50technomancydid a decision ever get reached about callable regexes?
12:51stuartsierraI believe the decision was "not yet."
12:52stuartsierraI thought about (defn fnre [re] (fn [s] (re-find re s))) but didn't include it.
12:52technomancyright, unless it's integrated with the reader the benefits are slim.
12:52stuartsierraExactly.
12:58raphinou_Chouser: it's working now. problem was with the jwt jar I was using.
12:58raphinou_I need to go now. Bye!
13:27ChouserWell, now, this puts classpath issues in perspective: http://fuhm.net/super-harmful
13:35m3llingI've got this StackOverflow Clojure question with a bounty of 250 points that expires in 24h. Trying to gather great small Clojure programs in one place.
13:35m3llinghttp://stackoverflow.com/questions/1261557/whats-the-most-useful-thing-youve-done-in-less-than-50-lines-of-clojure
13:36cemerickoh yeah, super in python is gnarly
13:37samlhey, is it reasonable to use clojure to write a script that does POST/PUT/DELETE... to a server?
13:37samlor should i do it in java?
13:37mrsolosure
13:37technomancysaml: you can use http://github.com/technomancy/clojure-http-client
13:37stuartsierraor clojure.contrib.http.agent :)
13:38samlthanks. i dont know clojure at all. i just thought it'd be faster for me to learn clojure + write the script than to do it in java
13:38technomancyhttp dance off!
13:38stuartsierraOh no, not another one! :)
13:38mrsolosaml: hmm if you know java already, it is faster in java for you..
13:39samlmrsolo, ok. i know basic java syntax. i never used http api in java
13:39stuartsierraI expect you will find both Clojure HTTP libraries simpler than their Java counterparts.
13:40mrsoloright since your java fu isn't there either
13:40clojurebot
13:40mrsoloclojure is faster
13:40samldon't know why they let me use java.. if i ship them clojure files i might get fired. yay
13:41mrsolowhy?
13:41mrsoloit is .jar
13:41samloh coolz!
13:42mrsoloi mean the clojure itself the script is clojure
13:42mrsolocan be bundled into jar etc
13:43samli'll investigate more.. i probably just need to fix ant build file.. then no one would notice that i did it in clojure
13:44samli can run repl.. do I start with The Reader document? and go through one by one under References ?
13:44Chouserthat's certainly one way.
13:44mrsolosaml: i assume you have plenty of time to get this done?
13:44mrsolojava is better..documented :-)
13:44samlno. today!
13:44samlokiez
13:45mrsoloyou can probablly copy n paste some http java code off the web and get it rolling
13:46samlalrighty. i guess i'll investigate cljore at home
13:49LauJensenGuys - You can render an imageicon in a JLabel, but how do I align the image to the bottom left of the label? (hint: .setVerticalAlignment and .setHorizontalAlignment doesnt do it)
14:11mrsoloso am i reading this right? http://groups.google.com/group/clojure/browse_thread/thread/1036286a3f17bd56?hl=en writing clojure in pure functional style takes huge performance penality?
14:13stuartsierraWell, yes, compared to imperative and non-thread-safe code.
14:13stuartsierraThis will probably improve over time.
14:14Chousercurrently clojure fns always have boxed args and return values, and clojure collections only store boxed things
14:14technomancyseems a bit odd that str on a lazy seq returns stuff like "clojure.lang.LazySeq@c1b2fa90"... I understand the desire to avoid realizing it, but it's still a bit funky.
14:14stuartsierraYes, and Clojure collections are actually trees, which obviously have much slower access than simple arrays.
14:15Chouserif you're doing intensive work on things that could be primitives (longs, doubles) then those boxing rules will hurt you
14:15technomancyis there any function like str that works on lazy seqs too?
14:15mrsolowell i don't like to program the 'other way' my main point of learning clojure
14:15mrsolobut i hate doing 'perofrmance' excercise more
14:15Chousertechnomancy: do you want pr-str ?
14:15Chouser,(pr-str (concat [1 2 3] [4 5 6]))
14:15clojurebot"(1 2 3 4 5 6)"
14:15technomancyChouser: that's exactly it; thanks
14:15technomancyI suppose that's what the repl uses?
14:15stuartsierramrsolo: http://clojure.org/transients will probably help
14:16Chousertechnomancy: yes, the repl uses pr stuff. these all use the print-method multimethod internally, so you can even extend it if you want to.
14:16technomancyexcellent
14:18mrsolostaurtsierra: impressive..does transient still do boxing and unboxing?
14:18stuartsierrayes
14:19ChouserI believe rhickey has a plan for supporting limited primitive args, returns, and collections.
14:19stuartsierraloops can use unboxed primitives already
14:23johnmn3hello all
14:25johnmn3I've been wanting to work on clojure documentation recently. Specifically, I've always thought a more graphical explanation of functions would help me.
14:26johnmn3I think more geometrically than algebraically. So, I whipped up a graphic of reduce and I wanted to show it here to get some feedback
14:26sivajag_Hi All
14:26johnmn3http://imgur.com/UmQoT.png
14:27sivajag_I am new to Clojure ... infact just finished my helloworld program
14:27johnmn3hello sivajag_
14:27Chouserjohnmn3: looks about right
14:27sivajag_My name is Siva and hoping to know you guys more and be helpful to this Community
14:28Chouserjohnmn3: might want to do something to make it clear the green box is a collection, not a series of arguments.
14:29johnmn3I'm mostly looking for feedback on the graphic, not so much the text. Are there standards for the shapes or colors of functions, variables, literals, etc.
14:29johnmn3Chouser: true.. noted.
14:30johnmn3ok, that'll be fixed.
14:30johnmn3I was thinking about doing a few of these, especially for the ones that are confusing.
14:31Chousergood luck with 'for' :-)
14:31Chouserbut I would bet similar graphics for 'comp' and 'partial' might help a lot of people.
14:32Chousersivajag_: welcome.
14:32johnmn3thanks. writing that down.. any more that you, or anyone else, can think of? Anyone having trouble wrapping their heads around certain functions?
14:34mrsolonot really..but i think current api page is a dump
14:35sivajag_hey thanks Chouser
14:35sivajag_I am Java and Ruby programmer
14:35sivajag_I never done any functional programming
14:36sivajag_do u think I have to learn LISP before learning Clojur?
14:36mrsolo*cough* ruby is *somewhat* functional..*cough*
14:36Chousersivajag_: nope. Common lisp won't help you much on the immutable side of functional
14:36sivajag_mrsolo: the problem is it is somewhat
14:36mrsolothe concept won't be that foreign to you
14:36johnmn3sivajag_: I don't think you have to learn another lisp first.
14:36Chousersivajag_: the high-level functions you've probably tasted in ruby already.
14:36stuartsierraRuby actually borrows a lot from Lisp. It uses lambdas all over the place, calling them blocks.
14:37mudphone1.9 is getting more lispy
14:38mudphone(Ruby 1.9)
14:38sivajag_ok cool
14:39johnmn3about the graphics in http://imgur.com/UmQoT.png does anyone think the parenthesis should be scrapped since the pink boxes are representing evaluation anyway?
14:39rathorewithout first-order functions, ruby can't get anywhere close to being lispy or functional
14:40johnmn3and the double left pointing arrows... which mean "result".. necessary? helpful?
14:41stuartsierraRuby has first order functions with Proc.new {}.
14:41cable_i would leave the parens and turn the double pointed arrows into equals signs
14:41rathoreblocks are first order, but the syntax is ridiculous
14:42cable_i'd also put parens somewhere at the top for consistency
14:42Chouser[1,2,3].map{|i| i+1} vs. (map #(+ i 1) [1 2 3]
14:42Chouser)
14:43rathorechouser: thats not bad!
14:43mrsolosame difference
14:43johnmn3cable_: so do you think the ping boxes are unnecessary?
14:43technomancyrathore: blocks are certainly not first order in Ruby; they must be converted to Procs before they're usable as objects.
14:43rathoretechnomancy: there u go
14:44mrsoloi don't mind ruby's sytax..but man is it slow or what? psfftt
14:44MarkVolkmannJRuby performance seems pretty good ... at least for what I'm doing.
14:44johnmn3s/ping/pink
14:44Chouserruby was my favorite language before clojure. There's a lot of good in there.
14:45mudphoneChouser: how about: class Fixnum; def add_one; self + 1; end; end ;;;; [1,2,3].map(&:add_one)
14:45rathoreruby is still my favorite imperative language :p
14:45mrsoloneed to work on performance part that's all
14:46stuartsierraChouser: same here.
14:46Chousermudphone: huh. wow.
14:46mudphonesymbol to proc is kinda cool, right?
14:46rathorethe point is, u can't do the same kind of functional composition in ruby
14:47mudphoneand the open classes
14:47rathorewithout lots of ugliness
14:47cable_johnmn3: maybe, i just think its inconsistent to have the parens in those and not up top
14:48Chouserbrb
14:49johnmn3cable_: rgr
14:50johnmn3how about the dots... is that an accurate representation of & or would something else be better?
14:50cable_not sure about that
14:51cable_seems ok
14:51Chousukephew.
14:51Chousukedone recreating my emacs.d :P
14:51Chousukeaccidentally deleted it earlier.
14:51Chousuke... took only the whole day.
14:52Chousuke(well, I was going to redo most of it anyway)
14:52mrsolo..backup...backup...
14:52Chousukemrsolo: I thought I had a backup, but I accidentally deleted it too.
14:53ChousukeI was moving around the dirs and deleting unneeded ones and somewhere in the process I deleted one dir too many.
14:53mrsoloi like this aspect of osx time machine
14:53mrsolostick a usb drive and forget about it
14:54ChousukeI have time machine; I just had put emacs.d in a directory that's ignored by it.
14:54technomancybackups are weak; it belongs on github.
14:54Chousukebecause it was in git, and I was supposed to push it there eventually.
14:54Chousuketo github, that is.
14:54mrsolochousuke: wow :-)
14:54Chousukebut now I have a clojure-mode that doesn't cause lag with eldoc
14:55mrsolomy time machine isn't that picky backup everything
14:55Chousukealso automatic autoloads!
14:55ChousukeI still need to do something about the theme though.
14:55Chousukethe emacs-starter-kit theme is not good on my laptop :/
14:56Chousukeall the "highlights" are weak colours that get drowned by the white background.
14:57Chousukewhich bring me to one of the reasons I prefer gist over lisppaste: gist actually highlights the code instead of just colouring it.
14:59technomancythere's no theme activated by default in the starter kit
14:59ChousukeWell, then it's Cocoa emacs default I guess.
15:05drewrdoes foo already exist? (foo {:bar 3} {:bar 5} {:quux 3}) => {:bar 8 :quux 3}
15:05drewroh, merge-with I think
15:08Chouserjust merge
15:10drewrI need the addition
15:10Chouseroh, whoops. sorry, didn't catch that.
15:15hiredmanwhen I get around to it, I'll have clojurebot tag gist urls in delicious with "gist"
15:17Rayneshttp://jng.imagine27.com/articles/2009-08-19-011225_clojure_the_false_lisp.html Could they at least /try/ to down Clojure. :\ It seems like they aren't even enthusiastic about it.
15:19Chousukewhoops
15:20Chousukewith all my emacs tweaking I forgot I was also running an upgrade on my FreeBSD server. and of course it had stopped to ask for input ;(
15:20hiredmannice
15:21ChousukeI'm upgrading it to 8-BETA2 so I can set up NFS4
15:21ChousukeI had to use samba previously because NFS3 caused trouble with filenames.
15:21hiredmanBATCH=yes is your friend
15:31cemerickinteresting that that zombie article has 137 comments on proggit, but a score of 3
15:32Chouseri'm personally very pleased that such articles are written
15:32Chouserand posted
15:32Chousersomewhere other than our google group.
15:35mrsolohmm anybody familiar with couchdb here?
15:36cemerickoh, I think they're the best geek marketing vehicle around. Nothing like a good, public flamewar against a huge pile of obvious straw men to gin up interest.
15:37cemerickmrsolo: only a little :-)
15:37cemerickmrsolo: danlarkin is your man, though
15:37danlarkinI'm no man's man!
15:38cemerickdanlarkin: go-to guy? button? cheese?
15:39danlarkinmrsolo: AFAIK there are two clojure couchdb libs, mine (https://github.com/danlarkin/clojure-couchdb/tree) and Tunde Ashafa's clutch (http://github.com/tashafa/clutch/tree)
15:39danlarkinwhich you use will depend on your evaluation of both, I suspect
15:40cemerickdanlarkin: have you gotten a view server together yet? A colleague of mine just started in with clutch's.
15:41danlarkincemerick: I've had no free hacking time this summer :'(
15:43danlarkinIt is still on my list, but other things have been placed above it
15:45Fossihmmm. common lisp error handling. yummy
15:49ChouserFossi: ?
15:51Fossii like erlang's way too and it's much easier to simulate ;)
15:51ChouserI attempt to bring over what I could from CL's error condition system as error-kit. Not sure I'm pleased with the results, but there it is.
15:52Fossiah. haven't seen that yet
15:52Fossiwill have a look
15:54Fossii always wonder how contrib is still full of plenty of goodness to discover after 2 months of clojure
15:54clojurebotcontrib is http://github.com/richhickey/clojure-contrib/tree/master
15:55Fossiyou say something like i just did and naturally, its already done in contrib :
15:55danlarkinerror-kit is used in clojure-couchdb! woo
15:55Fossihmmm. guess we didn't properly deal with errors when we used it ;)
15:56danlarkin:-o bugs in MY code? never!
15:57Chouserwow. a bunch of deferror's. Hm...
15:58Fossidanlarkin: your code?
15:58Fossiah. your code.
15:59Fossithanks for that then
15:59Fossiwe also added some stuff on top which might get commited sooner or later if you like :)
16:00Chouservery interesting.
16:00danlarkinFossi: I would like that, yes
16:00Fossidealing with views, parameters and such
16:01Chouserdanlarkin: so it would be rather more clumsy if you didn't have deferror and instead specified everything you wanted to at kit/raise time.
16:02ChouserI'm vaguely interested in trimming some fat out of error-kit, or breaking it apart somehow.
16:02Fossijust have to clean up all the code we produced so far and see what's general purpose :)
16:07danlarkinChouser: Well deferror is nice... but, sortof procedural... it would be more "dynamic" to have a :type at runtime I suppose...
16:11Chouserright. but then your default message, fallback Exception etc. have to be repeated.
16:12ChouserI guess you can make your own fn to raise a particular kind of error if you want...
16:13mrsolodanlarkin: thanks!
16:14danlarkinChouser: true. It feels imperative to be defining "types" for errors, but maybe that's the right way to do it? I don't know. deferror has conveniences other than just what could be replicated by :type, as you point out
16:14LauJensenDoes anyone remember what the standard java FTPClient is, ie. which class do I import?
16:17carkLauJensen: how about using org.apache.commons.net.ftp/FTPClient ?
16:17LauJensencark: if I can avoid adding dependencies, I'll prefer that route
16:17cemericklooks like the Agent threadpools are stalling the exit of the test process: https://twitter.com/fogus/status/3411806496
16:17carkoh i see
16:18cemerickor, https://twitter.com/fogus/status/3411706217 (for what the waiting looks like if you don't know about Agent.shutdown() :-)
16:18carkftp is hard, lots of different kinds, i'm not sure you'll find in the standard lib
16:19LauJensencark: I did a project about a year ago, where I added some simple ftp upload/download functionality, and I'm almost certain I did it using a class called FTPClient from the standard libs. I just seemed to have lost the source
16:20cemerickLauJensen: FTP URLs will be loaded OK for the most part, but anything beyond a simple fetch in a vanilla context (e.g. firewalls) will fail
16:20LauJensencemerick: loaded?
16:20cemerickI believe so. Might be totally making it all up.
16:21cark"un Microsystems provides an RFC959 implementation in the JDK, but it is internal, undocumented, and no source is provided"
16:22carkhttp://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html
16:22LauJensencemerick: You should get into politics :)
16:22carkat least you can upload and download
16:22cemerickhey, who knows :-P
16:22cemerickI seem to remember using straight FTP URLs in the distant, hazy past.
16:22carkso cemerick might be right, unless he's wrong, which is unlikely
16:23LauJensencemerick: But what do you pass that url to ?
16:23LauJensenFileWriter?
16:23carkyou have an example on the page i linked to you !
16:23carkbottom of first page
16:24cemerickurl.openConnection() or something like that
16:24LauJensencark, that doesnt tell me what to import, theyre not using qualified names
16:24LauJensenah ok, the io streams, gotcha
16:28cemerickheh, see, I never forget anything :-P
16:28cemerick(-> (URL. "http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/1.9.1.2/KEY&quot;) .getContent)
16:28cemerick#<PlainTextInputStream sun.net.www.content.text.PlainTextInputStream@e2f97ff>
16:28cemerickgah, that was supposed to be my ftp url
16:29cemerickuser=> (-> (URL. "ftp://ftp-test.mozilla.org/index.html") .getContent)
16:29cemerick#<MeteredStream sun.net.www.MeteredStream@424c4ff8>
16:29LauJensenAwesome
16:30LauJensenAlmost as seamlessly integrated as in .NET
16:30cemerickBut seriously, that client *will* break
16:30LauJensenYarly ?
16:30cemerickwell, as much as any other client will break
16:30carkwhat's this meteredstream ... looks like i reinvented the wheel again
16:30cemerickFTP is pretty rough with modern firewalls, NAT, etc
16:31LauJensencemerick: This is not a complicated case. My wife dislikes tinypic, so she wants an app where she can right click on an image, scale it quickly and then upload it to my ftp site, returning to her an url she can use to show the picture to her friends. I think it'll hold up for that challenge :)
16:32cemerickyou hope. Get her on a wifi network configured just right, and she won't be happy *shrug*
16:32LauJensenhehe - So you have the gift of pessimism I take it ?
16:32cemerickI guess I'm just virulently anti-FTP
16:32stuartsierraLauJensen: sounds like a case for a web service. POST the image, get URL back.
16:33stuartsierraProbably about 5 lines of PHP.
16:33cemerickstuartsierra: oooh, I'm calling the REST police on you. Shouldn't it be a PUT? :-P
16:33stuartsierraEither way.
16:33LauJensenstuartsierra: Nope, Swing app. When you start it with an image as a paramter, its render with X and Y axis shown in Sliders. You can drag those to quickly scale the image. Then upload when happy
16:33LauJensenI just need to implement cropping
16:34cemerickwell, it was fun to make the comment, anyway
16:34stuartsierraRight, but you could upload via HTTP.
16:34stuartsierracemerick: :P
16:35LauJensenstuartsierra: I think its simpler to just code the client and use an existing ftp server
16:35stuartsierraok
16:49LauJensenstuartsierra: But in the event that it wasnt, how do you post a file from java ?
16:49stuartsierraYou can use clojure.contrib.http.agent or clojure-http-client.
16:51LauJensenOr loot them anyway :)
16:53stuartsierra(http-agent "http://example.com/&quot; :method "POST" :body (File. "image.jpg"))
16:54LauJensenThats easy. But also async. Is there a progress callback or similar ?
16:54hiredmanthat is pretty nice
16:54stuartsierraCall (result (http-agent ...)) and it will block until finished.
16:54stuartsierraOr poll with (done? the-agent)
16:55LauJensenk
16:55LauJensenThanks
16:55stuartsierranp
16:56LauJensenstuartsierra: You also mentioned 'clojure-http-client', where can I look that up ?
16:57stuartsierrahttp://github.com/technomancy/clojure-http-client
16:57stuartsierraI think it uses Apache HTTP Client.
16:58LauJensenDoesnt look like it
16:59stuartsierraYou're right, it doesn't.
16:59LauJensenNow you woke him up :)
16:59stuartsierraoops :)
17:00LauJensenThe contrib version might be the way to go. It'd be great to implement some type of progress indicator though. When the client is the Mrs.' I'm not sure I can get away with "working"..."done" :)
17:02technomancydid I miss something?
17:02stuartsierraLauJensen: good point, hadn't thought of that.
17:03LauJensentechnomancy: Dont think so
17:03LauJensenJust having a look at your http-client
17:04stuartsierraTrouble is, in your case the slow part would be uploading, and that's all under the control of HttpURLConnection.
17:05stuartsierrawell, not entirely
17:06stuartsierraI suppose http.connection/send-request-entity could re-implement copy, and update an atom with the number of bytes copied.
17:07stuartsierralikewise with the default response handler
17:07LauJensenSounds good
17:07LauJensenSometimes you cant avoid having to go to a lower level though
17:08stuartsierraI'll certainly think about it. It's a worthwhile feature to add, and fits with the asynchronous design I was aiming for.
17:09LauJensenAlright
17:12Neronusgood lord, Dan Weinreb is really really excited about clojure...
17:12stuartsierraLauJensen: http://www.assembla.com/spaces/clojure-contrib/tickets/20-Report-progress-in-http-agent
17:12LauJensenI'm a little lost regarding the use of :use, :import, :require etc. When I want to refer stuartsierra's http-client, which options do I choose, and why ?
17:13Chouser:import is only for Java classes, not clojure libs.
17:13LauJensenk, thats an easy one to remember
17:14hiredmanand :require is better than :use
17:14hiredman:P
17:14Chouser:require provides only a subset of :use's features, so these days I recommend always using :use
17:14stuartsierra"use" copies symbols into the current namespace. "require" doesn't.
17:14hiredmanrequire keeps symbols prefixed
17:14Chouser(:use [clojure.contrib.http-client :as hc :only []])
17:14LauJensenhiredman: haha
17:14LauJensenOk, thanks guys
17:14technomancystuartsierra: I ended up defining "get" in the "resourcefully" ns in my http client, forcing people to require it instead of using it, just like your str-utils2.
17:14technomancyjury is still out on whether that's a win or not...
17:15LauJensenChouser: :only [] ??
17:15lowlycoderdoes clojure run on java 7 yet?
17:15stuartsierraI think it's inevitable that many libraries will want to define things that clash with core.
17:15ChouserLauJensen: yes, that part makes :use act like :require
17:15stuartsierraThe alternative is to put "my-lib-" prefixes on everything, and that's a pain.
17:15technomancyI guess it's good if it encourages people to not be sloppy about just dumping whole libs into their namespaces.
17:15LauJensenChouser: And if I dont use :as, all funcs will be interned into my own ns ?
17:15hiredmanlowlycoder: sure
17:16ChouserLauJensen: if you don't say :only [], all funcs will be refered into your own ns, yes.
17:16Chouserwe need :uses to replace :use and :require.
17:17ChouserOne big question I still have about :uses is how to provide a default alias without it being a name that magically shows up without beding declared.
17:17technomancydidn't realize you could :use with :as
17:18Chousertechnomancy: I like it because then if I want to refer in a name I can just add it to the :only [] list, instead of having to move the whole lib from a :require to a :use block.
17:19technomancyyeah, if :as is supported in :use I don't see why :require is necessary.
17:19technomancyfor common usage anyway
17:19Chouserright. but the default behavior of :use (refering in everything) is undesirable.
17:21LauJensenI think its sweet
17:22Chousukerah.
17:22Chousukewhy can't I change the background of the hl-line face :(
17:23stuartsierraI do
17:23stuartsierraChousuke: you can
17:25Chousukestuartsierra: no I can't. I'm trying to do it here via customise and it's just not taking effect.
17:25LauJensenstuartsierra: result and done?, where are they from?
17:25stuartsierraLauJensen: part of c.c.http.agent
17:25LauJensenMaybe I'm on an old version
17:25LauJensenIts spawns the agent, produces no result, and I dont have result/done?
17:26Chousukestuartsierra: I tell it to make background black and it stays the default olive green.
17:26technomancyChousuke: works for me: (set-face-background 'hl-line "black")
17:27stuartsierrasame, works for me, sorry
17:27Chousukecuriously enough, edits to other attributes do take effect.
17:27LauJensen"Agent has errors" hmm..
17:27Chousukemaybe it's customize being weird...
17:27Chouseroh! emacs?
17:29stuartsierraLauJensen: can you show me what you're trying?
17:29Chousukehm
17:29LauJensenstuartsierra: (def tst (http-agent "http://localhost:8888/backdoor/&quot; :method "POST" :body (File. *pic*)))
17:29Chousukeit says: invalid face: hl-face :/
17:30technomancyChousuke: hl-line or hl-face?
17:30stuartsierraLauJensen: check (agent-errors tst)
17:30LauJensenstuartsierra: (#<IllegalStateException java.lang.IllegalStateException: Already connected>)
17:30technomancyChousuke: if you do your IRC from Emacs you can eval it in-place. =)
17:30stuartsierrahmm, let's see
17:30LauJensenThats unexpected, since my webserver should tell me when a POST is attempted
17:30LauJensenLet me clean up and try again
17:31Chousuketechnomancy: complains about both :P
17:32LauJensenstuartsierra: Rebooted everything, server, client, slime, the works. Still goes to the same exception straight after being launched
17:32clojurebotslime is icky
17:32LauJensenCan somebody please ban clojurebot for that last remark ?
17:32clojurebotfor is not a loop
17:33stuartsierraLauJunsen: ok, can you paste (.printStackTrace (first (agent-errors tst)))
17:33LauJensenstuartsierra: Sure: "nil"
17:34stuartsierraAre you using SLIME? The result will be in the *inferior-lisp* buffer.
17:34LauJensen~paste
17:34clojurebotlisppaste8, url
17:34lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:34LauJensen(sorry)
17:35lisppaste8Lau pasted "Stacktrace http-agent" at http://paste.lisp.org/display/85688
17:36stuartsierraaha!
17:36stuartsierraLauJensen: I think you've got an old version.
17:36LauJensenWhat do you see?
17:36LauJensengit pull + ant will give me the lastest right?
17:37stuartsierraIf you're using the master branch, yes
17:37LauJensenI am
17:37LauJensensec
17:37LauJensenupdating
17:37stuartsierraHttpURLConnection.setFixedLengthStreamingMode is called in the wrong place, that's a bug that I fixed a couple of days ago.
17:38LauJensenstuartsierra: Updating actually worked, but fired an error on the server - That might be my wrongdoing though. java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
17:39stuartsierraLooks like a bad character in your URL.
17:39LauJensenhttp://localhost:8888/backdoor/ - Dont see what could be wrong with that
17:39samldo you have a hello world example? like writing (println "Hello World") to a file and run/compile the file?
17:40stuartsierraYou're saying the *server* threw an exception in response to the POST?
17:40LauJensenYes sir
17:41stuartsierraAh, I see. The server may be trying to parse the POST body as application/x-www-form-urlencoded, which it isn't, because you're posting the file directly.
17:42stuartsierraI haven't (yet) implemented multipart/form-data.
17:42LauJensenSounds likely...Hmm
17:42stuartsierraYou may need to set a "Content-Type" header on the POST, or modify your server code.
17:43LauJensenstuartsierra: Its simple to hardcode the content-type on my server, do you suppose this will work if its ust set to multipart/form-data ?
17:44LauJensenstuartsierra: No it dies the same way
17:44stuartsierraI don't think so. It's the content-type of the *request* that matters here, not the response.
17:45LauJensenk
17:45LauJensenstuartsierra: Cant I mangle the :body manually some how ?
17:45stuartsierraSure, if you want to implement multipart/form-data :)
17:46LauJensenHow about I implement a ticket on assembla and then you do it, and feel really productive? :)
17:46stuartsierraheh, ok
17:46stuartsierraI'm not promising it for this week, but it is a feature I plan to add
17:46LauJensenAlright, cool. Although that leaves me a little stuck. technomancy can your http-client handle this?
17:47technomancyLauJensen: only one way to find out.
17:47technomancyoh, form-data you mean?
17:47LauJensenAnd thats having you test it while I kick back and rela?
17:47LauJensenx
17:47LauJensenYea
17:47technomancyyeah, it's supported.
17:47stuartsierraWhat's your server doing? It should provide a way to access the raw POST body without parsing it.
17:48technomancyI haven't used it in a while though... since around the release of 1.0
17:48LauJensenstuartsierra: I would think so, Im just not sure why its throwing the exception at the level its doing, ie. not even understanding the url
17:48stuartsierraIt's not the URL. It's trying to URL-decode the POST body. I'm pretty sure.
17:49stuartsierraHTML forms sent via POST are URL-encoded.
17:49stuartsierratechnomancy: it doesn't generate multipart/form-data requests, does it?
17:50LauJensenstuartsierra: this is being done before my handler ever evaluates, so I dont know where to work around it
17:50technomancystuartsierra: no, I was thinking of application/x-www-form-urlencoded
17:50technomancymy bad
17:50technomancydanlarkin could have added it when I wasn't paying attention though.
17:50LauJensenI think I'll post it on Compojures google group, James Reeves usually has a 1-2-liner solution for this type of dilemma :)
17:51stuartsierraJust glanced at it, didn't see anything. Multipart is complicated, have to do base64 and everything.
17:53stuartsierraugh
17:54technomancyjavamail has a lot of good mime functionality, but adding a dep sucks.
17:57LauJensenstuartsierra: Get some coffee, msg me when youre done :)
17:57stuartsierraLauJensen: *You* get me a coffee. :)
17:57LauJensenHaha :)
17:58LauJensenI would love to sir, but I have to get to bed now - Good night all, and thanks for the help
18:04hiredmanI have uuencode/decode functions I started on, but it's finished or documented :(
18:05hiredmaner
18:05hiredmanit isn't
18:05stuartsierraThis is not trivial.
18:06hiredmanthat would explain why I never finished it
18:06hiredmanand gist.github is not resolving :(
18:20stuartsierrahttp://paste.lisp.org/display/85694 Close but not correct.
18:26stuartsierraDuh, use OR, not AND: http://paste.lisp.org/display/85694#1
18:29hiredmanso for length less then 3 you just pad to 3 and recur?
18:29stuartsierranot quite, working on that now
18:31stuartsierrahttp://paste.lisp.org/display/85694#2
18:36stuartsierraHah! http://paste.lisp.org/display/85694#3
18:37stuartsierra(encode-str "hello") ;;=> "aGVsbG8="
18:38stuartsierradoubtless not very efficient, but it does work
18:39carkcool addition to contrib =)
18:59stuartsierradoesn't do decoding yet, but I need to go home
19:39Chouserrhickey: I added a chunked doseq to http://www.assembla.com/spaces/clojure/tickets/1 -- is that how you want it, or do you want separate tickets or ...?
20:15rhickeyChouser: that's fine, as long as they are separate patches
21:40Chouser,(chunked-seq? (seq (map first (take-while identity (iterate next [1 2 3])))))
21:40clojurebotfalse
21:40Chouseris there a better way to un-chunk a seq (for testing)?
21:44Chousukehm
21:46Chousuke,(chunked-seq? (concat (map inc [1 2 3 4 5]) nil))
21:46clojurebotfalse
21:47ChousukeI guess the nil might be unnecessary :/
21:47Chousuke,(chunked-seq? (concat (map inc [1 2 3 4 5])))
21:47clojurebotfalse
21:48Chouserah! that'll do.
21:50Chouserconcat could become chunked though, I suppose
21:51Chouseriterate too, at that rate.
21:52Chouserrhickey: you have a list somewhere of the fns you want to support chunked seqs?
21:55rhickeyChouser: I imagine a seq1 function that will stream any seq as non-chunked
21:56rhickeyI don't have a list, 'for' would be a primary candidate, chunk handling only on fastest moving bit
21:57Chouserooh
21:57ChouserI've started looking at it, so reduced requirements are welcome.
21:58Chouserdoseq was meant as a warm-up. :-)
21:59Chouserso just the innermost seq, because that controls the resulting chunks
22:00rhickeyright, and dominates, being the inner loop
22:01ChouserI did a couple experiments translating 'for' forms into map/filter/take-while chains, hoping the chunking there would be good enough.
22:01Chouserit's not.
22:03Chousercurrent 'for' can be faster than that.
22:08Chouseroh, but take-while doesn't chunk yet -- I missed that.
22:09tomojhmm.. so the normal sequence operators will work faster with chunked seqs?
22:09tomojI thought it was a separate interface
22:10Chousertomoj: it's a separate interface at the first/rest chunk-first/chunk-rest level, but the higher level functions abstract that away
22:10Chouserif you're using map on a vector, it's already faster.
22:11tomojnice :)
22:19tomojI spent a few hours yesterday trying to figure this problem out only to realize there was a much easier way to solve my original problem without solving this problem
22:19tomojif anyone's interested, https://gist.github.com/e45aa328bb180bae8fd9
22:30rlbJust got the first audio playing with clojure acting as a controller for a squeezebox -- clojure acts as the controller, and for now, mpd serves the audio stream.
22:31rlbIt could be turned into a way to make a squeezebox track (and control) an mpd server.
22:31rlb(we'll see)
22:50deleuzeWhere would be a good place to start if I've never used clojure (but love scheme and know java) and want to write a terminal wrapper (I want to wrap rxvt or xterm or anything similar). I know this is very little to go on but terminals haven't been an easy thing for me to find info on.
22:52deleuzeI was hoping to learn clojure through this project.
22:52RaynesI would highly recommend purchasing Stuarts book, Programming Clojure.
22:55rhickeyKeynote at the JVM Language Summit!: http://openjdk.java.net/projects/mlvm/jvmlangsummit/agenda.html
22:59Chouserrhickey: great! Congrats!
22:59rhickeynow I just need something interesting to say :)
23:00rhickeylast year it was a terrific group of very experienced very smart people
23:02rlbIs DataOutputStream a reasonable way to create binary network packets from clojure, or is there something more clojure-specific?
23:06Chouserrlb: unlikely there's anything more clojure specific.
23:06rlbChouser: OK, thanks
23:08rlb(I also managed to arrange it so that you have a java Graphics that you can transfer to the squeezebox display. Though it's very rough as yet.)
23:08deleuzeRaynes: just ordered it :)
23:09deleuzeRaynes: I recently finished SICP, I'm very excited for something new.
23:09deleuzeRaynes: (just ordered it, on your suggestion I meant, thank you.)
23:11deleuzeRaynes: is writing a shell wrapper (enhancing the shell by wrapping it's output but having it remain interactive) an insane idea?
23:12deleuzeRaynes: I began by looking at the CLI class but it seemed more for handling getopt type func.
23:23lowlycoderwhich part of the clojure doc will tell me: "if all the fields of two structs are =, then they are =" ?
23:23lowlycoder(some preliminary testing shows this to be true, but I want to know if it's guranteed)
23:25hiredmanlowlycoder: clojure's = is egal, and that is a property of egal
23:26rlb(Why doesn't ByteArrayOutputStream have a rewind method...)
23:30rlbI'd like to leave a placeholder for the packet length, and fill it in at the end. I suppose I can just continue concatenating a length byte array and the command byte array.
23:31Raynesdeleuze: I'm sorry I disappeared there!
23:32Raynesdeleuze: I don't think it's an insane idea at all, and you're very welcome. It's a good book.
23:35rlbI know I can concatenate two byte arrays like this (or use native java ops): (into-array Byte/TYPE (concat ar-1 ar-2)), but is there a better clojure idiom?
23:37tomojthat into-array thing seems inefficient
23:40rlbtomoj: I would assume -- as I mentioned, I much prefer to just leave 2-bytes at the head of the packet and then fill it in after the packet's finished, but offhand, I don't see any way to do that with ByteArrayOutputStream.
23:40rlbOf course I could just fill in the length bytes myself. I may do that.
23:41rlbIt was just easy to use DataOutputStream's writeShort, writeInt, etc.
23:43rlbOf course none of this matters much, performance-wise. These are tiny packets.
23:43rlb(and not often sent)
23:45tomojwas there something like a DataOutputStream/DataInputStream that also had information about what type came next? I vaguely remember that from my java days
23:46lowlycoderhow do I create a vertex of references?
23:46lowlycoder*vector*
23:47tomoj,[(ref 0) (ref 1)]
23:47clojurebot[#<Ref@149a2c8: 0> #<Ref@15e0eab: 1>]
23:47lowlycoderi need n of them, where n is a variable
23:47lowlycodercreate the list and then 'vec' it ?
23:48hiredman,(vec (take 10 (repeatedly #(ref 1))))
23:48clojurebot[#<Ref@5789f3: 1> #<Ref@121ea24: 1> #<Ref@192e317: 1> #<Ref@7b0f4d: 1> #<Ref@12996d6: 1> #<Ref@16de641: 1> #<Ref@27de24: 1> #<Ref@1692a49: 1> #<Ref@157402b: 1> #<Ref@135f7f3: 1>]
23:48hiredman,(doc repeat)
23:48clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
23:48hiredman,(doc repeatedly)
23:48clojurebot"([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it"
23:49tomojis vec better than into?
23:49hiredmanpossibly
23:50hiredmanI thin into uses reduce and conj
23:50hiredmanvec might do something clever
23:50hiredman~def into
23:50hiredman~def vec
23:50tomojvec looks faster
23:51rlbs/aref/aget/...
23:51lowlycoderis there a more idiomatic way (not using #%) to write: (fn [f] (let [x (f :x) y (f :y) z (f : z)]
23:51lowlycoderbasically, I have a (defstruct face :x :y :z) ... and I want to deconstruct it
23:51hiredman~destructuring
23:51clojurebotdestructuring is http://clojure.org/special_forms#let
23:52hiredmaneverything you want to know
23:52hiredmanyeah
23:52lowlycoder{:keys [ ... ] } eh?
23:52hiredmanvec just pulls out an array and stuffs it into a vector
23:53hiredmanlowlycoder: destructuring also works in the argument vector
23:53lowlycoderhow so?
23:53hiredmanjust like in let
23:53lowlycoderwhoa, so fn [{:keys [x y z]] ?
23:53derridawhere does the vector data struct originate?
23:53hiredman,((fn [{:keys [a b c]}] [a b c]) {:a 1 :b 2 :c 3})
23:53clojurebot[1 2 3]
23:54hiredmanderrida: what do you mean?
23:55derridasorry, was just wondering out loud what language(s) use vector the same way
23:55lowlycoderhow do I add into a set?
23:56derridahiredman: didn't mean to interrupt ;)
23:56tomojruby has similar in-language vectors, but they're called arrays
23:56hiredman,(doc conj)
23:56clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
23:56lowlycoderwhat? I can cons into a set too?
23:56lowlycoderwhy should i use conj over cons?
23:56derridatomoj: java class Vector is not quite the same, right?
23:57r2q2clojurebot: (cons [1 2] [3 4])
23:57clojurebotIt's greek to me.
23:57tomojderrida: not even close
23:57r2q2clojurebot: eval (cons [1 2] [3 4])
23:57clojureboteval is evil
23:57tomojoh, and of course ruby's aren't even close either
23:57tomojsince they're not immutable
23:57derrida:)
23:57Chouser,(cons [1 2] [3 4])
23:57clojurebot([1 2] 3 4)
23:57tomojclojure's vectors are unique, afaik
23:57Chouser,(cons :x #{:a :b :c})
23:57clojurebot(:x :a :c :b)
23:57r2q2,(conj [1 2] [3 4])
23:57clojurebot[1 2 [3 4]]
23:57tomojbut some other languages also have in-language vectors
23:57hiredmansomeone ported them to scala
23:57r2q2Notice the difference?
23:57Chouser,(class (cons [1 2] [3 4]))
23:57clojurebotclojure.lang.Cons
23:57derridayeah, what do you mean in-language?
23:58Chouser,(class (conj [1 2] [3 4]))
23:58clojurebotclojure.lang.PersistentVector
23:58lowlycoderwhat's the inverse of get? (set is the set function, not actually setting a element)
23:58tomojderrida: vectors are part of the language itself, no one had to go write a Vector class
23:58derridatomoj: ah gotcha
23:58tomojmostly I think a literal syntax for vectors is the big thing
23:58clojurebotfor is not a loop
23:59hiredmanlowlycoder: spent anytime with the docs?
23:59derridatomoj: clojure's vector is the only vector i have encountered i felt deserved the title :)
23:59tomojyou don't have to screw around with ArrayList<FooBar> crap
23:59lowlycodernope, what's irc for?
23:59derridalowlycoder: procrastinating