2008-10-31
| 00:00 | wwmorgan | bradbev_: nope, just zipped. You can do a jar tf to find the path of the clojure file you want to load |
| 00:01 | bradbev_ | I guess I'm still confused then. why do I need the contrib jar file in my path? Can't I manually go & load-file the contribs I need? (which is what I thought I'd done) |
| 00:03 | wwmorgan | you could, but it's much nicer to do (ns your-project (:use (clojure xml))). Also it makes your code more portable |
| 00:04 | bradbev_ | wwmorgan: ok, I get it then. Before when I was just messing about I must have missed compiling a file. Can you change the classpath at runtime? |
| 00:05 | wwmorgan | bradbev_: there's add-classpath, but it might not work in this situation |
| 00:06 | bradbev_ | ok. Package management is a bit immature right now then? Not that CL is very much better |
| 00:08 | wwmorgan | I think the ns macro handles most use cases. Is there something you're trying to do that you don't think it covers? |
| 00:10 | bradbev_ | no, I'm just learning at the moment, but it seems odd to me so far :) Would one normally put all their jar files in the same place & then just add that directory to the classpath? |
| 00:13 | Chouser | bradbev_: java requires each jar to be listed in the classpath |
| 00:13 | wwmorgan | I use enclojure, which runs in netbeans. When you start up the Repl in the IDE it looks up all your dependencies and supplies them as a command-line argument to the Repl, like java -cp /foo/bar/baz.jar:/foo/bar/qut.jar:/foo/bar/clojure.jar clojure.lang.Repl. So everything's available from the start |
| 00:13 | Chouser | there's another command-line flag, though, hang on... |
| 00:14 | bradbev_ | I hadn't heard of enclojure before... |
| 00:15 | wwmorgan | if you like megalithic IDEs then check it out. It's pretty OK |
| 00:15 | Chouser | -Djava.ext.dirs |
| 00:15 | Chouser | that lets you specify a directory full of .jars |
| 00:17 | bradbev_ | Chouser: that's awesome |
| 00:17 | bradbev_ | wwmorgan: I'm more of an emacs guy now |
| 00:18 | Chouser | I haven't used it yet. I didn't learn about it until I had figured out pretty well how to cope with -cp |
| 00:20 | wwmorgan | anyway, you don't need to make jars to develop your own multi-file application. :use and :require will traverse a normal directory structure too |
| 00:21 | wwmorgan | then to distribute you jar the whole thing up and everything still works |
| 00:21 | bradbev_ | nice, I didn't know that |
| 00:23 | bradbev_ | so the namespace clojure.contrib.zip_filter.xml maps to the directory structure clojure/contrib/zip_filter/xml - is that enforced or just convention? And when I require clojure....filter.xml how does it know which clj file to load? |
| 00:26 | wwmorgan | it maps to clojure/contib/zip_filter/xml/xml.clj |
| 00:27 | bradbev_ | so only one file per directory then |
| 00:28 | wwmorgan | in general yes. |
| 00:28 | bradbev_ | thanks for the info, some of this is starting to come back from my java at school 10 years ago |
| 00:28 | wwmorgan | more correctly: one file that you can :use or :require per directory |
| 00:30 | Chouser | the specific place where it looks for a .clj file when given a namespace may be changing soon. |
| 00:30 | wwmorgan | if I have /foo/bar/baz.clj and /foo/bar/baz_helper.clj, I can do (ns foo.bar.baz (:load "baz_helper.clj")) in baz.clj |
| 00:31 | wwmorgan | but that might be "wrong" |
| 00:31 | bradbev_ | :) |
| 00:31 | Chouser | wwmorgan: actually, I think that's currently "right". |
| 00:31 | wwmorgan | oh sweet, cause I've been doing it _everywhere_ |
| 00:32 | Chouser | Part of the argument for the directory structure was to allow multiple files in the same directory to contribute to a single namespace. |
| 00:32 | wwmorgan | yes |
| 00:32 | Chouser | but like I said, that might be changing with the AOTC stuff. |
| 00:32 | Chouser | If you have good use cases for it, speak up. |
| 00:32 | Chouser | (not now, but when rhickey's listening. ;-) |
| 00:33 | bradbev_ | AOTC? |
| 00:33 | Chouser | ahead of time compilation |
| 00:33 | bradbev_ | nice |
| 00:33 | Chouser | generating .class files from .clj files |
| 00:41 | albino | what's the time frame on AOT? I would like it so I could use it for the Android the way the Scala people do |
| 00:45 | Chouser | last I heard it was "on hold" until after the election. |
| 00:46 | Chouser | my personal guess is it's be available to play with a couple weeks after that, but who knows. |
| 00:46 | wwmorgan | I don't know anything about Android, but the way it works now wouldn't work? |
| 00:47 | wwmorgan | java application that compiles to a .class file loads clojure code, get a var and invokes that fn? |
| 00:50 | Chouser | the problem is that .class files have to be converted ("compiled") to android's bytecode |
| 00:50 | abrooks | Dalvik bytecode, technically. |
| 00:51 | wwmorgan | oh I see, so all the bytecode generation is broken |
| 00:52 | Chouser | yeah, it'd generate JVM bytecode at runtime and then ... ? |
| 00:53 | abrooks | Where the JVM is stack based, the Dalvik VM is register based. I don't know how limiting this ultimately is (I haven't given it much thought) but I suspect that widens the gap between porting Java to the DVM and languages that specifically care about compiling their own code. |
| 00:53 | bradbev_ | Am I right in saying that android prevents runtime code generation? |
| 00:53 | Chouser | bradbev_: that may also be true, but it's not necessary to cause clojure trouble. |
| 00:54 | abrooks | bradbev_: That would probably depend on the class loader if they have a similar model. |
| 00:54 | Chouser | abrooks: but they already compile JVM bytecode to Dalvik, so the register thing must be a solved problem? |
| 00:55 | abrooks | Chouser: They do? I know they compiled Java to Dalvik. I hadn't heard about JVM bytecode. |
| 00:56 | Chouser | that's why compiling .clj to .class is going to be at all helpful |
| 00:56 | Chouser | for android |
| 00:57 | abrooks | Hm... Interesting (presuming it's accurate): http://rebelwithoutamouse.blogspot.com/2007/11/dalvik-googles-workaround-for-suns-jvm.html |
| 00:57 | abrooks | "The Android SDK does not compile your Java source code into Dalvik's bytecode directly, but it first uses a regular java compiler to generate regular java bytecode and then converts that bytecode into Dalvik's bytecode" |
| 00:58 | abrooks | Seems like I should have known that. |
| 01:30 | lisppaste8 | sunwukong pasted "printing in a proxy" at http://paste.lisp.org/display/69490 |
| 01:30 | sunwukong | seems like I cannot print from a proxy - any idea why? |
| 01:35 | Chouser | sunwukong: works for me. |
| 01:35 | Chouser | each time I click the button I see a new "Hello" print in my repl window. |
| 01:36 | Chouser | I'm using a plain repl in a term window. |
| 01:37 | sunwukong | thanks, I'll try it, maybe it's just some slime thing |
| 01:38 | sunwukong | yes, from plain repl it works for me, too |
| 01:51 | sohail | so there isn't any real way to pre-compile clojure code yet is there? my app takes 3 seconds to get to main... |
| 01:55 | Chouser | right |
| 01:56 | Chouser | it's like emacs -- just keep reusing the same process :-) |
| 01:57 | sohail | Chouser :-( |
| 01:58 | sohail | so no save-clojure-and-die planned? |
| 02:06 | Chouser | no, but AOTC is planned -- true compilation of .clj to .class |
| 02:46 | Pupeno | Good morning. |
| 03:09 | sohail | Chouser, cool, I look forward to it! |
| 03:40 | lisppaste8 | sohail pasted "right or wrong way to write a while loop?" at http://paste.lisp.org/display/69495 |
| 04:22 | Lau_of_DK | Morning gents |
| 04:22 | arbscht | hi lau |
| 04:49 | Lau_of_DK | Java guys, why is this |
| 04:50 | Lau_of_DK | static { |
| 04:50 | Lau_of_DK | com.trolltech.qt.Utilities.loadQtLibrary("QtCore"); |
| 04:50 | Lau_of_DK | com.trolltech.qt.Utilities.loadQtLibrary("QtNetwork"); |
| 04:50 | Lau_of_DK | } |
| 04:50 | Lau_of_DK | not the same as this |
| 04:50 | Lau_of_DK | (. com.trolltech.qt.Utilities (loadQtLibrary "QtCore")) |
| 04:50 | Lau_of_DK | (. com.trolltech.qt.Utilities (loadQtLibrary "QtNetwork")) |
| 04:52 | Lau_of_DK | (it compiles fine, but produces no effect) |
| 04:53 | Lau_of_DK | The question is probably this. How do I mimic the static { ... } ? |
| 04:54 | tWip | static block is run after the class is loaded |
| 04:54 | Lau_of_DK | oh |
| 04:54 | Lau_of_DK | Thats important |
| 04:54 | tWip | I don't know why that should matter as long as you do the calls before using anything |
| 04:55 | Lau_of_DK | It matters because this is a patch for a bug in Webkit |
| 04:55 | Lau_of_DK | Do you know how to do a static in Clojure? |
| 04:55 | tWip | I don't know how that would apply as clojure isn't class based in the same manner |
| 04:56 | tWip | couldn't you just do those calls before defining anything else? |
| 04:56 | Lau_of_DK | I can, but that didnt work, hence the question |
| 04:56 | tWip | oh ok |
| 04:57 | tWip | well I'm afraid I don't know more about this subject as that seems to be native interfacing issue |
| 04:58 | Lau_of_DK | Alright |
| 05:58 | AWizzArd | Moin |
| 07:18 | Lau_of_DK | cemerick, can you port a static {} clause to Clojure |
| 07:18 | Lau_of_DK | ? |
| 07:20 | cemerick | Lau_of_DK: that's sort of a non sequitur; there's no static initialization in clojure, everything is dynamic |
| 07:20 | cemerick | (modulo whatever is going to come out of AOT, perhaps) |
| 07:20 | Lau_of_DK | So what do I do when I have Java code that requires to be static ? |
| 07:21 | cemerick | no code requires a static invocation context -- static blocks are just a convenient method for executing code once when a class is first loaded |
| 07:22 | cemerick | You can have clojure code executed just once when a clj file is first loaded by making it a top-level form... |
| 07:24 | Lau_of_DK | oh |
| 07:24 | Lau_of_DK | I tried that, but it didnt work, so I figured static was the magic |
| 07:24 | Lau_of_DK | <Lau_of_DK> Java guys, why is this |
| 07:24 | Lau_of_DK | <Lau_of_DK> static { |
| 07:24 | Lau_of_DK | <Lau_of_DK> com.trolltech.qt.Utilities.loadQtLibrary("QtCore"); |
| 07:24 | Lau_of_DK | <Lau_of_DK> com.trolltech.qt.Utilities.loadQtLibrary("QtNetwork"); |
| 07:24 | Lau_of_DK | <Lau_of_DK> } |
| 07:24 | Lau_of_DK | <Lau_of_DK> not the same as this |
| 07:25 | Lau_of_DK | <Lau_of_DK> (. com.trolltech.qt.Utilities (loadQtLibrary "QtCore")) |
| 07:25 | Lau_of_DK | <Lau_of_DK> (. com.trolltech.qt.Utilities (loadQtLibrary "QtNetwork")) |
| 07:25 | Lau_of_DK | <Lau_of_DK> (it compiles fine, but produces no effect) |
| 07:26 | cemerick | totally a style point, but doing (com.trolltech.qt.Utilities/loadQtLibrary "QtCore") is more idiomatic at this point |
| 07:26 | cemerick | I assume those calls load some native libs or something? |
| 07:26 | tWip | well I guess you could have your own main, or class you touch in Java that has that static block |
| 07:27 | tWip | but I fail to see how the mere staticness of that code affects anything... as long as ordering is correct |
| 07:28 | cemerick | yeah, a static block is just like any other java code, except it does not execute within the context of an instance ("this", etc) |
| 07:29 | tWip | Lau_of_DK: have you tried having that in a classname as static? then doing (Class/forName "my.class.with.StaticCode") |
| 07:30 | tWip | in a class that is |
| 07:30 | tWip | that should execute your static block as the class is loaded |
| 07:32 | cemerick | That really should be no different than what Lau_of_DK pasted above. If it is, then it'd be interesting to find out why. |
| 07:32 | Lau_of_DK | Just trying to understand what you guys are saying. cemerick thanks for the style point, I had no idea that was a possibility |
| 07:32 | tWip | yeah I don't believe that it will make a difference... just to prove a point :) |
| 07:33 | tWip | it may be some weird jvm bug/issue |
| 07:33 | Lau_of_DK | user=> (com.trolltech.qt.Utilities/loadQtLibrary "QtCore") |
| 07:33 | Lau_of_DK | nil |
| 07:33 | Lau_of_DK | user=> (com.trolltech.qt.Utilities/loadQtLibrary "QtNetwork") |
| 07:33 | Lau_of_DK | nil |
| 07:33 | Lau_of_DK | user=> (main) |
| 07:33 | Lau_of_DK | com.trolltech.qt.designer.QUiLoaderException: Failed to load class (NO_SOURCE_FILE:0) |
| 07:34 | Lau_of_DK | http://lists.trolltech.com/pipermail/qt-jambi-interest/2008-March/000096.html |
| 07:34 | Lau_of_DK | read that, and the previous post |
| 07:36 | cemerick | Lau_of_DK: I don't know anything about jambi. Depending on what loadQtLibrary actually does, this might be a relevant issue: http://groups.google.com/group/clojure/browse_thread/thread/98714931a8edef1c |
| 07:36 | tWip | but your error seems different than the one discussed on the list |
| 07:38 | cemerick | yeah, "Failed to load class" sounds like a classpath or path issue? |
| 07:46 | Lau_of_DK | Im not sure what it is, but it directly relates to including QWebKit in your dialog |
| 07:46 | Lau_of_DK | And this is a known bug, which they solve by the static {}. |
| 07:47 | Lau_of_DK | cemerick, the link you provided may be related, but I dont see it presenting a fix ? |
| 07:48 | AWizzArd | rhickey: is there a way to "overload" syntax that is used for lists, vectors and maps? So, (sorted-map ..) returns a tree map, but one can use all functions that work on hash maps as well, and it prints the same. Can I add another tree in such a way as well? |
| 07:50 | rhickey | AWizzArd: yes, that's how it works. If you implement IPersistentMap your map will work like all of the others, with all functions that take maps, destructuring, everything |
| 07:50 | cemerick | Lau_of_DK: no, I didn't say that there was a clean fix yet -- looks like rhickey and Stephen are on it, at least for the use case(s) that they have |
| 07:50 | Lau_of_DK | ok |
| 07:51 | cemerick | If I were you, I'd make sure your classpath and path are configured properly, as the QUiLoaderException you pasted is different than what was in that mailing list post. |
| 07:51 | AWizzArd | rhickey: that's good news :-) |
| 07:52 | Lau_of_DK | cemerick, I've placed all the QtJambi.jars in my standard /clojure/libs dir, so that shouldnt be a problem |
| 07:52 | Lau_of_DK | And I connect the 2, because I can use every other widget in the book, except for WebKit |
| 07:52 | cemerick | Lau_of_DK: have you configured your path? I presume there's some native libs that need to be on your path for stuff like that to work. |
| 07:54 | Lau_of_DK | configured my path ? |
| 07:54 | Lau_of_DK | As far as I know, loading the .jars is all thats needed - which in turn, is all Ive done |
| 07:54 | Lau_of_DK | All my imports, incl. Webkit, work fine |
| 07:55 | cemerick | Lau_of_DK: #2 in the list @ http://lists.trolltech.com/pipermail/qt-jambi-interest/2008-March/000096.html says that you have to add some path(s) to your PATH env var |
| 07:56 | Lau_of_DK | Yes, but they are 2 seperate solutions, you pick 1 |
| 07:56 | cemerick | OK, but perhaps #2 will provide you with an interim solution. |
| 07:57 | Lau_of_DK | I didnt, I tried adding /bin to path |
| 07:57 | Lau_of_DK | Java loads only jars right, .so files and such are not loaded ? |
| 07:57 | cemerick | no, Java links into native libs all the time as a matter of course. Especially so when you're bringing in libraries that come with native libs. |
| 08:02 | Pupeno-G | Hello. |
| 08:02 | Pupeno-G | When you use a little Java program to bootstrap a clojure application, do you need this program to compile and load all the Clojure files? |
| 08:02 | tWip | how would you do that? |
| 08:03 | tWip | all the same dynamic features are available from repl and any embedded use afaik |
| 08:04 | Pupeno-G | tWip: calling Complier.load(on every file) I suppose. |
| 08:04 | tWip | just have the clj files in your classpath, clojure will find them when you use something |
| 08:05 | Pupeno-G | tWip: all the files are inside a jar. |
| 08:07 | tWip | if you run a jar, then that jar's files would be in the classpath |
| 08:08 | Pupeno-G | tWip: what? you lost me there. |
| 08:08 | tWip | in short, it should work |
| 08:09 | Pupeno-G | I have file1.clj, file2.clj, both in the same directory inside a jar and a Java program that in its main does, something like, Compiler.load(file1.clj), now file1.clj calls a function in file2.clj, so compiling fails due to a missing function. |
| 08:09 | tWip | oh I see, you should think about making clojure namespaces |
| 08:10 | tWip | and structuring code in them as appropriate |
| 08:11 | Lau_of_DK | cemerick, QtJambi comes with a alot of so.4 files in /lib/ - Youre saying everything has to be on the classpath ? |
| 08:12 | cemerick | Lau_of_DK: probably just their containing directory |
| 08:12 | rhickey | Pupeno-G: unless you have special needs, you can just us RT.var to create Var objects that correspond to Clojure vars you want to call, then just invoke them. That way, you can work it out in Clojure then do the same thing in Java |
| 08:12 | cemerick | to be clear, I've never used any flavor of Qt, that's just a suggestion |
| 08:17 | Pupeno-G | tWip: Did you mean that each file should be a namespace? |
| 08:20 | Pupeno-G | rhickey: for the moment, I'd rather improve the java wrapper and or build system to be able build the simplest possible cases, as what I'm really developing is not the program, but the plumbing to write programs. |
| 08:22 | rhickey | Pupeno-G: I understand, just advocating you do Var load = RT.var("clojure","load"); load.invoke(...); rather than Compiler.load(...) |
| 08:23 | Pupeno-G | rhickey: Oh! I totally misunderstood you. Right, I remember that way from Enclojure trunk. |
| 08:24 | AWizzArd | would it make sense that (dissoc my-vector n) would return a vector instead of throwing an exception? |
| 08:24 | gnuvince | Hello everyone |
| 08:24 | rhickey | AWizzArd: I don't think so |
| 08:26 | AWizzArd | so if I want to have a vector where I want to "delete" elements from the middle I should have a hash map with numeric keys probably |
| 08:28 | gnuvince | abrooks: thanks for the comments! |
| 08:30 | kib2 | gnuvince: hi, I've read your tutorial last night. |
| 08:31 | Lau_of_DK | cemerick, Ive extended the classpath, Ive set everything up the way they propose, Ive manually loaded the 2 libs, I still get the same error |
| 08:33 | Pupeno-G | clojure.lang.RT is not part of the 20080916 release, isn't it? |
| 08:34 | gnuvince | kib2: any comments? |
| 08:35 | kib2 | gnuvince: yes, it is said to be for beginners, and I don't think so (because I'm one). |
| 08:36 | rhickey | AWizzArd: yes, a hash-map makes a good sparse vector |
| 08:37 | rhickey | AWizzArd: sorted-map probably better if you care about sequential iteration |
| 08:37 | gnuvince | All right, I'll make a few final corrections and post it during my lunch break |
| 08:37 | duck1123 | rhickey: would it be possible (or wise) to just conj the two slices together? |
| 08:38 | Pupeno-G | Lau_of_DK: what error are you getting? |
| 08:40 | kib2 | gnuvince: ie you're talking about macros, I don't think anybody who has programmed in whatever langage but Lisp like will *really* know what's a macro. |
| 08:41 | AWizzArd | rhickey: btw, if I want to implement my own vector and implement IPersistentVector.. can I do this purely from within Clojure or would I have to do that part in Java? |
| 08:41 | gnuvince | kib2: I may get into them in a future post. |
| 08:41 | kib2 | gnuvince: Also, I found it hard to start with Clojure, because you need to know a little Java before, right or not ? |
| 08:42 | duck1123 | gnuvince: it might be helpful, when referring to certain pages, to provide a link |
| 08:42 | gnuvince | duck1123: I'll add more of them. Thank you. |
| 08:46 | Chouser | AWizzArd: you can implement IPersistentVector with proxy |
| 08:47 | AWizzArd | good |
| 08:48 | abrooks | gnuvince: Thanks for your post! |
| 08:48 | Lau_of_DK | Pupeno, , I'll do a lisppaste, hang on |
| 08:50 | gnuvince | abrooks: thanks for your comments :) |
| 08:50 | kib2 | is someone interested by GnuVince tutorial in pdf ? |
| 08:51 | Pupeno-G | kib2: by what? |
| 08:51 | kib2 | the tutorial written by gnuvince |
| 08:51 | lisppaste8 | Lau_of_DK pasted "QtWebkit load error" at http://paste.lisp.org/display/69503 |
| 08:53 | Pupeno-G | Lau_of_DK: Are you running 4.4 on Windows? |
| 08:54 | Lau_of_DK | On Linux |
| 08:54 | Pupeno-G | Lau_of_DK: and you've tried the equivalent Java code? |
| 08:55 | Lau_of_DK | No - Ive never written 1 char of Java in my life |
| 08:55 | Lau_of_DK | (which is a strong argument that Clojure should have been built on .Net) |
| 08:56 | Pupeno-G | Have you tried the workarounds in the mail you pointed to? |
| 08:56 | kib2 | here it is : http://kib2.alwaysdata.net/tempo/gnuvince.pdf |
| 08:56 | Lau_of_DK | Yes, those are the first 2 lines of the code |
| 08:56 | Lau_of_DK | And yes the paths are set up, according to their docs and the accompanying .sh scripts |
| 08:56 | Pupeno-G | Oh! I missed those, sorry. |
| 08:58 | Lau_of_DK | np :) |
| 08:58 | jdz | what does gnuvince use for writing that pdf? |
| 08:58 | Pupeno-G | I'm so pre-webkit era here :P |
| 08:59 | jdz | the code sure looks like colorized by emacs |
| 08:59 | Lau_of_DK | Pupeno-G, Webkit packs quite a punch though, and I want it for a specific app I have in mind |
| 09:00 | kib2 | jdz: I've used Pygments |
| 09:03 | Pupeno-G | Lau_of_DK: I'm sorry, I don't have any idea. Do you get any other messages, any backtrace? |
| 09:03 | rhickey | Interesting: http://groups.google.com/group/jvm-languages/msg/8baa984ab66f00bb |
| 09:03 | Lau_of_DK | Nada |
| 09:05 | Lau_of_DK | rhickey, almost makes you sea-sick with all those curly braces :) |
| 09:06 | rhickey | I wonder if they've done anything about the 'no classloaders in applets' security restriction? Else this is limited to pure interpreters or privileged runtimes |
| 09:07 | cemerick | rhickey: yes, update 10 is very, very welcome on a variety of fronts |
| 09:09 | kib2 | rhickey: very interesting |
| 09:09 | Pupeno-G | rhickey: I converted to using RT.loadResourceScript(...), but how should that help me regarding having two files, and one not seeing the namespace/contents of the other? or should I name the files/namespaces in a specific way? |
| 09:10 | cemerick | I don' t think update 10 changes the classloader policy -- although signing one's applet is a good thing to do, anyway |
| 09:11 | rhickey | cemerick: If most Flash had to be signed it never would have gotten off the ground - they need to fix this |
| 09:11 | rhickey | if they are serious about other languages |
| 09:12 | rhickey | I don;t understand why classes loaded from a custom classloader don't just get the same verification and sandbox restrictions |
| 09:12 | cemerick | rhickey: agreed. I was saying (poorly) that it's a problem for consumer-level stuff, but not a problem for commercial stuff. |
| 09:14 | rhickey | or some standard public load-from-bytes-in-memory supported on the standard loader - this protected nonsense is goofy |
| 09:15 | rhickey | everyone has to derive a custom classloader to do exactly the same thing, and incurs no end of grief for doing so |
| 09:18 | cemerick | the choir agrees :-D With update 10, every applet is in its own jvm process, so I'm guessing a lot of changes can now be put on the table. |
| 09:19 | rhickey | It would be so awesome to load your Clojure program to provide logic and remote control the browser-based UI |
| 09:22 | duck1123 | so, can clojurescript be used to generate javascript yet? |
| 09:22 | duck1123 | I thought it would be interesting to try to link clojure and mozrepl |
| 09:29 | gnuvince | http://gnuvince.wordpress.com/2008/10/31/fetching-web-comics-with-clojure-part-1/ |
| 09:32 | cemerick | rhickey: I'm actually hoping to deploy clojure to drive a GUI app as an applet in the not-too-distant future. Not having to maintain ajax or flash code in addition to our necessary "back end" that's in clojure/Java will be very pleasant. |
| 09:32 | rhickey | cemerick: cool! - the UI is Swing or HTML? |
| 09:35 | cemerick | aiming for Swing (although we may bring in a native browser component using jdic for a couple of webby tasks) |
| 09:36 | rhickey | is JWebPane still MIA? |
| 09:37 | Chouser | duck1123: clojurescript can generate javascript today, for probably 90% or more of the constructs needed. The runtime support is probably about 70% complete (these number are slightly educated guesses) |
| 09:37 | cemerick | I don't know what JWebPane is/was, but JDIC has a WebBrowser class that hooks into whatever native browser component you have installed (mozilla, webkit, etc) |
| 09:37 | Chouser | rhickey: Lau_of_DK's working hard on getting Qt and Webkit working for clojure |
| 09:37 | cemerick | I played with it for 20 minutes some months ago, and looks promising, although I suppose there may be hidden issues. |
| 09:37 | rhickey | JWebPane wwraps WebKit for consumption by Java - very deep integration |
| 09:38 | Chouser | that can apparently be deployed using java web start |
| 09:38 | rhickey | Saw JWebPane at JavaOne and was stunned by how smart they were about it |
| 09:38 | duck1123 | Chouser: that's cool. I haven't gotten around to playing with it yet, but it looks promising. |
| 09:38 | cemerick | ah, in that case, I'm behind the curve |
| 09:39 | Chouser | duck1123: well, the clojure-side API's still in flux, so it's not really ready to go yet |
| 09:39 | Chouser | but I'm hoping to have a repl up on the web in the next few days. |
| 09:39 | cemerick | The web is a decidedly second-class citizen for us |
| 09:41 | duck1123 | Chouser: I would also like to eventually replace my .conkerorrc file with some lisp-like language |
| 09:41 | Pupeno-G | So, if I RT.loadResourceScript all files it works, is that the way to go? I'm fine with that, but if there's a better way I'll take it. |
| 10:32 | gnuvince | Anyone wants to post my tutorial to programming.reddit? |
| 10:34 | tayssir | gnuvince: Done -- on programming.reddit! |
| 10:35 | gnuvince | tayssir: link? |
| 10:35 | tayssir | Er, yeah... http://www.reddit.com/r/programming/comments/7ait5/fetching_web_comics_with_clojure/ |
| 10:35 | gnuvince | Upvoted! |
| 10:36 | Pupeno-G | idem. |
| 10:46 | Pupeno-G | How does Clojure know how to find the file containing a specific namespace? |
| 10:47 | Chouser | it looks through the classpath for a matching directory. com.foo.pkg would have to be at com/foo/pkg/pkg.clj |
| 11:10 | TommyOnMac | hi |
| 11:11 | kib2 | didn't regexps supposed to be written like this #"..." ? |
| 11:11 | gnuvince | kib2: yes |
| 11:12 | jdz | only you don't need to escape backslashes since one of the recent patches |
| 11:12 | kib2 | so why should I write (.matches "abc" "(a((b)(c))") instead of (.matches "abc" #"(a((b)(c))") ? |
| 11:13 | abrooks | jdz: gnuvince notes that below in the post. |
| 11:20 | Chousuke | kib2: because you're calling String.matches() which takes a string parameter |
| 11:21 | kib2 | Chousuke: and then String.matches compiles the given string to a regexp, that's it ? |
| 11:23 | Chousuke | kib2: I don't know what String.matches really does, but most likely yes |
| 11:25 | kib2 | Chousuke: because when I look at Java docs, it is said to take a regexp as parameter, so I suppose Clojure makes it automaticaly. |
| 11:25 | Chousuke | kib2: it takes a String representing the regexp as a pattern |
| 11:25 | Chousuke | not an actuall java.util.regexp.Pattern |
| 11:25 | Chousuke | -l |
| 11:26 | kib2 | Chousuke: yes, so Java does the work |
| 11:26 | Chousuke | yeah |
| 11:28 | Chousuke | if you want to use an actual pattern object you'd have to do something like (-> #"foo" (.matcher "foo") (.matches)) |
| 11:30 | Lau_of_DK | Chouser: Update - I have a Webkit widget running in a UI driven from Clojure now :) |
| 11:30 | AWizzArd | sounds nice |
| 11:30 | Chouser | Lau_of_DK: excellent! |
| 11:30 | AWizzArd | Now we just need some tutorials, how to do the basic stuff, step-by-step, so that we can impress people with youtube videos. |
| 11:31 | Lau_of_DK | lol |
| 11:31 | AWizzArd | Especially for all these 16 year olds out there it will be nice to programm "their own webbrowser" and show off before their friends... they are the guys who will write the software of tomorrow. |
| 11:31 | Lau_of_DK | haha |
| 11:32 | Lau_of_DK | I'll put something up sooner or later, but not on Youtube |
| 11:32 | kib2 | Chousuke: thanks for the tip |
| 11:34 | kib2 | what is "->" synatxic sugar for ? |
| 11:34 | kib2 | "syntaxic" |
| 11:34 | gnuvince | kib2: syntactic |
| 11:34 | kib2 | oops :) |
| 11:35 | Chousuke | kib2: it takes the first form, puts it as the second element in the next form, then puts that as the second element in the next form, ad infinitym |
| 11:35 | gnuvince | kib2: (-> 3 (+ 1) (+ 2)) ==> 6 |
| 11:35 | Chousuke | infinitum :P |
| 11:36 | gnuvince | it moves the result through the forms. |
| 11:36 | gnuvince | It's similar to Haskell's do-form |
| 11:37 | Chousuke | it's not very clear at first glance, but it's quite nice once you get it :) |
| 11:37 | kib2 | nice :) I like most of Haskel features :)l |
| 11:38 | kib2 | Chousuke: I agree, I have to learn playing dominoes |
| 11:39 | Chousuke | my example above would expand to (-> (.matcher #"foo" "foo") (.matches)) which further expands to (.matches (.matcher #"foo" "foo")) |
| 11:40 | Chouser | for extra fun, parens are optional on all but the first form: (-> #"foo" (.matcher "foo") .matches) |
| 11:44 | kib2 | Chousuke: thanks, that's what I was trying to do, but I was lost. |
| 11:46 | Chousuke | hm. Just noticed that (-> 3 (+ 1) (+ 2)) looks like infix notation with weirdly placed parens :/ |
| 11:51 | duck1123 | with ->, the result becomes the 2nd param, right? |
| 11:51 | danlarkin | isn't -> deprecated? |
| 11:52 | Lau_of_DK | rhickey, I cant say that this isnt just my inexpertise talking, but I really would appreciate some examples to go along with the online documentation. Im trying to understand (gen-class) and (gen-class-and-load) and its not exactly straight-forward to me how to apply them |
| 11:53 | AWizzArd | Lau_of_DK: it's time for a how-to wiki or something like that |
| 11:53 | Lau_of_DK | Can somebody enlightmen me, if I want to create a class which has a constructor a private/public var and a helper function, how do I do that ? |
| 11:53 | AWizzArd | In principle for every function/aspect there could be a bunch of examples |
| 11:54 | AWizzArd | When should I use vectors? How can I use assoc? How can I make a .jar file out of my clojure program that only needs to be double clicked on my friends computer? And so on |
| 11:57 | Chousuke | danlarkin: why would -> be deprecated? |
| 11:57 | Chousuke | it pretty much replaces (. and (.. |
| 11:57 | Chouser | gen-class is among the trickiest pieces of clojure to use. |
| 11:57 | danlarkin | Chousuke: whoops! it's .-> that's deprecated |
| 11:58 | Chouser | but it's also illustrative of one reason that not too many docs have been written yet. gen-class is probably going away. |
| 12:04 | Lau_of_DK | Also one of the best reasons to get busy on some docs :) |
| 12:06 | Chouser | get busy writing docs for functions that are going away? |
| 12:06 | lisppaste8 | Lau_of_DK pasted "gen-class-tutorial-needed" at http://paste.lisp.org/display/69516 |
| 12:06 | Chouser | go right ahead. |
| 12:08 | Chouser | Here's my gen-class tutorial. Please forgive me if it's a little dense: http://paste.lisp.org/display/68406 |
| 12:10 | Lau_of_DK | Chouser, I gotta break, visitors coming - Could you do me a huge favor and annote my little example? :) |
| 12:11 | Chouser | Lau_of_DK: probably not. sorry. |
| 12:18 | Chousuke | gen-class is weird :/ |
| 12:21 | Chouser | it is. |
| 12:21 | Chouser | it's an unusual layout of clojure code for constructing an unusual kind of Java class. |
| 12:26 | Chousuke | I'm trying to make a trivial class and it fails with "no value supplied for 'init" :/ |
| 12:28 | Chousuke | ah, never mind. |
| 12:35 | lisppaste8 | sohail pasted "System tray app with SWT - comments?" at http://paste.lisp.org/display/69519 |
| 12:42 | Chousuke | sohail: nothing much, but you define unless and use it nowhere :) |
| 12:42 | sohail | Chouser hehe |
| 12:42 | sohail | I think I intended to replace one of the (if (not ... with that |
| 12:44 | Chousuke | also couldn't you use SWT/PUSH instead of (.PUSH SWT) |
| 12:45 | sohail | Chouser, could I?! |
| 12:45 | sohail | that would make me very happy!!! |
| 12:46 | Chousuke | I'm not Chouser, and I'm not sure. there were some limitations to the / form, but try it. |
| 12:46 | sohail | err sorry :-) |
| 12:46 | sohail | Chousuke, :-) |
| 12:47 | sohail | Chousuke, replacing (.Push SWT) with SWT/Push works |
| 12:47 | sohail | err PUSH |
| 12:48 | Chousuke | as far as I know / can be used to access static fields in a class |
| 12:48 | sohail | that's helpful |
| 12:48 | Chousuke | so you can do stuff like Math/PI etc. |
| 12:50 | Chousuke | it'll also work for the accesses in the .addListener calls :) |
| 12:52 | sohail | Chouser, yeah I replaced those as well |
| 12:53 | Chousuke | You have to be more careful with your tabcompletion :D |
| 12:53 | sohail | damnit |
| 12:53 | sohail | you need ot change your nick! |
| 12:53 | duck1123 | Chousuke: maybe one of you just needs to change their name |
| 12:54 | sohail | make yourself zChousuke :-) |
| 12:55 | H4ns | sohail: please post your reworked example! |
| 12:57 | lisppaste8 | sohail annotated #69519 with "for h4ns" at http://paste.lisp.org/display/69519#1 |
| 12:57 | H4ns | sohail: looks great, thanks! |
| 12:58 | Chousuke | you missed one. |
| 12:58 | Chousuke | (addListener (.Selection SWT) ... |
| 12:58 | sohail | so I did |
| 12:58 | sohail | thanks :-) |
| 12:59 | AWizzArd | sohail: see if you can add this to a wiki |
| 13:00 | sohail | AWizzArd, is there a wiki? |
| 13:00 | AWizzArd | http://en.wikibooks.org/wiki/Clojure_Programming is coming closest to it |
| 13:02 | AWizzArd | we need much much more howtos and examples |
| 13:02 | sohail | maybe not a good idea, just realized there is a "leak" b/c I didn't dispose the image |
| 13:02 | AWizzArd | things that have to do with guis and graphics will attract also young people |
| 13:03 | Chousuke | I just noticed. Your definition of proxy-listener seems to have an error |
| 13:03 | cemerick | AWizzArd: as one of the young people (ostensibly!), I'd say we're already here ;-) |
| 13:04 | AWizzArd | Very good |
| 13:04 | sohail | Chousuke, what is the error |
| 13:05 | lisppaste8 | Chousuke annotated #69519 with "hmm" at http://paste.lisp.org/display/69519#2 |
| 13:06 | sohail | Chousuke, ah, good catch. Howcome it doesn't affect things? |
| 13:08 | Chousuke | never tried running the code, I don't have SWT stuff in my classpath. I think it should break though if it's accidentally expanded into the qualified name :/ |
| 13:08 | sohail | it doesn't break... |
| 13:12 | Lau_of_DK | Gents, Ive only got a few minutes, and takes on this? http://paste.lisp.org/display/69516 |
| 13:14 | cemerick | Lau_of_DK: there's a ton of gen-class tutorials on the google group |
| 13:14 | cemerick | s/tutorials/examples |
| 13:15 | Lau_of_DK | thanks cemerick |
| 13:22 | Chousuke | sohail: seems like it works either way after all. |
| 13:23 | sohail | Chousuke, by design or accident? |
| 13:23 | sohail | why do you think it should barf? |
| 13:24 | Chousuke | maybe that was just my mistake. |
| 13:25 | rhickey_ | Chousuke: Revision #907 Committed by rhickey at 6/17/08 8:29:06 AM made proxy tolerant of ns-qualified method names |
| 13:26 | rhickey_ | before that it would have been bothered by the ns |
| 13:27 | Chousuke | ah |
| 13:27 | Lau_of_DK | What are the odds that gen-class functions will disappear, and what are the arguments behind it ? |
| 13:27 | rhickey_ | Lau_of_DK: genclass can be viewed as a special case of AOT compilation |
| 13:28 | rhickey_ | and thus subsumed by it |
| 13:29 | Lau_of_DK | "subsumed by it" ? |
| 13:38 | gnuvince | :) |
| 13:39 | Chouser | I'm not sure I'll ever use AOTC. sohail, what about it are you looking forward to? |
| 13:39 | Chouser | reduced startup time? |
| 13:41 | sohail | Chouser, that and you don't have to include all your sources |
| 13:42 | Chouser | so startup time and obfuscation. |
| 13:42 | sohail | pretty much, what else would I want it for |
| 13:42 | Chouser | no special classloader I think may make applets less cumbersome |
| 13:43 | Chouser | .class files can be compiled to work on android |
| 13:43 | Drakeson | how can I find the current "classpath" ? |
| 13:43 | sohail | I thought applet is now spelled as "flash" |
| 13:43 | sohail | ;-) |
| 13:44 | Drakeson | *classpath* is not default |
| 13:44 | Chouser | you may be able to deploy a clojure app without the Compiler or ASM, for reduction in deployed .jar size. |
| 13:45 | sohail | Chouser, good list! |
| 13:46 | Chouser | sohail: did you see the clojure-inspired lisp for flash? |
| 13:47 | Chouser | Drakeson: this may help you: http://groups.google.com/group/clojure/browse_thread/thread/d83ed2808eef00da/3cd31b25f123e9a7 |
| 13:48 | sohail | Chouser, I did not |
| 13:48 | sohail | but flash is horrible |
| 13:48 | Chouser | is it? |
| 13:49 | abrooks | Horible things can be done with flash. I don't think it's inherently that bad. |
| 13:49 | sohail | what abrooks said |
| 13:50 | Chouser | I have no doubt that plenty of horrible stuff will be written in Clojure. |
| 13:50 | rhickey | I certainly hope not! |
| 13:51 | Chouser | It'll be inevitable once it becomes the 3rd most popular language (behind cobol and vb) |
| 13:51 | rhickey | yikes |
| 13:52 | Chouser | :-) |
| 13:52 | abrooks | rhickey: You're making great strides evolving the programming language. It will take many generations to evolve the programmers. :-/ |
| 13:52 | sohail | ya, see my swt example above |
| 13:52 | sohail | very horrible |
| 13:52 | Drakeson | The "lispish" aura around it may repels many idiots ;) |
| 13:53 | sohail | I don't think so |
| 13:53 | Chouser | I'm not finding that flash link. |
| 13:53 | sohail | most people understand Lisp is this awesome language but can't make any practical use of it... clojure makes that possible |
| 13:54 | Drakeson | what is the ruby on rails for clojure? |
| 13:54 | rhickey | Outside of more purely functional languages, Clojure is one of the few with some sense of "the right thing" baked in. So at least you'll have to go out of your way to be horrible, at least as far as mutation and concurrency, but I have no illusions... |
| 13:55 | abrooks | ;-) I know you don't. |
| 13:56 | abrooks | Drakeson: Compojure and Webjure are web platforms in development but I don't think either is particularly Railsy. |
| 13:57 | abrooks | Drakeson: Besides neither is alliterative. We need Clojure on Crack or some such. |
| 13:57 | sohail | is there a way we can have another killer app for clojure than web programming |
| 13:57 | Kerris3 | haha abrooks |
| 13:57 | Drakeson | (ruby-on-rails: a *seeming* integrated web application server with nice *icons* and *graphics*) |
| 13:59 | Chouser | sohail: how about a programmer's text editor? |
| 13:59 | Drakeson | sohail: maybe some document processing. There is no good-enough tool-chain around SVG yet. |
| 13:59 | sohail | Chouser, clojmacs? |
| 13:59 | Chouser | we could call it Emacs on Euphemisms or something |
| 13:59 | sohail | heh |
| 13:59 | devinus | will clojure ever have tail call optimization? |
| 14:00 | Chouser | devinus: when the JVM does |
| 14:00 | sohail | devinus, if the jvm gets it |
| 14:00 | Kerris3 | is that the domain of the javac jvm |
| 14:00 | Kerris3 | edit: beaten |
| 14:00 | devinus | isn't that support to be in java 7? |
| 14:00 | Kerris3 | devinus: I've no idea, but you can check on http://download.java.net/jdk7/binaries/ |
| 14:01 | rhickey | http://openjdk.java.net/projects/mlvm/subprojects.html |
| 14:01 | Chouser | ah! A Clojure-derived Lisp for the AVM2: http://github.com/aemoncannon/las3r/wikis |
| 14:02 | Chouser | that's the clojure-like flash thingy |
| 14:05 | sohail | ah crap |
| 14:05 | sohail | I just did (loop [] (recur)) |
| 14:05 | sohail | in the flash thingy |
| 14:05 | Chouser | heh. will you have to close your browser? |
| 14:07 | sohail | yep |
| 14:08 | Chouser | sorry, man. At least when I do that in clojurescript, the browser steps in after a moment and offers to kill the loop. |
| 14:08 | sohail | the flash thingy is pretty cool |
| 14:35 | aperotte | Does anyone remember the name of the company that Rich mentioned when he was talking about a java cluster that ran the ant colony simulation? |
| 14:41 | dudleyf | aperotte: Was that Azul Systems? |
| 14:41 | Chouser | aperotte: azulsystems? |
| 14:41 | aperotte | thanks guys, I was listening to his screencasts trying to find it again, but wasn't having much luck |
| 14:42 | Chouser | http://blogs.azulsystems.com/cliff/2008/09/jvm-language-su.html |
| 14:46 | Drakeson | isn't a classpath path to a jar file? if so, what is the meaning of the following (from http://en.wikibooks.org/wiki/Clojure_Programming#Libraries) : Now we have to create a file in the classpath with the filename "example/ourlib/ourlib.clj" |
| 14:48 | sohail | Drakeson, clojure hijacks the classpath for it's own purposes too |
| 14:48 | Drakeson | ok, is classpath a variable? |
| 14:49 | Drakeson | can I see its value? can I add an extra path to it? |
| 14:49 | Drakeson | I also tried this --> http://groups.google.com/group/clojure/browse_thread/thread/d83ed2808eef00da/3cd31b25f123e9a7 |
| 14:49 | Drakeson | which gives me a list of jar files. |
| 14:53 | Drakeson | or at least, is it too obvious what it means? |
| 14:53 | AWizzArd | Funny. When you type on the repl: (in-ns 'java), how do you then go back into (in-ns 'user)? |
| 14:53 | kotarak | Drakeson: (add-classpath "file:///to/some/path") adds to the classpath |
| 14:54 | devinus | is there a clojure textmate bundle? |
| 14:55 | Drakeson | kotarak: thanks. |
| 14:57 | Chouser | AWizzArd: oops |
| 14:58 | Chouser | AWizzArd: don't do that |
| 15:00 | lisppaste8 | fyuryu pasted "fighting with macros" at http://paste.lisp.org/display/69528 |
| 15:01 | fyuryu | I've been fighting with this macro for the last 1.5 hours |
| 15:01 | sohail | fyuryu, what are you trying to do? |
| 15:01 | fyuryu | and don't know how to achieve the desired effect |
| 15:02 | sohail | chunk doesn't need to be a macro |
| 15:02 | sohail | oh I see |
| 15:03 | sohail | do you need the @? |
| 15:03 | fyuryu | sohail: this is a simplified version, I want to be able to pass both, the test predicate and action from m-main |
| 15:04 | sohail | I don't know what you are trying to do actually |
| 15:04 | fyuryu | sohail: well, I think I need the @ |
| 15:04 | lisppaste8 | kotarak annotated #69528 with "fyuryu's macro with gensym" at http://paste.lisp.org/display/69528#1 |
| 15:05 | fyuryu | sohail: I want the commented line to appear in place of ~@(chunk ...) |
| 15:06 | fyuryu | kotarak: Thanks, I think I tried that already, but let me try again |
| 15:07 | fyuryu | kotarak: yep, doesn't work |
| 15:11 | devinus | what does this do -> |
| 15:12 | fyuryu | devinus: (-> {} (assoc :a 1) (assoc :b 2)) --> {:a 1 :b 2} |
| 15:12 | Drakeson | is there a way better than web scraping to get the content of clojure.org ? |
| 15:13 | lisppaste8 | chousuke annotated #69528 with "shouldn't this work?" at http://paste.lisp.org/display/69528#2 |
| 15:13 | devinus | fyuryu: is it like an inline test case? |
| 15:13 | fyuryu | devinus: takes the first arg and puts it as the first arg of the following expression |
| 15:13 | fyuryu | then the result as first arg of the next one |
| 15:14 | fyuryu | devinus: no, more like chaining calls |
| 15:16 | Chousuke | fyuryu: did my version produce what you wanted? |
| 15:18 | fyuryu | Chousuke: yes, thanks a lot. Started writing the same thing, following sohail's comment about making chunk a function |
| 15:19 | fyuryu | when you have a hammer... |
| 15:22 | Chousuke | I've noticed that writing helper functions that return forms helps bring macro complexity down a lot. |
| 15:22 | Kerris4 | fyuryu: everything looks like a thumb? :V |
| 15:23 | fyuryu | :-) |
| 15:24 | Chousuke | you have a function that takes a parameter and "instantiates" a template with the parameter. then in your macro you can call map with that function over the macro arguments to generate code for each of them. |
| 15:25 | aperotte | Drakeson: there is a pdf in the files on the google group that contains the contents of the site |
| 15:26 | aperotte | Drakeson: http://groups.google.com/group/clojure/files |
| 15:27 | aperotte | Drakeson: manual.pdf |
| 15:30 | Drakeson | aperotte: cool, thanks. Shouldn't that be in this channel's topic? |
| 15:32 | aperotte | I dunno, I'm pretty new here and only found it myself yesterday |
| 15:33 | aperotte | has anyone used the patch that allows gen-class to access ancestral protected members? |
| 16:24 | Drakeson | what it takes to get tilda expansion? |
| 16:24 | kotarak | Drakeson: what tilde expansion? |
| 16:25 | Drakeson | ~/thing rather than file:///path/to/user's/home/directory/thing |
| 16:26 | kotarak | If it is not supported by the underlying Java classes, you probably have to write your own wrapper around the corresponding functions, which does that for you. |
| 16:28 | Drakeson | well, CL has user-homedir-pathname, and elisp has expand-file-name. what do you use here? I guess you don't write your own wrappers, right? |
| 16:29 | kotarak | Never needed ~/whatever up to now. I don't know whether there such functions. |
| 16:32 | kotarak | At least java.io.File seems not to support ~. |
| 16:34 | danlarkin | Does this work for you? (. System (getProperty "user.home")) |
| 16:34 | Drakeson | yes, but that is not very convenient. |
| 16:34 | danlarkin | well that's what you've got |
| 16:34 | Chouser | (System/getProperty "user.home") |
| 16:35 | Chouser | save those parens for CL programmers -- they need all they can get. |
| 16:35 | Drakeson | Chouser: :) |
| 16:35 | danlarkin | ah yes I keep forgetting / |
| 16:35 | Drakeson | I was hoping for something cleaner. Like a clean path syntax. |
| 16:36 | Chouser | Drakeson: it's not a terribly cross-platform standard. only unixen use ~ for the user home dir, I think. |
| 16:36 | kotarak | Drakeson: (defn expand-tilde [s] (if (= (first s) \~) (apply str (System/getProperty "user.home") (rest s)) s)) (untested) |
| 16:37 | Drakeson | it is not as clean as #P~/thing ;) |
| 16:39 | Drakeson | Chouser: true, but it would make things easier if there was a way (pick your own favorite character) to mean user home directory. It could translate to C:\\Documents\ and\ Settings\\Username for Windows. |
| 16:40 | Chouser | sohail: find a way for different libs to provide reader macros without conflict, and rhickey may take your patch. |
| 16:41 | abrooks | sohail: I don't think you'll get them. rhickey (who has largely convinced me too) is pretty much against dirtying the language with user-defined reader macros which would break tools, etc. If you really need something, just create your own reader and hand off to the compiler. |
| 16:41 | Chouser | I've thought perhaps by making them look like fns or macros that follow namespace rules... |
| 16:42 | sohail | I don't see why you couldn't make them use... what Chouser said |
| 16:42 | Chouser | (myns/myreadmac now I can do what I want " this macro ends in a ] |
| 16:42 | sohail | hm |
| 16:42 | sohail | no |
| 16:42 | sohail | :-) |
| 16:42 | Kerris4 | abrooks: sounds like Clojure halready has legacy apps to support ;-P |
| 16:42 | sohail | but maybe if #P could be read as # namespace/P and you dispatch on namespace/P |
| 16:43 | sohail | but I don't know how that would work |
| 16:43 | Chouser | Kerris4: no, the point is that two people could write two different libs, but if each can mess with the one reader table, you're never going to be able to use those two libs in the same project |
| 16:43 | abrooks | Kerris4: I don't think it's just a legacy thing. Writing code that a tool must first execute to be able to read creates a mess, particularly if the code is broken. Plus, I don't think the power is ultimately necessary. |
| 16:44 | abrooks | Lisp + macros is a sufficiently powerful and yet hygienic system. |
| 16:45 | sohail | sheep! |
| 16:45 | sohail | :-) |
| 16:46 | Chouser | sohail: our proposals aren't very different, I was just thinking ( instead of # |
| 16:46 | abrooks | User defined reader macros add a bit but dirty the system massively. |
| 16:46 | Chouser | abrooks: that's roughly the same argument other languages make against macros |
| 16:46 | sohail | Chouser, problem is that ( is already used for something else |
| 16:47 | abrooks | Chouser: Other languages don't have CL like macros. |
| 16:47 | Chouser | sohail: sure, for invoking stuff, currently either at compile time or runtime. Why not at read time? |
| 16:47 | Chouser | abrooks: right, because the "add a bit of power, but dirty the system massively" |
| 16:47 | sohail | doesn't the syntax become ambiguous then? |
| 16:47 | sohail | (p or (p-function ? |
| 16:47 | Kerris4 | Chouser: thanks for the explanation :) |
| 16:48 | sohail | no |
| 16:48 | Chouser | sohail: well, I don't have a patch working or anything, but I think it could be done. |
| 16:48 | sohail | still, I think using ( is insane :-) |
| 16:48 | abrooks | Chouser: Yes. Clojure DOES have powerful macros that don't dirty the system thanks to the homoiconicity that other languages don't have. |
| 16:49 | sohail | ok I think if reader macros dirty the system, then we should remove the object literal syntax because it uses a reader macro |
| 16:49 | sohail | if it's good enough for rich to use, good enough for me, I say :-) |
| 16:49 | kotarak | Chouser has a point with (. It would be some strange kind of consistent. But it should be also closed with ). Otherwise we create special cases again. I'm happy, that the () syntax is so regular. It makes writing tools easy. |
| 16:49 | abrooks | Hm... Clojure should really just adopt M4 now that I think about it... |
| 16:50 | abrooks | </joke> |
| 16:50 | sohail | ( to indicate a reader macro will cause no end of confusion |
| 16:50 | Chouser | kotarak: yeah, the closing ] was intentionally ugly. most macros would want to end in ), but it'd be up to them to quit reading and give up control |
| 16:50 | sohail | (f "i") -> function or macro? |
| 16:51 | sohail | function, macro or reader macro, that is |
| 16:51 | kotarak | As does ( to indicate a macro instead of a function creates confusion. |
| 16:51 | Chouser | kotarak's got my point. :-) |
| 16:51 | sohail | not the same though |
| 16:51 | Chouser | no, just a gradient. |
| 16:52 | sohail | they both follow the rules except a macro is a function that doesn't evaluate its arguments |
| 16:52 | sohail | a reader macro is a what? |
| 16:52 | sohail | (ok not exactly, but...) |
| 16:52 | Chouser | a reader macro is a function that takes a PushbackReader instead of an s-expression |
| 16:53 | sohail | you are asking for it |
| 16:53 | Chouser | both macros and reader macros return s-expressions |
| 16:53 | sohail | the evils that are possible with ( for reader macros... |
| 16:53 | sohail | atleast with # you aren't required to delimit, whereas with ( you are, unless you are really mean |
| 16:55 | kotarak | sohail: If I give you a rope and tree, will you hang yourself? |
| 16:55 | Kerris4 | :( |
| 16:55 | sohail | if I have to use ( for reader macros |
| 16:55 | sohail | :-) |
| 16:55 | kotarak | If I give you ( for read macros, will you do evil things? |
| 16:55 | sohail | emacs will be very unhappy with me |
| 16:56 | kotarak | Not when there is a ) necessary. |
| 16:56 | kotarak | Emacs won't note a difference. |
| 16:56 | sohail | if it's necessary, then sure I am happy |
| 16:56 | sohail | I just cringed at Chouser's example above |
| 16:56 | kotarak | beh :( |
| 16:56 | kotarak | Such things are evil. |
| 16:57 | kotarak | Solution: don't do it. Don't use other code which does it. |
| 16:57 | kotarak | Simple. |
| 16:57 | sohail | uh, no |
| 16:57 | sohail | solution: don't allow it |
| 16:57 | sohail | much easier |
| 16:57 | sohail | you're just helping rhickey make his case against! |
| 16:57 | Chouser | sohail: how would you indicate the end of a # macro? |
| 16:57 | kotarak | I feel Ada coming up.... |
| 16:58 | sohail | Chouser, I wouldn't, and Emacs wouldn't care |
| 16:58 | sohail | but if there is a ( and no ), I fear |
| 16:58 | sohail | by the way, do we really want clojure to be a language that gives you enough rope to hang yourself? |
| 16:59 | sohail | it is not the place to be |
| 16:59 | kotarak | rich talked about #+ and #-, in this I see much more potential for rope.... |
| 17:00 | sohail | you see more potential in a regular syntax to give you rope than allowing irregular syntax? |
| 17:00 | sohail | interesting |
| 17:01 | sohail | though whatever argument you make for #+ applies to (+ :-) |
| 17:02 | Kerris4 | is there a -Wall or XLint equivalent for Clojure? |
| 17:05 | kotarak | sohail: How is this handled? (cond (foo) bar #+frob (frobnicate) flogiston) |
| 17:05 | sohail | I don't understand why you are harping on about #+ |
| 17:06 | kotarak | I want to understand it, because the people are so interested in it. In the above example: is this a valid example use? |
| 17:08 | sohail | kotarak, that is an odd cond |
| 17:08 | kotarak | sohail: May question is: would the reader complain? |
| 17:09 | sohail | what does the cond have to do with it |
| 17:09 | sohail | that cond doesn't even look correct |
| 17:11 | kotarak | Without #+frob it's a normal cond. However with #+frob it's easy to break the code. This is the same thing as with ( doing strange things without closing ). Or do I misunderstand something? |
| 17:11 | ReplRat | Why doesn't (doc def) work? I get java.lang.Exception: Unable to resolve var: def in this context |
| 17:11 | ReplRat | clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:22: Unable to resolve var: def in this context |
| 17:11 | kotarak | ReplRat: def is a special form |
| 17:11 | sohail | why would you write a cond like that |
| 17:11 | kotarak | why would I write a ( reader macro which doesn't close the )? |
| 17:12 | ReplRat | (def apply) |
| 17:12 | sohail | kotarak, why should you have the choice |
| 17:12 | kotarak | ReplRat: http://clojure.org/special_forms for more on special forms. |
| 17:12 | kotarak | sohail: why should I be able to break the cond with #+? |
| 17:13 | ReplRat | kotarak: thanks |
| 17:13 | sohail | why will it break |
| 17:14 | kotarak | Because without frob feature the (frobnicate) will be removed. Leavind an odd number of clauses and flogiston in the position of a test. |
| 17:15 | sohail | so you're asking me why can you break cond by putting in an odd number? |
| 17:15 | sohail | I don't get it |
| 17:15 | sohail | I don't need #+ to do that |
| 17:16 | kotarak | It's not important. Certainly a misunderstanding of this whole stuff on my side. |
| 17:16 | Chouser | kotarak: you were doing so well! |
| 17:17 | Chouser | sohail: the person writing the cond probably meant for the #+ to apply to the entire condition. It was a simple mistake that may go unnoticed for a long time. |
| 17:17 | sohail | ok.. |
| 17:18 | sohail | yesterday I accidentally wrote (defmacro while [cond & body] `(when ~@cond ...)) |
| 17:18 | kotarak | A *poof* the regular syntax of #+ introduced the rope... |
| 17:18 | sohail | which did odd things |
| 17:18 | sohail | so let's get rid of ~@ too |
| 17:18 | kotarak | Ah! Macros are bad! |
| 17:18 | sohail | see |
| 17:19 | kotarak | Other languages saw this already and remove them completely. ;) |
| 17:19 | Chouser | so maybe we already have enough rope to hang ourselves. in which case, what's wrong with ( for reader macros? |
| 17:19 | kotarak | sohail: I think there will alway be rope. Bondage and Discipline is not really the way to go... |
| 17:19 | sohail | I can't believe you are seriously considering ( without ) |
| 17:19 | sohail | kotarak, exactly |
| 17:19 | Chouser | ah, nevermind. kotarak, you were right to give up. |
| 17:19 | sohail | so why are you advocating NO READER MACROS |
| 17:19 | Chouser | this is not a condusive forum for this kind of disucssion. |
| 17:20 | Chouser | I have a feeling that if were all in the same room and had a whiteboard, we would have reached a concensus (or at least an understanding) quite a while ago. |
| 17:20 | kotarak | probably |
| 17:28 | ReplRat | is there a way to access the nth most recent expression result in the Repl? like i can do in bash? |
| 17:28 | kotarak | there is *1 *2 and *3 |
| 17:28 | ReplRat | thanks |
| 17:29 | ReplRat | where is that documented |
| 17:29 | kotarak | *e for the last thrown expection |
| 17:30 | ReplRat | hmm, i'm getting Unable to resolve symbol |
| 17:31 | kotarak | which version clojure do you use? Maybe it's only in SVN up to now... |
| 17:31 | ReplRat | an svn from less than 3 days ago |
| 17:32 | ReplRat | i'm using git svn but i haven't figured out how to see what the most recent commit is yet |
| 17:32 | ReplRat | (trying to learn git as well as clojure) :) |
| 17:33 | kotarak | Just e sec |
| 17:33 | kotarak | Works for me... |
| 17:34 | ReplRat | i'm just typing *1 at the repl, should it eval as an expression or do i need to wrap it in something else? |
| 17:34 | sohail | I think you need to update swank if you are using it |
| 17:34 | ReplRat | ahh well i'm just using a naked repl at the moment, not slime/swank. |
| 17:34 | Chousuke | ReplRat: git log HEAD^.. |
| 17:36 | Chousuke | more generally: git log HEAD~n.. shows you the log entries for the last n commits, and ^ is a synonym for ~1 |
| 17:36 | ReplRat | Chousuke: thanks. the last commit seems to be July 22? i must be doing something stupid with git which is why *1 doesn't work. |
| 17:36 | Chousuke | you can also use tags or hashes, or specify and endpoint for the range. |
| 17:37 | Chousuke | july 22? that doesn't sound right. |
| 17:37 | ReplRat | i did git clone last weekend, and git fetch on wednesday to update my repo. |
| 17:37 | ReplRat | git svn clone i mean |
| 17:38 | Chousuke | r1086 | rhickey | 2008-10-29 14:42:40 +0200 (Wed, 29 Oct 2008) | 1 line |
| 17:38 | Chousuke | most recent, it seems |
| 17:38 | ReplRat | that looks more like it. |
| 17:38 | Chousuke | maybe you need to use git svn log or something |
| 17:39 | Chousuke | I have the clojure repo as plain svn so I can't test mysefl |
| 17:39 | ReplRat | Chousuke: that's it. git svn log shows r1085. |
| 17:39 | Chousuke | should really clone it as a git repo. |
| 17:39 | Chousuke | git is so much better than subversion |
| 17:40 | ReplRat | yep, and lots of clojure stuff, (clojure-mode etc) is on git |
| 17:40 | ReplRat | there seems to be a clojure clone on github, but i wonder how it is kept up to date? |
| 17:40 | ReplRat | http://github.com/kevinoneill/clojure/tree/master |
| 17:41 | Chousuke | well it seems to be current right now at least :) |
| 17:42 | ReplRat | maybe github has some svn sync magic that i don't know about |
| 17:42 | Chousuke | or maybe the person who created that just has a cronjob that updates it periodically :) |
| 17:43 | ReplRat | i thought i would be better off just using git svn myself that cloning his clone. |
| 17:43 | Chousuke | oh, apparently github can do svn imports by itself. nice. |
| 17:44 | Chousuke | though looking closer, it doesn't keep them synchronised automatically :P |
| 18:39 | ReplRat | should i use ant or maven to build clojure? |
| 18:40 | kotarak | I use ant. Never had problems. |
| 20:23 | mmcgrana | I see that the meta information on a var holding a function includes its file and line: e.g. (meta (resolve 'doc)) => {... :file "boot.clj", :line 2506 ...} but the file name is not qualified with a directory. Is there a reason for this, and can the fully qualified name be derived using e.g. the classpath? |
| 20:32 | mmcgrana | Probably should have asked if anyone was here first, I'll post to the group... |
| 23:15 | gnuvince_ | Hmmm |
| 23:15 | gnuvince_ | Did you guys watch the presentation by Slava about Factor? His EBFN library is *really* nice |
| 23:29 | sohail | man, I still remember when factor ran on the JVM |