#clojure logs

2008-10-12

07:47Lau_of_DKCan somebody enlighten me on the syntax of Cond?
07:57hoeckLau_of_DK: (cond condition1 expression1 conditionN expressionN ..)
07:58Lau_of_DKhoeck, yes, I realised that if one condition is true, other true values are ignored. That just surprised me. I was looking for something like (cond (> 2 1) ((do 1) (do 2) (do 3)) (> 2 0) ((do 1) ... (do n)))
08:02hoeckthen use multiple ifs, cond is really just a replacement for else-nested ifs
08:03Lau_of_DKk
08:03Lau_of_DKDo we have something like (if (isin list1 list2)) that checks for replicates in either list?
08:05hoeckno, but we have sets, so just use (set/intersection (set list1) (set list2))
08:05PupenoIs there a downloadable version of the documentationz
08:05PupenoZ
08:06Pupeno?
08:06Chouserhttp://clojure.googlegroups.com/web/manual.pdf
08:12Lau_of_DKhoeck, first Im using a sequence of LazyCons with integer in it, secondly, my Clojure doesnt have set/intersection, that something new?
08:13PupenoChouser: how is that generated, do you know?
08:17hoeckLau_of_DK: its the set.clj which comes with clojure and the correct name is clojure.set/intersection, sorry
08:18hansPupeno: custom css, browser printing to acrobat. search the group archive, i posted the css
08:18Lau_of_DKno worries, I got it
08:52Lau_of_DKIs there an alternative to pop, which drops the first item in a list, but that does not throw an exception if its an empty list?
08:58Chouser"rest", depending on the data structure
08:59Lau_of_DKk, thanks
11:11Fandahello all!
11:12rhickeyhi
11:12Fandai have couple questions
11:12Fandaone is about contributing
11:12Fandahow do you contribute to clojure-contrib?
11:12Fandarhickey: I sent you a letter (agreement)
11:13rhickeywho is Fanda?
11:13FandaFrantisek Sodomka
11:14Fandamy usual way is to put code on my website:
11:14Fandahttp://intricatevisions.com/index.cgi?page=clojure
11:14rhickeyok, I've got your CA
11:14Fandagood :-)
11:15Fandamy question is, how code gets into clojure-contrib
11:15rhickeyfirst step would be to submit patches for contrib on the Clojure group, the contrib owners will include them if they fit in
11:15rhickeyAfter I get a feel for your contributions I might make you a developer on the SF contrib project
11:16rhickeyif you have a whole new lib for contrib, again post to group, I'll look at it and decide
11:16Fandaok, i see
11:16Fandai like to contribute anything that I find useful for myself
11:16rhickeywhat did you want to contribute?
11:18Fandajust a second, i will find it...
11:18Fandahttp://groups.google.com/group/clojure/browse_frm/thread/d15f190f09c0eead/bb705e2e2d897349?lnk=gst&q=aspect#bb705e2e2d897349
11:19Fanda"code sections", which were rewritten Stephen C. Gilardi as "aspects"
11:20Fandai would put it into some 'util' namespace
11:20Fandasimilar goes for http://groups.google.com/group/clojure/browse_frm/thread/d7e82974b2b58d0a/b8f1d7adeba0dfda?lnk=gst&q=time-expr#b8f1d7adeba0dfda
11:21rhickeyok, I remember, sorry I didn't chime in then. Are you familiar with CL #+ and #- ?
11:21Fandano, I don't really have experience with CL
11:21Fandawhat #+ and #- do?
11:23rhickeyhttp://www.lispworks.com/documentation/HyperSpec/Body/02_dhq.htm
11:23rhickeyhttp://www.lispworks.com/documentation/HyperSpec/Body/24_abaa.htm
11:27rhickeybetter: http://www.lispworks.com/documentation/HyperSpec/Body/24_aba.htm
11:29Fandayes, (aspect :debug (do-something)) would be (do #+debug (do-something))
11:30rhickeya big difference is #+/- are reader macros that conditionally read
11:32Fanda_sorry, my connection isn't too stable
11:32Fanda_my last sentence was "since # is special for Clojure, it would need to be implemented in the core, right?"
11:33rhickeyyes, reader macros have to go in LispReader
11:34Fanda_it is just a suggestion... i like both versions
11:34Fanda_i am sure that I will just it when developing, since it is a common pattern
11:34rhickeysomething like #+ will end up in Clojure
11:37Fanda_can (do #+debug (do-something)) be somehow rewritten without 'do'?
11:37Fanda_(#+debug (do-something)) ???
11:38rhickey#+ turns into whitespace if false
11:39Fanda_so #+debug (do-something) would be fine
11:39rhickeywould just disappear if not debug
11:40Fanda_yeah, sounds good
11:40Fanda_sometimes i need to define different levels of debugging - debug-calculation, debug-writing-to-file, debug-ui, ...
11:41Fanda_or logging - log-xyz, ...
11:41Fanda_... so that's where it started :-)
11:42rhickeylogging is different - vars help there
11:42rhickey(binding [*log-level* :verbose] ...)
11:43Fanda_oh, i see
11:43Fanda_that makes sence
11:43Fanda_sense
11:43kotarakIf I understand correctly, this is compile time. So it's like good olde #ifdef?
11:44Fanda_yes, exactly
11:44rhickeyread-time
11:44rhickeycompiler never sees it
11:44kotarakOk.
11:44Fanda_preprocessor-time :-)
11:45kotarakas in C. #ifdef is also not seen by the compiler.
11:46Fanda_.......
11:46Fanda_other thing - compiler now has *warn-on-reflection*, right?
11:46Fanda_i would put it into map
11:46Fanda_something like *compiler-settings*
11:47Fanda_and do (def *compiler-settings* {:warn-on-reflection true})
11:47Fanda_so that we can easily add more compiler options later...
11:48kotarakI'm not sure, I like this #+ thing....
11:49Fanda_syntax of it or the behavior (semantics)?
11:49Fanda_(still here)
11:49kotarakthe behaviour
11:51Fanda_what don't you like? i find it very useful
11:53kotarakIf there something, that can be done with it, which cannot be done with "normal" macros?
11:53kotarak /If/Is/
11:53Fanda_it is up to Rich - if he wants it in the core or not
11:53Fanda_i am ok with macro
11:54kotarakI didn't say it shouldn't go to Clojure core. I don't have to use it after all. It is up to Rich.
11:57Fanda_ok
11:57Fanda_other thing: should boot.clj be renamed to clojure.clj??? since it is a 'clojure' namespace? :-)
11:58rhickeykotarak: normal macros can't disappear
11:58rhickeyFanda_: will rename soon
11:58Fanda_:-)
11:58Fanda_and what about testing Clojure?
11:59Fanda_i would create some test-clojure.clj, test-set.clj, ...
11:59Fanda_to test its correctness
11:59rhickeyFanda_: go for it!
11:59kotarakrhickey: I see stuff like (if (something) #+ (x) (y)) and people asking, why does my code not work? A macro can always expand to nil...
12:00Fanda_rhickey: I actually might - it would be a nice exercise
12:00Fanda_rhickey: once it gets started, other people will join and it can be done very quickly
12:02rhickeykotarak: in source, nil is not the same as whitespace
12:05duck1123what does it mean if I get an InvocationTargetException when trying to construct an object?
12:07kotarakrhickey: I still don't get the use. It's like old #ifdef. I don't see why I would that.
12:08rhickeyduck1123: do you have an example?
12:10lisppaste8duck1123 pasted "exception when creating object" at http://paste.lisp.org/display/68368
12:11Fanda_kotarak: look in thread http://groups.google.com/group/clojure/browse_frm/thread/ce795dd1fb646df1/d1c6c3b3f6485ece
12:11Fanda_kotarak: download http://groups.google.com/group/clojure/attach/394c5334d6d7e2a1/cfa.clj.zip?part=4
12:11Fanda_kotarak: see lines like ;(println (list r g b a));;;;DEBUG
12:12Fanda_;(try
12:12Fanda_ ; (println (list 'push cnt (.. Thread (currentThread) (getName))))
12:12Fanda_ ; (println stack)
12:12Fanda_;(catch Exception e (println (list 'exception at c cnt))))
12:13rhickeyduck1123: you might be missing other needed jars - also try putting them in your real classpath vs add-classpath
12:13Fanda_kotarak: all these lines could be put into #+debug (do ...)
12:14Fanda_kotarak: #+test (do ...)
12:15Fanda_rhickey: where does symbol for #+ come from? is it from global namespace? it might cause symbol pollution...
12:15Fanda_rhickey: aspect macro has (def +aspects+ #{:debug :log0 :log1}) which looks better to me
12:17kotarakFanda_: And all these lines can be put into macro which conditionally evaluates to nil at compile-time.... But have to go now. Bye.
12:17rhickeyCL isn't perfect, but you need to fully understand it before you attempt to better it
12:18Fanda_bye, kotarak
12:19Fanda_rhickey: Yeah, no offense. I have no clue about CL.
12:19rhickeymore to kotarak's point, there are cases where generating nil is insufficient
12:20Fanda_yes, I believe in that
12:20rhickey#+it-takes-another-arg that-arg
12:22Fanda_could you elaborate more, please?
12:24karmazillais there a literal syntax for BigIntegers, like 3M is a BigDecimal?
12:24rhickey#+ can deal with platform differences, API versions etc. Imagine an api has added an argument in a new version. Code that needs to work with both version needs to supply that arg only if it is the new version, if not, it can't pass nil
12:26rhickeykarmazilla: no - you want to create a small BigInteger?
12:27karmazillawell.... yes. it just happens to be the only class that have the isProbablyPrime method, that I need for a project euler problem
12:28Fanda_rhickey: i am still wondering about grouping symbols for #+
12:28Fanda_rhickey: maybe just put it into namespace!
12:29Fanda_rhickey: reader-options/it-takes-another-arg
12:29rhickeykarmazilla: (BigInteger/valueOf 123)
12:32Fanda_rhickey: after all - symbols for #+ will be automatically only in the namespace, where I write the code, so I will create symbols only in certain namespaces
12:32Fanda_rhickey: good enough
12:35Fanda_thanks for chatting all!
12:35Fanda_have to go
12:53achim_p_hi everyone
12:53achim_p_rhickey: i like the new #= reader macro and print emitting constructor calls.
12:54achim_p_i assume there's no easy way to determine whether a java class can take its toString representation as a ctor arg and make sense out of it, or is there?
12:55kotarakback with a problem: did anyone experience problems with gen-interface? The .class file is generated and in the classpath, but using/importing the interface throws a NoClassDefFoundError: <vector: - 1 items>.
12:55rhickeyachim_p_: there isn't, but the default presumes that might work
12:56duck1123is proxy what I need to be using if I need to create a new class to pass to a function? (like this http://jena.sourceforge.net/ARP/standalone.html#sample)
12:57danlarkinduck1123: proxy creates an instance of a class
12:57achim_p_rhickey: on my machine a printed j.u.Date won't read for some reason, while it appears to work for other people - did you consider falling back to java's serialization for java classes without dedicated print method?
12:58achim_p_sth like (RT/resurrect \? \? \
12:58achim_p_it doesn't look humane at all, but might make serialization via print more generally applicable ...
12:58rhickeyachim_p_: how does a date print for you?
12:59rhickeyachim_p_: I'd really prefer text serialization
12:59achim_p_like that: #=(java.util.Date. "Sun Oct 12 18:56:32 CEST 2008")
12:59achim_p_localization issues, i assume
13:00rhickeyachim_p_: that's really lame
13:01rhickeywell, it may end up that Date needs a print-method
13:01achim_p_but it *might* end up that lots of classes need a print method ;)
13:02rhickeyachim_p_: that's true
13:09Chouserkotarak: how are you trying to use gen-interface?
13:12kotarakChouser: I did (gen-and-save-interface "some-dir" 'full.qualified.Name ['bla [] Object] ['blub [] Object]). It generated a class file.
13:12kotarakThen using the interface somehow fails, although the file is in the classpath.
13:15Chouserusing it in what way?
13:16kotarak(proxy [Name] [] ....) , or via import. Neither works (it blows the import, or later on the proxy, when using a fully qualified name)
13:16Chouserhm...
13:20Chouserok, I'm seeing that, but I don't understand -- I can use introspection on the interface
13:23kotarakShall I try something on my side?
13:26Chouserno, I've got proxy failing for me here, I just don't understand how, since the introspection works.
13:27kotarakok
13:36achim_p_lisppaste8: url
13:36lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:37lisppaste8achim_p pasted "printing dates" at http://paste.lisp.org/display/68377
13:37Lau_of_DKI'm working on a (supposedly) simple decimal expansion routine, that would expand something like 1/7 to 1.142857. It should expand further than that because the sequence then repeats itself, and it should not expand to anything shorter, because that would be inaccurate. Does anybody here have a few minutes to help out?
13:41achim_p_Lau_of_DK: (double 1/7)?
13:42Lau_of_DKAnd you can see, that expands further than I need
13:42Lau_of_DKI need it to stop as soon as the infinite cycle has been identified
13:42Lau_of_DKHere's a couple of ideas on how to attack it: http://www.bestinclass.dk/download/fraction.clj
13:42Lau_of_DKsadly, neither work, thought I think option #2 is closer to working
13:44Lau_of_DK(just updated)
14:05Chouserkotarak left.
14:06achim_p_Lau_of_DK: mmh, what's your strategy here?
14:06achim_p_i'd first try to obtain a sequence of the digits and then run some cycle-detection algo on it
14:07Lau_of_DKstrategy is this. if x > a, then a*10 goes into recursion. if not, then the first digit of (x / a) is the next digit in my result, and (rem a x) goes into recursion. This breaks when (rem a x) gives a result, which has already been given once before
14:07Lau_of_DKachim_p, that not possible, sometimes I will need to dig deeper than 600 digits
14:09duck1123aren't all iterators seq-able?
14:09duck1123if not, how would I get a seq from one
14:10Chouserduck1123: (seq iterator) ?
14:11duck1123Don't know how to create ISeq from: StmtIteratorImpl
14:11Chouserwhat's a StmtIteratorImpl?
14:12duck1123don't know about the impl part, but http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/model/StmtIterator.html
14:13duck1123got it from this http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/model/Model.html#listStatements()
14:18ChouserHm, seq need it to be Iterable, and oddly Iterator is not?
14:18rhickeyduck1123: (iterator-seq iter)
14:20duck1123that works
14:21gnuvince_rhickey: do the profits for the "State: you're doing it wrong" t-shirt go to you?
14:22achim_p_Lau_of_DK: i might be a bit slow on the uptake atm, but what's the idea behind this approach?
14:23Lau_of_DKNo nothing special, its just imo the simplest approach to computing all the decimals of a decimal expansion, one by one
14:23achim_p_i'd suggest floyd's cycle detection on the sequence of digits, which you can generate as you go
14:23rhickeygnuvince_: what shirt?
14:24achim_p_it's a one pass thing, so it should be reasonably fast
14:24achim_p_Lau_of_DK: http://en.wikipedia.org/wiki/Cycle_detection
14:24gnuvince_http://www.zazzle.com/state_youre_doing_it_wrong_black_shirt-235150036182618712
14:24Chousergnuvince_: the zazzle clojure account is mine currently, and I have so far spent every penny
14:24Chouser...of the $0 it has raised.
14:25gnuvince_ok
14:25Lau_of_DKachim_p_, but its still overkill. If you take the first solution I posted, the bulky one, then it actually generates the sequence justs as its supposed to. All I need to implement is something that abort the whole show, if (rem a x) equals something thats already in list 'modulus'
14:25gnuvince_Chouser: upvote to get more views: http://www.reddit.com/r/programming/comments/76p6s/clojure_tshirt_state_youre_doing_it_wrong/
14:25Chousergnuvince_: The profits will be passed along to Rich.
14:29anynhi
14:31anynI'm a newb, so I'm looking for some basic help. I'm playing around with the java-gnome bindings and, when utilizing Gtk, one must first 'initialize' gtk. In the java-gnome examples, they do this:
14:31anynpublic static void main(String[] args) { Gtk.init(args); ...
14:31achim_p_Lau_of_DK: modulus contains digits, right? how do you handle recurring sequences like 12131213?
14:32anynI'm guessing that, in those examples (I've ran them), args is just an empty String Array
14:32Lau_of_DKI handle them individually. The solution would probably lie in making this work according to my will (= true (some #(= % last) (rest modulus))) and it almost works
14:33Lau_of_DKuser=> (fraction 7.0)
14:33Lau_of_DK(1 4 2 8 5 7 1 4 2 8 5 7)
14:33Lau_of_DKthis is a good expansion, it just runs twice as long as its supposed to
14:34Lau_of_DKthe corresponding sequence of modulus is
14:34Lau_of_DK (fraction 7.0)
14:34Lau_of_DK(3 2 6 4 5 1 3 2 6 4)
14:34Lau_of_DKand at the 2.nd '3', it was supposed to break, that would have given the correct result
14:34anynand the trouble I'm having is in feeding an empty String Array into init
14:35gnuvince_Did you guys get a chance to read my first blog post on Clojure? http://www.reddit.com/r/programming/comments/76ofb/cribbage_points_counter_in_clojure/
14:37anyngnuvince_: talking to me?
14:37Chouseranyn: (make-array String 0) is a zero-length array of String
14:38anynChouser: ah, ok.. I was trying (make-array String 1) and it crashed the gui-Repl :)
14:38Chouserthat would be the right type, but with a null that apparently made gtk mad.
14:39gnuvince_anyn: I was asking in general. I'd like to get feedback for that code.
14:39gnuvince_(especially the count-straight function which makes me cringe)
14:41achim_p_Lau_of_DK: (fraction 7.0) returns about 500 digits for me
14:41Lau_of_DKyes, but notice the commented out line in the beginning of the lop
14:41Lau_of_DK(cond (or (> count 10)
14:41Lau_of_DK (= true (some #(= % last) (rest modulus))))
14:41Lau_of_DKif you use this as the circuit-breaker, then you'll only get a few
14:45Lau_of_DKAccording to my head, this:
14:45Lau_of_DK(= true (some #(= % last) (rest modulus)))
14:45anynChouser: that worked
14:45Lau_of_DKmeans, if the value of the var "last" is found anywhere in "modulus" except for the first value, then break, right?
14:57Lau_of_DKMaybe I'm imaging, but doesn't clojure have something along the lines of (but-last list)
14:57Lau_of_DKsomething that gives me everything, except the last item, and does not throw exceptions
14:58fyuryuLau_of_DK: butlast
14:58Lau_of_DKgreat
14:58Lau_of_DKexactly what I needed.
14:59Lau_of_DKachim_p_, stand down, and thanks alot for looking into it, its working now
14:59duck1123fyuryu: is that lazy?
15:00achim_p_Lau_of_DK: cool. i hate number theory, but at least now i understand that why you're safe to assume that each element in the sequence of recurring digits is unique. :)
15:01Lau_of_DKoh, I sent you out on a mathematical hike?
15:02achim_p_correction: each remainder must be unique. yeah, enough hiking for today.
15:02fyuryuduck1123: no
15:03Lau_of_DKuser=> (fraction 7.0)
15:03Lau_of_DK"1.1428571"
15:03Lau_of_DKuser=> (/ 1 7.0)
15:03Lau_of_DK0.14285714285714285
15:03Lau_of_DKargh, correction
15:04Lau_of_DKuser=> (fraction 7.0)
15:04Lau_of_DK"0.1428571"
15:04Lau_of_DKuser=> (/ 1 7.0)
15:04Lau_of_DK0.14285714285714285
15:04Lau_of_DKthere, now fraction yields the infinite sequence, which is accurate
15:19anynTrying to tie some events into the gui here, in java-gnome bindings. How they do it, as they describe, "you need to hook up a "signal handler" to deal with the 'clicked' signal" ... "Button.Clicked is a Java interface. You create an instance of it to do what you want when the callback happens, and thenn pass it to the Button's connect() method."
15:19anynhttp://java-gnome.sourceforge.net/4.0/doc/examples/button/ExamplePressMe.html
15:20anynSo, I'm trying to figure out how to translate that into clojure
15:20anynI've got something like...
15:21anyn(.connect b (Button. Clicked ... hmm
15:21anynor would it be (.connect b (.Clicked Button.
15:22rhickeyButton$Clicked
15:22anynand then I need to implement the method, as would be done inside java's {}, after the new Button.Clicked()
15:22anynrhickey: $? is that new?
15:22rhickeyanyn: no, that's the JVM name for a nested class
15:23rhickeythen you'll need to use proxy
15:23rhickeyhttp://clojure.org/jvm_hosted
15:23anynok, something analogous to the celcius example
15:25Lau_of_DKanyn, I got this from blackdog, it makes things easier:
15:25Lau_of_DK(defmacro onClick [obj & body]
15:25Lau_of_DK `(. ~obj addActionListener
15:25Lau_of_DK (proxy [ActionListener] []
15:25Lau_of_DK (~'actionPerformed [evt#]
15:25Lau_of_DK ~@body))))
15:28anynLau_of_DK: I'm not quite there yet. still learning defs.. but once I get the hang of it, I'll try to use that.. I'm using the java-gnome binginds too
15:29Lau_of_DKk
15:36anynin "new Button.Clicked()" .. is Clicked() a regular method or a constructor for a class called DeleteEvent? Trying to use proxy.. would I use (.connect b (proxy [Button$Clicked] (onClicked [source] (print "clicked")))) ?
15:36anynor (proxy [Button] [Clicked] (onClicked ...
15:37anynor (proxy [.Clicked Button] (onClicked
15:39rhickey(proxy [Button$Clicked] [] (onClicked ...
15:41anynok, I'll give that a shot
15:48anynUnable to resolve symbol: Button$Clicked in this context
15:49anyni'm running a fairly recent version of clojure
15:53hoeckanyn: have you imported Button$Clicked?
15:54hoeckanyn: or does `Button' on the repl eval to sth useful?
15:57anynhmm. the java version doesn't import it.. but I'll try
15:57rhickeyanyn: you need to import it
15:58anynah.. my bad.. I've never noticed that $ usage yet in clojure
16:03anynit's working slightly
16:08lisppaste8karmazilla pasted "partial reduce patch?" at http://paste.lisp.org/display/68385
16:11rhickeykarmazilla: interesting, but begs the question about currying map, filter etc similarly
16:12karmazillayes it does... should I?
16:12rhickeynot right now, let me think about it
16:13Hunone could also add autocurrying for 2+-adic functions.. not sure if it fits in the picture though
16:13rhickeythat sort of currying is not idiomatic Clojure - people don't expect those functions to return fns
16:14rhickeybut many of the fns are set up for partial application, and could curry
16:15rhickeycould you post on the group so we can get some feedback from more users?
16:15karmazillasure
16:15achim_p_what's the recommended way of providing a print-method for something that already has one (Class, in this case)? switching to the clojure ns and redefining feels wrong.
16:16rhickeyachim_p_: why do you want to do that?
16:24achim_p_rhickey: hm, you're right, it hardly makes sense. different print behaviour (with serialization) is probably better implemented separately
16:24rhickeyachim_p_: you can always build your own multimethod where the default calls print-method
16:25gnuvince_rhickey: are you considering adding currying to clojure?
16:26rhickeygnuvince_: no, karmazilla was suggesting some fns like reduce could curry themselves
16:27gnuvince_OK
16:28gnuvince_Not sure that currying is very "Lispy"
16:28rhickeyI agree
16:29rhickeycurrying is a dubious shorthand, because it requires reader of code to know the arity in order to distinguish a curry from a call
16:30karmazillaI suppose it is kind of foreign to any language that allow callables to have more than one signature
16:31rhickeyit's also weak in being arg-order dependent, thus flip etc
16:31gnuvince_I really like Haskell, but sometimes I think that currying makes some code harder to grasp than it would be otherwise
16:31rhickeyexactly +1 for write, -1 for reader
16:31gnuvince_Especially when people go crazy with currying and function composition.
16:31rhickeywriter
16:32rhickeyI like Clojure's #(), can replace any arg or args easily, stands out that you are doing a partial application and returning a fn
16:32rhickeyand fairly concise
16:32karmazillahaskell takes the consept to the extreme. I'm only suggesting this for a select few functions
16:34rhickeykarmazilla: I understand, and I think if it was very uniform in the libs, i.e. every fn that takes a fn + args can be curried given fn, then maybe
16:35rhickeyotoh I don't want people to presume there is general currying
16:40karmazillaman, language design is hard :)
16:40gnuvince_It is
16:42anynwhen I run (.main Gtk), the repl hangs until I close the gui. I'd like to be able to interactively change the gui while it's running. How does one do that?
16:42rhickeyanyn: can you run the GUI in another thread?
16:45anynyea, would I use a ref or an agent?
16:46rhickeyan agent
16:46rhickeyor just Thread
16:46rhickeyClojure fns are Runnable
16:47anynk
16:49karmazillathat reminds me, BGGA closures can do this trick with single-method interfaces. Can Clojure do that too?
16:50Chousergnuvince_: "for" can walk over more than seq, in which case they act like they're nested. "powerset" could be written with a single "for"
16:50rhickeykarmazilla: no sugar for that yet
17:03lisppaste8achim_p_ pasted "patch: ctor exceptions with class names" at http://paste.lisp.org/display/68389
17:04rhickeyachim_p_: please post patches to group - I can't take patches from pastes, thanks
17:35rhickeyrev 1065 has first steps toward AOT compilation - constants now read from strings in classfiles vs. hand-off from classloader, looking for testers
18:02karmazillait ain't much but my four project euler scripts all seem to work with 1065 :p
18:05rhickeykarmazilla: thanks, I expect most normal stuff to work, but macros that emit tricky constant values might need some print-methods
18:24achim_p_rhickey: ok, i thought such a minor change wasn't worth bothering the mailing list, but i understand there are probably license issues. i just posted it.
18:30mhincheyrhickey: slime fails to start with svn 1065
18:53achim_p_require seems broken
18:54achim_p_when requiring a file that's empty except for a namespace declaration, an exception is thrown: java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0)
18:54achim_p_Caused by: java.lang.IllegalStateException: var: clojure/*loaded-libs* is not public
19:15cadshello
19:16cadsI just watched the clojure video I was impressed
19:18cadsI've been reading about concurrency and wanting to try it... also been interested in lisp
19:19cadsnow I read about clojure and it's very interesting as a lisp with powerful concurrency primitives
19:20cadsbut I don't know whether it will be too hard for me to learn with my schedule
19:21cadsthere is another concurrency-strong language that I've been thinking about, and that is erlang
19:22cadsand I was wondering if I could get your opinions about which of the languages would be more approachable for someone with limited background in writing concurrent code
19:26cadsone thing I was wondering about is whether clojure being a lisp makes learning it particularly difficut
19:34gnuvince_cads: depends on your background.
19:50rhickeymhinchey: what's the error from slime with svn 1065?
19:51mhincheyuser=> java.lang.ExceptionInInitializerError (core.clj:0)
19:51mhincheyuser=> java.lang.Exception: No such var: swank/ignore-protocol-version (NO_SOURCE_FILE:5)
19:51mhincheyuser=> java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:7)
19:53mhincheythat's probably not too helpful. I'll try to debug it more to find out.
19:53cadsI've mostly played around in ruby haskell, in ruby where I loved the friendliness but it didn't seem like it would be simple to do concurrency, and I wanted to be able to redefine some syntax and could not, and in haskell where I loved recursion and the power of algebraic datatypes but where again the level of abstraction needed to do concurrency was too complicated for me to do on my own right away.
19:53achim_p_rhickey: a (require 'anything) triggers a Compiler.resolveIn(current-ns, clojure/*loaded-libs*), which fails because it's not public.
19:54achim_p_that didn't happen in r1064
19:55achim_p_i think that's the same problem mhinchey describes
19:57mhincheyyes, same thing
20:12arbschtcads: that clojure is a lisp does not make it especially difficult
20:17spacebat_cads: erlang is hell bent on concurrency, while other aspects of the language leave much to be desired
20:17spacebat_but its process based concurrency not threading yes?
20:18spacebat_I think clojure has much more sound fundamentals, flexibility of expression with easy and correct thread based concurrency
20:19spacebat_and someday it will probably have the multiprocess/multiserver concurrency of erlang via some library or other
20:48rhickeymhinchey: looking at it now, thanks
21:00rhickeyrev 1066 should help with require error
21:19cadsthanks for the input you guys
21:20rhickeycads: did you get any? I was of for an hour
21:20rhickeyoff
21:24mhincheyrhickey: thanks, slime starts now
21:25rhickeymhinchey: great!
21:34cadsrhickey, yeah, I'm going to go ahead and try messing around with it
21:35cadsI think I'll miss the smalltalk-esque encapsulation and object oriented rapid prototyping from ruby, at least till I learn the idioms
21:36cadsput to get to use java's libraries for graphics and what have you... without having to touch java... seems like a big plus
21:37rhickeycads: you should find a lot of people from similar backgrounds both here and on the group to help out with the paradigm shifts
21:38Chouserruby was my favorite language to play in before Clojure.
21:38rhickeyChouser: do you miss he OO?
21:38rhickeythe
21:39Chouserhaven't yet.
21:39ChouserI fumble a bit with design questions
21:40Chouseras in, I knew OO well enough that most problems have "obvious" design solutions for me
21:42ChouserI'm not there yet with Clojure -- I'm afraid I'm making poor choices of when to use a multimethod, how to structure my data, etc.
21:43ChouserIn practice, the couple times I've chosen poorly, the "refactoring" has been pretty shallow and easy to deal with.
21:46rhickeyI had become so tired of "new class per idea", had already gotten used to using generic data structures even when in C#/Java
21:47cadsruby seems to make it a bit less painless than java
21:48Chouserhm, I was not tired of "new class per idea" in ruby. I saw that as an upgrade from the generic data structures of perl.
21:48rhickeyheh
21:48rhickeyso isn't Clojure similar in that way?
21:49ChouserI loved the ruby generator/iterator stuff, but of course that's a sort of weak echo of macros.
21:50cadsI've been wondering if that isn't that case, too
21:51cadsrubyists seem extremely averse to any kind of macro system
21:52Chouserthat's an interesting point. hadn't thought of it that way. Maybe the difference is that I thought I was supposed to be using objects.
21:53cadseven though ruby it pretty good at defining a domain specific language using its block closures, sometimes the syntax is unwieldly and I wish I could just define a construct
21:53Chouserperl didn't have multimethods and multi-taxonomy inheritence to help manage the generic data structures.
21:54mhincheyrhichey: 1066 causes this exception in my code, still trying to track down the cause: Caused by: java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.Namespace at clojure.lang.Reflector.invokeConstructor(Reflector.java:136)
21:54rhickeymhinchey: do you have a macro that embeds a namespace object in the expansion?
21:55mhincheyyes
21:55rhickeythat's it
21:56cadschouser, was clojure your first introduction to a lisp?
21:56rhickeymhinchey: you can try defining a print-method for Namspace that prints to a #= call to Namespace/find
21:57rhickeyback in a bit
21:57Chousercads: I had made a couple solid runs at CL, but never got comfortable with the parens, and felt betrayed by the lackluster libraries.
22:00ChouserSince much of my "fun" little programs need to plug into other things -- web site, files, directories, GUI toolkits -- I felt like CL was supposed to be this great powerful thing, but it was lots of work to do anything useful.
23:00rhickeymhinchey: I've added a print-method for namespaces, svn rev 1067
23:00mhincheythanks, I'll check it later
23:06spacebat_I've learned a bit of CLOS now, and I wonder if anything like that exists in clojure
23:07spacebat_or do we just have structs and generic methods, and leave the OOP to java
23:08rhickeyClojure has multimethods and ad hoc hierarchies and metadata
23:08rhickeymix and match to make as much OO as the problem requires
23:08spacebat_type hierarchies, like structs that inherit?
23:08anyngtk wants to return a zero at the end of a method. How do I do that?
23:08rhickey(derive :square :rect)
23:08spacebat_ok
23:08spacebat_that sounds sane
23:09anynerm, I mean false
23:09rhickeyuser=> (derive ::square ::rect)
23:09rhickeynil
23:09rhickeyuser=> (isa? ::square ::rect)
23:09rhickeytrue
23:09anyn"return false)
23:09anyns/)/"
23:09Chouseranyn: (fn [] ..... (false))
23:09Chousergah
23:09rhickeyso you can use ns-qualified keywords as 'types', but put them in map attributes, metadata etc
23:10Chouseranyn: (fn [] ..... false)
23:10anynah, ok
23:10spacebatrhickey: I noticed a bunch of projects like dotLisp and foil that you've involved with, are they live/active or more like stepping stones on your way to clojure?
23:10anynperfect
23:11rhickeyspacebat: you can also 'derive' Java classes from keywords, to superimpose additional taxonomies on classes you didn't write
23:11rhickeyspacebat: jFli has seen some enhancement from Nick Levine, the others are static
23:12rhickeyClojure goes way beyond what they could do
23:12spacebatok, yeah I thought if they were live and you were involved, you'd be unspeakably busy
23:12spacebatso there's a clojure book out from pragmatic programmers next march or so?
23:13spacebatI'll have to start reading the docs again, after playing with CL a few months I think things will make more sense
23:14rhickeyspacebat: they work, but one thing I learned was that very very few CL people care about Java integration, yet Clojure proves many people care about Lisp + JVM and the other things Clojure addresses
23:15spacebatwell I like CL, and I have some hopes that Armed Bear CL will get there in the end
23:16spacebatbut I know that lisp needs a single modern implementation to focus on, and clojure might just be it
23:16spacebats/implementation/dialect/
23:17rhickeyI'm on a 'Next 50 Years of Lisp' panel at OOPSLA - should be interesting
23:17spacebatsweet
23:17spacebata bit more conservative than the idea of a '100 year language' like arc
23:18spacebatI want to believe arc is significant, but I've yet to grok what's so good about it
23:18spacebatbeen playing with ECL, librep and picolisp the last little while
23:19spacebatboth librep and picolisp are mentioned as pre-arc arcs by some people
23:19ChouserI used a window manager for a long time that was largely written in librep
23:19spacebatpicolisp is probably the most radical, purely interpreted, functions can mutate their own forms at runtime etc
23:20gnuvince_rhickey: what's that panel gonna address? Multi-core programming?
23:20spacebatsawfish, yes I've been meaning to run that again and play
23:20anynhttp://paste.lisp.org/display/68403
23:21anynconverted the celcius example to java-gnome
23:21anynit's probably more verbose than it needs to be, but it works
23:21spacebatand picolisp has no special forms, you just bypass evaluation by declaring a function like (de myfunc X (;;in here X is a list of all arguments, and you can evaluate what you want))
23:21rhickeygnuvince_: It's a panel - me, Will Clinger, Kent Pitman, and Martin Simmons opining about the future of Lisp
23:22spacebatmacros are just normal functions because everything is runtime
23:22rhickeyClojure represents my opinion pretty well
23:22spacebatI hope they video that talk
23:22gnuvince_I imagine
23:25Chouserhm, using a javascript debugger to examine clojure data structures is ... tricky.
23:52cadsspacebat, have you read heinlein's stranger in a strange land?
23:56spacebatno, its just been on my list forever
23:57spacebatand I've spent enough time on slashdot for grok to slip into my vocab
23:57dnmHowdy.
23:58Chouserdnm: hi!