Re: Learning Clojure
On Dec 11, 7:06 am, Alex Burka wrote: > To the debate on whether there should be examples early in the text, > here are my two cents: > > When I click on something called "Learning [programming language]" I > like to see a representative example of the syntax early on. If > there's just text as far as the eye can see (that is, the first > screen) it is off-putting for some reason. After all, it is a > programming language. > Hi, I've discovered Clojure recently, and so I guess I'm part of the target audience for such a document :-) I must say I agree with Alex: I would really like to see code examples. >From the title, I had expected a step by step tutorial for building my first Clojure program. I find your documentation *very* interesting but I filed it under 'Understanding Clojure' ;-) Raph > Alex > > On Dec 11, 2008, at 12:55 AM, Timothy Pratley wrote: > > > > > Hi Brian, > > >> Rich talks about destructuring in the part about "let" on the > >> "special > >> forms" page. > > > Ah indeed, thanks for pointing that out :) > > >> If you have any examples to add, please add them yourself (it is a > >> wiki > >> page). > > > You've given some really good reasons why I shouldn't mess with it > > *chuckle* so I'm getting mixed messages. If you do want me to add > > example link, I'm happy to do that but for now I'm assuming you'd > > prefer it left as is :) > > >> Thanks for your feedback. > > > You are most welcome. > > > Regards, > > Tim. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure articles and blogs
On 28 jan, 18:38, Mark Volkmann wrote: > Are there web pages that provide links to articles and blogs about Clojure? > It would be nice if an "Articles" link and a "Blogs" link to such > pages appeared in the upper-right corner ofhttp://clojure.org. Bill Clementson created a Yahoo Pipe aggregating clojure articles, you can find it here: http://pipes.yahoo.com/pipes/pipe.info?_id=4cc8ebb9ae0b852d6ab7d94956ce2638 raph > > -- > R. Mark Volkmann > Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
anyone going to FOSDEM?
Hi, are any clojure developers going to FOSDEM, next week-end in Brussels (Belgium)? It would be cool to meet there. (I'm a complete newbie at clojure, but that would make it the more interesting for me to meet other clojure developers:-) Cheers Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
google notebook -> delicious thanks to Clojure
Hi, My first useful code writted in Clojure is a migration script from Google Notebook to Delicious. It's available at http://www.nsa.be/nb_exporter/ (complete package to download) and code is at http://github.com/raphinou/nb_exporter. It is code developed on the pre-lazy clojure. Here are some questions and reactions after this first step in Clojure land: * I felt in the trap a couple of times when testing and using first, second and then nth: after calling second I called nth 3, where it has to be nth 2. * (sql(read)) has problems if value read is a path with slashes like / tmp/blup. The solution is to type it in double quotes: "/tmp/blup" * I'm not sure how I should read user input without echo, for the password. Currently the password of the user is displayed when it is typed. * As I'm new to Lisp like languages, I'm not sure if I used defmulti wisely. But I followed the rules of the Macro Club: there is none in the code as everything could be done with functions * zip/children returns a map, that cannot manipulated with the zip functions. I got used to the zip way and was surprised the children function returned something I could not manipulate the zip way. As a conclusion, I enjoyed it a lot and I'm happy I finally found a language that has the following qualities: - a lisp with a low barrier of entry (in my humble experience, I had tried common lisp before but found it harder to begin with) - a language I like that gives me access to the java libraries out there! Looking forward to developing more in Clojure! Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
contrib api documentation?
Hi, is there a place where I can find the documentation of clojure.contrib in the same vein as clojure.core is documented at http://clojure.org/API ? Thanks Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: contrib api documentation?
On Mar 10, 11:47 am, Chas Emerick wrote: > This is a pretty nice reference: > > http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html Nice, especially after you update the css to have #doc-items position set to fixed :-) > > A little old now, though. The tool that generated it is open-source > (on github, I think), so refreshing it for yourself shouldn't be too > difficult. Didn't find the link rapidly, I'll look further later. Thanks for your help! Raph > > - Chas > > On Mar 10, 2009, at 6:16 AM, rb wrote: > > > > > Hi, > > > is there a place where I can find the documentation of clojure.contrib > > in the same vein as clojure.core is documented athttp://clojure.org/API > > ? > > > Thanks > > > Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
transposing a small java class in clojure
Hi, I'm experimenting with http://mina.apache.org/ftpserver I have written a small java class that gets used by the ftp server, and am trying to transpose it to clojure, but unsuccessfully until now The class generated with clojure is detected and used by the server, but the code of the method implemented is not run, and even worse, the ftp server isn't functional anymore (though I don't see any exception raised). Does anyone have an idea about what I'm doing wrong? Thanks Raphaël Here's the java code: package com.raphinou; import java.io.IOException; import org.apache.ftpserver.*; import org.apache.ftpserver.ftplet.*; public class Ftplet extends DefaultFtplet { public FtpletResult onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException { java.util.logging.Logger logger= java.util.logging.Logger.getLogger("com.raphinou"); logger.addHandler( new java.util.logging.FileHandler("/tmp/ ftp.log")); logger.severe("Logging in!!"); return FtpletResult.DEFAULT; } } and here's the clojure code: (ns com.raphinou.ftplet (:gen-class :name com.raphinou.Ftplet :extends org.apache.ftpserver.ftplet.DefaultFtplet) (:import [org.apache.ftpserver.ftplet DefaultFtpReply FtpletResult])) (def logger (java.util.logging.Logger/getLogger "com.raphinou")) (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) (defn -onLogin [session request] (.severe logger "Logging in, clj") FtpletResult/DEFAULT) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: transposing a small java class in clojure
HI Chris, thanks for your response, and I'll update the code as you suggest. However, I actually have problems even when the -onLogin function is empty, returns nil, or returns FtpletResult/DEFAULT. It seems it causes trouble once it's defined. I'll post an update tomorrow Raphaël On Mar 10, 6:50 pm, chris wrote: > I can see one possible difference, depending on how you are loading > the code into the ftp server. > > In your clojure example you are accessing the logger through a top- > level define. I believe this will run *during the file loading > process* as static code. > > In your working java example, you aren't accessing the logger until > the actual onLogin function is called. > > If the logger is in an odd state (like null) or god forbid the runtime > sets up the logger just before it calls into your function then you > may get different results. I would recommend calling the getlogger > call in the function perhaps; change the 'def logger' to 'defn logger > []' and work out the resulting details. This would make the clojure > example a little closer to your java example and at least eliminate > one possible problem. > > Chris > > On Mar 10, 7:35 am, rb wrote: > > > Hi, > > > I'm experimenting withhttp://mina.apache.org/ftpserver > > I have written a small java class that gets used by the ftp server, > > and am trying to transpose it to clojure, but unsuccessfully until > > now > > > The class generated with clojure is detected and used by the server, > > but the code of the method implemented is not run, and even worse, the > > ftp server isn't functional anymore (though I don't see any exception > > raised). > > > Does anyone have an idea about what I'm doing wrong? > > > Thanks > > > Raphaël > > > Here's the java code: > > > package com.raphinou; > > > import java.io.IOException; > > import org.apache.ftpserver.*; > > import org.apache.ftpserver.ftplet.*; > > > public class Ftplet extends DefaultFtplet { > > public FtpletResult onLogin(FtpSession session, FtpRequest > > request) > > throws FtpException, IOException { > > java.util.logging.Logger logger= > > java.util.logging.Logger.getLogger("com.raphinou"); > > logger.addHandler( new java.util.logging.FileHandler("/tmp/ > > ftp.log")); > > logger.severe("Logging in!!"); > > return FtpletResult.DEFAULT; > > } > > > } > > > and here's the clojure code: > > > (ns com.raphinou.ftplet > > (:gen-class :name com.raphinou.Ftplet > > :extends org.apache.ftpserver.ftplet.DefaultFtplet) > > (:import [org.apache.ftpserver.ftplet DefaultFtpReply > > FtpletResult])) > > > (def logger (java.util.logging.Logger/getLogger "com.raphinou")) > > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) > > > (defn -onLogin [session request] > > (.severe logger "Logging in, clj") > > FtpletResult/DEFAULT) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: transposing a small java class in clojure
On Mar 10, 8:24 pm, Kevin Downey wrote: > I don't know how many arguments the method you are overriding with > onLogin takes, but the function you define should take one more > argument then the method you are overiding, the first argument being > an explicit reference to an instance That was it! Here's the working function: (defn -onLogin [this session request] (.severe logger "Logging in, clj") FtpletResult/DEFAULT) Thanks! Raphaël > > > > On Tue, Mar 10, 2009 at 12:16 PM, rb wrote: > > > HI Chris, > > > thanks for your response, and I'll update the code as you suggest. > > However, I actually have problems even when the -onLogin function is > > empty, returns nil, or returns FtpletResult/DEFAULT. It seems it > > causes trouble once it's defined. > > > I'll post an update tomorrow > > > Raphaël > > > On Mar 10, 6:50 pm, chris wrote: > >> I can see one possible difference, depending on how you are loading > >> the code into the ftp server. > > >> In your clojure example you are accessing the logger through a top- > >> level define. I believe this will run *during the file loading > >> process* as static code. > > >> In your working java example, you aren't accessing the logger until > >> the actual onLogin function is called. > > >> If the logger is in an odd state (like null) or god forbid the runtime > >> sets up the logger just before it calls into your function then you > >> may get different results. I would recommend calling the getlogger > >> call in the function perhaps; change the 'def logger' to 'defn logger > >> []' and work out the resulting details. This would make the clojure > >> example a little closer to your java example and at least eliminate > >> one possible problem. > > >> Chris > > >> On Mar 10, 7:35 am, rb wrote: > > >> > Hi, > > >> > I'm experimenting withhttp://mina.apache.org/ftpserver > >> > I have written a small java class that gets used by the ftp server, > >> > and am trying to transpose it to clojure, but unsuccessfully until > >> > now > > >> > The class generated with clojure is detected and used by the server, > >> > but the code of the method implemented is not run, and even worse, the > >> > ftp server isn't functional anymore (though I don't see any exception > >> > raised). > > >> > Does anyone have an idea about what I'm doing wrong? > > >> > Thanks > > >> > Raphaël > > >> > Here's the java code: > > >> > package com.raphinou; > > >> > import java.io.IOException; > >> > import org.apache.ftpserver.*; > >> > import org.apache.ftpserver.ftplet.*; > > >> > public class Ftplet extends DefaultFtplet { > >> > public FtpletResult onLogin(FtpSession session, FtpRequest > >> > request) > >> > throws FtpException, IOException { > >> > java.util.logging.Logger logger= > >> > java.util.logging.Logger.getLogger("com.raphinou"); > >> > logger.addHandler( new java.util.logging.FileHandler("/tmp/ > >> > ftp.log")); > >> > logger.severe("Logging in!!"); > >> > return FtpletResult.DEFAULT; > >> > } > > >> > } > > >> > and here's the clojure code: > > >> > (ns com.raphinou.ftplet > >> > (:gen-class :name com.raphinou.Ftplet > >> > :extends org.apache.ftpserver.ftplet.DefaultFtplet) > >> > (:import [org.apache.ftpserver.ftplet DefaultFtpReply > >> > FtpletResult])) > > >> > (def logger (java.util.logging.Logger/getLogger "com.raphinou")) > >> > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) > > >> > (defn -onLogin [session request] > >> > (.severe logger "Logging in, clj") > >> > FtpletResult/DEFAULT) > > -- > And what is good, Phaedrus, > And what is not good— > Need we ask anyone to tell us these things? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how do I create a runnable clojure program
On Apr 29, 1:04 pm, Santanu wrote: > Hi Everybody, > > I wanted to compile a .clj clojure file into a .jar/.class file so > that I could run it using java. (I don't know what is the actual way > to run clojure file. So far, I have only been trying it from within > emacs/slime). > > But I don't know how to create the .class/.jar file. I also don't know > how to use ant (is that required?). I know javac can be applied on > a .java file to get a .class file... but I dunno what applies to > a .clj file? > > Kindly suggest how do I do this. Any pointer(s) to a suitable online > article would be great. I remember this helped me: http://clojure.org/compilation Cheers Raphaël > > Thanks in advance for your help. > > Reards, > Santanu Chatterjee --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Updating a running app
HI, in his post "Macro design, by example" [1], Meikel Brandmeyer mentioned that it is possible to reload a function (in contrast to a macro) in a running application: "Now all you have to do is to just reload the single function in the running application. This can be easily done by environments like SLIME or VimClojure. Et voila. The next time the function is called you already get the benefit. Without recompilation of the whole app... " Is achieving this a general possibility for any app, or are there limitations to updating running applications? For example, is it necessary to start the app in a REPL to be able to update it while it's running? Or is it possible to open a REPL attached to a running application? I'm very curious about this (possibly compared to Erlang's hot code update possibilities) and would appreciate any pointer or example. Thanks! Raphael [1] http://groups.google.com/group/clojure/browse_thread/thread/5ff31c9d7fc58b0b# --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Mnesia like?
On Jun 15, 6:02 pm, Wilson MacGyver wrote: > Does clojure have anything like erlang's Mnesia? or is anyone working on such > project? I know I can fall back to using JDBC+ various RDBMS, but I > was curious if there is something that works like Mnesia. Depending on what you mean by "works like Mnesia", you might be interested to look at http://hadoop.apache.org/hbase/ Cheers Raph > > Thanks, > Mac > > -- > Omnem crede diem tibi diluxisse supremum. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Runtime Compilation of Clojure from Android
On Jun 16, 5:51 am, George Jahad wrote: > Remco van't Veer has done a lot of great working porting Clojure to > Android, but one thing remains missing, runtime compilation which > would allow a fully functional Repl. The problem is that the Android > VM doesn't use standard Java class files but rather Android specific > ones. There is a host-side tool that converts Java byte codes to > Android ones. But that tool doesn't normally run on Android. > > So, being an Android systems hacker, I was wondering how hard it would > be to get runtime compilation working. > > Turns out, it doesn't seem to be too hard. The trick is basically to > run the Java to Android/Dalvik byte code converter through itself, so > that the convertor can be run on Android; if you load that converted > convertor into Android, you can then invoke it after each class is > compiled, essentially like this: > > if(RT.booleanCast(COMPILE_FILES.deref())) > { > writeClassFile(internalName, bytecode); > String strings[] = {"--dex", "--output=/data/gbj/classes.dex", "/ > data/gbj/classes"}; > com.android.dx.command.Main.main(strings); > } > > (Note that *compile-path* is set elsewhere to "/data/gbj/classes") > > Loading the generated class file is also a bit tricky, but not too > bad. > > It isn't too fast, partly because of Android's slow GC and partly > because I'm using the filesystem as intermediate storage before > loading the classes, (because I haven't figured out how to do it all > in memory yet.) > > I'll send out a full set of patches if there is interest, but for now > here is an Android app with the repl built in so you can play with > it. (It is version of Remco's simple calculator app with a socket > based repl added.) > > Much thanks to Remco upon whose Android/Clojure work this is all > built. > > App install instructions below. > > g > > (Note: I've only tested these install instructions out on a Linux host > with this sdk: android-sdk-linux_x86-1.5_r2.zip) > > Download the prebuilt apk file > here:http://georgejahad.com/clojure/calc-debug.apk > Is your source code available somewhere? (I'm interested to know how you added the socket based REPL and how it interacts with the app ) Raphaël > To configure the emulator: > emulator -avd > adb install -r calc-debug.apk > adb shell mkdir /data/gbj > adb shell mkdir /data/gbj/classes > adb shell chmod 777 /data/dalvik-cache > adb shell chmod 777 /data/gbj > adb shell chmod 777 /data/gbj/classes > adb forward tcp:8030 tcp:8030 > > Then start up the calc app from the emulator gui. > > Then access the repl like so: > telnet localhost 8030 > > Allow compilation like so: > (def *android* true) (def *compile-files* true) > > Now you can compile from the repl. For example, this adds a simple > exponent operator to the calculator: > > (in-ns 'examples.calc) > (defn exp [ b e] (reduce * (repeat b e))) > (def calc-opers {\+ #'+ > \- #'- > \/ #'/ > \* #'* \e #'exp}) > (def calc-allowed-chars (.toCharArray "e0123456789.")) > > You can examine Remco's source code to see how the calculator works > here:http://github.com/remvee/clj-android/blob/d1e96d33487ddcdc04b403e97f8... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another web framework for Clojure.
On Jun 18, 11:11 pm, Matt wrote: > Hi all, > > I was recently introduced to Clojure by a coworker, and have been > loving it ever since. I jumped in head first writing a Rails like web > framework with it before I realized how many other basic web > frameworks are out there. Anyways, it's a fun project and I'm pretty > happy with the state it's in right now so I released the code on > Github. If anyone is interested in playing with it and giving me some > pointers, you can find it at: > > http://github.com/macourtney/Conjure/tree/master > > I've also added a simple hello world tutorial which demonstrates most > of the features of Conjure so far: > > http://wiki.github.com/macourtney/Conjure/hello-world-tutorial > > I realize the model and view code leave much to be desired, and there > are a few good libraries for both out right now. I plan on adding some > of those libraries in the next release. Very interesting! Do you plan to actively develop it on the longer term? Raphaël > > Any other suggestions are welcome. > > -Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Jwt from Clojure?
HI, Jwt (http://www.webtoolkit.eu/jwt ) is a java translation of the C++ web toolkit (http://www.webtoolkit.eu/wt ) I'd like to develop a web app in clojure based on Jwt, but Jwt apps need to run in a servlet container. What's the best path to follow in that case? Is developing a Ring adapter which would then allow me to run the app with Jetty the way to go? Every pointer will be welcome! :-) Thanks Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clojure article in french magazine
Hey, I was looking computer magazines and I had the good surprise to see clojure mentioned on the cover of Programmez, a french magazine. The article is titled 'Cloure, a Lisp for the JVM", and seems positive (eg, it says "Clojure (...) est génial" meaning "Clojure is great"): http://www.programmez.com/magazine_articles.php?titre=Clojure, un Lisp pour la JVM&id_article=1251&magazine=121 Cheers Raph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
advice needed about macro for proxy with argument
HI, I have several calls to addListener, for which I have to create a proxy:: (.. (WPushButton. "Greet me" root) clicked (addListener wapp (proxy [Signal1$Listener] [] (trigger [ mouse-event ] (.setText result-text (.getText line-edit)) I think this is code elligible for simplification with a macro (correct me if I'm wrong). In the example above, the macro has to expand to: (proxy [Signal1$Listener] [] (trigger [ mouse-event ] (.setText result- text (.getText line-edit but there are other cases, according to the number of argument passed to trigger: (proxy [Signal$Listener] [] (trigger [ ] (.setText result-text (.getText line-edit (proxy [Signal2$Listener] [] (trigger [ arg1 arg2 ] ... )) (proxy [Signal3$Listener] [] (trigger [ arg1 arg2 arg3 ] ... )) Here is what I've done for now: (defmacro deflistener [ interfaces trigger-args & body] `(proxy [ ~...@interfaces ] [] (trigger [...@trigger-args] ~...@body)) ) Which can be used like this: ( deflistener (Signal1$Listener) (mouse-event) (.setText result-text (.getText line-edit)) )) It takes as arguments * the list of interfaces it implements (currently necessary for http://www.assembla.com/spaces/clojure/tickets/181) * the list of arguments passed to the trigger method implemented * the body of the implementation of trigger Here are the questions that arise: * I thought I could and should do away with trigger-args, but if I use gensyms in the macro to define the arguments received by trigger, how can I get to the argument values in the code of the method? * if it implements SignalX$Listener, trigger takes X arguments. How can implement that with one macro, and still have access to these arguments in the forms I pass as body of trigger? Thanks for your help Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: advice needed about macro for proxy with argument
On Aug 25, 9:54 pm, Meikel Brandmeyer wrote: > Hi, > > Am 25.08.2009 um 20:09 schrieb rb: > > > Here is what I've done for now: > > > (defmacro deflistener [ interfaces trigger-args & body] > > `(proxy [ ~...@interfaces ] [] (trigger [...@trigger-args] ~...@body)) > > ) > > > Which can be used like this: > > ( deflistener (Signal1$Listener) (mouse-event) (.setText result-text > > (.getText line-edit)) )) > > I would rewrite it as follows: > > (defmacro create-listener > [interfaces args & body] > `(proxy ~interfaces [] (trigger ~args ~...@body))) > > First the macro doesn't "def" something global. So it should not be > called deflistener. Compare with create-struct and defstruct. > > Then with the above changes the call looks like > > (create-listener [inter faces] [a b c] (do-stuff a b c)) > > This is more idiomatic Clojure. (Effectively you can specify a vector > in your version also, but seems like waste to define vector which is > thrown away just to define another vector with the same contents. I > find this not very elegant) > > > It takes as arguments > > * the list of interfaces it implements (currently necessary for > >http://www.assembla.com/spaces/clojure/tickets/181) > > ?? You always have to specify the interfaces, no? What I meant is that if I always implement SignalX$Listener, I could even get rid of the interfaces list as argument to the macro as it can be derived from the number or arguments that will be passed to trigger. I could write (create-listener [a1 a2 a3] ( do-stuf a b c ) ) and know that this has to proxy Signal3$Listener. However, the bug linked makes that impossible for now as all nested interfaces have the same name. Thanks for your remarks! Raphaël > > > * the list of arguments passed to the trigger method implemented > > * the body of the implementation of trigger > > > Here are the questions that arise: > > > * I thought I could and should do away with trigger-args, but if I use > > gensyms in the macro to define the arguments received by trigger, how > > can I get to the argument values in the code of the method? > > You cannot get rid of the argument vector. > > > * if it implements SignalX$Listener, trigger takes X arguments. How > > can implement that with one macro, and still have access to these > > arguments in the forms I pass as body of trigger? > > You could pass the body as a fn. > > (defmacro create-listener > [x f] > (let [args (take x (repeatedly gensym))] > `(proxy [~(symbol (str "Signal" x "$Listener"))] [] (trigger > [...@args] (~f ~...@args) > > And call it like > > (create-listener 2 (fn [a b] ...)) > > Whether this is better than the above I would prefer the first > solution. > > Hope this helps. > > Sincerely > Meikel > > smime.p7s > 2KViewDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: advice needed about macro for proxy with argument
> > > It takes as arguments > > > * the list of interfaces it implements (currently necessary for > > >http://www.assembla.com/spaces/clojure/tickets/181) > > > ?? You always have to specify the interfaces, no? > > What I meant is that if I always implement SignalX$Listener, I could > even get rid of the interfaces list as argument to the macro as it can > be derived from the number or arguments that will be passed to > trigger. > I could write > (create-listener [a1 a2 a3] ( do-stuf a b c ) ) Here is the macro I came up with: (defmacro create-listener [ args & body] (let [argsnum# (count args)] `(proxy [ ~(symbol (str "Signal" argsnum# "$Listener")) ] [] (trigger ~args ~...@body --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Jwt from Clojure?
On Aug 17, 6:17 pm, Adrian Cuthbertson wrote: > Hi Raphaël, > > If you're going to drive your app (and server) from clojure, then you > can use Compojure's jetty.clj module. This allows you to create a Thanks Adiran for this information. It has allowed me to get it running quite easily. I've posted notes of what I've learned, including a first macro to facilitate development, at http://www.nsa.be/index.php/eng/Blog/Using-Jwt-yes-it-s-a-J-with-Clojure Feedback and comments welcome! Raphaël > servlet holder (in which you can add an instantiatedJwtservlet on a > jetty url path). Compojure also supports the Ring protocol, so you can > also then use it for other webapp functionality. > > You could also use the Ring library, but (afaik) it uses a Jetty > AbstractHander (which is a higher abstraction of the Http connection > than a servlet). You would need to add some logic to create a Jetty > ServletHolder class yourself (check out the Jetty api). > > If you're hooking into an existing server, then you can just create a > webapp/war with theJwtservlet and add your clojure (comporure/ring) > apps in their own servlet using gen-class. There is an example of > doing this on the compojure wiki. > > There are also some other frameworks that have been announced in this > group - perhaps others will chip in, or search the group for previous > posts on web frameworks. > > (Jwtlooks interesting, I'm going to take a good look at it as well.) > > Hth, Adrian. > > On Mon, Aug 17, 2009 at 5:07 PM, rb wrote: > > > HI, > > >Jwt(http://www.webtoolkit.eu/jwt) is a java translation of the C++ > > web toolkit (http://www.webtoolkit.eu/wt) > > I'd like to develop a web app in clojure based onJwt, butJwtapps > > need to run in a servlet container. > > > What's the best path to follow in that case? Is developing a Ring > > adapter which would then allow me to run the app with Jetty the way to > > go? > > > Every pointer will be welcome! :-) > > > Thanks > > > Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure/EPL and the GPL
On Aug 28, 4:18 pm, Matthias Benkard wrote: > On 28 Aug., 13:42, Tassilo Horn wrote: > > > I have a licensing question. Am I allowed to include clojure.jar in a > > GPL project? > > IANAL, but if I understand the GPL correctly, it prohibits you from > distributing a GPL-covered programme that is based on Clojure, because > it would need to be linked to the EPL'd Clojure library code and so > would make the combination have to be distributed under the GPL, which > is impossible. Note that the GPL has this requirement only for derivative works! In the case you write clojure code, clojure wouldn't be a derivative work of your program and so clojure doesn't need to be licensed under the GPL There are GPL software that run on windows and use windows libraries, this doesn't require windows to be licensed under the GPL. If you want to modify clojure itself and redistribute it under the GPL, then this link applies: http://www.eclipse.org/legal/eplfaq.php#USEINANOTHER Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Easily add a Java Listener
Hi, After using Jwt from Clojure, I did it with Jruby and discovered that Jruby has what they call Closure Conversion (http://kenai.com/projects/ jruby/pages/CallingJavaFromJRuby#Closure_conversion ) where a Ruby block or closure is converted to an appropriate Java interface. From the wiki: "When calling a method that expects an interface, JRuby checks if a block is passed and automatically converts the block to an object implementing the interface". I found this to be unbelievably easy to use and efficient (for the developer) as the listener is added this way: button.clicked.add_listener(self) do greeting_.setText(nameEdit_.getText) end There's no need for the developer to implement any interface or manage any proxy object. I wondered if something similar is possible in Clojure. If not, would this be considered a valuable addition to Clojure? Thanks Raphaël --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
from OO to Lisp style (a blog post)
Hi, In using the Jwt library, for which I only found examples in object oriented languages that structure the code in class definitions and do heavy usage of instance variables, I was in a situation where I wondered how I could best structure my code. With help on the IRC channel I got to a working solution which I document in a blog post at http://www.nsa.be/index.php/eng/Blog/From-OO-to-Lisp-style-structuring-my-Clojure-Jwt-app I'm interested in feedback and advices for improvements Thanks Raph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: from OO to Lisp style (a blog post)
On Sep 4, 8:30 pm, Jonathan Smith wrote: > Hi Ralph, > > First off, nice post! We need more of these types of tutorials on GUI > in clojure, they're very useful. > > On make-login-widget you can probably do a doto when you do this part: > > > (.addWidget layout (WLabel. "Login:") 0 0 ) > > (.addWidget layout login-field 0 1 ) > > (.addWidget layout (WLabel. "Password:") 1 0 ) > > (.addWidget layout password-field 1 1) > > (.addWidget layout submit-button 2 0 1 2) > > Can be like (doto layout (add ) (add)) > yes, I didn't think of that! > I don't have any experience using Jwt, but with regard to listeners > and such, I've been using a 'continuation passing' style when writing > little toy applications using swing. The first version of my code was like that (see here: http://paste.lisp.org/display/86499), but then I decided to try using signals. Thanks for your feedback. raph > > I guess the best way to explain it is that rather than using .trigger > on the signal in the do-login function block, you would just apply a > passed in (possibly anonymous) function. I can give an example: > > Think of this as pseudocode that may or may not run, as I only have > Swing for ui on this computer. > > (defn make-login-form [logged-in-fn wrong-creds-fn] > (let [layout (WGridLayout.) > container (WContainerWidget.) > password-field (doto (WLineEdit. container) > (.setEchoMode WLineEdit$EchoMode/Password ) ) > password #(.getText password-field) > login-field (WLineEdit. container) > login #(.getText login-field) > do-login (fn [evt] > (if (authenticate (login) (password)) > (logged-in-fn) > (wrong-creds-fn))) > submit-button (WPushButton. "Login")] > (-> submit-button .clicked > (.addListener container > ( create-listener [mouse-event] > (do-login mouse-event > (doto layout > (.addWidget (WLabel. "Login:") 0 0 ) > (.addWidget login-field 0 1 ) > (.addWidget (WLabel. "Password:") 1 0 ) > (.addWidget password-field 1 1) > (.addWidget submit-button 2 0 1 2)) > (.setLayout container layout) > (.setFocus login-field) > container)) > > (defn make-login-app > ([env continuation] > (let [wapp (new WApplication env) > root (.getRoot wapp) > result-text (WText. "") > user nil > dialog (WDialog. "test") > dialog-container (.getContents dialog) > app-screen (make-app-screen) > form (make-login-form > #(do (.remove dialog) > (.setText (-> app-screen .getLayout (.getItemAt 0) > .getWidget) > "Logged in!") > (continuation)) > #(do (.setText (-> app-screen .getLayout (.getItemAt 0) > .getWidget) > "Wrong credentials!")))] > (.setTitle wapp "Login Example") > (doto dialog (.. getContents (addWidget form)) .show) > (.addWidget root app-screen) > wapp)) > ([env] > (make-login-app env identity))) > > And so then, to get a dialog that is like a sequence of panels, you > can go through and do like: > > (make-login-app env make-next-widget) > > Anyway, is not particularly any better than using signal passing > technique, > but is another approach that you might consider in your application. > > On Sep 4, 11:01 am, rb wrote: > > > Hi, > > > In using the Jwt library, for which I only found examples in object > > oriented languages that structure the code in class definitions and do > > heavy usage of instance variables, I was in a situation where I > > wondered how I could best structure my code. > > > With help on the IRC channel I got to a working solution which I > > document in a blog post > > athttp://www.nsa.be/index.php/eng/Blog/From-OO-to-Lisp-style-structurin... > > > I'm interested in feedback and advices for improvements > > > Thanks > > > Raph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clj-gradle – a Clojure Plugin for Gradle
On Oct 13, 9:16 pm, Meikel Brandmeyer wrote: > Hi, > > I'd like to announce the first release of a Clojure plugin for Gradle. > It features integration in the Gradle build and configuration system > and automatic namespace discovery for compilation. It is targeted for > Gradle 0.8. An example of use is included in the README. > > http://bitbucket.org/kotarak/clj-gradle > > If you are interested in a more dynamic build script than ant (and > maybe maven?) allows have look and let me know what you think. > > To build the plugin set the GRADLE_HOME environment variable to the > directory, where you installed Gradle. Put the clojure.jar in the lib > subdirectory and adjust the version information in the build.gradle > file. The file should be named clojure-.jar. The plugin is > tested with clojure 1.0 but post-1.0 should also work. Issues can be > reported on the bitbucket issue tracker ('Issues' tab at above link). Just wondering: how does it compare to Lancet? ( http://github.com/stuarthalloway/lancet ) Raphaël PS: Stu, is Lancet maintained or was it just an illustration for the book? > > Sincerely > Meikel > > smime.p7s > 3KViewDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Latest news on ClojureQL
On Dec 11, 11:58 am, LauJensen wrote: > Hi all, > > ClojureQL is now moved to Gradle and Jars are pushed to Clojars as > version 0.9.7 > > Blogpost on > status:http://www.bestinclass.dk/index.php/2009/12/clojureql-where-are-we-go... Very interesting. I wondered some days ago what is the best way to interact with a database from clojure and it's great to see this project progress! I'm wondering: how would you compare the use of ClojureQL and clj- record(which sadly doesn't show much activity currently)? Isn't CQL going back to the SQL level or database queries, whereas clj-record is at a higher level? Would it be easy to code this higher level layer on top of cql? Or is that less important in Clojure than it is in OO languages? And a suggestion: having migrations in CQL would be great! Raph > > Thanks, > Lau -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Latest news on ClojureQL
> > And a suggestion: having migrations in CQL would be great! > > Could you elaborate a little? Migrations are a way to manage the evolution of a schema of a database. I'm familiar with migration in Ruby on Rails which are explained here: http://api.rubyonrails.org/classes/ActiveRecord/Migration.html All changes to the data schema are made with migrations that, when applied (in the right order), build your database. You can also possibly go back and undo the change if the operation was not destructive (migrations have an up- and downgrade operation). The list of migrations applied are kept in a table of the database, so when an upgrade is done, the migration system knows which migrations have to be run in the upgrade step. When a migration is run, its id is added to the list of migrations that have been applied to the database. And when a migration is unapplied (downgrade operation), its id is removed from the list. That way, you can go up and down in the version of your schema. Of course you most often only play with the last migrations during the development phase. And when you deploy to production, you may be sure the same changes will be applied as what you did. And migration can also manipulate the data in addition to change the data structure. For example, it can create and populate a table with initial data. In an extreme case, if you want to split a table in multiple tables, you could do that in a migration which would - create the new tables - populate them with data from the initial table - drop columns that are now superfluous in the initial table These operation can be non-destructive, and so the migration can be undone. It's really been a time saver and I think it's a really good fit with ClojureQL. Raphaël -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Latest news on ClojureQL
On Dec 14, 12:17 pm, LauJensen wrote: > > It's really been a time saver and I think it's a really good fit with > > ClojureQL. > > > Raphaël > > Raphaél, thank you for bringing this to my attention, it looks > interesting. > > I think this falls more in the tool-category than the language- > category. In its simplest form ClojureQL aims to make you totally DB- > Agnostic, adhering only to its own syntax and then totally > disregarding the target DBMS. I hope that it will be picked up for > further high-level abstractions ala clj-record or similar. These tools > can easily be built on top of ClojureQL, but I'm not sure that they > should be knitted into ClojureQL. > > I'm open for discussion though. I totally agree that tools like clj-records are higher level than ClojureQL and should not be part of it. For the migrations, I'm not that sure it's completely separated. If I use ClojureQL in an application, I'll certainly use it to build my database schema, and at that time it's of great value to have migrations integrated in ClojureQL. Migrations are so interesting that I would use them even if I had to write the SQL by hand in my application: they have values even used independently from higher level tools. I'm fully aware that my argumentation would carry much more weight if I had the opportunity to contribute some code for migrations, but I currently don't have :( Raph > > /Lau B. Jensen -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ClojureQL docs?
Hi, After the recent discussion about ClojureQL, I wanted to try it, but I haven't found any documentation outside examples in blog posts. Did I miss something or is the code the current documentation? Raphaël -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Agents of Swing ported to Jwt
Hi, After reading Stuart Sierra's post titled "Agents of Swing" [1] I couldn't wait to try and port it to Jwt [2]. I finally had the time and documented it in a blog post at http://www.nsa.be/index.php/eng/Blog/From-Swing-to-Jwt I thought this could be of interest to some people here, expecially those looking for a web app framework. Cheers Raph [1] http://stuartsierra.com/2010/01/08/agents-of-swing [2] http://www.webtoolkit.eu/jwt -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Full Disclojure - I Need Topics!
On Jan 25, 6:34 am, Sean Devlin wrote: > Hello everyone, > I'm having a blast making the Full Disclojure series. It's one the > best projects I've had a chance to work on. > > However, there's going to be a problem soon. I only have a few more > topics left before I run out. No more topics, no more videos. > > This is where you come in. I'm interested in what the community (i.e. > you) would like to see talked about. It could be the core language, > contrib, a popular library, your-really-awesome-library-that-you-would- > like-to-get-exposure, or some development tool. Bring up anything and > everything. If it's interesting enough, I'll try to do an episode on > it. There are no bad suggestions. * interacting with a database in general, and covering clojureql in particular * debugging with http://georgejahad.com/clojure/debug-repl-macros.html * clojure.contrib: there's a lot of good things in there to cover > > Thanks in advance, > Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Dutch Clojure users
On Feb 6, 12:26 pm, Joop Kiefte wrote: > Hello folks! > > I am from the Netherlands and I am learning Clojure now, using it at work, > and loving it so far. Are there any more dutch Clojure programmers on this > list so we can meet? I am also interested to know about Clojure-programmers > from any country in a reasonable distance from Strasbourg. I'm in Brussels Raph > > Joop Kiefte > > -- > Communication is essential. So we need decent tools when communication is > lacking, when language capability is hard to acquire... > > -http://esperanto.net -http://esperanto-jongeren.nl > > Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Requesting Feedback on new Relational Mapping lib for Clojure
Hi Brenton: I think it would be nice if rather than specifying the columns of each table in the call to the model macro, it was extracted from the database directly. Raph On Jun 14, 6:14 pm, Brenton wrote: > Hello group. > > I have been working on a relational mapping library for Clojure named > Carte. > > http://github.com/brentonashworth/carte > > The current version is what I would consider to be a working prototype > and I would love to get feedback from the community before I do much > more work on this. The project includes a rather lengthy README. > Mainly, I am interested in constructive criticism of the ideas and > examples contained in the README but if you would like to jump into > the code and critique that, that would be great. > > This is my idea of an idiomatic Clojure relational mapping library. Do > you think I am on the right track? If not, what would that look like? > What would Rich do? > > This project is being developing for my own immediate needs but I > would be interested in improving it outside of the scope of my work > based on your feedback. > > Thank you, > Brenton -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about lein swank and emacs
Check out this Emacs package: http://github.com/remvee/elein The command you need is called `elein-reswank' there. cheers, rb On Oct 25, 7:13 am, Mark Engelberg wrote: > When you start a swank server with lein swank, and then connect to it > via slime-connect in emacs, is there any way from within emacs to > restart the swank server and/or delete all definitions to start from a > clean slate? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
how to pass lazy seq to function for processing without keeping the head?
I have a big MySQL database containing telephone call detail records. The database is on a remote server and it's a bit slow to access. I want to migrate the data to local SQLite databases on my machine for further processing. I want to store each month's records in separate files, located under ~/calls///-.db, where is a string identifying the telephone switch which processed the call ("lucent" or "c4"), while and correspond to the start date of the call. I wrote two functions, one to SELECT the records from the MySQL database, the other to store them in SQLite. The first function would generate a lazy seq of records (maps), while the second would take this seq of maps and INSERT the records to the appropriate SQLite databases. Here are the current versions of the two functions: (defn c4-calls [st-prefix] (let [conn (datasource/connection datasource/cdr-c4) stmt (.prepareStatement conn (format "SELECT SUBSTRING(a,5) AS a, SUBSTRING(b,3) AS b, SUBSTRING(st,1,14) AS st, duration/1000 AS duration FROM `call` WHERE st LIKE '%s%%' ORDER BY st" st-prefix))] (for [rec (resultset-seq (.executeQuery stmt)) :let [{:keys [a b st duration]} rec]] {:a a :b b :st st :duration duration}))) The (datasource/connection datasource/cdr-c4) call returns a java.sql.Connection to the MySQL db. Each record returned from MySQL gets packaged into map and is returned to the caller in a lazy seq (or at least that's what I expect reading the documentation of the 'for' macro). Here is the one which stores the records to the corresponding SQLite db: (defn store-calls [source calls] (when (not (#{"lucent" "c4"} source)) (throw (RuntimeException. "invalid source, must be \"lucent\" or \"c4\""))) (loop [calls calls conn nil stmt nil year nil month nil] (if-let [c (first calls)] (let [y (Integer/parseInt (.substring (:st c) 0 4)) m (Integer/parseInt (.substring (:st c) 4 6))] (if (or (nil? conn) (not= y year) (not= m month)) (do (when conn (.commit conn)) (let [conn (call-db source y m) stmt (.prepareStatement conn "INSERT INTO `call` (a,b,st,duration) VALUES (?,?,?,?)")] (recur calls conn stmt y m))) (do (.setString stmt 1 (:a c)) (.setString stmt 2 (:b c)) (.setString stmt 3 (:st c)) (.setDouble stmt 4 (:duration c)) (.executeUpdate stmt) (recur (rest calls) conn stmt year month (when conn (.commit conn) The idea is to iterate over the calls and if there is a difference between the year/month of the previously processed record and this one, switch to the corresponding SQLite connection, before the record is written via INSERT. The function 'call-db' ensures that the SQLite database identified by the passed source-year-month triad exists and returns a java.sql.Connection to it. My problem is a java heap space overflow error. The likely reason may be that I keep a reference to 'calls' in the store-calls function 1. in the function arg, 2. in the loop ([calls calls]) - although I doubt that the second would be a problem. I thought about using two signatures, [source calls] on one hand and [source calls conn stmt year month] on the other, thereby substituting the loop with a function which I can recur to, but even then, the [source calls] version would be called first, which would pass the calls to the other, which means the head was just kept again. It also occurred to me that I should think in records instead of maps and write store-calls as a kind of filter (store-call), but then I'd lose the ability to compare the dates of the previous/current records or would have to resort to some caching trickery which I'd rather avoid. Any ideas? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to pass lazy seq to function for processing without keeping the head?
Oops, I made an error in the last paragraph: > It also occurred to me that I should think in records instead of __seqs__ > and write store-calls as a kind of filter (store-call), but then I'd > lose the ability to compare the dates of the previous/current records > or would have to resort to some caching trickery which I'd rather > avoid. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to pass lazy seq to function for processing without keeping the head?
Hi everyone, I found the solution and it has nothing to do with my ramblings above. It turns out that when I do (.executeQuery stmt), the MySQL JDBC driver fetches the entire resultset from the server at once. Here is how to make it lazy also on the JDBC side: (let [conn (datasource/connection datasource/cdr-c4) stmt (.prepareStatement conn (format "SELECT SUBSTRING(a,5) AS a, SUBSTRING(b,3) AS b, SUBSTRING(st,1,14) AS st, duration/1000 AS duration FROM `call` WHERE st LIKE '%s%%' ORDER BY st" st-prefix) java.sql.ResultSet/TYPE_FORWARD_ONLY java.sql.ResultSet/CONCUR_READ_ONLY)] (.setFetchSize stmt Integer/MIN_VALUE) ... With this change, everything works as expected. Details about why this works: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html (scroll down to the section on "ResultSet") (Note, that this is a MySQL-only solution, other JDBC drivers may require different tricks.) P.s. I still don't understand though why the 'calls' argument to the store-calls function is not a held reference to the head of the lazy seq... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to pass lazy seq to function for processing without keeping the head?
On Oct 27, 4:36 pm, Chris Maier wrote: > On Wed, Oct 27, 2010 at 10:18 AM, rb wrote: > > P.s. I still don't understand though why the 'calls' argument to the > > store-calls function is not a held reference to the head of the lazy > > seq... > > I think (and someone please correct me if I'm wrong) that the head of > 'calls' isn't being retained because you recur on (rest calls), > replacing your hold on the head with the next item downstream. Now > nobody's holding on to the head, so it gets GC'd. Keep recurring, and > you just move down the sequence, always dropping what you were holding > onto, thus allowing it all to be GC'd. > > Chris Yes, this is quite clear in the case of the loop construct: (loop [calls calls conn nil stmt nil year nil month nil] (if-let [c (first calls)] ... (recur (rest calls) conn stmt year month The 'calls' variable bound in the loop is clearly not retained. What bothers me is the function argument: (defn store-calls [source calls] ... Here the lazy seq coming in as the second arg is bound to a local variable named 'calls'. I would think this counts as retainment of the head of the lazy seq (for the lifetime of the function), but it apparently doesn't. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Unification
On Jan 21, 11:41 pm, Alex Baranosky wrote: > Hi, > > I've read a bit about clojure.core.unify > (http://blog.fogus.me/2010/12/14/unification-versus-pattern-matching-t... > ) > > I haven't gotten through PAIP yet, but I gather unification libraries enable > logic programming? Is it true that unification is a superset of pattern > matching? > > Mostly, I'd like to hear more about what something like clojure.core.unify > is good for. I've used unification with dataflow variables and data structures holding unbound variables (though not in clojure) and found it really powerful! I'm not sure dataflow variables are available in clojure though, but would be happy to stand corrected (I heard about the contrib dataflow module, but from what I read it's more like cells updating based on upstream cells it depends on, whereas what I mean by dataflow variable is a variable that makes a thread wait until it gets bound if that thread uses that variable) Cheers raph > > Best, > Alex -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Unification
On Jan 22, 8:16 pm, David Nolen wrote: > On Sat, Jan 22, 2011 at 2:09 PM, rb wrote: > > On Jan 21, 11:41 pm, Alex Baranosky > > wrote: > > > Hi, > > > > I've read a bit about clojure.core.unify ( > >http://blog.fogus.me/2010/12/14/unification-versus-pattern-matching-t... > > > ) > > > > I haven't gotten through PAIP yet, but I gather unification libraries > > enable > > > logic programming? Is it true that unification is a superset of pattern > > > matching? > > > > Mostly, I'd like to hear more about what something like > > clojure.core.unify > > > is good for. > > > I've used unification with dataflow variables and data structures > > holding unbound variables (though not in clojure) and found it really > > powerful! > > > I'm not sure dataflow variables are available in clojure though, but > > would be happy to stand corrected (I heard about the contrib dataflow > > module, but from what I read it's more like cells updating based on > > upstream cells it depends on, whereas what I mean by dataflow variable > > is a variable that makes a thread wait until it gets bound if that > > thread uses that variable) > > This exists in Clojure in the form of promise/deliver. > Thanks Ken and David, I'll take a closer look! Raph > > > > Cheers > > > raph > > > > Best, > > > Alex -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en