#clojure logs

2008-11-07

00:01Chouseryes, .clj files in .jars will be found by require and use
00:03djkthxcool
00:03djkthxand if someone has clojure, could they run it from java?
00:09Chouseryou can actually bundle clojure and your code into a single .jar, and the user won't even have to know clojure's in there. it'll just run like a java .jar
00:09djkthxawesome
00:21pmfI've uploaded a patch to the files-section of the group that fixes the behaviour of gen-class when a field to be exposed via :exposes is not declared in the immediate superclass, but somewhere in the ancestors.
00:30Chouserpmf: it'd be best to announce that on the group
00:30Chouseralong with the file name
00:32pmfURL of the uploaded file is http://clojure.googlegroups.com/web/genclass-exposes-fix.patch
00:34pmfFor some reason, I can upload files to the group, but am unable to post there (get an error email from GOOG).
00:56H4nslisppaste8: url
00:56lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
04:32Lau_of_DKTop of the morning gents :)
04:42hoeckgood morning Lau_of_DK
07:42Lau_of_DKrhickey, pure interest question, how long did it take you to write ants, start to finish?
07:43rhickeyLau_of_DK: a couple of hours
07:43Lau_of_DKImpressive...But perhaps its an advantage have written the language your working in, thanks
07:48Lau_of_DKrhickey, now that Ive got you: Will you consider letting print/println return whats being printed instead of nil
07:49rhickeyLau_of_DK: probably not
07:49Lau_of_DKrhickey: May I ask why ?
07:49rhickeyyou can ask
07:50H4nsone good reason is (print & more)
07:50rhickeyprint et al are not functions, they do IO, they can take multiple args, there's no more reason to return the thing being printed than the stream being printed to etc
07:51H4nsrhickey: if it'd be (print object), it would be convenient to return the object, too. this makes it easy to insert printing for debug purposes, at almost arbitary places
07:52H4nsrhickey: but i like (print & more) better, as it is more helpful in the general case. one can always define a debug-printing macro that drt and only accepts one argument
07:52H4ns(not that i've been asked) :)
07:53rhickeyright, a debug print would be a macro and could do that
07:55alvin-xwas Clojure at work on election night?
07:56rhickeyalvin-x: I cannot discuss the details of that system, sorry
07:58alvin-xno problem
07:59Lau_of_DKrhickey, alright I see your point. My exact situation was actually trying to debug something, and then ended up causing more errors because of prints behavior. Is there a debug macro I could use instead?
08:17gnuvinceGood morning
08:24rhickeygnuvince: hey
08:25gnuvinceHow's everybody doing?
08:28alvin-xlooking forward to the weekend and the new Bond movie :)
08:29gnuvinceOoh, yeah!
08:34Lau_of_DKH4ns, have a good flight :)
08:34gnuvinceToo bad the beta costs money
08:35gnuvinceI like how the Bryan O'Sulllivan, Don Stewart and the other gentleman whose name I cannot recall did with "Real World Haskell": directly online with a per-paragraph comment system.
08:51aperotteIf I wanted to do some heavy numerical computations in clojure, what would be the best approach? Writing it in java, using type hints, or coercions?
08:53rhickeyaperotte: you can use the primitive support in your inner loops to get the same perf as Java, then wrap in a function of macro wrapper lib for ease of use/expressivity. You'll probably want to stick with (Java) arrays of primitives for best results
08:58aperotterhickey: just to be sure I understand. If I want to do something like a matrix vector multiplication, I'd represent the matrix and vector as java arrays of primitives (by coercion), and write a function or macro whose inner loop(s) perform the computation.
09:01rhickeyaperotte: not exactly sure what you mean by coercion, but yes, you can use arrays of primitives directly, and use amap/areduce, as shown here: http://clojure.org/java_interop
09:01rhickeysee the section: Support for Java Primitives
09:02aperotterhickey: Thanks, I think I got it. I got coercion from that page at the bottom (ie. using (int x) to use a primitive type)
09:06aperotterhickey: p.s. Thanks for clojure in general. I'm sure you've heard this before, but it's exactly what I've been looking for.
09:07rhickeyyou're welcome!
09:19Carkquestion : in the ns macro, is there a one liner to specify i want to require 'cara.dialog and filter to get only the show-message symbol imported ?
09:23rhickeyCark: yes, using the :use option with :only
09:23Carki tried =P
09:23Cark(:use (cara.language :only (lgstr add-strings)))
09:24Carkand (:use cara.language :only (lgstr add-strings))
09:24Carkbut that does not work
09:25rhickey(:use [cara.language :only (lgstr add-strings)]) ?
09:26Carkthat's it...thanks a lot
09:26Carkmaybe a better example in the doc would be usefull
09:27Carkcouldn't find any such bracket to give me a hint
09:27Carkand it's not consistent with :refer or :import
09:29rhickeyCark: yeah, (doc require) describes the libspec format, but has no example of that
10:36ChouserI can only extract the vaguest of gists from Haskell code. Syntax is tiring to learn.
10:37rhickeyChouser: I agree, the syntax is write-only, so much parsing required to read
10:38ChouserI think I understand the basics of that IO stream slideset, but I'm not terribly confident.
10:42danlarkinhah tell me about it... I'm reading a paper on parser combinators and the haskell code used in examples is not making it easier to understand
10:55djkthxis there something i need to have enabled to have [ret] go to a newline and indent with clojure-mode on emacs?
11:00gnuvincedjkthx: you need to remap it.
11:01gnuvinceMy elisp-fu is rusty, but it should be something like (global-set-key [ret] 'newline-and-indent)
11:01gnuvinceIt's been a while since I used Emacs.
11:03drewrChouser: Can you not permalink in your clojure log anymore?
11:03drewrHow do I link to a paragraph? (FF3)
11:10Chouserdrewr: you can either use #05:23b type syntax or #05:23b-14:03
11:11Chousereither way you may need to reload once you've built the url to see it work.
11:11drewrOK.
11:12drewrIt's that new Clojure-Firefox integration.
11:15djkthxthanks gnuvince
11:15djkthxit was "\r"
11:15djkthxbut it works now
11:21Chouserrhickey: do you have any thoughts on deprecating .. (in favor of ->) ?
11:30gnuvincedjkthx: happy to know I was in the ballpark :) I've not used Emacs in two years after pain in my wrists and pinky finger made it impossible to continue using it.
11:30djkthxthat sucks
11:30djkthxwhat do you use now?
11:30gnuvinceWent back to vim.
11:31djkthxgotcha
11:31gnuvinceI was a vim user who converted to Emacs and who came back.
11:31djkthxyeah, i primarily use vim, but lisp-y stuff seems so much nicer in emacs
11:31gnuvinceI'll be writing a book about it: "There and back again"
11:31gnuvince:)
11:31djkthxhaha
11:31gnuvinceYeah, Emacs is way ahead of vim when it comes to any language that has a REPL.
11:32gnuvinceand Lisp support in Emacs is great.
11:33drewrAnd that's using it 8-10 hours a day.
11:34gnuvincedrewr: there are some factors that come into
11:34gnuvinceplay
11:43duck1123I've had some days where my left pinky was so sore after working all day in emacs
11:45drewrMaybe it's the intense pre-work finger workout I subject myself to.
11:49ChousukeIf I didn't use caps lock as control I probably couldn't use emacs for longer than few minutes at a time :/
11:49drewrChousuke: No doubt.
11:50duck1123My caps lock is my meta key for stumpwm
11:51gnuvinceI have capslock mapped to control
11:51gnuvinceand I used my ring finger
11:52gnuvincebut I always kept my pinky curled up
11:52duck1123is your control still a control?
11:52drewrgnuvince: Why not use your pinky? My wrist and my fingers barely move because everything is in the right place.
11:53gnuvincedrewr: small hands
11:53duck1123I think the frustration trying to break that muscle memory would be worse than any RSI it might save
11:53drewrgnuvince: That seems to be even more reason to use the pinky.
11:54gnuvincedrewr: small hands, little strength
11:54gnuvinceanyway
11:54Chousukehaving caps lock as control has become a requirement for me... Caps lock only really caused annoyance :/
11:54gnuvinceI'm very comfortable in vim now.
11:54drewrHeh. I like vim too.
11:54gnuvinceSLIME would be nice, but I'll trade that for being able to play the guitar and stuff when I'm 40 :)
11:55drewrgnuvince: Maybe my guitar playing is what keeps my fingers strong enough for Emacs. :-)
11:57gnuvince:)
11:57Chousukekotarak is working on some improved REPL support for vim/clojure I think. he has chimp on his site, but he said he's working on "gorilla" now.
11:59gnuvincedrewr: one thing that really wears out my pinky is that with my keyboard binding (french canadian), / is done with Shift-3 and I do that chord with pinky-index
12:00gnuvinceso that's a lot of shifting in a day
12:02duck1123I've been tempted to buy one of those gamer's keyboards for using with emacs
12:21danlarkinkotarak: just the man I want to speak to
12:22kotarakdanlarkin: who? me? must be misunderstanding! ;)
12:22danlarkinI stumbled upon your parser combinator library last night
12:22danlarkinit's a nice piece of work
12:23kotarakunfortunately, it doesn't get the time slice of my spare time, it deserves. :/
12:23danlarkinyes I noticed it's using some old idioms
12:24kotarakIt's in a transition state...
12:24danlarkinoh are you working on it?
12:25kotarakyes, but the last change of in september or so...
12:26kotarakAs soon as I get some time off from Gorilla and ClojureCheck, I will continue on Parser.
12:28gnuvincekotarak: What is Gorilla?
12:29kotaraksuccessor of Chimp. With both way information flow, Repl inside a Vim, buffer etc...
12:29gnuvinceok
12:29gnuvincethat's interesting, we were just talking about SLIME and how us vim users didn't have it
12:33SnowBuddyI have something like this: (take-while !nil (all-lines-from file)), where !nil is defined as (defn !nil [x] (not (nil? x))). is there a function that already gives me the same effect as !nil that I just haven't seen?
12:33kotarakgnuvince: on http://tinyurl.com/5ma9d8 there is a short screencast, with my initial prototype. Currently I'm working make it usable for someone who's not me...
12:34Chousukeheh
12:34kotarakSnowBuddy: (complement nil?) (not that is shorter)
12:34rhickeySnowBuddy: (comp not nil?), or maybe identity
12:34Chousukekotarak: I tried cloning your hg repo but make fails :/
12:35Chousukeit just says Makefile:40: *** missing separator. Stop.
12:35kotarakChousuke: which hg repo?
12:35kotarakChousuke: this a BSD makefile, no GNU makefile
12:35Chousukegorilla's; using the url I found on your site
12:35Chousukeright.
12:35ChousukeI suspected that. need to get bsd make then.
12:35kotarakChousuke: hmm... give until tomorrow.
12:35Chousukeoh, no I don't. it's there already :D
12:36kotarakChousuke: then I will put up a jar.
12:36kotarakChousuke: then there's no need for the make. :)
12:36ChousukeI seem to be missing shtool too. :)
12:37SnowBuddyok, so other options are just alternative ways of writing the same thing then?
12:37rhickeySnowBuddy: identity isn't
12:38danlarkinkotarak: is Parser in a usable state right now? I've only skimmed through your code and examples so far, haven't tried to run anything yet
12:39rhickeySnowBuddy: and re: all-lines-from-file see line-seq
12:39duck1123identity would also fail on false, right?
12:39rhickeyduck1123: yes, but for his lines use would be ok
12:40rhickeypresuming string or nil
12:41SnowBuddyrhickey: so something like (take-while #(identity %) (line-seq file)) then?
12:41SnowBuddyit took me a moment to grok how identity solves the problem ;)
12:41rhickeySnowBuddy: just (take-while identity ...)
12:43SnowBuddyrhickey: ah, I see. on a style note, how does (take-while identity ...) compare to (take-while !nil ...) in terms of readability?
12:44duck1123"while it's there, take this..." is how I mentally translate it
12:45duck1123vs. "while it's not nill, take this..."
12:46rhickeyI prefer identity when false isn't involved, else (complement nil?) - prefer standard fns
12:46SnowBuddyrhickey: what do you mean by "when false isn't involved"?
12:46rhickeybut I think all-lines-from-file is suspect, not using seqs
12:48rhickey(filter identity [1 2 false nil 6])
12:48rhickey(filter (complement nil?) [1 2 false nil 6])
12:51SnowBuddyall-lines-from boils down to a repeatedly on readLine. so in the first filter are false and nil treated as the same while in the second they're unique?
12:57ChouserSnowBuddy: right.
12:58Chouserline-seq is a standard function that also does readLine repeatedly.
12:59kotarakdanlarkin: Parser is not really usable at the moment.
13:00kotarakChousuke: the makefile more some convenience for internal usage....
13:01SnowBuddyI'm still learning what all the standard functions are and what they do. looking at line-seq, it uses lazy-cons and a recursive call instead of the repeatedly I was using. what's the difference?
13:01danlarkinkotarak: aw :-/
13:01gnuvinceHas anyone started a style guide for Clojure?
13:02Chousukekotarak: I managed to build the .jar and run the socketrepl but I can't figure out how to run the actual vim repl :/
13:02drewrgnuvince: boot.clj :-)
13:02gnuvince:)
13:02Chouserrhickey: I just finished the binding-vector audit and patch. fixing up the doc strings now.
13:03kotarakChousuke: In a clojure buffer \sr
13:03gnuvinceSpecifically, I'm wondering if (. obj method), (. obj (method)) or (.method obj) is prefered
13:03Chouserthere weren't as many as I thought
13:03rhickeyChouser: cool! thanks
13:04kotarakdanlarkin: I'm working on it. :) Patience, I say! ;)
13:05drewrgnuvince: I think the latter. (. obj (method)) is probably from code that hasn't been updated.
13:06Chousukekotarak: hmm, for some reason vim doesn't seem to be detecting clojure files properly now... need to fix that first I suppose.
13:07gnuvincedrewr: cool, that's actually my favorite ;)
13:08drewrYeah, it's the lispiest.
13:08drewrVery CLOS-like.
13:09duck1123(new Object) or (Object.) ?
13:10kotarakI prefer new, but the dot-notation is wide-spread
13:17Chousukekotarak: I'm trying to run it but it says "pattern not found: print-method" :/
13:20kotarakChousuke: sounds like broken, keyboard mapping...
13:20kotarakChousuke: just a sec
13:21kotarakChousuke: try to run it manually, :call GorillaStartRepl()
13:21danlarkinkotarak: I guess while I wait I can learn a little more about how it works :) it's mostly still over my head at this point
13:21Chousukekotarak: well that worked
13:22kotarakdanlarkin: one get the hang of it, you see combinators all over the place. :)
13:23kotarakChousuke: <C-CR> send to the Clojure instance, <C-Up> goes in history, <C-Down> goes down, never ever send two things at the same time!
13:24ChousukeI get "IndexError: (eval):66:in `[]': index 0 out of buffer" :/
13:25Chousukeah right
13:25Chousukethat was because I had an extraneous newline
13:26abrookskotarak: Is Gorilla publicly available now?
13:26kotarakChousuke: as I said: prototype. I'm working making it more robust right now. Hopefully I have something tomorrow. (I wanted to have something already this week....)
13:26kotarakabrooks: not really.
13:26kotarakabrooks: you can have a look at http://kotka.de/projects/clojure/gorilla.html, but you won't have fun...
13:27abrookskotarak: Okay. Should I keep an eye out in the Clojure Group for your announcement when it is?
13:27Chousukekotarak: well, I wasn't expecting it to be perfect. Still, looks promising.
13:27abrookskotarak: Hehe. :)
13:27kotarakabrooks: yes. I will send an announcement
13:29kotarakChousuke: the biiig improvement over chimp is: it's two-way. With Chimp the information goes only in one-way - out of Vim. Since it's via network, one can also do remote repling, independent of Windows or Unix or Mac, or via a ssh tunnel or whatever
13:32abrookskotarak: I use (and enjoy) Chimp. I create splits in my Chimp session and can use Screen to copy stuff back and forth.
13:32Chousukehmm
13:33abrookskotarak: It's a lot less smooth than going back-and-forth between Vim buffers since I have to shift from Vim to Screen to Vim key bindings but I do use it bidirectionally.
13:33kotarakabrooks: yes, but for example auto-completion with display of arglists (omni-completion), etc, is not possible with Chimp.
13:33Chousukeoops. I managed to send java into an infinite loop again.
13:33abrookskotarak: Absolutely. And I'm looking forwards to Gorilla for that reason. :)
13:34kotarakChousuke: that's possible if you send something like this: Gorilla=> :a :b
13:34kotarakThen vim and clojure get out of sync.
13:34kotarakI'm still working on that one....
13:34danlarkinChousuke: I think we all do that more than we'd care to admit
13:35Chousukethe repl kind of encourages it
13:35Chousukesince it's so easy to experiment.
13:35abrooksYeah, infinite, lazy seqs are landmines for the forgetful or typo prone...
13:35kotarakabrooks: In the beginning I want to first make Chimp and Gorilla equivalent in functionality. Then I will start to implement additional things like omni-completion.
13:36kotarakOr maybe ballons with docstrings...
13:36Chousukesome way to tell clojure to abort evaluation might be useful.
13:36abrooksOooo. :)
13:38danlarkinChousuke: now you're talking
13:38danlarkinI like that in python C-c raises a KeyboardInterrupt exception
13:39danlarkinand brings you back to the repl
13:39Chouserthere was some discussion of that on the group some months ago
13:52rhickeythere's *print-length* now
14:11AWizzArdHello
14:11Lau_of_DKHey AWizzArd
14:11AWizzArdGood evening Lau
14:11kotarakhi wizz, hi lau
14:12AWizzArdMoin Kota
14:12Lau_of_DKOla Kota
14:12AWizzArdeveryone is slowly waking up :-)
14:12Lau_of_DKFriday night, time for coding!
14:13AWizzArdqt?
14:13Lau_of_DKHmm, Im as far with Qt now as I need
14:14Lau_of_DKI have the designer integrated, I have webkit running, I have hooked slots/signals to anonymous functions. So, its functional as far as smaller fancy GUIs go :)
14:14ChouserLau_of_DK: is that code posted anywhere?
14:14Lau_of_DKyea, I put it all in /home/lau
14:14Lau_of_DK:)
14:21sohailLau_of_DK, paste.lisp.org man!
14:21Lau_of_DKI need to compile the whole thing and comment it, giving credit where credit is due, before I unleash it
14:21Lau_of_DKBut there are problems with Qt at the core, which makes me a bit cautious to distribute
14:24sohailLau_of_DK, what problems?
14:26Lau_of_DKThe signal/slot system does not throw errors. If somethings fails it will be silently dropped. If a slot throws an error, QApplication ignores it.
14:27Lau_of_DKQObjects are non-thread-safe - Objects spawned in 1 thread can only be called from that thread ( this is probably fixable/patchable), but as of yet its a real problem
14:27Lau_of_DKSome of these issues, especially with slots, quire alot of work and attention before being industry grade, and Im not sure anybody will put that work in, or just instead start using it as is, and by doing so throwing all clojure concurrency guarantees overboard
14:30sohailLau_of_DK, they did that by design
14:31sohailI still don't understand it
14:31sohailmaybe it helps in thread-safety or something
14:31sohailand yeah for slots throwing errors, you need to basically wrap all your slots somehow
14:32sohailPython has a really nice "unhandled exception" handler which does this very nicely for pyqt
14:32sohailI doubt clojure has something similar
14:33Lau_of_DKIf it could be written in a good way, Im all for it. But Ive seen a few people just jump allover Qt (incl me), which might not be so good
14:33Lau_of_DKBut Im no expert :) Im just sharing a concern
14:33sohailI don't understand what you mean by "jump all over Qt"
14:34Lau_of_DKI read a blogspot which celebrated that there was now a Lisp with Qt in it, and gave an example of a GUI and such, without any mention of any of these restrictions, and that gives an inaccurate view of the platform
14:35sohaillol, that's probably me
14:35Lau_of_DKoh :)
14:35sohailthe one thread-per QObject is nothing you can change
14:35AWizzArdwhat does this mean? One thread per QObj?
14:36sohailmeans that a QObject may only be used from one thread
14:36AWizzArdhmm
14:36Chouserfor what it's worth, I expect all those issues could be handled pretty well with a single well-thought-out lib.
14:36AWizzArdis it not good if you can run each component of your gui in its own thread?
14:37AWizzArdscrollbar, each point in the menu, buttons, etc
14:37sohailAWizzArd, all GUI stuff must be done on the main thread
14:37sohailbut QObjects aren't always GUI threads
14:37AWizzArdand what about swing?
14:37sohailsame, iirc
14:37sohailI think all GUI frameworks do that
14:37AWizzArdso it's nothing special to point out then?
14:38sohailnope
14:38sohailLau_of_DK, as for signals/slots, yes Qt pretends exceptions don't exist
14:38Lau_of_DKChouser, thats worth alot
14:38sohailso you have to do something
14:38sohailit's fine to have an unhandled exception handler for clojure-qt or whatever
14:38Lau_of_DKYea, I might look into that as the next project
14:38sohailit's not very hard
14:39sohailfor my qtcl thing, I had one function that all slots went through
14:39sohailthat's where I did the error handling
14:39sohailI think anyway!
14:40Lau_of_DKWrite it up man
14:41sohailhm, no I lied
14:42sohailI didn't do the error handling
14:42Lau_of_DKYou just pretended, like Qt ? :)
14:42sohailbut had a macro define-slot-handler which generated a cffi:callback which should have done the error handling
14:43Lau_of_DKok
14:45sohailand I had a bunch of (define-slot-handler some-name "(SlotArgList)" (:cffi-arg-list)) so: (define-slot-handler activation-reason "(QSystemTrayIcon::ActivationReason)" (:int)) for example.. then any slots that had the arg list of QSystemTrayIcon::ActivationReason would use that one callback (through some other magic)
14:45sohailand since I'm sure that makes nos ense, I will take my leave and go debug some multi-threaded code
14:47Lau_of_DKOk :)
14:47Lau_of_DKIt might make perfect sense, but I cant grapple with it right now, long day
14:48sohailLau_of_DK, I'd like to see what you've done with Qt
14:48Lau_of_DKWhen I have the time and the energy, I'll wrap something up for you, I'll try to get it done this weekend
14:59AWizzArdI am running tons and tons of agents. Can I somehow check how much of them are still in the queue?
15:05Chouserrhickey: is it intentional that for doesn't support :when and :while at the same time?
15:06djkthxdoes clojure have its own integer square root like isqrt?
15:07rhickeyChouser: probably not
15:13djkthxalso, is there a bit-vector or anything like that?
15:14rhickeyChouser: doseq based on for is a perf loss, easiest implementation, I know, but the objective should be imperative version of for
15:16Chouserah, so no laziness inside.
15:16Chouserbut still :while :when and nesting?
15:17rhickeyChouser: that would be best
15:17rhickeyChouser: yes, same interface
15:18Chouserthat would probably be easier for me than trying to understand for well enough to fix the :when-and-:while bug. :-P
15:18rhickeyChouser: it's not a bug, but a lack of a feature, so no need to fix yet, but yes, imperative much easier
15:19Lau_of_DKrhickey, have you plans on making any more screencasts like the one with Ants, where you similarily would walk through lines of code, explaining them as you go along ?
15:20kotarakrhickey: may I ask something rather unprofessional? Are you working in parallel to Clojure development? Or is clojure your main engagement at the moment?
15:21rhickeyLau_of_DK: the most recent thought was to conduct some sort of online study group, but it hasn't moved forward due to my schedule recently
15:21kotarakrhickey, Lau_of_DK: yeah, there was this netmeeting thing spooking around.
15:21kotarakyea, exactly
15:21Lau_of_DKrhickey, great, where can I sign up? :)
15:22kotarakLau_of_DK: you considered the time shift?
15:22rhickeyLau_of_DK: it's a matter of getting enough people interested who can attend at the same times
15:22rhickeykotarak: I do consulting and Clojure
15:22Lau_of_DKAlright, well Im pretty flexible, which I'll have to be considering im in CET
15:23kotaraknote me down also! I'm absolutely interested.
15:24kotarakBut something earlier than 2 o'clock in the night would be good. (also CET)
15:30gnuvinceWhat's a $ in an identifier? Inner-class?
15:31kotarakinner class
15:31rhickeygnuvince: yes, you'll need $ to reach a nested class
15:31gnuvinceThanks.
15:32gnuvincerhickey: how much Java do you think a casual Clojure programmer ought to know? I only had one (very bad) semester of Java 1.1 in school 5 years ago.
15:33rhickeygnuvince: you need to know very little Java syntax, but should understand the object model and how to read JavaDoc
15:33gnuvinceOK.
15:34rhickeythe object model is very simple single inheritance + interfaces
15:34rhickeyno need to know generics
15:34kib2_awayrhickey: not so sure (for me indeed), playing ie with Swing if you never touched Java and Clojure before is really hard.
15:34gnuvinceJust to make sure, inner classes are: class Foo { class Bar { /* I am an inner class */ } }?
15:37rhickeykib2_away: well, you do need to know some
15:37kotarakthe problem with Java is the huge number of classes one has to understand at least a bit. JTree, TreeModel, TreeNode, TreePath, BlaLaberThingyListener, ....
15:37rhickeykotarak: that has more to do with Swing than Java per se
15:37kib2_awayThisMethodIsRatherBeautifulDontYouThinkSo ?
15:38gnuvinceI might check out "Head First Into Java" by Kathy Sierra
15:38kotarakrhickey: well, that was my closest contact to java up to now. Interfaces and that isn't really a problem.
15:41kotarakthere was a google tech talk of some Java Guru, talking about interfaces, with a "don't do it like that" example where some Java library needed have a dozen classes to a simple task....
15:42AWizzArdkotarak: you could think about not using swing but a browser instead for displaying a gui
15:42rhickeykotarak: in the end, whatever pain exists in Java, Clojure can make go away
15:45kotarakAWizzArd: bah, I hate those browser guis.
15:47kotarakrhickey: Clojure - a painkiller - For risks asks you doctor, side effects are forbidden. (So even better than Aspirin. :)
15:50Lau_of_DKkotarak, I'll fire up the T-Shirt printer :)
15:50duck1123I like that
15:51gnuvinceSomebody in the Clojure Book reddit thread mentioned the Joda library. That's a very nice one!
15:52sohailjoda = yoda?
15:52gnuvinceI'm not sure if that's what they were going after.
15:53sohailmy date times you have replaced
15:55gnuvince:)
15:55AWizzArdkotarak: I think in the past 10 years it were exclusively web applications that made people billionairs
15:55gnuvinceuser=> (Days/daysBetween (DateTime.) (DateTime. 2009 1 20 12 0 0 0))
15:55gnuvinceP73D
16:00kotarakAWizzArd: I was never fond of things, which made others billionairs. (Whether these billions are reallistic or not is another story). I'm sitting in the train, no web, esoteric rays, crappy connection, annoying sluggish interface, .... I'm not a fan of having to be online all the time, to read my mails .... I'd rather have them locally with a goode olde mail reader.
16:00sohailAWizzArd, that is really, really ignorant!
16:01AWizzArd*g*
16:01sohailbillionaire on paper doesn't count
16:01sohailI have a company right now that I value at 15 billion and I own half the shares, am I a billionaire?
16:01sohailhell no :-)
16:02Lau_of_DKsohail, but lets imagine that you were a billionaraire, for a second... can I borrow a few bucks? :)
16:02AWizzArdIf you are allowed to sell them and if they are worth so much/requested so much you could do it like Bill Gates and sell them for 30 million a day
16:03sohailso your only example is someone who didn't make his billions via web apps :-)
16:03sohailLau_of_DK, I didn't get paper rich by giving money away!
16:03Lau_of_DKhaha
16:04AWizzArdI just say they could (if the law allows it) make at least a few millions per day by selling, or not?
16:04sohailbut you said billions
16:04sohailanyway, I've dealt with both web app companies and traditional desktop apps... latter makes many, many times more in my experience
16:04AWizzArdno one has billions on his bank account.. your investment manager will "force" you to buy shares and stuff
16:05Lau_of_DKGuys, it would be kind of cool it we could get back into a Clojure discussion
16:05sohailyeah, so clojure needs to have a good qt interface to make me rich
16:05Lau_of_DKHave any of you made some interesting webapps with Clojure ?
16:06AWizzArdhmm no, don't know how to do it with the jvm..
16:09Lau_of_DKNobody made anything that runs on a webserver yet?
16:09sohailweb apps suck
16:10Lau_of_DKhmm, I must be gettin forgetful, sohail show me the line where I asked for your oppinion on web apps :)
16:10sohail<Lau_of_DK> Have any of you made some interesting webapps with Clojure ? sohail specifically, what do you think about web apps?
16:10sohailthat's what I saw
16:10Lau_of_DKLOOOOOOOL
16:11Lau_of_DKSohail, try this out http://www.sumopaint.com/
16:13sohailLau_of_DK, flash != web app, sorry
16:13AWizzArdwell, they come with advantages and disadvantages
16:14AWizzArdfor the user it's nice that he needs no installation and gets gradual updates so easily
16:14rhickeylet's try to stick to Clojure, please
16:20Lau_of_DKWhat are people in here doing with Clojure atm ?
16:20Lau_of_DKAre you all building Swing apps?
16:21drewrMigrating massive amounts of data.
16:22kotarakLau_of_DK: mainly libraries, but also a Swing app, and tools for Vim mainly...
16:22Chouserprocrastinating
16:22duck1123I'm working on a web app
16:23AWizzArdLau_of_DK: I am testing performance of agents, and I will need tons of them, cause I am looking into porting my Genetic Programming system from Common Lisp to Clojure
16:23Lau_of_DKSounds like you guys are doing some advanced stuff
16:24AWizzArdAnd I am having memory problems, and maybe rhickey or someone else has an idea why:
16:24lisppaste8AWizzArd pasted "Running into problems with the Java Heap" at http://paste.lisp.org/display/69919
16:25AWizzArdIt runs okay when doing a few 100k iterations
16:27AWizzArdCould it have to do with (fak 35) resulting in a BigInteger which does not get GCed fast enough?
16:27rhickeyAWizzArd: you are awaiting nothing
16:27AWizzArdI thought await would wait until the current thread finished all agents
16:27rhickeyagents don't run on the current thread
16:27rhickeyyou can await for specific agents
16:27AWizzArddamn, right
16:28AWizzArdyes, I usually do that
16:28AWizzArdin this example I wanted to use anonymous agents, but anyway, even if I can't time this correctly right now it still runs into memory problems
16:30rhickeyAWizzArd: you'll have to allocate enough memory to hold your agents, I have problems with -Xmx1024M
16:31rhickeyI have no problems
16:32Lau_of_DKhuh? You have problems with -Xmx1024M but you have no problems?
16:33rhickeya type
16:33AWizzArdI think he means when he runs it with 1g it won't cause memory problems
16:33rhickeytypo
16:33AWizzArdokay, so the problem is in the queue? It stores the calls faster than working them off
16:33Lau_of_DKoh
16:33rhickeyAWizzArd: or whatever, it's just a memory allocation/usage thing
16:33AWizzArdgood good, that is fine for me
16:34AWizzArdI will then configure slime to run clojure always with 1024M
16:34rhickeyI don't know exactly how much you'll need, but -server and -Xmx can help
16:34AWizzArdrhickey: do you see a good reason to *not* run Clojure with the -server flag when developing?
16:34rhickeythe important thing is, no problem having that many agents
16:35rhickeyAWizzArd: I always run with -server
16:35AWizzArdyes, I see, that's good news, so it just means I need more memory
16:35AWizzArdfunny that the default seems to be just these 128mb
16:50AWizzArdI remember that I got emacs to show me a gui in which I could configure slime/swank/clojure, but I forgot how to do it. Anyone here maybe knows how?
16:53Lau_of_DKIf the GUI is called firefox and the contents was the Clojure-wiki, then yes, I can point you in the right direction
16:55AWizzArdI was running some emacs command and inside emacs there were some options I could set, for example the path to java, etc
16:57AWizzArdah yes, M-x customize-group swank-clojure
16:57Lau_of_DKcool, I'll have to try that out
17:26AWizzArdis there a way to see in the repl with what command line arguments Java was started?
17:26AWizzArd(like -server -Xmx1024M and so forth)
17:30rhickey(.maxMemory (Runtime/getRuntime))
17:30rhickey(System/getProperties)
17:36AWizzArdthx
17:36HunAWizzArd: customize-group slime
17:36Hunoh, you found that already :)
17:37AWizzArdyes, but thanks
17:37Hunhmm... reading history forwards does not work. backwards neither. any suggestions for better reading? :)
17:39AWizzArdWill AOT mean that one can compile all clojure code into .class files and that way is not forced to deliver source code to customers?
17:39rhickeyAWizzArd: yes
17:40solkisWhat function can I use to determine if a variable has already been bound using def? I need to only initialize something once with an if.
17:41rhickeysolkis: there is defonce
17:42solkisrhickey: thx, that's what I need
17:42lisppaste8Chouser pasted "new doseq" at http://paste.lisp.org/display/69926
17:42rhickeyalso (.isBound #'foo)
17:43Chouserugleee but it produces good code (re: doseq)
17:44Chouserhm, it'd be simpler if I left "when" blocks in but used "true" if no :when or :while was given.
17:44Chouseris that too much slower?
17:44AWizzArdGood code in what way? You mean efficient?
17:45rhickeyChouser: that's what for does IIRC
17:45rhickeysimpler is better, HotSpot will remove later
17:46AWizzArdBtw, are there already any real world apps written in Clojure yet?
17:47Lau_of_DKrhickey, apropos the study group you mentioned earlier, where do I sign up?
17:48rhickeyLau_of_DK: when I get some time to organize it, I'll post on the group to measure interest
17:48Lau_of_DKAlright, I'll be patiently waiting.
17:50solkisAnybody know how to restart (basically clear out) a slime environment in emacs? I just want a fresh REPL with nothing yet defined.
17:53ChousukeIIRC there was a slime-reset or something like that
17:54Chousukethough you could just kill the clojure repl and restart slime.
17:57AWizzArdsolkis: you could also just delete all vars from within clojure
17:57solkisChousuke: thx
17:58solkisAWizzArd: just for fun, how would you do that?
18:01lisppaste8solkis pasted "Clojure Java GTK Sample" at http://paste.lisp.org/display/69927
18:01AWizzArdsolkis: (map #(ns-unmap 'user %) (keys (ns-interns 'user))) where 'user is your namespace
18:03solkisAWizzArd: thx, I'll figure that one out as an exercise in Clojure :-)
18:03AWizzArdit will kill everything in that namespace that you set up via def or defn
18:05solkisAlso, I just pasted a short example (based on anther one I saw in the archive) using clojure and the java gtk bindings (I'd never used them and I thought it might be fun.) The original Java example was here: http://java-gnome.sourceforge.net/4.0/doc/examples/button/ExamplePressMe.html
18:06AWizzArdsolkis: or even better is Chousers version: (doseq [n v] (ns-interns *ns*) (ns-unmap *ns* n))
18:06solkisAWizzArd: thx
18:39Lau_of_DKPotentially dumb question: Im sitting here on my very first Dual-core system ever. And I wonder why, if I start up some large computation in Clojure, that it only utilizes 1 CPU 100% and the other is resting at around 20%. ?
18:47ivanyou're right, that is pretty dumb :)
18:47ivanare you expecting it to parallelize?
18:48Lau_of_DKI was actually expecting it to use the full capacity of the system - I mean, whats the idea of a high level language anyway ?
18:51ivani really have little clue
18:51ivanbut http://clojure.org/concurrent_programming suggests that you manage the concurrency for now
18:51AWizzArdLau_of_DK: this is not possible the way you think about it
18:52Lau_of_DKYou mean in terms of raw power and utilization ?
18:52AWizzArdyou will need to inform Clojure what exactly it should run
18:52AWizzArdClojure itself will run in only one thread all the time if you don't do anything against that.
18:53AWizzArdthe problem is: threads cause overhead
18:53rhickeyAWizzArd: there is pmap and the parallel lib, but otherwise, yes
18:53AWizzArdrhickey: sure, and I am adding more parallel mapping functions
18:54AWizzArdLau_of_DK: Clojure should not simply go around and let each function call run in its own thread
18:54Lau_of_DKAWizzArd, can you define 'overhead' for me ?
18:54AWizzArdif you want to do (count my-vector) then this can be done within a few microseconds
18:55AWizzArdbut if you would say: hey Clojure, run this in a thread, then some extra work needs to be done
18:55AWizzArdyour thread has its exclusive copy of "global vars"
18:55AWizzArdand some scheduling must be done, etc
18:55ChousukeLau_of_DK: The main problem is, clojure can't tell which operations are safe to parallelise, or whether it makes sense.
18:55ChousukeLau_of_DK: so you need to take care of it manually.
18:55AWizzArdso in the end your (count my-vector) in its own thread will take some thousand or ten thousand microseconds
18:56Lau_of_DKOkay I get what you guys are saying
18:56Lau_of_DKThanks alot
18:56AWizzArdin principle everything should be safe to parallelize in a pure functional environment, but yes, detecting this is also not so easy
18:57AWizzArdLau_of_DK: if you have a function that will run for 1 second or longer, then you could decide to give it its own thread
18:57AWizzArdbecause the administrative work of the JVM of 2 msecs is not important then anymore
18:58Lau_of_DKOk
18:58AWizzArdyou will benefit of having 2 calls running at the same time and finish after 1.002 seconds, vs 2 secs with just one thread
18:58AWizzArdit could be interesting to know where the break-even point is
18:59Lau_of_DKBut the possibilities for improvements are quite large I see
18:59AWizzArdLau_of_DK: and btw, threads make sense for positive user experience
18:59Chousukethere are algorithms that really don
18:59Chousukedon't gain benefit from parallelisation
18:59Lau_of_DKYea I know
19:00AWizzArdif your application is used by several people at the same time then running their requests in different threads. Just imagine google replying: sorry, can't search because someone else is doing that right now :-)
19:01AWizzArdbut Clojure makes it very easy for you to run your code in parallel
19:01Chousukefunctional languages in general make it less troublesome I suppose.
19:01AWizzArdexactly
19:03AWizzArdIn principle we try to make as much code as possible a mathmatical function. It depends only on it's arguments and will always return the same result when given the same args. In that case it doesn't matter on what processor you run (+ 1 3)
19:25Lau_of_DKI gots to the hit sack, thanks for all the input guys
20:08rhickeyNote on SVN rev 1089:
20:08rhickeyInterim checkin - DO NOT USE!!
20:08rhickeyUnless you are interested in helping test:
20:08rhickeynew print-dup functionality for replica generation of compilation constants
20:08rhickeynew *print-dup* flag, prints duplicators
20:08rhickeyback to simplified readably printing for repl
20:08rhickeyreadable fns, as long as they are not closures
20:14AWizzArdyummy
20:43lisppaste8Chouser annotated #69926 with "simpler doseq" at http://paste.lisp.org/display/69926#1
20:55djkthxwhy doesn't this return true?
20:55djkthxuser> (false? (let [a (make-array (. Boolean TYPE) 10)] (aget a 0)))
20:55djkthxfalse
20:55djkthx?
20:56djkthxall the values are false in the array
21:02duck1123but it's an array of non-zero size
21:03pjb3djkthx: false? returns true if it's argument is false, otherwise false
21:03pjb3(false? [false]) => true
21:03pjb3err (false? [false]) => false
21:03pjb3I meant
21:05pjb3oh wait, I didn't see the last part of your expression
21:05djkthxbut i'm just taking one of the elements
21:05djkthxyeah
21:06djkthxuser> (let [a (make-array (. Boolean TYPE) 10)]
21:06djkthxuser> (let [a (make-array (. Boolean TYPE) 10)] (aget a 0))
21:06djkthxfalse
21:06djkthxis what aget returns
21:06pjb3(= (. Boolean TYPE) false) => false
21:06djkthxah
21:08pjb3(= (new Boolean false) false) => true
21:08djkthxyeah
21:09djkthxyay, got it working
21:09djkthxalright, thanks :)
21:25djkthxdoes anyone have a sample clojure prime sieve function?
21:26djkthxi had a nice one in common lisp, but it used type declaration and mutable bit-vectors, which i'm not sure how to replicate in clojure...
21:26djkthxi tried copying my CL function, but it wasn't nearly as fast
21:27djkthxuser> (time (last (sieve 100000)))
21:27djkthx"Elapsed time: 5950.069 msecs"
21:27djkthx99991
21:27djkthxin clojure
21:27djkthxNIFTY-FUNS> (time (last (sieve5 100000)))
21:27djkthxEvaluation took: 0.001 seconds of real time
21:27djkthx 0.001421 econds of total run time (0.0(01413 user, 0.000008 system) 100.00% CPU
21:27djkthx 2,829,528 processor ycles 90,112 bytes consed
21:27djkthx(99991)
21:27djkthxin sbcl
21:58djkthxah, cool
21:58djkthxtype declarations helped out quite a bit
22:53djkthxis there a tab completion for symbols in clojure-mode?
22:54drewrI can ESC-TAB, but that might be SLIME.
22:55duck1123M-/
22:55djkthxah, there we go
22:55djkthxthanks duck1123
22:56duck1123np
22:56djkthxdo you know the name of the function so i could rebind it to tab?
22:57duck1123dabbrev-expand
22:58duck1123a little tip. C-h k then a keystroke will give info about the command
22:58duck1123C-h c does similar, but only shows minimal info
22:59djkthxcool
22:59djkthxthanks
23:00duck1123you also might want to bind hippie-expand instead
23:00duck1123it uses multiple methods
23:00djkthxmultiple methods?
23:01djkthxis that like slime-fuzzy-completion?
23:01duck1123there are several different completion algorithms, it'll try them in order
23:01djkthxah
23:01duck1123I'm not familiar with that one
23:02djkthxi used it with common lisp
23:02duck1123also, if you like using [tab] check out pabbrev-mode
23:02djkthxtyping m-v-b and tab would give multiple-destructuring-bind
23:02duck1123I use it all the time with ruby, but havn't gotten around to hooking it to clojure-mode
23:02djkthxgotcha
23:09djkthxblah, emacs
23:09djkthxi can't seem to rebind this stupid key
23:10duck1123how are you doing it?
23:10djkthx(global-set-key (kbd "TAB") 'dabbrev-expand)
23:10djkthxtried dabbrev-completion also
23:11djkthxi put it in my run-clojure fun
23:11djkthxso it would only redifine it if i was using clojure-slime
23:11djkthxredefine*
23:12duck1123in that case (define-key clojure-mode-map (kbd "TAB") 'dabbrev-expand)
23:13duck1123although I'm not sure if (kbd "TAB") is the right syntax
23:14djkthxi believe it is
23:14duck1123modify to taste: (add-hook 'clojure-mode-hook '(lambda () (define-key clojure-mode-map (kbd "C-x C-e") 'lisp-eval-last-sexp))))
23:15djkthxwait, do i need both?
23:16djkthxim not terribly well versed in emacs config stuff...
23:17duck1123if you replace that second thing I sent with your commands, it'll load that key binding when clojure-mode is loaded
23:17djkthxgotcha
23:17duck1123I just copied that out of my init.el file, so I didn't bother fixing it
23:19djkthxgot it working, thanks :)
23:19duck1123cool
23:20djkthxi feel ready to get down to some clojure hacking now
23:21duck1123I need to set up a global lisp eval binding so I can eval stuff out of irc windows
23:21djkthxthat'd be pretty slick
23:25duck1123ok, someone send a clojure form
23:26duck1123(+ 2 2)
23:26djkthx(* 1 2 3 4)
23:26duck1123didn't work the way I wanted
23:26djkthx(map (fn [x] (* x x)) (range 1 10))