#clojure logs

2008-08-15

02:52jamii_whats the clojure equivalent of import myPackage.* ? I tried (import '(myPackage)) and (import '(myPackage *)). Is there some keyword for it?
02:56hoeckjamii_: there is no clojure equvalent for that
02:57jamii_Ok. Do you have any idea what would cause java.lang.UnsatisfiedLinkError?
02:57hoeckjamii_: see http://groups.google.com/group/clojure/browse_thread/thread/fa00a0ff4c264f9a/095ddcd1f92556eb?lnk=gst&q=import#095ddcd1f92556eb
02:57hoeckjamii_: no, sorry
02:57jamii_Hmm. To google
03:01jamii_Ah, its a jni error. Probably nothing to do with clojure then
05:02rhickeywhere's cgrand these days?
05:25ChouserHe connected momentarily yesterday at 3:42 AM.
05:33ChouserI think that's 9:42 PM in France.
05:35jamii_If I reflect on a generated proxy what type will I see for the method?
05:36jamii_Im trying to get QtJambi to work nicely with clojure but I need to be able to write slots like: slider.valueChanged.connect(lcd, "display(int)");
05:36Chouserjamii_: You can't make up new methods in a proxy, so I would expect the method types to match those of the base classes.
05:38Chouserjamii_: I got QtJambi working a little at one point, but it wants to run in the main thread, and I didn't take the time to figure out how to manage that correctly.
05:38jamii_Im intending to let it run in the main thread and have a terminal in my app which sends text to eval
05:39jamii_I think I misunderstood how proxies word
05:40jamii_*work
05:41jamii_I guess I need to use gen-and-load-class to make my own slots
05:43ChouserI don't think I tried making up my own new slots, just connecting existing buttons and widgets. I didn't get very far.
05:43ChouserBut yes I think you're right, you'll need to use gen-class.
05:44ChouserI wonder if you could generate classes on the fly with a slot matching the connection you need, and wrap it all up so the clojure API just accepts a signal and a fn.
05:48jamii_I think so. I would have to gensym the class name and be careful to match up the types, but it seems reasonable
05:49jamii_Unable to resolve symbol: gen-and-load-class in this context
05:49jamii_Strange
05:52Chouserwhat version of Clojure are you using?
05:52Chouserand why can't I find my jambi .clj experiment??
05:52jamii_not sure. downloading the most recent just now
05:55jamii_Is june 12th new enough? Thats the most recent packaged version
05:58Chouserthat's probably usable. There's newer in SVN. With the June 12th release you probably need to load the gen-class.clj manually.
06:07jamii_Have I done something stupid here? (gen-and-load-class 'BoolSlot ( :methods [['slot [Boolean] Void]] ))
06:07jamii_Im getting
06:07jamii_java.lang.IllegalArgumentException: No value supplied for key: null
06:07jamii_ at clojure.lang.PersistentHashMap.create(PersistentHashMap.java:65)
06:10hoeckjamii_: maybe the extra parens around ":methods [..]" are unnecessary
06:11jamii_Thanks, that was the problem. Going to take me a while to get used to all these parentheses
06:13hoeckjamii_: but i think clojure does a good job in removing extra levels of parens in let and cond (compared to common-lisp or scheme)
06:13jamii_I've not used either. I'm a lisp virgin
06:17Chouseryou'll probably need a package prefix on your class too. jamii.BoolSlot
06:18jamii_Awesome - the slot works
06:21parth_mHello.
06:21Chouserparth_m: hi
06:21parth_mI downloaded the sources for clojure-contrib but don't really know how to use the contribs. Any pointers?
06:24Chouserwell, things are in the process of changing right now. What OS are you on?
06:24parth_mLinux (Debian)
06:26Chousergreat. Here's what I do (not sure how kosher this is, but it works) in my clojure-contrib dir: mkdir -p clojure; cd clojure; ln -s .. contrib
06:27Chouserthen I can run java with /home/whatever/clojure-contrib in my classpath, and lib.clj will find clojure.contrib.stuff right were it expects to (going through that little symlink)
06:28parth_mOk. Will try this. So I need to (load-file lib.clj) to see all the contribs?
06:29ChouserThen at the top of a .clj where I want to use clojure-contrib, I can say:
06:29Chouser(clojure.lang.RT/loadResourceScript "clojure/contrib/lib/lib.clj")
06:29Chouser(clojure.contrib.lib/require '(clojure.contrib duck-streams))
06:29Chouser(alias 'ds 'clojure.contrib.duck-streams)
06:30ChouserI believe this will be simplified over the next few weeks if lib.clj gets incorporated into clojure proper.
06:30parth_mIs "loadResourceStript" any different from "load-file"?
06:30parth_m"lib.clj" getting in clojure would be nice.
06:30Chouseryeah, loadResourceScript respects the class path. load-file just takes a plain file name.
06:31parth_mThis helps. Thanks. Will try this.
06:31Chouserso as an alternative to all of the above, you could just do (load-file "/full/path/to/clojure-contrib/foo.clj"), and then do alias or refer or whatever.
06:32parth_mAre there any dependencies among that contribs that might break if I load an individual contrib?
06:33parth_mI will probably go with the second method ... it seems much easier to me :)
06:33Chouserthat's a great question. I think most of the libs stand alone.
06:33Chouser:-) that's fine. I almost mentioned it first.
06:34parth_mSo what is lib.clj?
06:34parth_mDoes lib mean one of the sub modules in this context?
06:37Chouserbah. I'm getting sloppy.
06:38ChouserI think most of the .clj files in clojure-contrib each stand alone.
06:38parth_m:)
06:38Chouserlib.clj provides functions to make it easy to load .clj files and import the funcitons you want all in one step.
06:39Chouserbtw, if you're not using the latest svn Clojure, you may need to use a slightly older clojure-contrib as well.
06:40Chouserright now it would be pretty tricky for any file in clojure-contrib to depend on any other without breaking a lot. Once we're all using lib.clj, that kind of interdependancy should be trivial and robust.
06:42Chouserwhich is why I described the more complicated method first, because it gets you into the lib.clj world where we'll all be soon. ...but maybe not yet. :-)
06:58lisppaste8jamii pasted "(Very) simple qt prompt" at http://paste.lisp.org/display/65363
07:02Chouserjamii_: cool!
07:03Chouserunless your Clojure is too old, you can say "QTextEdit." instead of "new QTextEdit" if you want.
07:04Chouserit's interesting you're using proxy with genclass like that. I hadn't thought of donig that.
07:05Chouseryou can provide an implementation for BoolSlot directly instead, but I'm not sure it's any easier.
07:06rhickeycould use gen-interface instead
07:07rhickeyshould
07:08jamii_I cant find gen-interface in the docs
07:09jamii_Is it new(ish)?
07:09rhickeyjamii_: yes, Chouser's latest creation :)
07:11jamiiIm going to take a wild leap and guess that it generates an instance instead of a class? Is that an advantage here?
07:11rhickeygenerates an interface instead of a class
07:12jamiithat was meant to say interface. the lure of qt has kept me up later than my brain can handle
07:13rhickeyyes, it's perfect for your case - gen an interface once and proxy it many times
07:14jamiiI wonder if theres a way to avoid having to have a different interface for each signal return type
07:15jamiiCan any of gen-class etc handle generics?
07:16rhickeyno
07:17Chouserjamii: you could write a function that whips up new interfaces on the fly for each type of slot
07:17jamiiYep
07:18jamiiWas just going to wrap up what I had at the moment in a macro
07:18Chouserlike your own connect that would take a function (instead of an Object) and the Qt slot string.
07:19ChouserIt would just have to convert the Qt slot string to a gen-interface spec, and then hook it up.
07:21jamiiCool. I can add syntax highlighting and error handling to this fairly easily too. Will make a nice terminal
07:39parth_m_Hello ... I seemed to have dropped off.
07:39vixeyyou are still here
07:39parth_m_Yes. :)
07:40parth_m_I was wondering if Clojure has something like CLOJUREPATH that is automatically searched for .clj files in case a "load-file" is not found in the current directory
07:42Chouseryou can use loadResourceScript as I described above, and Java's classpath will then be used.
07:42parth_m_Great. Thanks.
07:43ericthorsenIs there clojure function for going from java class name to the clojure symbol?
07:44rhickeylike the string "java.util.Collection" to java.util.Collection?
07:44ericthorsen(clojure/symbol-from-class clojure.map_123123123)
07:44ericthorsenyeilds #'clojure/map
07:44rhickeyah
07:45rhickeythere isn't necessarily a mapping, anonymous fns and all
07:46ericthorsenrhickey: I need to look this up and I was trying to do it without having to build an index of all loaded clojure funcs
07:47rhickeyto go backwards from class to the var name?
07:47ericthorsenyes
09:00roblallyWhat's the right incantation to load parallel.clj now? I'm using HEAD and I don't have clojure-contrib on my classpath right now. The website suggests (load-file "src/parallel.clj") but that doesn't seem to be current.
09:12rhickeyroblally: it's now in src/clj/clojure/parallel/parallel.clj
09:14roblallyThanks, although it seems to be in clojure/parallel/parallel.clj when I untar the jar file I built from HEAD. I loaded it using (clojure.lang.RT/loadResourceScript "clojure/parallel/parallel.clj")
09:14roblallyAt least I think I did ... jsr166 is giving me a little trouble
12:17lpetithello, anybody here ?
12:17Chouseryep, hi.
12:17lpetitTime for answering a question ?
12:18Chousertry me. :-)
12:20lpetit_Yup, my IRC client seems very bad, I think I will change soon. Did you see my post concerning the problem?
12:21Chousernope, sorry.
12:21lpetit_BTW, I seem to have inherited from another nickname
12:21lpetit_OK, so here is the problem again : I'm packaging clojure in an eclipse plugin. I'm still new as far as eclipse plugin development is concerned, but I'm quite sure I've encountered a real problem between Eclipse's way of managing ClassLoader, and the way Clojure uses them
12:22Chouserah, seems plausible. This is not an area of strength for me, but I can try to help.
12:22lpetit_Once packaged in a plugin, when I try to access it, I get a ClassNotFoundException error while clojure is bootstraping
12:25lpetit_Here it is : java.lang.NoClassDefFoundError: clojure/lang/DynamicClassLoader. And it occurs at this point in clojure : at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:52)
12:26ChouserI don't have any idea how eclipse manages classloaders.
12:27lpetit_I've found a solution that got rid of the error and allowed my Repl to function. Indeed, I've found that the root DynamicClassLoader does not reference any parent classLoader : and I think, maybe in a standard environment this may cause no harm, but in an environment such as Eclipse startup, with OSGI controlling access, it fails because there is no parent classLoader
12:27lpetit_The symptom is : DynamicClassLoader does not appear to be able to find ... itself !
12:29ChouserYou could try setting *use-context-classloader*
12:30lpetit_The fix for me was : replace one line in RT.java : line 262 (in svn rev 999) was initially static final public DynamicClassLoader ROOT_CLASSLOADER = new DynamicClassLoader(); || and I replaced it with static final public DynamicClassLoader ROOT_CLASSLOADER = new DynamicClassLoader(RT.class.getClassLoader()); <== I've referenced the class loader that contains Clojure classes
12:31lpetit_Ah, could you explain me what *use-context-classloader* means ?
12:31Chouserif you look in RT.java, you'll see where it's referenced.
12:32Chouserwhen set, the current thread's context classloader is used instead of ROOT_CLASSLOADER
12:32ChouserI don't really know what that means, but at least it's a different classloader. :-)
12:33Chouseron the other hand, since you have a potential fix you might try posting it to the forum to see if people think it's a good idea in general.
12:34lpetit_OK, that's interesting, I'm not sure for which use *use-context-classloader* could be used, but here I think it may not help, because the problem appears in Clojure's static code before I have a chance to bind this var :-(
12:34lpetit_OK, after having talked about it with you, I think indeed it's time to post my problem to the group, thanks !
12:42Chouserheh, sure. Sorry I'm not much help.
12:52lpetit_Sure you were, you told me about *use-context-classloader* which seems as another interesting path to fix the problem
20:51krsankyhi !