Re: Clojure Poll 09/2008
On Thu, Sep 11, 2008 at 11:52 AM, Allen Rohner <[EMAIL PROTECTED]> wrote: > I already voted, but I agree with this. Having a standard way to run > clojure scripts from a command line would be very useful. One could trivially take the command-line generated by the shell magick and put it into a simple shell script that lets you invoke Clojure on the named script and arguments, couldn't you? % clojure foo.clj bar baz qux would run foo.clj and pass the arguments. Seems to me this is easier (and cleaner) than coming up with some way of support shebang. -tree -- Tom Emerson [EMAIL PROTECTED] http://www.dreamersrealm.net/~tree --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
Yes - I know. And there is 'println' also... The full mini-language provided by format is much more powerful ... [1]> (format nil "~{[~{~a~^:~}]~^~&~}" '((1 2 3)(7 8 9))) "[1:2:3] [7:8:9]" [2]> (format nil "~r" 123456) "one hundred and twenty-three thousand, four hundred and fifty-six" [3]> But, this is really just a 'nice to have' ... Regards, Apurva - Original Message - From: "Stuart Sierra" <[EMAIL PROTECTED]> To: "Clojure" Sent: Thursday, September 11, 2008 7:22:39 PM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi Subject: Re: Clojure Poll 09/2008 On Sep 11, 1:18 am, Apurva Sharan <[EMAIL PROTECTED]> wrote: > 3) Equivalent of 'format' macro. This would be really helpful in debugging. There is a "printf" in recent Clojure SVN. -Stuart --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Making Clojure Popular
Great minds think alike. ;-) I just left a post on Rich's poll (comment #33) much to this effect. > The most important purpose > of the book would be give people confidence in Clojure. yes, because the language can then be seen to clearly hang together as a whole, rather than just as a random assortment of features. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
On Sep 11, 8:32 am, "Paul Stadig" <[EMAIL PROTECTED]> wrote: > I have a stupid idea as well (related to reader macros). Is there any > way we can get the reader to not have problems with > "#!/usr/bin/clojure" as the first line? > > This would allow simple and standard use of Clojure in a script file. > Or perhaps a solution (other than mucking with the reader) is to have > clojure.lang.Script ignore the first line if it is the shebang? > > I mean this is cool (in a really geeky way) > > #^:shebang '[ > exec java -cp "$HOME/src/clj/clojure/clojure.jar" clojure.lang.Script > "$0" -- "$@" > ] > > But its not standard, nor is it simple to remember, and if you have a > bin script that does stuff like read a Clojure rc file, or set the > classpath, or something you either lose that functionality, or you > have to basically try to duplicate the bin script at the top of every > clojure script. Additionally, if you want to hard code the path for > security like so > > #^:shebang '[ > exec /usr/bin/java -cp "$HOME/src/clj/clojure/clojure.jar" > clojure.lang.Script "$0" -- "$@" > ] > > Clojure has issues with it. > I already voted, but I agree with this. Having a standard way to run clojure scripts from a command line would be very useful. Allen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Method dispatch on class - "ns-*" functions accepting symbols
On Sep 11, 2008, at 8:12 AM, Rich Hickey wrote:Using the latest syntax is good, although the idiom for static callsis (Classname/method args). For instance:(clojure.lang.Namespace/find sym)instead of:(.find clojure.lang.Namespace sym)because static methods really aren't functions taking classes, butfunctions in a class namespace.I see now, cool.I think it's close. The other tip I have is that by type-hinting the-ns you can avoid the hint in every let:(defn #^{:private true :tag clojure.lang.Namespace} the-ns ...)(defn ns-name "Returns the name of the namespace, a symbol." [ns] (let [ns (the-ns ns)] (.getName ns)))getName is a non-reflective call.I made that change and then removed the let altogether when ns was used only once. I also remove the call to the-ns in the one case (ns-imports) where ns was only being passed along to another ns- function.I tried to verify that removing the let wouldn't interfere with making it a non-reflective call, but I wasn't able to get any calls to these functions to give me a reflection warning even if I removed the ":tag" from 'the-ns. Was this the right way to test that: user=> (binding [*warn-on-reflection* true] (ns-name 'clojure))If you could make these changes I'll incorporate the patch, thanks!You're quite welcome. Thanks for all the tips. If it needs further refinement, please let me know.--Steve ns-symbol-2.patch Description: Binary data
Re: Clojure Poll 09/2008
On Sep 11, 1:18 am, Apurva Sharan <[EMAIL PROTECTED]> wrote: > 3) Equivalent of 'format' macro. This would be really helpful in debugging. There is a "printf" in recent Clojure SVN. -Stuart --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Debian package for clojure
I have created a debian package for clojure. I've basically packaged up the JAR with the bin script from http://github.com/jochu/clojure-extra/tree/master. It's still a work-in-progress, but if there are any debian users out there, I'd like feedback. To install the debian package you need to first add the following line to your apt sources: deb http://ppa.launchpad.net/pjstadig/ubuntu hardy main Then just do an apt update and "sudo apt-get install clojure" and it should work for you (*fingers crossed*). You can find my GPG key out in the ether ([EMAIL PROTECTED]) to verify the installation, whether you *trust* me is another issue ("Who is this guy?!"). ;) This deb was actually built on Ubuntu. I think it'll work on any debian based distribution, but I'm a newb at this, so please send me your feedback. This project raises (at least) two issues: 1. How can we get this into the standard debian distribution? It is my understanding that someone has to be (or become) an official debian developer to get it into the distribution. I'm willing to pursue that unless someone else is already there. 2. How should this be maintained/expanded? I am willing to contribute the debian build files back to clojure (it just adds a debian directory with some files in it). However, some of the things that are part of the debian build should probably be integrated into the main project and build file (man pages, bin scripts, etc.), because there may be other distributions that could reuse some of those files. Additionally, this could all be expanded to include bin scripts and such for Windows, too. If we're not going to merge this back into the main source (or if we don't want to do it yet), I could setup a GitHub project to maintain the debian build system separately. Any thoughts on all this? Paul --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
I have a stupid idea as well (related to reader macros). Is there any way we can get the reader to not have problems with "#!/usr/bin/clojure" as the first line? This would allow simple and standard use of Clojure in a script file. Or perhaps a solution (other than mucking with the reader) is to have clojure.lang.Script ignore the first line if it is the shebang? I mean this is cool (in a really geeky way) #^:shebang '[ exec java -cp "$HOME/src/clj/clojure/clojure.jar" clojure.lang.Script "$0" -- "$@" ] But its not standard, nor is it simple to remember, and if you have a bin script that does stuff like read a Clojure rc file, or set the classpath, or something you either lose that functionality, or you have to basically try to duplicate the bin script at the top of every clojure script. Additionally, if you want to hard code the path for security like so #^:shebang '[ exec /usr/bin/java -cp "$HOME/src/clj/clojure/clojure.jar" clojure.lang.Script "$0" -- "$@" ] Clojure has issues with it. Low priority, but still useful. Paul On Thu, Sep 11, 2008 at 9:20 AM, noahr <[EMAIL PROTECTED]> wrote: > > Another (possibly stupid) idea: > > Have some prefix-character to allow you to have the argument to a > macro be evaluated (sorta like a function), and its resulting data > structure given to the macro instead. I realize the whole point of > macros is that the arguments ARENT evaluated, but would it be useful > to selectively turn that off for specific arguments in specific calls > to the macro?? > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
Another (possibly stupid) idea: Have some prefix-character to allow you to have the argument to a macro be evaluated (sorta like a function), and its resulting data structure given to the macro instead. I realize the whole point of macros is that the arguments ARENT evaluated, but would it be useful to selectively turn that off for specific arguments in specific calls to the macro?? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: local functions?
On Sep 11, 3:01 am, Allen Rohner <[EMAIL PROTECTED]> wrote: > > For very short functions one can use the cut notation: #(...). In case > > there are several functions or functions going over several lines, this > > is a sign that they should go into an own defn(-) with appropriate > > docstring. > > Maybe the solution is to use defn-. Scheme made me used to the local > function approach for encapsulation. I don't have a problem with doing > > (defn foo [x] > (defn bar [y] > ) > (defn baz [z]) > (do_stuff (bar[x])) > > except that the interior defns are public. I like the idea. defn- would also work like this but that won't prevent bar and baz from being used inside the package itself. (let [foo (fn [x] ...)] (foo 42)) Does tend to get a little ugly if fn grows more than a line or two. Not sure how it can be done though. Parth --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
On Thu, Sep 11, 2008 at 3:23 AM, hoeck <[EMAIL PROTECTED]> wrote: > > Funny, had this idea too and know playing with an implementation of > relational algebra in clojure. I'm using clojures hashmaps for indexes > and vectors to represent the tuples. For conditions, I am using > functions returning true on matching vectors and for creating > conditions i use a macro. It's fun but hard to get right. Sounds similar to clojure.set: (doseq [n v] (ns-publics (find-ns 'clojure.set)) (print-doc v)) --Chouser --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Thank you. I looked right over that. On Sep 11, 8:12 am, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > Take a look athttp://clojure.org/java_interop. > > Bill > > > Would someone be able to point me towards some information on that > > syntax? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Method dispatch on class - "ns-*" functions accepting symbols
On Sep 10, 10:59 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > On Sep 10, 2008, at 2:08 PM, Rich Hickey wrote: > > > It would work, but it seems like overkill. In particular, there's no > > intention to extend it any further, and all symbol versions do the > > same thing, call find-ns and delegate, so maybe just adding a let > > level to the existing fns is best: > > > (let [ns (the-ns ns)] ...) > > > where the-ns x is just (if (instance? Namespace x) x (find-ns x)) > > That looks good. Thanks for the advice. I adopted it in the enclosed > patch. > > These are the changes it makes to boot.clj: > > add private the-ns > change to allow namespace arguments to be either a namespace or a > symbol in ns-* > change to lispy syntax for java calls in ns-* and find-ns, create-ns, > remove-ns, all-ns > > I made the last change for consistency and brevity--moving to the more > modern syntax while I was in this code. I can give you a patch that > excludes that change if you prefer. > Using the latest syntax is good, although the idiom for static calls is (Classname/method args). For instance: (clojure.lang.Namespace/find sym) instead of: (.find clojure.lang.Namespace sym) because static methods really aren't functions taking classes, but functions in a class namespace. > I've tested all the modified functions and worked with the new > behavior a little. Using these functions feels more flexible after the > change. Please consider adopting this patch. > I think it's close. The other tip I have is that by type-hinting the- ns you can avoid the hint in every let: (defn #^{:private true :tag clojure.lang.Namespace} the-ns ...) (defn ns-name "Returns the name of the namespace, a symbol." [ns] (let [ns (the-ns ns)] (.getName ns))) getName is a non-reflective call. If you could make these changes I'll incorporate the patch, thanks! Rich --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Take a look at http://clojure.org/java_interop. Bill > Would someone be able to point me towards some information on that > syntax? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Aw, dang. Just caught the typo: '(javax.imageio_._ImageIO) I'm afraid I don't understand the usage of the preceding dot used in the examples: (.read ImageIO (new File name))) and (.createGraphics #^java.awt.image.BufferedImage (load-image "...")) Would someone be able to point me towards some information on that syntax? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Making Clojure Popular
> I think there should be a book on Clojure. Not a book on how to use Clojure > but a book on how Clojure was built. Somebody should be able to actually > build their own Clojure at the end of it. There is no reason why they should > do this and this is not the purpose of the book. The most important purpose > of the book would be give people confidence in Clojure. > I second that: knowing 1) how to emit JVM bytecode and 2) why the specific data structures were chosen (refs, vars, agents) wrapped in explanations and examples for transactional memory and multithreaded environments ... that would be just the book I'd like to read right now. Albert -- Albert Cardona http://www.mcdb.ucla.edu/Research/Hartenstein/acardona --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Sorry about the double post. I was unable to see my post from last night until now. On Sep 10, 9:50 pm, Alex Charlton <[EMAIL PROTECTED]> wrote: > I imported the following: > > (import '(java.awt.image BufferedImage) > '(java.io File) > '(javax.imageio.ImageIO)) > > On Sep 10, 9:27 pm, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > > > Did you import ImageIO? > > > Bill --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Bug in clojure.zip/up?
On Sep 10, 12:26 pm, Christophe Grand <[EMAIL PROTECTED]> wrote: > Hello, > > I'm playing with zippers (and zip filters) and I think there's a bug > when you replace the root: > user=> (-> [:before] zip/vector-zip (zip/replace [:after]) zip/up) > [[[:after]] nil] > > Changing (when path ...) to (when pnodes ...) in clojure.zip/up seems to > fix it. > Fixed - thanks for the report! Rich --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Making Clojure Popular
Somebody mentioned in the last few days that they were wondering how Clojure can be made more popular. I actually have two ideas on this but will only mention one of them here. The other is a bit self serving so I don't think it is appropriate :-) I think there should be a book on Clojure. Not a book on how to use Clojure but a book on how Clojure was built. Somebody should be able to actually build their own Clojure at the end of it. There is no reason why they should do this and this is not the purpose of the book. The most important purpose of the book would be give people confidence in Clojure. I could talk a lot more about this but I just for now wanted to put the idea out there and get some thoughts. Regards, PJ Fitzpatrick --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
I imported the following: (import '(java.awt.image BufferedImage) '(java.io File) '(javax.imageio.ImageIO)) On Sep 10, 9:27 pm, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > Did you import ImageIO? > > Bill --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Hi Alex, This works for me: (import '(javax.imageio ImageIO) '(java.io File)) (defn load-image [name] (.read ImageIO (new File name))) (load-image "tim/disaster2007_Genoa19.gif") I'd suggest not worrying about type tips until after you get your code doing what you want it to do. Type tips are just a way to speed up your program, by removing reflection. You can enable a warning mode *warn-on-reflection* later which will show all the possible improvements that could be obtained by providing a type tip. Sounds like the perfect job for a tool to do it for you. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Type hints for expressions and a problem
Thanks for the type hint clarification. I had imported the packages via: (import '(java.awt.image BufferedImage) '(java.io File) '(javax.imageio.ImageIO)) Should that not be enough? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Processing wrapper
Wow, cool, 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Poll 09/2008
On 10 Sep., 21:28, Allen Rohner <[EMAIL PROTECTED]> wrote: > Finally, not that I'm asking you or anyone else to build this, I'm > just throwing this out there to see if anyone else is thinking along > the same lines as me :-). I think it would be really cool to build a > database in Clojure. SQL the language sucks, and the overhead of > sending SQL strings to a remote process and having it compile the > command sucks. Funny, had this idea too and know playing with an implementation of relational algebra in clojure. I'm using clojures hashmaps for indexes and vectors to represent the tuples. For conditions, I am using functions returning true on matching vectors and for creating conditions i use a macro. It's fun but hard to get right. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---