#clojure log - Dec 14 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:18 gnuvince_: Don't you hate it when you get a NO_SOURCE_FILE:0 error?

0:18 mmcgrana: are you not using repl-ln?

0:18 gnuvince_: no

0:19 mmcgrana: not not using it or not using it? lol

0:19 gnuvince_: Not using it.

0:20 mmcgrana: well just remember that the regular repl doesn't feed line numbers to the compiler. hence an error in code entered in the repl has that message. repl-ln is very nice you should try it

0:23 gnuvince_: k

0:23 mmcgrana: 1:3 user=> (max) java.lang.IllegalArgumentException: Wrong number of args passed to: core$max (repl-1:3)

0:24 just so you can see what the repl line numbering looks like

0:25 gnuvince_: Does that tell where the error occured in the file that was required?

0:27 mmcgrana: if there error was in another file it should show up as such in the regular repl anyways. you might have an error in the declaration getting those resorces. happens to me alot with (ns and all the (:use and (:import stuff etc.

0:27 gnuvince_: bleh

0:27 => (fetch-comic (first *comics*))

0:27 java.lang.NullPointerException (repl-1:7)

0:28 mmcgrana: try (first *comics*)

0:28 gnuvince_: 1:8 net.gnuvince.comics=> (first *comics*)

0:28 {:prefix "", :regex #"http://abstrusegoose.com/strips/.+?\.(?:jpg|gif|png)", :url "http://abstrusegoose.com/", :name "Abstruse Goose"}

0:29 mmcgrana: hmm, and line 7 is the line you invoked the call from, so not helpful?

0:29 gnuvince_: The error is somewhere in fetch-comic

0:29 I'd really love to know *which* line

0:31 mmcgrana: oic. well im not positive but i think that with clojure it only puts line numbers for the entire fn in the bytecodes. now often you have nested fns with e.g. #(foo %) and (fn [] (foo)) but otherwise i dont think there is anything we can do

0:31 except look at fetch-comic and think about it deeply

0:31 ):

0:33 gnuvince_: Which is code I don't really care to look at, cause it's a bunch of Java stuff :-/

0:33 (proxy and stuff like that)

0:34 mmcgrana: http?

0:34 gnuvince_: yeah

0:34 mmcgrana: i've actually been working on an http lib

0:34 gnuvince_: It's more HTML parsing actually.

0:34 mmcgrana: oic. need hpricot port (:

0:34 gnuvince_: something like that

0:35 mmcgrana: its still on my list. i'll have a month off over january to pound out some serious clojure code

0:37 gnuvince_: I dislike Java's handling of namespaces

0:37 with all that org.bar.whatever business

0:38 zakwilson: Isn't that just a convention?

0:38 gnuvince_: zakwilson: don't you need to declare your namespace name exactly as the directory structure?

0:39 like net/gnuvince/comics.clj needs to be (ns 'net.gnuvince.comics)?

0:39 zakwilson: I think you do. I didn't understand exactly what you didn't like.

0:39 mmcgrana: right, the convention part is the choice of net.gnuvince.comics

0:40 gnuvince_: That's a part of Clojure I really don't understand well

0:41 zakwilson: I can see the benefit - it means the locations of things will be very predictable.

0:43 gnuvince_: I guess I'll need to dish out the cash to get an early beta of Stu's book.

0:54 Chouser: new chart: http://clojure.googlegroups.com/web/chart.png

0:54 diamonds are non-clojure classes

0:54 interfaces, actually.

0:56 mmcgrana: Chouser: very nice, thanks

0:56 Chouser: you're welcome!

0:56 I'll put the code up somewhere tomorrow. But for now, bed...

6:27 Lau_of_DK: Good afternoon gents

6:27 bOR_: and to you.

9:09 RSchulz: clojurebot: svn?

9:09 clojurebot: svn is https://clojure.svn.sourceforge.net/svnroot/clojure/

9:09 RSchulz: clojurebot: latest?

9:09 clojurebot: latest is 1159

9:09 RSchulz: clojurebot: contrib?

9:09 clojurebot: contrib is http://sourceforge.net/projects/clojure-contrib/

9:09 RSchulz: clojurebot: contrib latest?

9:09 clojurebot: contrib is http://sourceforge.net/projects/clojure-contrib/

9:35 Chouser: RSchulz: http://clojure.googlegroups.com/web/chart.png

9:36 RSchulz: New one?

9:36 Chouser: yep.

9:36 RSchulz: What are diamonds?

9:36 Chouser: non-clojure classes

9:36 it it better or too crowded now?

9:37 RSchulz: I strongly prefer being able to fit it on one page, so no, not too crowded. You should post the code somewhere, too.

9:37 Can DOT produce SVG output?

9:37 Chouser: yeah, working on that.

9:38 yep

9:38 that .png is actually dot->svg->inkscape->png

9:38 RSchulz: Is there something about that route that's preferable to getting PNG directly from dot?

9:39 Anyway, I like it.

9:39 I still think it deserves the caption: "What a tangled web we weave..."

9:39 Chouser: yes, I think the text layout looks better

9:40 RSchulz: Diagmonds are interfaces?

9:40 You're a Linux user?

9:40 Chouser: diamonds are standard Java interfaces. everything in an oval is in clojure.lang

9:41 yep

9:41 RSchulz: The Obj / IObj stuff is a recent addition? I don't remember seeing that before.

9:42 This is one of the few times I wish I had a color printer.

9:42 I like the inclusion of the built-in predicates for those types that have them.

9:43 How long have you been doing FP?

10:34 duck1123: Chouser: is it possible to get the SVG version of that chart?

10:52 RSchulz: Chouser: +1 for duck1123's request; Also...

10:53 Did you have to manually alter the DOT's layout in Inkskape?

12:17 replaca: Q: Can the reader read hex constants a la #x1FC in common lisp?

12:26 kotarak: replaca: I think so.

12:26 Just x1fc should be fine.

12:27 replaca: ahh, let me try

12:27 kotarak: No.

12:27 rhickey: user=> 0x1cf

12:27 463

12:27 kotarak: You need a zero

12:27 Ah. right Rich was faster

12:27 replaca: yup, otherwise it's a symbol

12:28 thanks rich, sorry to bother with uch a mindane Q, but I wasn't seeing it in the doc

12:28 *uch => such

12:29 argh typos! still on the first cup of coffee :-)

13:02 RSchulz: Q: Can (declare ...)-ed names be (defn- ...)-ed? That is, will (declare ...) work for private defns?

13:08 Chousuke: RSchulz: I think private defs differ from regular ones only by having the :private metadata key set to true, so I don't see why that wouldn't work

13:09 RSchulz: OK. I figured it should, but wanted to check.

13:09 Many years of C and a few of C++ have made me wary of learning a language through empirical observation...

13:46 Is there a way to get struct keys from a struct basis? (keys (create-struct ...)) fails with "IllegalArgumentException: Don't know how to create ISeq from: Def"

13:56 clojurebot: 1159

13:56 clojurebot: Gabh mo leithsc�al?

13:57 RSchulz: clojurebot: svn 1159

13:57 clojurebot: svn is https://clojure.svn.sourceforge.net/svnroot/clojure/

13:57 RSchulz: clojurebot: 1159?

13:57 clojurebot: Gabh mo leithsc�al?

13:57 mehrheit: svn rev 1159

13:57 clojurebot: svn rev 1159; proxy perf tweaks Note breaking change if you are using the proxy interface other than the proxy macro itself - proxy maps are now maps of (preferably interned) strings to fns, not symbols to fns, and if you construct a proxy manually you must establish initial map with init-proxy

13:59 RSchulz: mehrheit: Thank you!

14:38 Chouser: RSchulz: (.get (first (.getDeclaredFields (class x))) x)

14:38 But of course that's not really supported.

14:38 RSchulz: What is it?

14:39 Oh, the struct question.

14:39 Chouser: yeah

14:39 RSchulz: Do you think it's something that should be supported? I'm trying not to have to replicate the set of struct keys in the code.

14:39 To avoid the possibility of them being out-of-sync.

14:40 Chouser: depends on why you need them, I suppose.

14:40 RSchulz: It's something I always like to do. It's sort of like a kind of normalization for source code.

14:40 danm_: Chouser: print-dup doesn't seem to work with PersistentStructMap, is that intended?

14:41 rhickey: danm_: struct maps aren't serializable yet

14:41 danm_: rhickey: yeah, figured as much looking through the code

14:41 thanks

14:42 Chouser: RSchulz: I agree you don't want to repeat yourself

14:43 rhickey: clojurebot: faq #1

14:43 clojurebot: Excuse me?

14:43 rhickey: clojurebot: FAQ #1

14:43 clojurebot: FAQ #1 is http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b

14:44 Chouser: RSchulz: though you could (def sk [:a :b :c]) (def s (apply create-struct sk))

14:44 RSchulz: Yes, I thought of that.

14:44 It's still cleaner to create the struct basis and have that be the locus of all information about that struct.

14:44 Chouser: RSchulz: the question is why your program wants to treat the included keys differently from the others.

14:45 RSchulz: It's the reverse, I want to have separate processing for the onese that are _not_ in the struct basis.

14:46 Chouser: RSchulz: ok, but what and why?

14:46 my point is that it's a bit of an implementation detail, at least right now.

14:46 RSchulz: Does it really matter? I'd have explain a lot of what I'm doing.

14:47 It's certainly not an implementation detail to know what keys comprise a struct basis, is it?

14:47 In a dynamic language?

14:47 rhickey: moving to EPL - prefer: http://opensource.org/licenses/eclipse-1.0.php or http://www.eclipse.org/org/documents/epl-v10.html as the license URL, i.e. does opensource.org add any value?

14:49 rsynnott: rhickey: probably doesn't make much difference

14:49 what license is it at the moment?

14:49 rhickey: CPL

14:49 rsynnott: ah

14:50 why're you changing?

14:50 rhickey: EPL is successor to CPL, acceptable to Google Code and others

14:51 rsynnott: ah, right

15:01 Chouser: RSchulz: I didn't make any changes to the graph in inkscape, though perhaps adding a legend would good.

15:04 clojurebot: svn rev 1160; Moved to Eclipse Public License - see epl-v10.html or http://opensource.org/licenses/eclipse-1.0.php

15:06 rhickey: Chouser: getting ready to move to google code - have created clojure and clojure-contrib projects there

15:06 Chouser: Do you have a Google Code account?

15:07 Also any other contib members here?

15:09 Chouser: rhickey: yep, username chouser

15:09 rhickey: chouser@gmail.com?

15:09 Chouser: yes.

15:20 RSchulz: rhickey: Does this mean you're vacating the SourceForge project?

15:21 rhickey: RSchulz: there are several steps involved - still looking into what it takes to move the code, which is all that is left as SF

15:21 at SF

15:21 RSchulz: There are advantages to hosting at Google Code?

15:22 rhickey: RSchulz: hopefully more usable issue tracking and wiki

15:22 RSchulz: Ah. It's true SF's bug tracking and forum interfaces are pretty bad.

15:24 rhickey: right, google group replaces forums, I pay for wikispaces rather than deal with SF's subframing of it, and SF's issue tracking is awful

15:26 RSchulz: Does this entail switching to Git?

15:26 * Chouser doubts it

15:27 * RSchulz is glad

15:27 RSchulz: Uh... Not mercurial, either, right? In other words, sticking with Subversion?

16:27 gp: anyoen could link me to monads in clojure?

16:29 Chouser: did you search on the google group? they come up there from time to time.

16:29 gp: on my way

16:30 jcrites: I didn't know Clojure had a monad representation .... gp send me a link if you find something :)

16:30 gp: rhickey: could there be made some sort of optimization or auto-parallellism with macros+monads in clojure?

16:30 rhickey: http://groups.google.com/group/clojure/browse_thread/thread/9581bf66eb01ca56/8b8f03bcd5854164?lnk=gst&q=monads#8b8f03bcd5854164

16:34 Lau_of_DK: Evening gentlement

16:34 -t

16:34 :)

16:35 danm_: hello

16:56 gp: ((comp map filter) #(* % %) #(< % 5) [1 2 3 4 5 6 7 8 9])

16:57 wrong number of args, ok but how do i write it then?

16:58 Lau_of_DK: (doc comp)

16:58 clojurebot: Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.; arglists ([& fs])

16:58 Lau_of_DK: I havent used that function before, bt it says that its return is a function

16:59 So wouldnt it be (map (comp #(* % %) #(< % 5)) [1 2 3 4]) ?

17:02 kotarak: (map #(* % %) (filter #(< % 5) [1 2 3 4]))

17:04 ((comp #(* % %) #(< % 5)) 2) => (< 2 5) is true => (* true true) => ?

17:10 Chousuke: gp: ((comp (partial map #(* % %)) (partial filter #(< % 5))) [1 2 3 4 5 6 7 8]) works but you'll really want just (map #(* % %) (filter #(< % 5) [1 2 3 4 5 6 7]))

17:13 or at least give the component functions names before composing :)

17:30 alphazero: hi all, have a question regarding http://paste.lisp.org/display/72155

17:31 test.Foo.doX() simply does a stack trace. first version seems to be basically to the metal, but the variant that calls a method on the instance later is using reflection. Why is that?

17:48 wipewindows: i successfully send the message but the

17:48 can someone explain to me how do use agents there?

17:48 http://hpaste.org/13078

17:48 i successfully send the message but it doesnt seem to get updated.

17:50 * alphazero steps aside to do other stuff but will check to see if anyone answered. tia.

18:03 Chouser: alphazero: since locals are immutable, Clojure can apparently infer that your first 'a' will always be a test.Foo

18:03 alphazero: but that may not be a valid assumption for (def a ...)

18:04 you should be able to type hint, to avoid the reflection though: (def #^test.Foo a (new test.Foo))

18:08 wipewindows: would it be possible to write a macro that tags types to a function?

18:09 using :inline will that inline it as java code or what des that mean?

18:23 Chouser: sure, you can emit metadata-related code from macros

18:24 the :inline stuff essentially allows you to create a function that in some cases can expand into inline clojure like a macro does

18:25 inline in clojure means inline in the generate java bytecode, which I suppose can allow HotSpot to do better optimization.

18:43 alphazero: Chouser: thanks. let me try that and see.

18:45 Chouser: that did it. Thanks.

18:51 RSchulz: Q: If I have a Java Iterator, how can I iterate over the values it yields?

18:52 user=> (doseq [erec (.iterateErrors psl-all-proc)] (println erec))

18:52 java.lang.IllegalArgumentException: Don't know how to create ISeq from: Itr

18:52 danm_: RSchulz: iterate?

18:53 RSchulz: See above...

18:53 danm_: mmm, sorry

18:53 RSchulz: Iterator<ErrorRecord> iterateErrors()

18:53 Iterate over recorded ErrorRecords.

18:53 blackdog: try putting a seq round it?

18:53 RSchulz: I did that. Exact same diagnostic from Clojure.

18:55 danm_: yeah, the sequence functions call seq for you afaik

18:56 RSchulz: Also...

18:56 user=> (.iterateErrors psl-all-proc)

18:56 #<Itr java.util.AbstractList$Itr@195dd5b>

18:58 danm_: I guess only collections are seq-able

18:58 RSchulz: OK. Flipping it around, what _can_ we do with Java Iterator instances?

18:59 danm_: well, anything you can do in java ;)

18:59 hiredman: there is a function that makes seqs out of iterators

18:59 (doc iterator-seq)

18:59 clojurebot: Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly.; arglists ([iter])

18:59 danm_: cool

18:59 RSchulz: Yeah. I just found that.

19:00 So anything Iterable is directly useable as a seq but not a naked Iterator?

19:00 I once asked on the Advanced-Java list why Iterators weren't themselves Iterable.

19:00 hiredman: thats how it reads to me

19:00 RSchulz: But it's moot, of course. They are what they are. I wrote my own IterableIterator class to wrap aribtrary iterators and make them Iterable.

19:01 hiredman: heh

19:01 RSchulz: This particular class's iterator-generating function must have pre-dated the inception of that class.

19:01 hiredman: cute

19:02 RSchulz: God, I love writing my own software. Got a problem with your API? Enhance it!

19:02 Chousuke: I guess an iterator itself is not iterable... but still, it sounds a bit weird

19:03 RSchulz: Chousuke: It definitely is not.

19:04 And just like that, problem solved!

19:04 Chousuke: looks like the iterator interface only specifies the "iterator" function... could be confusing to have iterators return themselves I suppose :/

19:07 rhickey: (doc iterator-seq)

19:07 clojurebot: Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly.; arglists ([iter])

19:10 slangan: octave has a c++ api, does that mean i have to write c++ -> java -> clojure?

19:15 RSchulz: You don't _have to_ do anything, of course.

19:15 rhickey: https://jna.dev.java.net/

19:16 People have done JNA directly from Clojure

19:27 aperotte: hello all, I've posted about this before, but I've been trying for a little while and I for some reason really can't get the new gen-class to work well, was wondering if someone could help me out

19:27 More specifically I don't really understand how exposes works

19:29 I am exposing an ancestral protected member, but after compiling, I can only call the public getter from the instance (not from the class) and also it returns nil instead of the thing I was expecting it to get

19:33 rhickey: aperotte: can you paste something?

19:34 RSchulz: Is it possible to call void (-returning) methods of Java classes?

19:34 aperotte: rhickey: sure, give me a second

19:37 phf: is it possible to extract source location information from java side?

19:38 rhickey: phf: you can call any Clojure fn from Java

19:39 get vars with RT.var("ns","name");

19:39 call them with invoke()

19:41 whidden: changes in 1160 just the move to eclipse public license?

19:42 rhickey: whidden: yes

19:44 whidden: rhickey: Thanks, saw all the updates and was now sure what was happening :)

19:46 phf: rhickey: sorry, i wasn't at all clear. i meant, is it possible to get the source file location for a java class at run time

19:46 for jumping to source in slime

19:46 apparently not (or only using heuristics anyway)

19:47 rhickey: phf: ah, that's a debugger thing I think

19:48 phf: oh, yeah, that's a good idea

19:50 RSchulz: What determines argument compatibility in calling Java methods? I've got a call that appears to be valid, but is eliciting this:

19:50 java.lang.IllegalArgumentException: No matching method found: printMessage for class rrs.util.ErrorRecord

19:50 The method in question "returns" void.

19:51 rhickey: RSchulz: the return value is irrelevant for matching - is the method overloaded?

19:51 RSchulz: Yes. Two different kinds of output sinks.

19:51 PrintStream and PrintWriter. I'm calling it with *out* (the default one)

19:52 It's also overrided for different arities.

19:52 rhickey: user=> (supers (class *out*))

19:52 #{java.io.Writer java.io.Closeable java.lang.Object java.lang.Appendable java.io.Flushable}

19:52 *out* is neither of those

19:53 RSchulz: Gagh. Why not?

19:53 Why isn't it System.out?

19:53 rhickey: user=> (class *out*)

19:53 java.io.OutputStreamWriter

19:55 RSchulz: But why is it not simpley equal to java.lang.System/out?

19:57 ???

19:58 rhickey: I'd really like to know why *out* is distinct both in value and type from System.out?

19:59 aperotte: rhickey: paste.lisp.org worked without the channel. Here's my paste, http://paste.lisp.org/display/72170

20:00 rhickey: RSchulz: printing is defined in terms of Writers, which are more useful and avalable than PrintStreams - note how few subclasses of PrintStream there are

20:01 RSchulz: More useful is pretty subjective. I'm fine with it being a PrintWriter, but a mere Writer? Could you make it a PrintWriter?

20:17 rhickey: RSchulz: why don't you bring it up on the group? - I know there were some issues with charsets

20:17 RSchulz: OK. I'll send out a short message on the issue.

20:18 Huh. I just noticed this:

20:18 user=> *err*

20:18 #<PrintWriter java.io.PrintWriter@6397eb>

20:24 aperotte: rhickey: I need to reboot, I'll brb

20:31 rhickey: you have any thoughts on what I might be doing wrong?

20:48 wipewindows: rhickey: was that for me before? could I somehow call a C++ API from Clojure you mean?

20:50 Chouser: wipewindows: http://groups.google.com/group/clojure/browse_thread/thread/77e626c5440bf1a0

20:59 aperotte: rhickey: I have to run, but thanks for offering to help

21:00 RSchulz: aperotte: I had the same problem with paste.lisp.org yesterday. If I selected #clojure as the channel, my paste just disappeared. Only when I did not select a channel (as Rich suggested) was I able to get the paste recorded.

21:01 aperotte: RSchulz: I'm not sure what's going on with it, it doesn't seem to be affecting all of the channels

21:02 RSchulz: I only tried #clojure, though I did that a couple of times. But it was also the case that the whole site appeared to be having serious problems at the time I was trying to use it. One time I got a 502 error.

21:04 rhickey: aperotte: :exposes doesn't handle static fields as static getters/setters, probably should

21:06 aperotte: rhickey: oh ok, thanks! I'm still unsure what was going wrong with the first thing I tried to expose there. Do I need to specify in the methods the return type of the public getter?

21:08 rhickey: sadly, I really have to go, thanks again

21:08 rhickey: aperotte: no - it will match the type of the field

21:09 aperotte: rhickey: ok, I'll try again

21:22 phf: starting a jvm with a remote debugger and then recursively connecting from the inside allows for all sorts of introspection capabilities

21:22 for example, to answer my original question

21:22 (.sourcePath (.location (.concreteMethodByName (first (.classesByName vm (.getName (class [1 2 3])))) "count" "()I")))

21:23 returns "clojure/lang/LazilyPersistentVector.java"

21:23 rhickey: phf: fun

21:28 durka: RSchulz: is it not sufficient to do (def *pout* (PrintWriter. *out*)) ?

21:29 RSchulz: Flushing?

21:30 durka: hmm?

21:30 RSchulz: What is Clojure trying to tell me with this diagnostic:

21:30 Can't embed object in code, maybe print-dup not defined: clojure.lang.LispReader$Unquote@5d391d

21:32 durka: If you wrap one I/O object around another, you get into trouble when multiple sources do not always flush after writing. And flushing excessively can be a detriment to good I/O performance.

21:32 rhickey: RSchulz: you've got an unquote outside of a syntax-quote?

21:32 durka: i see

21:32 that's a pain

21:34 RSchulz: rhickey: I don't think so, but I'll look more closely.

21:35 Ah. That's it. Yet Another Copy-and-Paste Error.

23:08 yangsx: hi, if my clojure-contrib.jar was updated after slime/swank, how can I force swank to reload it?

Logging service provided by n01se.net