Re: a macro to debug the let form
Thanks Alan, I have in fact realized the mistake after I posted it .. and I had posted another message which has it the way you mentioned. Sunil. On Tue, Dec 7, 2010 at 11:55 PM, Alan a...@malloys.org wrote: I see you have defined a print-and-return macro; you might prefer my and-print: (defmacro and-print A useful debugging tool when you can't figure out what's going on: wrap a form with and-print, and the form will be printed alongside its result. The result will still be passed along. [val] `(let [x# ~val] (println '~val is x#) x#)) I'm not sure what you're using the flag argument for; if it's to keep track of what prints belong to what statements then my automatic printing of the input form might be useful for you. I'd pull the (repeat blah blah blah) stuff in with-separator out into an optional argument, so that (a) you only have to write it once, and (b) you can use a different separator easily. I find the map in local-bindings pretty hard to read - what on earth is `'~x# for? Without trying to understand what you're doing, it seems like you could gain readability by replacing (list 'println [`'~x# x#]) with `(println ['~x# x#]) On Nov 28, 12:32 am, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Robert, What I had posted before was half-baked buggy code .. the following gist has a few more helper debug macroshttps://gist.github.com/718725 https://gist.github.com/718725This code was written when I was trying to learn writing macros .. so any criticism is very welcome. Thanks Sunil. On Sat, Nov 27, 2010 at 11:06 PM, Robert McIntyre r...@mit.edu wrote: cool! Although I think with-seperator should be spelled with-separator --Robert McIntyre On Thu, Nov 25, 2010 at 9:13 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: I just tried to re-write with-seperator without using the symbol-macros from macro-utils and it seems to work fine .. On Thu, Nov 25, 2010 at 1:27 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was trying to learn to write clojure macros and the code is posted here in the following link https://gist.github.com/715047 There are basically three macros 1. with-seperator - a zero argument macro and is supposed to just draw a line to indicate beginning and ending of the execution of the body. 2. display-local-bindings - a function to print the local bindings in the lexical scope where the macro is called 3. letd - a helper macro to print the values of all the bindings followed by printing of the local bindings using display-local-bindings The letd macro as posted works as expected but without the seperation line . It is supposed to print the seperation line when I uncomment line 14 and comment line 15 but some how this is causing the env variable automatically passed with every macro to be nil display-local-binding .. but the I feel it is not the case .. can somebody help me understand this. This was an exercise to learn macro writing than to writing a letd debugging helper function.. Thanks, Sunil. -- 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.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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
Re: batch could be fun in clojure
On Dec 8, 11:12 pm, Raoul Duke rao...@gmail.com wrote: another take on rpc/queries/services: www.odbms.org/download/2010-09-Batches-ICOODB.pdf apparently very preliminary, i can't find the java implementation referred to in the slides. I liked the idea but was sceptical since most remote work is done using RPC, web services or SQL. Then at the end of the presentation they show that they have layers to handle this and I was very impressed. The batch statement should be relatively easy to make using macros. Cool. Saul -- 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
Meta information of form
Hello everybody, I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? Thanks, Sunil. -- 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: Meta information of form
On Thu, Dec 9, 2010 at 4:20 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? user= (defmacro foo [x] `(quote ~(meta form))) #'user/foo user= (foo bar) {:line 380} in faddle.clj (ns faddle) (defmacro foo [x] `(quote ~(meta form))) (defn futz [] (foo bar)) load-file #'faddle/futz user= change-repl-to-file-ns faddle= (futz) {:line 3} No. It looks like the form meta contains only the :line key. -- 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: Meta information of form
hmm.. so how do we get the file name inside our macro?? Sunil. On Thu, Dec 9, 2010 at 2:57 PM, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 4:20 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? user= (defmacro foo [x] `(quote ~(meta form))) #'user/foo user= (foo bar) {:line 380} in faddle.clj (ns faddle) (defmacro foo [x] `(quote ~(meta form))) (defn futz [] (foo bar)) load-file #'faddle/futz user= change-repl-to-file-ns faddle= (futz) {:line 3} No. It looks like the form meta contains only the :line key. -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Meta information of form
On Thu, Dec 9, 2010 at 4:48 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: hmm.. so how do we get the file name inside our macro?? I guess we ask nicely for it to be added to the form metadata in 1.3. :) Interestingly, extracting the correct line number in cases of multi-line forms is already handled: (ns faddle) (defmacro foo [x] `(quote ~(meta (second form (defn futz [] (foo (bar baz))) faddle= (futz) {:line 4} Not 3 or nil, 4. The subform (bar baz) has its own metadata with the correct line number. Since new, non-blank lines almost always start with an open parenthesis after the leading whitespace, pretty much any error can be localized to the correct line number even if the macro body spans multiple lines. Furthermore, the exception lines tend to contain a literal followed by a close paren, as with the final line in (if foo (bar quux baz) 42) and there's *usually* nothing that can go wrong on such a line. When there is it's usually an error in a *form* inside the literal: (if foo (bar quux baz) [42 (count mumble) (.lastIndexOf frotz \q) 3 (19)]) ;oops! -^^ and that form will again have line metadata. -- 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: Meta information of form
It might be possible to get other info (such as var-name, var-body etc), but it's mostly subjective (depending on the form being passed): https://bitbucket.org/kumarshantanu/clj-miscutil/src/e16432dc0b6c/src/main/clj/org/bituf/clj_miscutil.clj#cl-251 Regards, Shantanu On Dec 9, 3:04 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 4:48 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: hmm.. so how do we get the file name inside our macro?? I guess we ask nicely for it to be added to the form metadata in 1.3. :) Interestingly, extracting the correct line number in cases of multi-line forms is already handled: (ns faddle) (defmacro foo [x] `(quote ~(meta (second form (defn futz [] (foo (bar baz))) faddle= (futz) {:line 4} Not 3 or nil, 4. The subform (bar baz) has its own metadata with the correct line number. Since new, non-blank lines almost always start with an open parenthesis after the leading whitespace, pretty much any error can be localized to the correct line number even if the macro body spans multiple lines. Furthermore, the exception lines tend to contain a literal followed by a close paren, as with the final line in (if foo (bar quux baz) 42) and there's *usually* nothing that can go wrong on such a line. When there is it's usually an error in a *form* inside the literal: (if foo (bar quux baz) [42 (count mumble) (.lastIndexOf frotz \q) 3 (19)]) ;oops! -^^ and that form will again have line metadata. -- 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: Meta information of form
On Thu, Dec 9, 2010 at 5:18 AM, Shantanu Kumar kumar.shant...@gmail.com wrote: It might be possible to get other info (such as var-name, var-body etc), but it's mostly subjective (depending on the form being passed): https://bitbucket.org/kumarshantanu/clj-miscutil/src/e16432dc0b6c/src/main/clj/org/bituf/clj_miscutil.clj#cl-251 Eh. I suppose you could try extracting the namespace parts from symbols embedded in the sexp. Ignore the ones that the macro knows about, introspect on the rest to see which ones :use or :refer which other ones, and whichever one is at the apex of the importation pyramid is probably the namespace containing the macro invocation, from which the filename can in turn be guessed. But that strikes me as hackish and probably somewhat brittle. -- 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: Meta information of form
Sunil S Nandihalli sunil.nandiha...@gmail.com writes: I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? The currently evaluating/compiling file (if it is a file and not the REPL or some other instance of eval) is in the var *file*. The current namespace is in the var *ns*. -- 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: Meta information of form
On Thu, Dec 9, 2010 at 5:58 AM, Alex Osborne a...@meshy.org wrote: Sunil S Nandihalli sunil.nandiha...@gmail.com writes: I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? The currently evaluating/compiling file (if it is a file and not the REPL or some other instance of eval) is in the var *file*. The current namespace is in the var *ns*. Hm. *ns* is sometimes overridden (usually inside a call to eval though) but *file* is probably pretty reliable and I did not know about it, and it will directly give Sunil the file name he wants. Thanks. -- 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: Meta information of form
Thanks Alex. That helps. Sunil. On Thu, Dec 9, 2010 at 4:28 PM, Alex Osborne a...@meshy.org wrote: Sunil S Nandihalli sunil.nandiha...@gmail.com writes: I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? The currently evaluating/compiling file (if it is a file and not the REPL or some other instance of eval) is in the var *file*. The current namespace is in the var *ns*. -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: batch could be fun in clojure
The idea is interesting, it is an application of the principle: move the computation where the data resides, rather than shovel data between remote locations there is quite an interesting implementation in scala http://lambda-the-ultimate.org/node/3626 ps sorry if a bit off-topic Las 2010/12/9 Saul Hazledine shaz...@gmail.com On Dec 8, 11:12 pm, Raoul Duke rao...@gmail.com wrote: another take on rpc/queries/services: www.odbms.org/download/2010-09-Batches-ICOODB.pdf apparently very preliminary, i can't find the java implementation referred to in the slides. I liked the idea but was sceptical since most remote work is done using RPC, web services or SQL. Then at the end of the presentation they show that they have layers to handle this and I was very impressed. The batch statement should be relatively easy to make using macros. Cool. Saul -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Meta information of form
You can get lots of information out of env and form, with a bit of effort. See https://github.com/stuartsierra/lazytest/blob/86a75572e81625b09f9ed15981fb9efd670e00a9/modules/lazytest/src/main/clojure/lazytest/expect.clj#L39 for an example. -S On Dec 9, 4:20 am, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I would like to know what meta info does form that get passed to your macro.. actually contain? I am able to only get the line number.. Is there a way to get the file name aswell? Thanks, Sunil. -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
You're not going to convey much useful information in 15 minutes, but you can do something inspiring. A couple of years ago I saw a video - probably by Marco Berringer - that showed a CL/emacs expert solving a nontrivial problem. I was purely amazed at the amount of code that appeared on the screen in a short length of time, and the stuff that had been accomplished by the end of the short video. So wow 'em (especially if you're comfortable with emacs). Announce that you're going to build a webserver, take five minutes to install Clojure and Lein from scratch, then the last ten minutes to do a Compojure app. They don't have to understand much of what you're doing; explain only in general terms as you proceed, don't get bogged in the details - it'll only slow you down, and you want to be productive. Hopefully they'll come away impressed and wanting to know more. -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
If the audience is Java / Ruby, my guess is that they don't want to know about emacs, for one. My guess is also that it's not in 15 minute that you'll make them comfortable with the IDE of using a LISP syntax. Of course, maybe they already know about clojure. If so, either they will learn nothing, either it's a possibility for you to take out of their heads false premature conclusions they may have inferred from what they've seen : lisp syntax, bleh ; functional programming, like if no current program done in 'classic' languages/idioms worked. You don't have to show the language. It's a means towards an end (several ends, really). Talk about the current problems in the field (hopefully in the domain problem of the audience, though it's hard to guess), and which features Clojure offers to solve them. Point them to clojure. LISP syntax is of course not a detail (for macros), but almost. 2010/12/9 David Andrews dammi...@gmail.com You're not going to convey much useful information in 15 minutes, but you can do something inspiring. A couple of years ago I saw a video - probably by Marco Berringer - that showed a CL/emacs expert solving a nontrivial problem. I was purely amazed at the amount of code that appeared on the screen in a short length of time, and the stuff that had been accomplished by the end of the short video. So wow 'em (especially if you're comfortable with emacs). Announce that you're going to build a webserver, take five minutes to install Clojure and Lein from scratch, then the last ten minutes to do a Compojure app. They don't have to understand much of what you're doing; explain only in general terms as you proceed, don't get bogged in the details - it'll only slow you down, and you want to be productive. Hopefully they'll come away impressed and wanting to know more. -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: String-friendly first/rest?
clojure.contrib.string has take and drop, which do what you want (though you have to ask for exactly one character to emulate first/ rest). However, my understanding is that c.c.string is going away in 1.3, and many of its features will be removed rather than moved, so I don't think you're supposed to use it anymore. On Dec 8, 11:43 am, Surgo morgon.kan...@gmail.com wrote: To help myself learn Clojure, I figured I would write a pattern matching / destructing macro to better look like languages I'm more familiar with; i.e., destructuring by [first|second|rest] instead of [first second rest]. To do this I'm turning the aforementioned vector into a string (via str) and looking for / replacing the | character. However, this led to the following issue... (def test abc) (first test) \a (rest test) (\b \c) (string? (rest test)) false It would be really helpful if first/rest returned strings (or a character in the case of first), not lists, when given string input. Is there a design reason for the current behaviour and, if so, are there equivalent built-in functions that do the right thing for strings? -- 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
Recipe for using two databases with contrib.sql
I'm using contrib,sql to clean rows from one DB and insert them into another. I was thinking something like (pseudo-code (sql/with-connection db1 . (doseq [x (map rs)] (insert-into-other x))) (defn insert-into-other [r] (sql/with-connection db2 ...)) But this obviously will open/close a connection to db2 for each row. Can someone assist with an idiomatic solution? Do I need to bind *db*? -- 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: String-friendly first/rest?
On Dec 9, 12:52 pm, Alan a...@malloys.org wrote: rest). However, my understanding is that c.c.string is going away in 1.3, and many of its features will be removed rather than moved, so I Yes, it is replaced by clojure.string. c.c.string is deprecated in 1.2 and removed in 1.3 -S -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
On Dec 9, 7:08 am, Laurent PETIT laurent.pe...@gmail.com wrote: If the audience is Java / Ruby, my guess is that they don't want to know about emacs, for one. I agree - learning clojure, I don't want to know about emacs either (especially since installing clojure support has been unsuccessful so far). Eclipse has a nice plugin, by Sean Devlin I believe. The killer app for Clojure, I'm pretty certain, is a long-running concurrent application. You know, something like a web server. Long- running is neat because you can modify the runtime without the limitations of hotswap or jrebel, and concurrent is neat because it's a lot simpler to write concurrent programs with enforced mutability. Note that the REPL is a pretty killer app, and it would certainly be interesting to grow the REPL into two completely different programs! Of course, it could also be a GUI app, too. But, for some reason Lispy programmers don't seem to be very good at making things look pretty. -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
2010/12/10 javajosh javaj...@gmail.com On Dec 9, 7:08 am, Laurent PETIT laurent.pe...@gmail.com wrote: If the audience is Java / Ruby, my guess is that they don't want to know about emacs, for one. I agree - learning clojure, I don't want to know about emacs either (especially since installing clojure support has been unsuccessful so far). Eclipse has a nice plugin, by Sean Devlin I believe. *cough* ;) -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
On Thu, Dec 9, 2010 at 6:23 PM, javajosh javaj...@gmail.com wrote: Of course, it could also be a GUI app, too. But, for some reason Lispy programmers don't seem to be very good at making things look pretty. Watch this space for me proving that statement wrong sometime soon. :) -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
2010/12/10 Ken Wesson kwess...@gmail.com On Thu, Dec 9, 2010 at 6:23 PM, javajosh javaj...@gmail.com wrote: Of course, it could also be a GUI app, too. But, for some reason Lispy programmers don't seem to be very good at making things look pretty. Watch this space for me proving that statement wrong sometime soon. :) Great ! What techno ? Web ? Swing ? SWT ? other ? ... -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
Thanks, for all of your thoughts, guys. I'm letting all the ideas boucne around. I'll be sure to let you all know how it goes after the talk. -- 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: Giving a 15 minute Clojure lightning talk. Any ideas?
Hi people! Recently, I used as final example in a short presentation: https://github.com/sfraser/MultithreadedGameOfLife http://www.youtube.com/watch?v=CFCYVfApPUc It shows: - Multithreading - persistence data, transactions - access to Java tech, as Swing My first minutes were dedicated to simple Lisp/Clojure concepts. Angel Java Lopez http://www.ajlopez.com http://twitter.com/ajlopez On Thu, Dec 9, 2010 at 8:36 PM, Alex Baranosky alexander.barano...@gmail.com wrote: Thanks, for all of your thoughts, guys. I'm letting all the ideas boucne around. I'll be sure to let you all know how it goes after the talk. -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Recipe for using two databases with contrib.sql
Take a look at this for connection pooling: http://bitbucket.org/kumarshantanu/clj-dbcp/src On Thu, Dec 9, 2010 at 1:39 PM, Ghadi Shayban gshay...@gmail.com wrote: I'm using contrib,sql to clean rows from one DB and insert them into another. I was thinking something like (pseudo-code (sql/with-connection db1 . (doseq [x (map rs)] (insert-into-other x))) (defn insert-into-other [r] (sql/with-connection db2 ...)) But this obviously will open/close a connection to db2 for each row. Can someone assist with an idiomatic solution? Do I need to bind *db*? -- 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: Moderately off-topic: installing emacs on OSX
On Dec 6, 9:16 pm, Phil Hagelberg p...@hagelb.org wrote: On Mon, Dec 6, 2010 at 9:00 PM, javajosh javaj...@gmail.com wrote: Sorry for asking here, but I think it's at least a little relevant to Clojure since I for one wouldn't be installing emacs if it wasn't for Clojure and Slime. Getting prompts about what the function arguments are seems like a HUGE benefit when learning this langauge. I imagine other non-emacs people might have a related question, so I'll give asking this question a shot. sudo ports install slime Swank Clojure (the Clojure adapter for SLIME) depends on a particular version of Slime; the one in Macports is probably not it. I recommend installing via package.el instead as the swank-clojure readm suggests:https://github.com/technomancy/swank-clojure#readme Thanks Phil, I'll give that a shot. Did that work? If not, try installing a different emacs. I don't use OSX, but with the installation process temacs and src failing to load in the error message and all, I'd try that. http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_715.html Alec -- 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
Google AI winner uses lisp
I'm sure a few people have read this news already. It's been up for a week, though strangely ZDnet -- which, on principle, I refuse to link to -- is one of the only places to write it up. http://pr-usa.net/index.php?option=com_contenttask=viewid=560484Itemid= Nice news to read before bedtime. A -- 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: Google AI winner uses lisp
On Thu, Dec 9, 2010 at 8:53 PM, Alec Battles alec.batt...@gmail.com wrote: I'm sure a few people have read this news already. It's been up for a week, though strangely ZDnet -- which, on principle, I refuse to link to Why? -- is one of the only places to write it up. http://pr-usa.net/index.php?option=com_contenttask=viewid=560484Itemid= Nice news to read before bedtime. Yes, but was it Clojure, or another Lisp? -- 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: mapmap?
On Thu, Dec 9, 2010 at 8:43 PM, Steven E. Harris s...@panix.com wrote: Ken Wesson kwess...@gmail.com writes: and to encapsulate as a function: (defn fmap [f m] (into {} (for [[k v] m] [k (f v)]))) Here, fmap is a poor choice of name, if it's meant to be a reference to Haskell's function of the same name. It's not obvious to me that mapping a function over a map should just apply the function to the values. Yes, applying the function to the keys instead could yield duplicates, but just because one choice of behavior isn't promising doesn't make the other choice obviously valid. If you called your function, say, fmap-values I would not have complained. Please direct all complaints regarding calling it fmap to Sunil. He was the first to suggest that name in this thread, not I. (aanlkti=-m4c2wwnhjta=jqfsfpzhnofed-hfzs-yb...@mail.gmail.com) I merely copied him. :) -- 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
Getting strange behavior when stubbing
I've been playing with Amit Rathore's simple mocking functions: http://s-expressions.com/2010/01/24/conjure-simple-mocking-and-stubbing-for-clojure-unit-tests/ I'm seeing the weirdest effect, and after banging my head on it for a couple hours I figure it's time to ask about it. Any ideas would be greatly appreciated. I'm still in the process of learning Clojure, and that means every new thing can be painful to work through the kinks. *I'm testing this function:* (defn distances [origin locations] (map (fn [dest] (dist-in-miles origin dest)) locations)) *With this spec:* (defspec distances-in-miles-to-multiple-locations-from-origin (stubbing [dist-in-miles 2.0] (distances Boston,MA Albany,NY LosAngeles,CA)) = [2.0 2.0]) *Which uses this macro wrapper around clojure.test:* (defmacro defspec [name actual arrow expected] `(deftest ~name (is (= ~expected ~actual It seems the stubbing is not happening when (distances Boston,MA Albany,NY LosAngeles,CA) is being evaluated. But if I put print statements in the function to see the value of dist-in-miles, it is clearly 2.0! I have two other specs that use stubbing and work as expected. *For reference:* (defspec distances-map-to-multiple-locations-from-origin (stubbing [dist-in-miles 2.0] (map-of-distances Boston,MA Newport,RI LosAngeles,CA)) = {LosAngeles,CA 2.0, Newport,RI 2.0}) (defspec relative-values-of-locations-dependent-on-frequency-of-visits-per-year (stubbing [dist-in-miles 365.0] (relative-distances Boston,MA Newport,RI 2 LosAngeles,CA 1)) = {LosAngeles,CA 365.0, Newport,RI 730.0}) *Two functions for the above two, working specs:* (defn map-of-distances [origin locations] (apply hash-map (interleave locations (apply distances origin locations (defn relative-distances Gives distance * frequency. frequencies are in days out of 365 [origin locations-n-frequencies] (let [loc-w-dists (apply map-of-distances origin (take-nth 2 locations-n-frequencies)) loc-w-freqs (apply hash-map locations-n-frequencies)] (fmap * loc-w-dists loc-w-freqs))) Thank in advance, 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: Getting strange behavior when stubbing
On Thu, Dec 9, 2010 at 10:50 PM, Alex Baranosky alexander.barano...@gmail.com wrote: (map (fn [dest] (dist-in-miles origin dest)) locations)) It seems the stubbing is not happening when (distances Boston,MA Albany,NY LosAngeles,CA) is being evaluated. But if I put print statements in the function to see the value of dist-in-miles, it is clearly 2.0! Perhaps you're being bitten by laziness. The value of dist-in-miles is set to 2.0 for the duration of your test, then it reverts to something else, *then* the (map ...) produced seq is being realized and using the reverted value. If you put the print in distances it's printing the 2.0 and then creating and returning the unrealized lazy seq, which isn't realized until after the value reverts. Laziness and temporary bindings mix like oil and water, unfortunately. If you don't really need laziness, wrap a (doall ...) around the (map ...) in distances and see if that fixes it. -- 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: Getting strange behavior when stubbing
Thanks Ken. (doall) to the rescue! It worked! Makes perfect sense. It explains why sometimes it would seem to work if I put the result of the mapping into a let binding... it was calculating the value. -- 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: Google AI winner uses lisp
Common Lisp. http://quotenil.com/ On Dec 9, 7:09 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 8:53 PM, Alec Battles alec.batt...@gmail.com wrote: I'm sure a few people have read this news already. It's been up for a week, though strangely ZDnet -- which, on principle, I refuse to link to Why? -- is one of the only places to write it up. http://pr-usa.net/index.php?option=com_contenttask=viewid=560484It... Nice news to read before bedtime. Yes, but was it Clojure, or another Lisp? -- 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
Null-safe threading macro?
I could have sworn I had seen a clojure macro -? which was just like - except that if it, at any point, evaluated to nil, then it would return nil, instead of throwing a NullPointerException. Is there such a thing out there, or am I misremembering? 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: Null-safe threading macro?
it's in clojure.contrib On Thu, Dec 9, 2010 at 11:58 PM, Alex Baranosky alexander.barano...@gmail.com wrote: I could have sworn I had seen a clojure macro -? which was just like - except that if it, at any point, evaluated to nil, then it would return nil, instead of throwing a NullPointerException. Is there such a thing out there, or am I misremembering? 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Google AI winner uses lisp
On Thu, Dec 9, 2010 at 11:55 PM, javajosh javaj...@gmail.com wrote: Common Lisp. It figures. :) -- 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: Getting strange behavior when stubbing
On Thu, Dec 9, 2010 at 11:35 PM, Alex Baranosky alexander.barano...@gmail.com wrote: Thanks Ken. You're welcome. -- 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: Google AI winner uses lisp
On Dec 9, 9:07 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 11:55 PM, javajosh javaj...@gmail.com wrote: Common Lisp. It figures. :) It's still a really exciting story - thanks Alec for sharing it! I was reading Gabor's post (http://quotenil.com/Planet-Wars-Post- Mortem.html) and it sounds like something I might enjoy next time. Perhaps I'll give it a shot with clojure. The exciting thing is that a) the winning program was Lisp, b) it won by a lot, and c) 99 out of the top 100 were not Lisp. Now, this could just mean that Gabor was unusually obsessed with the contest, and the language just got out of his way. Personally, I'm ok with that. -- 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: Google AI winner uses lisp
On Fri, Dec 10, 2010 at 12:13 AM, javajosh javaj...@gmail.com wrote: On Dec 9, 9:07 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 11:55 PM, javajosh javaj...@gmail.com wrote: Common Lisp. It figures. :) It's still a really exciting story - thanks Alec for sharing it! I was reading Gabor's post (http://quotenil.com/Planet-Wars-Post- Mortem.html) and it sounds like something I might enjoy next time. Perhaps I'll give it a shot with clojure. The exciting thing is that a) the winning program was Lisp, b) it won by a lot, and c) 99 out of the top 100 were not Lisp. Now, this could just mean that Gabor was unusually obsessed with the contest, and the language just got out of his way. Personally, I'm ok with that. That is indeed one of Lisp's strengths -- once you're reasonably proficient with it, the language frequently does just get out of the way, in much the way that Java 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: Null-safe threading macro?
Thanks, it is so hard to google symbols. On Fri, Dec 10, 2010 at 12:01 AM, Mark Rathwell mark.rathw...@gmail.comwrote: it's in clojure.contrib On Thu, Dec 9, 2010 at 11:58 PM, Alex Baranosky alexander.barano...@gmail.com wrote: I could have sworn I had seen a clojure macro -? which was just like - except that if it, at any point, evaluated to nil, then it would return nil, instead of throwing a NullPointerException. Is there such a thing out there, or am I misremembering? 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Moderately off-topic: installing emacs on OSX
On Dec 9, 5:41 pm, Alec Battles alec.batt...@gmail.com wrote: On Dec 6, 9:16 pm, Phil Hagelberg p...@hagelb.org wrote: On Mon, Dec 6, 2010 at 9:00 PM, javajosh javaj...@gmail.com wrote: Sorry for asking here, but I think it's at least a little relevant to Clojure since I for one wouldn't be installing emacs if it wasn't for Clojure and Slime. Getting prompts about what the function arguments are seems like a HUGE benefit when learning this langauge. I imagine other non-emacs people might have a related question, so I'll give asking this question a shot. sudo ports install slime Swank Clojure (the Clojure adapter for SLIME) depends on a particular version of Slime; the one in Macports is probably not it. I recommend installing via package.el instead as the swank-clojure readm suggests:https://github.com/technomancy/swank-clojure#readme Thanks Phil, I'll give that a shot. Did that work? If not, try installing a different emacs. I don't use OSX, but with the installation process temacs and src failing to load in the error message and all, I'd try that. http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_715.html Alec The short answer is that I've punted and have been using the counterclockwise plugin for Eclipse. (http://code.google.com/p/ counterclockwise/) It is more excellent than I have any right to expect. It does things like highlight the difference between macros and functions, and that makes me happy. I would still like to see slime in action, however. I have two emacs installed, GNU and Aquamacs. macports is still not able to do anything - I'm actually rather concerned about it's health. $ emacs --version GNU Emacs 22.1.1 I don't really know macports (or the native packager, pkgutil I think) well enough to know what is responsible for installing that emacs. -- 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: Google AI winner uses lisp
On Dec 9, 9:16 pm, Ken Wesson kwess...@gmail.com wrote: On Fri, Dec 10, 2010 at 12:13 AM, javajosh javaj...@gmail.com wrote: On Dec 9, 9:07 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Dec 9, 2010 at 11:55 PM, javajosh javaj...@gmail.com wrote: Common Lisp. It figures. :) It's still a really exciting story - thanks Alec for sharing it! I was reading Gabor's post (http://quotenil.com/Planet-Wars-Post- Mortem.html) and it sounds like something I might enjoy next time. Perhaps I'll give it a shot with clojure. The exciting thing is that a) the winning program was Lisp, b) it won by a lot, and c) 99 out of the top 100 were not Lisp. Now, this could just mean that Gabor was unusually obsessed with the contest, and the language just got out of his way. Personally, I'm ok with that. That is indeed one of Lisp's strengths -- once you're reasonably proficient with it, the language frequently does just get out of the way, in much the way that Java doesn't. Yeah, I just wrote in a blog comment somewhere (now lost in the aether, alas) that, basically, you can make *any* reasonable solution sketch work in a Lisp. If you want to keep thinking in Java, fine. You can do that. If you want get all functional, cool. In the end, all real programming work is just ordering the execution of imperative, side-effect generating functions. The ordering and parameterization of those calls is arbitrary (and fun!). For Clojure there's the added question of what level of side-effect functions will you want? - e.g. with javax.Swing or java.awt.Graphics? I don't know anything about Common Lisp but I'm sure they have the same decisions to make WRT C libraries. It does beg the question, though: what is a reasonable bare minimum function set that a real-life lisp would require? -- 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: Google AI winner uses lisp
On Fri, Dec 10, 2010 at 12:43 AM, javajosh javaj...@gmail.com wrote: It does beg the question, though: what is a reasonable bare minimum function set that a real-life lisp would require? I think different people might give different answers to that. The academic computer scientist is likely to consider lambda, the function-call operator, nil, if, and eval to suffice. After all those suffice for anything you can express in lambda calculus. A Lisper interested in Lisp hacking as an end in itself will want to add cons, car/cdr or first/rest, =, cond, etc. The application programmer is going to additionally require FFI with, particularly, GUI libraries, not to mention various forms of disk, networking, keyboard, and mouse I/O. The systems programmer is going to additionally require being able to get at the bare metal and run tight, efficient, non-interpreted code in kernel mode. Ultimately I suppose it hinges on what someone means by a real-life Lisp. I'd say the application programmer's needs are probably th best answer there, since Lisp hacking for its own sake and academic computer science are more mathematics than real-world, and systems programming can be accomodated by a combination of C and a Lisp with some kind of FFI. (Clojure as the Lisp requires Java as well, and Clojure and C calling each other indirectly via Java and JNI as a go-between.) -- 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: Moderately off-topic: installing emacs on OSX
I would still like to see slime in action, however. I have two emacs installed, GNU and Aquamacs. macports is still not able to do anything Sorry if this sounds silly but have you tried with carbon emacs? I heard from old time hardcore emacsers that that is the best emacs for OS X (I'm not one myself). I have carbon emacs + slime + swank running just fine. I've installed all things related to slime and swank as per the instructions listed in one of the previous emails in the thread (through ELPA). HTH, U -- 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: Moderately off-topic: installing emacs on OSX
Here is a list of steps that should get you to a working Emacs+Clojure SLIME on Mac OS X. I've also used it on Linux (without the MacPorts command, instead using its package manager to install a working GNU emacs). If you don't have many MacPorts programs installed, or don't mind reinstalling them, you can nuke the site from orbit, just to be sure by removing /opt and everything in it, then do: sudo port install em...@+x11 That will take a while. Then start up the X11 server, either the default one that comes with OS X as an optional install, or Xquartz from http://xquartz.macosforge.org Hopefully /opt/local/bin will be earlier in your PATH than /usr/bin at this point. Installing MacPorts should edit your shell's rc file to do this for you already. You can check with echo $PATH or which emacs. The latter should show /opt/local/bin/emacs if everything is set up to use MacPorts commands in preference over the default OS X versions. If not, use the command: PATH=/opt/local/bin:$PATH preferably in your .bashrc or corresponding init file for the shell you use. Then you can use the command emacs to start the MacPorts version (which is GNU Emacs). Follow the instructions on the ELPA page for installing it: http://tromey.com/elpa/install.html After you do M-x package-list-packages, go down the list of packages until the cursor is on the line for the package clojure-mode, press the i key to mark it for later installation. Do the same for the slime-repl package. Then press x to execute the installations of those marked packages. Install Leiningen by following the instructions on its home page. Create a new project with it, like so: lein new swank-clj-1.2 cd swank-clj-1.2 Now edit the file project.clj to look like this: (defproject swank-clj-1.2.0 1.0.0-SNAPSHOT :description FIXME: write :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0]] :dev-dependencies [[swank-clojure 1.2.1]]) Tweak the version numbers if you want to be closer to the bleeding edge. Then run: lein deps (this downloads JAR files if needed, and copies them into subdirectory lib) lein swank You should see this: user= Connection opened on local port 4005 #ServerSocket ServerSocket[addr=localhost/ 127.0.0.1,port=0,localport=4005] From inside of emacs, use the command: M-x slime-connect Press return after that, and you should see prompts asking you for the IP address and port number. The defaults hopefully match the 127.0.0.1 and 4005 in the output of lein swank, but if not, type in values that do match the ones output from lein swank. If you see a message at the bottom of the emacs window like: Versions differ: nil (slime) vs. 20100404 (swank). Continue? (y or n) Just press y and go on. I don't know exactly why that happens, but it hasn't caused me any problems I've noticed. An emacs buffer should be created with a Clojure prompt user. Type the characters (, then +, then a space, and look at the bottom of the emacs window and you should see the arguments taken by + as: ([] [x] [x y] [x y more]) Or type (pmap (ending with a space character), and you should see at the bottom its arguments: ([f coll] [f coll colls]) You should also see similar hints when editing files in Clojure mode, e.g. ones that end in .clj should automatically be in Clojure mode. Andy On Dec 9, 2010, at 9:33 PM, javajosh wrote: On Dec 9, 5:41 pm, Alec Battles alec.batt...@gmail.com wrote: On Dec 6, 9:16 pm, Phil Hagelberg p...@hagelb.org wrote: On Mon, Dec 6, 2010 at 9:00 PM, javajosh javaj...@gmail.com wrote: Sorry for asking here, but I think it's at least a little relevant to Clojure since I for one wouldn't be installing emacs if it wasn't for Clojure and Slime. Getting prompts about what the function arguments are seems like a HUGE benefit when learning this langauge. I imagine other non-emacs people might have a related question, so I'll give asking this question a shot. sudo ports install slime Swank Clojure (the Clojure adapter for SLIME) depends on a particular version of Slime; the one in Macports is probably not it. I recommend installing via package.el instead as the swank-clojure readm suggests:https://github.com/technomancy/swank-clojure#readme Thanks Phil, I'll give that a shot. Did that work? If not, try installing a different emacs. I don't use OSX, but with the installation process temacs and src failing to load in the error message and all, I'd try that. http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_715.html Alec The short answer is that I've punted and have been using the counterclockwise plugin for Eclipse. (http://code.google.com/p/ counterclockwise/) It is more excellent than I have any right to expect.