2008-08-15
| 02:52 | jamii_ | whats the clojure equivalent of import myPackage.* ? I tried (import '(myPackage)) and (import '(myPackage *)). Is there some keyword for it? |
| 02:56 | hoeck | jamii_: there is no clojure equvalent for that |
| 02:57 | jamii_ | Ok. Do you have any idea what would cause java.lang.UnsatisfiedLinkError? |
| 02:57 | hoeck | jamii_: see http://groups.google.com/group/clojure/browse_thread/thread/fa00a0ff4c264f9a/095ddcd1f92556eb?lnk=gst&q=import#095ddcd1f92556eb |
| 02:57 | hoeck | jamii_: no, sorry |
| 02:57 | jamii_ | Hmm. To google |
| 03:01 | jamii_ | Ah, its a jni error. Probably nothing to do with clojure then |
| 05:02 | rhickey | where's cgrand these days? |
| 05:25 | Chouser | He connected momentarily yesterday at 3:42 AM. |
| 05:33 | Chouser | I think that's 9:42 PM in France. |
| 05:35 | jamii_ | If I reflect on a generated proxy what type will I see for the method? |
| 05:36 | jamii_ | 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:36 | Chouser | jamii_: 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:38 | Chouser | jamii_: 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:38 | jamii_ | Im intending to let it run in the main thread and have a terminal in my app which sends text to eval |
| 05:39 | jamii_ | I think I misunderstood how proxies word |
| 05:40 | jamii_ | *work |
| 05:41 | jamii_ | I guess I need to use gen-and-load-class to make my own slots |
| 05:43 | Chouser | I don't think I tried making up my own new slots, just connecting existing buttons and widgets. I didn't get very far. |
| 05:43 | Chouser | But yes I think you're right, you'll need to use gen-class. |
| 05:44 | Chouser | I 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:48 | jamii_ | I think so. I would have to gensym the class name and be careful to match up the types, but it seems reasonable |
| 05:49 | jamii_ | Unable to resolve symbol: gen-and-load-class in this context |
| 05:49 | jamii_ | Strange |
| 05:52 | Chouser | what version of Clojure are you using? |
| 05:52 | Chouser | and why can't I find my jambi .clj experiment?? |
| 05:52 | jamii_ | not sure. downloading the most recent just now |
| 05:55 | jamii_ | Is june 12th new enough? Thats the most recent packaged version |
| 05:58 | Chouser | that's probably usable. There's newer in SVN. With the June 12th release you probably need to load the gen-class.clj manually. |
| 06:07 | jamii_ | Have I done something stupid here? (gen-and-load-class 'BoolSlot ( :methods [['slot [Boolean] Void]] )) |
| 06:07 | jamii_ | Im getting |
| 06:07 | jamii_ | java.lang.IllegalArgumentException: No value supplied for key: null |
| 06:07 | jamii_ | at clojure.lang.PersistentHashMap.create(PersistentHashMap.java:65) |
| 06:10 | hoeck | jamii_: maybe the extra parens around ":methods [..]" are unnecessary |
| 06:11 | jamii_ | Thanks, that was the problem. Going to take me a while to get used to all these parentheses |
| 06:13 | hoeck | jamii_: 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:13 | jamii_ | I've not used either. I'm a lisp virgin |
| 06:17 | Chouser | you'll probably need a package prefix on your class too. jamii.BoolSlot |
| 06:18 | jamii_ | Awesome - the slot works |
| 06:21 | parth_m | Hello. |
| 06:21 | Chouser | parth_m: hi |
| 06:21 | parth_m | I downloaded the sources for clojure-contrib but don't really know how to use the contribs. Any pointers? |
| 06:24 | Chouser | well, things are in the process of changing right now. What OS are you on? |
| 06:24 | parth_m | Linux (Debian) |
| 06:26 | Chouser | great. 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:27 | Chouser | then 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:28 | parth_m | Ok. Will try this. So I need to (load-file lib.clj) to see all the contribs? |
| 06:29 | Chouser | Then at the top of a .clj where I want to use clojure-contrib, I can say: |
| 06:29 | Chouser | (clojure.lang.RT/loadResourceScript "clojure/contrib/lib/lib.clj") |
| 06:29 | Chouser | (clojure.contrib.lib/require '(clojure.contrib duck-streams)) |
| 06:29 | Chouser | (alias 'ds 'clojure.contrib.duck-streams) |
| 06:30 | Chouser | I believe this will be simplified over the next few weeks if lib.clj gets incorporated into clojure proper. |
| 06:30 | parth_m | Is "loadResourceStript" any different from "load-file"? |
| 06:30 | parth_m | "lib.clj" getting in clojure would be nice. |
| 06:30 | Chouser | yeah, loadResourceScript respects the class path. load-file just takes a plain file name. |
| 06:31 | parth_m | This helps. Thanks. Will try this. |
| 06:31 | Chouser | so 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:32 | parth_m | Are there any dependencies among that contribs that might break if I load an individual contrib? |
| 06:33 | parth_m | I will probably go with the second method ... it seems much easier to me :) |
| 06:33 | Chouser | that's a great question. I think most of the libs stand alone. |
| 06:33 | Chouser | :-) that's fine. I almost mentioned it first. |
| 06:34 | parth_m | So what is lib.clj? |
| 06:34 | parth_m | Does lib mean one of the sub modules in this context? |
| 06:37 | Chouser | bah. I'm getting sloppy. |
| 06:38 | Chouser | I think most of the .clj files in clojure-contrib each stand alone. |
| 06:38 | parth_m | :) |
| 06:38 | Chouser | lib.clj provides functions to make it easy to load .clj files and import the funcitons you want all in one step. |
| 06:39 | Chouser | btw, if you're not using the latest svn Clojure, you may need to use a slightly older clojure-contrib as well. |
| 06:40 | Chouser | right 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:42 | Chouser | which 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:58 | lisppaste8 | jamii pasted "(Very) simple qt prompt" at http://paste.lisp.org/display/65363 |
| 07:02 | Chouser | jamii_: cool! |
| 07:03 | Chouser | unless your Clojure is too old, you can say "QTextEdit." instead of "new QTextEdit" if you want. |
| 07:04 | Chouser | it's interesting you're using proxy with genclass like that. I hadn't thought of donig that. |
| 07:05 | Chouser | you can provide an implementation for BoolSlot directly instead, but I'm not sure it's any easier. |
| 07:06 | rhickey | could use gen-interface instead |
| 07:07 | rhickey | should |
| 07:08 | jamii_ | I cant find gen-interface in the docs |
| 07:09 | jamii_ | Is it new(ish)? |
| 07:09 | rhickey | jamii_: yes, Chouser's latest creation :) |
| 07:11 | jamii | Im going to take a wild leap and guess that it generates an instance instead of a class? Is that an advantage here? |
| 07:11 | rhickey | generates an interface instead of a class |
| 07:12 | jamii | that was meant to say interface. the lure of qt has kept me up later than my brain can handle |
| 07:13 | rhickey | yes, it's perfect for your case - gen an interface once and proxy it many times |
| 07:14 | jamii | I wonder if theres a way to avoid having to have a different interface for each signal return type |
| 07:15 | jamii | Can any of gen-class etc handle generics? |
| 07:16 | rhickey | no |
| 07:17 | Chouser | jamii: you could write a function that whips up new interfaces on the fly for each type of slot |
| 07:17 | jamii | Yep |
| 07:18 | jamii | Was just going to wrap up what I had at the moment in a macro |
| 07:18 | Chouser | like your own connect that would take a function (instead of an Object) and the Qt slot string. |
| 07:19 | Chouser | It would just have to convert the Qt slot string to a gen-interface spec, and then hook it up. |
| 07:21 | jamii | Cool. I can add syntax highlighting and error handling to this fairly easily too. Will make a nice terminal |
| 07:39 | parth_m_ | Hello ... I seemed to have dropped off. |
| 07:39 | vixey | you are still here |
| 07:39 | parth_m_ | Yes. :) |
| 07:40 | parth_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:42 | Chouser | you can use loadResourceScript as I described above, and Java's classpath will then be used. |
| 07:42 | parth_m_ | Great. Thanks. |
| 07:43 | ericthorsen | Is there clojure function for going from java class name to the clojure symbol? |
| 07:44 | rhickey | like the string "java.util.Collection" to java.util.Collection? |
| 07:44 | ericthorsen | (clojure/symbol-from-class clojure.map_123123123) |
| 07:44 | ericthorsen | yeilds #'clojure/map |
| 07:44 | rhickey | ah |
| 07:45 | rhickey | there isn't necessarily a mapping, anonymous fns and all |
| 07:46 | ericthorsen | rhickey: 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:47 | rhickey | to go backwards from class to the var name? |
| 07:47 | ericthorsen | yes |
| 09:00 | roblally | What'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:12 | rhickey | roblally: it's now in src/clj/clojure/parallel/parallel.clj |
| 09:14 | roblally | Thanks, 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:14 | roblally | At least I think I did ... jsr166 is giving me a little trouble |
| 12:17 | lpetit | hello, anybody here ? |
| 12:17 | Chouser | yep, hi. |
| 12:17 | lpetit | Time for answering a question ? |
| 12:18 | Chouser | try me. :-) |
| 12:20 | lpetit_ | Yup, my IRC client seems very bad, I think I will change soon. Did you see my post concerning the problem? |
| 12:21 | Chouser | nope, sorry. |
| 12:21 | lpetit_ | BTW, I seem to have inherited from another nickname |
| 12:21 | lpetit_ | 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:22 | Chouser | ah, seems plausible. This is not an area of strength for me, but I can try to help. |
| 12:22 | lpetit_ | Once packaged in a plugin, when I try to access it, I get a ClassNotFoundException error while clojure is bootstraping |
| 12:25 | lpetit_ | 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:26 | Chouser | I don't have any idea how eclipse manages classloaders. |
| 12:27 | lpetit_ | 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:27 | lpetit_ | The symptom is : DynamicClassLoader does not appear to be able to find ... itself ! |
| 12:29 | Chouser | You could try setting *use-context-classloader* |
| 12:30 | lpetit_ | 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:31 | lpetit_ | Ah, could you explain me what *use-context-classloader* means ? |
| 12:31 | Chouser | if you look in RT.java, you'll see where it's referenced. |
| 12:32 | Chouser | when set, the current thread's context classloader is used instead of ROOT_CLASSLOADER |
| 12:32 | Chouser | I don't really know what that means, but at least it's a different classloader. :-) |
| 12:33 | Chouser | on 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:34 | lpetit_ | 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:34 | lpetit_ | OK, after having talked about it with you, I think indeed it's time to post my problem to the group, thanks ! |
| 12:42 | Chouser | heh, sure. Sorry I'm not much help. |
| 12:52 | lpetit_ | Sure you were, you told me about *use-context-classloader* which seems as another interesting path to fix the problem |
| 20:51 | krsanky | hi ! |