2008-10-12
| 07:47 | Lau_of_DK | Can somebody enlighten me on the syntax of Cond? |
| 07:57 | hoeck | Lau_of_DK: (cond condition1 expression1 conditionN expressionN ..) |
| 07:58 | Lau_of_DK | hoeck, 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:02 | hoeck | then use multiple ifs, cond is really just a replacement for else-nested ifs |
| 08:03 | Lau_of_DK | k |
| 08:03 | Lau_of_DK | Do we have something like (if (isin list1 list2)) that checks for replicates in either list? |
| 08:05 | hoeck | no, but we have sets, so just use (set/intersection (set list1) (set list2)) |
| 08:05 | Pupeno | Is there a downloadable version of the documentationz |
| 08:05 | Pupeno | Z |
| 08:06 | Pupeno | ? |
| 08:06 | Chouser | http://clojure.googlegroups.com/web/manual.pdf |
| 08:12 | Lau_of_DK | hoeck, first Im using a sequence of LazyCons with integer in it, secondly, my Clojure doesnt have set/intersection, that something new? |
| 08:13 | Pupeno | Chouser: how is that generated, do you know? |
| 08:17 | hoeck | Lau_of_DK: its the set.clj which comes with clojure and the correct name is clojure.set/intersection, sorry |
| 08:18 | hans | Pupeno: custom css, browser printing to acrobat. search the group archive, i posted the css |
| 08:18 | Lau_of_DK | no worries, I got it |
| 08:52 | Lau_of_DK | Is 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:58 | Chouser | "rest", depending on the data structure |
| 08:59 | Lau_of_DK | k, thanks |
| 11:11 | Fanda | hello all! |
| 11:12 | rhickey | hi |
| 11:12 | Fanda | i have couple questions |
| 11:12 | Fanda | one is about contributing |
| 11:12 | Fanda | how do you contribute to clojure-contrib? |
| 11:12 | Fanda | rhickey: I sent you a letter (agreement) |
| 11:13 | rhickey | who is Fanda? |
| 11:13 | Fanda | Frantisek Sodomka |
| 11:14 | Fanda | my usual way is to put code on my website: |
| 11:14 | Fanda | http://intricatevisions.com/index.cgi?page=clojure |
| 11:14 | rhickey | ok, I've got your CA |
| 11:14 | Fanda | good :-) |
| 11:15 | Fanda | my question is, how code gets into clojure-contrib |
| 11:15 | rhickey | first step would be to submit patches for contrib on the Clojure group, the contrib owners will include them if they fit in |
| 11:15 | rhickey | After I get a feel for your contributions I might make you a developer on the SF contrib project |
| 11:16 | rhickey | if you have a whole new lib for contrib, again post to group, I'll look at it and decide |
| 11:16 | Fanda | ok, i see |
| 11:16 | Fanda | i like to contribute anything that I find useful for myself |
| 11:16 | rhickey | what did you want to contribute? |
| 11:18 | Fanda | just a second, i will find it... |
| 11:18 | Fanda | http://groups.google.com/group/clojure/browse_frm/thread/d15f190f09c0eead/bb705e2e2d897349?lnk=gst&q=aspect#bb705e2e2d897349 |
| 11:19 | Fanda | "code sections", which were rewritten Stephen C. Gilardi as "aspects" |
| 11:20 | Fanda | i would put it into some 'util' namespace |
| 11:20 | Fanda | similar goes for http://groups.google.com/group/clojure/browse_frm/thread/d7e82974b2b58d0a/b8f1d7adeba0dfda?lnk=gst&q=time-expr#b8f1d7adeba0dfda |
| 11:21 | rhickey | ok, I remember, sorry I didn't chime in then. Are you familiar with CL #+ and #- ? |
| 11:21 | Fanda | no, I don't really have experience with CL |
| 11:21 | Fanda | what #+ and #- do? |
| 11:23 | rhickey | http://www.lispworks.com/documentation/HyperSpec/Body/02_dhq.htm |
| 11:23 | rhickey | http://www.lispworks.com/documentation/HyperSpec/Body/24_abaa.htm |
| 11:27 | rhickey | better: http://www.lispworks.com/documentation/HyperSpec/Body/24_aba.htm |
| 11:29 | Fanda | yes, (aspect :debug (do-something)) would be (do #+debug (do-something)) |
| 11:30 | rhickey | a big difference is #+/- are reader macros that conditionally read |
| 11:32 | Fanda_ | sorry, my connection isn't too stable |
| 11:32 | Fanda_ | my last sentence was "since # is special for Clojure, it would need to be implemented in the core, right?" |
| 11:33 | rhickey | yes, reader macros have to go in LispReader |
| 11:34 | Fanda_ | it is just a suggestion... i like both versions |
| 11:34 | Fanda_ | i am sure that I will just it when developing, since it is a common pattern |
| 11:34 | rhickey | something like #+ will end up in Clojure |
| 11:37 | Fanda_ | can (do #+debug (do-something)) be somehow rewritten without 'do'? |
| 11:37 | Fanda_ | (#+debug (do-something)) ??? |
| 11:38 | rhickey | #+ turns into whitespace if false |
| 11:39 | Fanda_ | so #+debug (do-something) would be fine |
| 11:39 | rhickey | would just disappear if not debug |
| 11:40 | Fanda_ | yeah, sounds good |
| 11:40 | Fanda_ | sometimes i need to define different levels of debugging - debug-calculation, debug-writing-to-file, debug-ui, ... |
| 11:41 | Fanda_ | or logging - log-xyz, ... |
| 11:41 | Fanda_ | ... so that's where it started :-) |
| 11:42 | rhickey | logging is different - vars help there |
| 11:42 | rhickey | (binding [*log-level* :verbose] ...) |
| 11:43 | Fanda_ | oh, i see |
| 11:43 | Fanda_ | that makes sence |
| 11:43 | Fanda_ | sense |
| 11:43 | kotarak | If I understand correctly, this is compile time. So it's like good olde #ifdef? |
| 11:44 | Fanda_ | yes, exactly |
| 11:44 | rhickey | read-time |
| 11:44 | rhickey | compiler never sees it |
| 11:44 | kotarak | Ok. |
| 11:44 | Fanda_ | preprocessor-time :-) |
| 11:45 | kotarak | as in C. #ifdef is also not seen by the compiler. |
| 11:46 | Fanda_ | ....... |
| 11:46 | Fanda_ | other thing - compiler now has *warn-on-reflection*, right? |
| 11:46 | Fanda_ | i would put it into map |
| 11:46 | Fanda_ | something like *compiler-settings* |
| 11:47 | Fanda_ | and do (def *compiler-settings* {:warn-on-reflection true}) |
| 11:47 | Fanda_ | so that we can easily add more compiler options later... |
| 11:48 | kotarak | I'm not sure, I like this #+ thing.... |
| 11:49 | Fanda_ | syntax of it or the behavior (semantics)? |
| 11:49 | Fanda_ | (still here) |
| 11:49 | kotarak | the behaviour |
| 11:51 | Fanda_ | what don't you like? i find it very useful |
| 11:53 | kotarak | If there something, that can be done with it, which cannot be done with "normal" macros? |
| 11:53 | kotarak | /If/Is/ |
| 11:53 | Fanda_ | it is up to Rich - if he wants it in the core or not |
| 11:53 | Fanda_ | i am ok with macro |
| 11:54 | kotarak | I 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:57 | Fanda_ | ok |
| 11:57 | Fanda_ | other thing: should boot.clj be renamed to clojure.clj??? since it is a 'clojure' namespace? :-) |
| 11:58 | rhickey | kotarak: normal macros can't disappear |
| 11:58 | rhickey | Fanda_: will rename soon |
| 11:58 | Fanda_ | :-) |
| 11:58 | Fanda_ | and what about testing Clojure? |
| 11:59 | Fanda_ | i would create some test-clojure.clj, test-set.clj, ... |
| 11:59 | Fanda_ | to test its correctness |
| 11:59 | rhickey | Fanda_: go for it! |
| 11:59 | kotarak | rhickey: 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:00 | Fanda_ | rhickey: I actually might - it would be a nice exercise |
| 12:00 | Fanda_ | rhickey: once it gets started, other people will join and it can be done very quickly |
| 12:02 | rhickey | kotarak: in source, nil is not the same as whitespace |
| 12:05 | duck1123 | what does it mean if I get an InvocationTargetException when trying to construct an object? |
| 12:07 | kotarak | rhickey: I still don't get the use. It's like old #ifdef. I don't see why I would that. |
| 12:08 | rhickey | duck1123: do you have an example? |
| 12:10 | lisppaste8 | duck1123 pasted "exception when creating object" at http://paste.lisp.org/display/68368 |
| 12:11 | Fanda_ | kotarak: look in thread http://groups.google.com/group/clojure/browse_frm/thread/ce795dd1fb646df1/d1c6c3b3f6485ece |
| 12:11 | Fanda_ | kotarak: download http://groups.google.com/group/clojure/attach/394c5334d6d7e2a1/cfa.clj.zip?part=4 |
| 12:11 | Fanda_ | kotarak: see lines like ;(println (list r g b a));;;;DEBUG |
| 12:12 | Fanda_ | ;(try |
| 12:12 | Fanda_ | ; (println (list 'push cnt (.. Thread (currentThread) (getName)))) |
| 12:12 | Fanda_ | ; (println stack) |
| 12:12 | Fanda_ | ;(catch Exception e (println (list 'exception at c cnt)))) |
| 12:13 | rhickey | duck1123: you might be missing other needed jars - also try putting them in your real classpath vs add-classpath |
| 12:13 | Fanda_ | kotarak: all these lines could be put into #+debug (do ...) |
| 12:14 | Fanda_ | kotarak: #+test (do ...) |
| 12:15 | Fanda_ | rhickey: where does symbol for #+ come from? is it from global namespace? it might cause symbol pollution... |
| 12:15 | Fanda_ | rhickey: aspect macro has (def +aspects+ #{:debug :log0 :log1}) which looks better to me |
| 12:17 | kotarak | Fanda_: And all these lines can be put into macro which conditionally evaluates to nil at compile-time.... But have to go now. Bye. |
| 12:17 | rhickey | CL isn't perfect, but you need to fully understand it before you attempt to better it |
| 12:18 | Fanda_ | bye, kotarak |
| 12:19 | Fanda_ | rhickey: Yeah, no offense. I have no clue about CL. |
| 12:19 | rhickey | more to kotarak's point, there are cases where generating nil is insufficient |
| 12:20 | Fanda_ | yes, I believe in that |
| 12:20 | rhickey | #+it-takes-another-arg that-arg |
| 12:22 | Fanda_ | could you elaborate more, please? |
| 12:24 | karmazilla | is there a literal syntax for BigIntegers, like 3M is a BigDecimal? |
| 12:24 | rhickey | #+ 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:26 | rhickey | karmazilla: no - you want to create a small BigInteger? |
| 12:27 | karmazilla | well.... yes. it just happens to be the only class that have the isProbablyPrime method, that I need for a project euler problem |
| 12:28 | Fanda_ | rhickey: i am still wondering about grouping symbols for #+ |
| 12:28 | Fanda_ | rhickey: maybe just put it into namespace! |
| 12:29 | Fanda_ | rhickey: reader-options/it-takes-another-arg |
| 12:29 | rhickey | karmazilla: (BigInteger/valueOf 123) |
| 12:32 | Fanda_ | 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:32 | Fanda_ | rhickey: good enough |
| 12:35 | Fanda_ | thanks for chatting all! |
| 12:35 | Fanda_ | have to go |
| 12:53 | achim_p_ | hi everyone |
| 12:53 | achim_p_ | rhickey: i like the new #= reader macro and print emitting constructor calls. |
| 12:54 | achim_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:55 | kotarak | back 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:55 | rhickey | achim_p_: there isn't, but the default presumes that might work |
| 12:56 | duck1123 | is 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:57 | danlarkin | duck1123: proxy creates an instance of a class |
| 12:57 | achim_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:58 | achim_p_ | sth like (RT/resurrect \? \? \ |
| 12:58 | achim_p_ | it doesn't look humane at all, but might make serialization via print more generally applicable ... |
| 12:58 | rhickey | achim_p_: how does a date print for you? |
| 12:59 | rhickey | achim_p_: I'd really prefer text serialization |
| 12:59 | achim_p_ | like that: #=(java.util.Date. "Sun Oct 12 18:56:32 CEST 2008") |
| 12:59 | achim_p_ | localization issues, i assume |
| 13:00 | rhickey | achim_p_: that's really lame |
| 13:01 | rhickey | well, it may end up that Date needs a print-method |
| 13:01 | achim_p_ | but it *might* end up that lots of classes need a print method ;) |
| 13:02 | rhickey | achim_p_: that's true |
| 13:09 | Chouser | kotarak: how are you trying to use gen-interface? |
| 13:12 | kotarak | Chouser: I did (gen-and-save-interface "some-dir" 'full.qualified.Name ['bla [] Object] ['blub [] Object]). It generated a class file. |
| 13:12 | kotarak | Then using the interface somehow fails, although the file is in the classpath. |
| 13:15 | Chouser | using it in what way? |
| 13:16 | kotarak | (proxy [Name] [] ....) , or via import. Neither works (it blows the import, or later on the proxy, when using a fully qualified name) |
| 13:16 | Chouser | hm... |
| 13:20 | Chouser | ok, I'm seeing that, but I don't understand -- I can use introspection on the interface |
| 13:23 | kotarak | Shall I try something on my side? |
| 13:26 | Chouser | no, I've got proxy failing for me here, I just don't understand how, since the introspection works. |
| 13:27 | kotarak | ok |
| 13:36 | achim_p_ | lisppaste8: url |
| 13:36 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 13:37 | lisppaste8 | achim_p pasted "printing dates" at http://paste.lisp.org/display/68377 |
| 13:37 | Lau_of_DK | I'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:41 | achim_p_ | Lau_of_DK: (double 1/7)? |
| 13:42 | Lau_of_DK | And you can see, that expands further than I need |
| 13:42 | Lau_of_DK | I need it to stop as soon as the infinite cycle has been identified |
| 13:42 | Lau_of_DK | Here's a couple of ideas on how to attack it: http://www.bestinclass.dk/download/fraction.clj |
| 13:42 | Lau_of_DK | sadly, neither work, thought I think option #2 is closer to working |
| 13:44 | Lau_of_DK | (just updated) |
| 14:05 | Chouser | kotarak left. |
| 14:06 | achim_p_ | Lau_of_DK: mmh, what's your strategy here? |
| 14:06 | achim_p_ | i'd first try to obtain a sequence of the digits and then run some cycle-detection algo on it |
| 14:07 | Lau_of_DK | strategy 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:07 | Lau_of_DK | achim_p, that not possible, sometimes I will need to dig deeper than 600 digits |
| 14:09 | duck1123 | aren't all iterators seq-able? |
| 14:09 | duck1123 | if not, how would I get a seq from one |
| 14:10 | Chouser | duck1123: (seq iterator) ? |
| 14:11 | duck1123 | Don't know how to create ISeq from: StmtIteratorImpl |
| 14:11 | Chouser | what's a StmtIteratorImpl? |
| 14:12 | duck1123 | don't know about the impl part, but http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/model/StmtIterator.html |
| 14:13 | duck1123 | got it from this http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/model/Model.html#listStatements() |
| 14:18 | Chouser | Hm, seq need it to be Iterable, and oddly Iterator is not? |
| 14:18 | rhickey | duck1123: (iterator-seq iter) |
| 14:20 | duck1123 | that works |
| 14:21 | gnuvince_ | rhickey: do the profits for the "State: you're doing it wrong" t-shirt go to you? |
| 14:22 | achim_p_ | Lau_of_DK: i might be a bit slow on the uptake atm, but what's the idea behind this approach? |
| 14:23 | Lau_of_DK | No nothing special, its just imo the simplest approach to computing all the decimals of a decimal expansion, one by one |
| 14:23 | achim_p_ | i'd suggest floyd's cycle detection on the sequence of digits, which you can generate as you go |
| 14:23 | rhickey | gnuvince_: what shirt? |
| 14:24 | achim_p_ | it's a one pass thing, so it should be reasonably fast |
| 14:24 | achim_p_ | Lau_of_DK: http://en.wikipedia.org/wiki/Cycle_detection |
| 14:24 | gnuvince_ | http://www.zazzle.com/state_youre_doing_it_wrong_black_shirt-235150036182618712 |
| 14:24 | Chouser | gnuvince_: the zazzle clojure account is mine currently, and I have so far spent every penny |
| 14:24 | Chouser | ...of the $0 it has raised. |
| 14:25 | gnuvince_ | ok |
| 14:25 | Lau_of_DK | achim_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:25 | gnuvince_ | Chouser: upvote to get more views: http://www.reddit.com/r/programming/comments/76p6s/clojure_tshirt_state_youre_doing_it_wrong/ |
| 14:25 | Chouser | gnuvince_: The profits will be passed along to Rich. |
| 14:29 | anyn | hi |
| 14:31 | anyn | I'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:31 | anyn | public static void main(String[] args) { Gtk.init(args); ... |
| 14:31 | achim_p_ | Lau_of_DK: modulus contains digits, right? how do you handle recurring sequences like 12131213? |
| 14:32 | anyn | I'm guessing that, in those examples (I've ran them), args is just an empty String Array |
| 14:32 | Lau_of_DK | I 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:33 | Lau_of_DK | user=> (fraction 7.0) |
| 14:33 | Lau_of_DK | (1 4 2 8 5 7 1 4 2 8 5 7) |
| 14:33 | Lau_of_DK | this is a good expansion, it just runs twice as long as its supposed to |
| 14:34 | Lau_of_DK | the corresponding sequence of modulus is |
| 14:34 | Lau_of_DK | (fraction 7.0) |
| 14:34 | Lau_of_DK | (3 2 6 4 5 1 3 2 6 4) |
| 14:34 | Lau_of_DK | and at the 2.nd '3', it was supposed to break, that would have given the correct result |
| 14:34 | anyn | and the trouble I'm having is in feeding an empty String Array into init |
| 14:35 | gnuvince_ | 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:37 | anyn | gnuvince_: talking to me? |
| 14:37 | Chouser | anyn: (make-array String 0) is a zero-length array of String |
| 14:38 | anyn | Chouser: ah, ok.. I was trying (make-array String 1) and it crashed the gui-Repl :) |
| 14:38 | Chouser | that would be the right type, but with a null that apparently made gtk mad. |
| 14:39 | gnuvince_ | anyn: I was asking in general. I'd like to get feedback for that code. |
| 14:39 | gnuvince_ | (especially the count-straight function which makes me cringe) |
| 14:41 | achim_p_ | Lau_of_DK: (fraction 7.0) returns about 500 digits for me |
| 14:41 | Lau_of_DK | yes, but notice the commented out line in the beginning of the lop |
| 14:41 | Lau_of_DK | (cond (or (> count 10) |
| 14:41 | Lau_of_DK | (= true (some #(= % last) (rest modulus)))) |
| 14:41 | Lau_of_DK | if you use this as the circuit-breaker, then you'll only get a few |
| 14:45 | Lau_of_DK | According to my head, this: |
| 14:45 | Lau_of_DK | (= true (some #(= % last) (rest modulus))) |
| 14:45 | anyn | Chouser: that worked |
| 14:45 | Lau_of_DK | means, if the value of the var "last" is found anywhere in "modulus" except for the first value, then break, right? |
| 14:57 | Lau_of_DK | Maybe I'm imaging, but doesn't clojure have something along the lines of (but-last list) |
| 14:57 | Lau_of_DK | something that gives me everything, except the last item, and does not throw exceptions |
| 14:58 | fyuryu | Lau_of_DK: butlast |
| 14:58 | Lau_of_DK | great |
| 14:58 | Lau_of_DK | exactly what I needed. |
| 14:59 | Lau_of_DK | achim_p_, stand down, and thanks alot for looking into it, its working now |
| 14:59 | duck1123 | fyuryu: is that lazy? |
| 15:00 | achim_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:01 | Lau_of_DK | oh, I sent you out on a mathematical hike? |
| 15:02 | achim_p_ | correction: each remainder must be unique. yeah, enough hiking for today. |
| 15:02 | fyuryu | duck1123: no |
| 15:03 | Lau_of_DK | user=> (fraction 7.0) |
| 15:03 | Lau_of_DK | "1.1428571" |
| 15:03 | Lau_of_DK | user=> (/ 1 7.0) |
| 15:03 | Lau_of_DK | 0.14285714285714285 |
| 15:03 | Lau_of_DK | argh, correction |
| 15:04 | Lau_of_DK | user=> (fraction 7.0) |
| 15:04 | Lau_of_DK | "0.1428571" |
| 15:04 | Lau_of_DK | user=> (/ 1 7.0) |
| 15:04 | Lau_of_DK | 0.14285714285714285 |
| 15:04 | Lau_of_DK | there, now fraction yields the infinite sequence, which is accurate |
| 15:19 | anyn | Trying 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:19 | anyn | http://java-gnome.sourceforge.net/4.0/doc/examples/button/ExamplePressMe.html |
| 15:20 | anyn | So, I'm trying to figure out how to translate that into clojure |
| 15:20 | anyn | I've got something like... |
| 15:21 | anyn | (.connect b (Button. Clicked ... hmm |
| 15:21 | anyn | or would it be (.connect b (.Clicked Button. |
| 15:22 | rhickey | Button$Clicked |
| 15:22 | anyn | and then I need to implement the method, as would be done inside java's {}, after the new Button.Clicked() |
| 15:22 | anyn | rhickey: $? is that new? |
| 15:22 | rhickey | anyn: no, that's the JVM name for a nested class |
| 15:23 | rhickey | then you'll need to use proxy |
| 15:23 | rhickey | http://clojure.org/jvm_hosted |
| 15:23 | anyn | ok, something analogous to the celcius example |
| 15:25 | Lau_of_DK | anyn, I got this from blackdog, it makes things easier: |
| 15:25 | Lau_of_DK | (defmacro onClick [obj & body] |
| 15:25 | Lau_of_DK | `(. ~obj addActionListener |
| 15:25 | Lau_of_DK | (proxy [ActionListener] [] |
| 15:25 | Lau_of_DK | (~'actionPerformed [evt#] |
| 15:25 | Lau_of_DK | ~@body)))) |
| 15:28 | anyn | Lau_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:29 | Lau_of_DK | k |
| 15:36 | anyn | in "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:36 | anyn | or (proxy [Button] [Clicked] (onClicked ... |
| 15:37 | anyn | or (proxy [.Clicked Button] (onClicked |
| 15:39 | rhickey | (proxy [Button$Clicked] [] (onClicked ... |
| 15:41 | anyn | ok, I'll give that a shot |
| 15:48 | anyn | Unable to resolve symbol: Button$Clicked in this context |
| 15:49 | anyn | i'm running a fairly recent version of clojure |
| 15:53 | hoeck | anyn: have you imported Button$Clicked? |
| 15:54 | hoeck | anyn: or does `Button' on the repl eval to sth useful? |
| 15:57 | anyn | hmm. the java version doesn't import it.. but I'll try |
| 15:57 | rhickey | anyn: you need to import it |
| 15:58 | anyn | ah.. my bad.. I've never noticed that $ usage yet in clojure |
| 16:03 | anyn | it's working slightly |
| 16:08 | lisppaste8 | karmazilla pasted "partial reduce patch?" at http://paste.lisp.org/display/68385 |
| 16:11 | rhickey | karmazilla: interesting, but begs the question about currying map, filter etc similarly |
| 16:12 | karmazilla | yes it does... should I? |
| 16:12 | rhickey | not right now, let me think about it |
| 16:13 | Hun | one could also add autocurrying for 2+-adic functions.. not sure if it fits in the picture though |
| 16:13 | rhickey | that sort of currying is not idiomatic Clojure - people don't expect those functions to return fns |
| 16:14 | rhickey | but many of the fns are set up for partial application, and could curry |
| 16:15 | rhickey | could you post on the group so we can get some feedback from more users? |
| 16:15 | karmazilla | sure |
| 16:15 | achim_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:16 | rhickey | achim_p_: why do you want to do that? |
| 16:24 | achim_p_ | rhickey: hm, you're right, it hardly makes sense. different print behaviour (with serialization) is probably better implemented separately |
| 16:24 | rhickey | achim_p_: you can always build your own multimethod where the default calls print-method |
| 16:25 | gnuvince_ | rhickey: are you considering adding currying to clojure? |
| 16:26 | rhickey | gnuvince_: no, karmazilla was suggesting some fns like reduce could curry themselves |
| 16:27 | gnuvince_ | OK |
| 16:28 | gnuvince_ | Not sure that currying is very "Lispy" |
| 16:28 | rhickey | I agree |
| 16:29 | rhickey | currying is a dubious shorthand, because it requires reader of code to know the arity in order to distinguish a curry from a call |
| 16:30 | karmazilla | I suppose it is kind of foreign to any language that allow callables to have more than one signature |
| 16:31 | rhickey | it's also weak in being arg-order dependent, thus flip etc |
| 16:31 | gnuvince_ | I really like Haskell, but sometimes I think that currying makes some code harder to grasp than it would be otherwise |
| 16:31 | rhickey | exactly +1 for write, -1 for reader |
| 16:31 | gnuvince_ | Especially when people go crazy with currying and function composition. |
| 16:31 | rhickey | writer |
| 16:32 | rhickey | I like Clojure's #(), can replace any arg or args easily, stands out that you are doing a partial application and returning a fn |
| 16:32 | rhickey | and fairly concise |
| 16:32 | karmazilla | haskell takes the consept to the extreme. I'm only suggesting this for a select few functions |
| 16:34 | rhickey | karmazilla: 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:35 | rhickey | otoh I don't want people to presume there is general currying |
| 16:40 | karmazilla | man, language design is hard :) |
| 16:40 | gnuvince_ | It is |
| 16:42 | anyn | when 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:42 | rhickey | anyn: can you run the GUI in another thread? |
| 16:45 | anyn | yea, would I use a ref or an agent? |
| 16:46 | rhickey | an agent |
| 16:46 | rhickey | or just Thread |
| 16:46 | rhickey | Clojure fns are Runnable |
| 16:47 | anyn | k |
| 16:49 | karmazilla | that reminds me, BGGA closures can do this trick with single-method interfaces. Can Clojure do that too? |
| 16:50 | Chouser | gnuvince_: "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:50 | rhickey | karmazilla: no sugar for that yet |
| 17:03 | lisppaste8 | achim_p_ pasted "patch: ctor exceptions with class names" at http://paste.lisp.org/display/68389 |
| 17:04 | rhickey | achim_p_: please post patches to group - I can't take patches from pastes, thanks |
| 17:35 | rhickey | rev 1065 has first steps toward AOT compilation - constants now read from strings in classfiles vs. hand-off from classloader, looking for testers |
| 18:02 | karmazilla | it ain't much but my four project euler scripts all seem to work with 1065 :p |
| 18:05 | rhickey | karmazilla: thanks, I expect most normal stuff to work, but macros that emit tricky constant values might need some print-methods |
| 18:24 | achim_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:30 | mhinchey | rhickey: slime fails to start with svn 1065 |
| 18:53 | achim_p_ | require seems broken |
| 18:54 | achim_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:54 | achim_p_ | Caused by: java.lang.IllegalStateException: var: clojure/*loaded-libs* is not public |
| 19:15 | cads | hello |
| 19:16 | cads | I just watched the clojure video I was impressed |
| 19:18 | cads | I've been reading about concurrency and wanting to try it... also been interested in lisp |
| 19:19 | cads | now I read about clojure and it's very interesting as a lisp with powerful concurrency primitives |
| 19:20 | cads | but I don't know whether it will be too hard for me to learn with my schedule |
| 19:21 | cads | there is another concurrency-strong language that I've been thinking about, and that is erlang |
| 19:22 | cads | and 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:26 | cads | one thing I was wondering about is whether clojure being a lisp makes learning it particularly difficut |
| 19:34 | gnuvince_ | cads: depends on your background. |
| 19:50 | rhickey | mhinchey: what's the error from slime with svn 1065? |
| 19:51 | mhinchey | user=> java.lang.ExceptionInInitializerError (core.clj:0) |
| 19:51 | mhinchey | user=> java.lang.Exception: No such var: swank/ignore-protocol-version (NO_SOURCE_FILE:5) |
| 19:51 | mhinchey | user=> java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:7) |
| 19:53 | mhinchey | that's probably not too helpful. I'll try to debug it more to find out. |
| 19:53 | cads | I'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:53 | achim_p_ | rhickey: a (require 'anything) triggers a Compiler.resolveIn(current-ns, clojure/*loaded-libs*), which fails because it's not public. |
| 19:54 | achim_p_ | that didn't happen in r1064 |
| 19:55 | achim_p_ | i think that's the same problem mhinchey describes |
| 19:57 | mhinchey | yes, same thing |
| 20:12 | arbscht | cads: that clojure is a lisp does not make it especially difficult |
| 20:17 | spacebat_ | cads: erlang is hell bent on concurrency, while other aspects of the language leave much to be desired |
| 20:17 | spacebat_ | but its process based concurrency not threading yes? |
| 20:18 | spacebat_ | I think clojure has much more sound fundamentals, flexibility of expression with easy and correct thread based concurrency |
| 20:19 | spacebat_ | and someday it will probably have the multiprocess/multiserver concurrency of erlang via some library or other |
| 20:48 | rhickey | mhinchey: looking at it now, thanks |
| 21:00 | rhickey | rev 1066 should help with require error |
| 21:19 | cads | thanks for the input you guys |
| 21:20 | rhickey | cads: did you get any? I was of for an hour |
| 21:20 | rhickey | off |
| 21:24 | mhinchey | rhickey: thanks, slime starts now |
| 21:25 | rhickey | mhinchey: great! |
| 21:34 | cads | rhickey, yeah, I'm going to go ahead and try messing around with it |
| 21:35 | cads | I think I'll miss the smalltalk-esque encapsulation and object oriented rapid prototyping from ruby, at least till I learn the idioms |
| 21:36 | cads | put to get to use java's libraries for graphics and what have you... without having to touch java... seems like a big plus |
| 21:37 | rhickey | cads: you should find a lot of people from similar backgrounds both here and on the group to help out with the paradigm shifts |
| 21:38 | Chouser | ruby was my favorite language to play in before Clojure. |
| 21:38 | rhickey | Chouser: do you miss he OO? |
| 21:38 | rhickey | the |
| 21:39 | Chouser | haven't yet. |
| 21:39 | Chouser | I fumble a bit with design questions |
| 21:40 | Chouser | as in, I knew OO well enough that most problems have "obvious" design solutions for me |
| 21:42 | Chouser | I'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:43 | Chouser | In practice, the couple times I've chosen poorly, the "refactoring" has been pretty shallow and easy to deal with. |
| 21:46 | rhickey | I had become so tired of "new class per idea", had already gotten used to using generic data structures even when in C#/Java |
| 21:47 | cads | ruby seems to make it a bit less painless than java |
| 21:48 | Chouser | hm, 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:48 | rhickey | heh |
| 21:48 | rhickey | so isn't Clojure similar in that way? |
| 21:49 | Chouser | I loved the ruby generator/iterator stuff, but of course that's a sort of weak echo of macros. |
| 21:50 | cads | I've been wondering if that isn't that case, too |
| 21:51 | cads | rubyists seem extremely averse to any kind of macro system |
| 21:52 | Chouser | that'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:53 | cads | even 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:53 | Chouser | perl didn't have multimethods and multi-taxonomy inheritence to help manage the generic data structures. |
| 21:54 | mhinchey | rhichey: 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:54 | rhickey | mhinchey: do you have a macro that embeds a namespace object in the expansion? |
| 21:55 | mhinchey | yes |
| 21:55 | rhickey | that's it |
| 21:56 | cads | chouser, was clojure your first introduction to a lisp? |
| 21:56 | rhickey | mhinchey: you can try defining a print-method for Namspace that prints to a #= call to Namespace/find |
| 21:57 | rhickey | back in a bit |
| 21:57 | Chouser | cads: I had made a couple solid runs at CL, but never got comfortable with the parens, and felt betrayed by the lackluster libraries. |
| 22:00 | Chouser | Since 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:00 | rhickey | mhinchey: I've added a print-method for namespaces, svn rev 1067 |
| 23:00 | mhinchey | thanks, I'll check it later |
| 23:06 | spacebat_ | I've learned a bit of CLOS now, and I wonder if anything like that exists in clojure |
| 23:07 | spacebat_ | or do we just have structs and generic methods, and leave the OOP to java |
| 23:08 | rhickey | Clojure has multimethods and ad hoc hierarchies and metadata |
| 23:08 | rhickey | mix and match to make as much OO as the problem requires |
| 23:08 | spacebat_ | type hierarchies, like structs that inherit? |
| 23:08 | anyn | gtk wants to return a zero at the end of a method. How do I do that? |
| 23:08 | rhickey | (derive :square :rect) |
| 23:08 | spacebat_ | ok |
| 23:08 | spacebat_ | that sounds sane |
| 23:09 | anyn | erm, I mean false |
| 23:09 | rhickey | user=> (derive ::square ::rect) |
| 23:09 | rhickey | nil |
| 23:09 | rhickey | user=> (isa? ::square ::rect) |
| 23:09 | rhickey | true |
| 23:09 | anyn | "return false) |
| 23:09 | anyn | s/)/" |
| 23:09 | Chouser | anyn: (fn [] ..... (false)) |
| 23:09 | Chouser | gah |
| 23:09 | rhickey | so you can use ns-qualified keywords as 'types', but put them in map attributes, metadata etc |
| 23:10 | Chouser | anyn: (fn [] ..... false) |
| 23:10 | anyn | ah, ok |
| 23:10 | spacebat | rhickey: 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:10 | anyn | perfect |
| 23:11 | rhickey | spacebat: you can also 'derive' Java classes from keywords, to superimpose additional taxonomies on classes you didn't write |
| 23:11 | rhickey | spacebat: jFli has seen some enhancement from Nick Levine, the others are static |
| 23:12 | rhickey | Clojure goes way beyond what they could do |
| 23:12 | spacebat | ok, yeah I thought if they were live and you were involved, you'd be unspeakably busy |
| 23:12 | spacebat | so there's a clojure book out from pragmatic programmers next march or so? |
| 23:13 | spacebat | I'll have to start reading the docs again, after playing with CL a few months I think things will make more sense |
| 23:14 | rhickey | spacebat: 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:15 | spacebat | well I like CL, and I have some hopes that Armed Bear CL will get there in the end |
| 23:16 | spacebat | but I know that lisp needs a single modern implementation to focus on, and clojure might just be it |
| 23:16 | spacebat | s/implementation/dialect/ |
| 23:17 | rhickey | I'm on a 'Next 50 Years of Lisp' panel at OOPSLA - should be interesting |
| 23:17 | spacebat | sweet |
| 23:17 | spacebat | a bit more conservative than the idea of a '100 year language' like arc |
| 23:18 | spacebat | I want to believe arc is significant, but I've yet to grok what's so good about it |
| 23:18 | spacebat | been playing with ECL, librep and picolisp the last little while |
| 23:19 | spacebat | both librep and picolisp are mentioned as pre-arc arcs by some people |
| 23:19 | Chouser | I used a window manager for a long time that was largely written in librep |
| 23:19 | spacebat | picolisp is probably the most radical, purely interpreted, functions can mutate their own forms at runtime etc |
| 23:20 | gnuvince_ | rhickey: what's that panel gonna address? Multi-core programming? |
| 23:20 | spacebat | sawfish, yes I've been meaning to run that again and play |
| 23:20 | anyn | http://paste.lisp.org/display/68403 |
| 23:21 | anyn | converted the celcius example to java-gnome |
| 23:21 | anyn | it's probably more verbose than it needs to be, but it works |
| 23:21 | spacebat | and 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:21 | rhickey | gnuvince_: It's a panel - me, Will Clinger, Kent Pitman, and Martin Simmons opining about the future of Lisp |
| 23:22 | spacebat | macros are just normal functions because everything is runtime |
| 23:22 | rhickey | Clojure represents my opinion pretty well |
| 23:22 | spacebat | I hope they video that talk |
| 23:22 | gnuvince_ | I imagine |
| 23:25 | Chouser | hm, using a javascript debugger to examine clojure data structures is ... tricky. |
| 23:52 | cads | spacebat, have you read heinlein's stranger in a strange land? |
| 23:56 | spacebat | no, its just been on my list forever |
| 23:57 | spacebat | and I've spent enough time on slashdot for grok to slip into my vocab |
| 23:57 | dnm | Howdy. |
| 23:58 | Chouser | dnm: hi! |