Re: Constant expression optimization
On 31.12.2008, at 17:56, Rich Hickey wrote: >> Does the Clojure compiler calculate the constant expression (. Math >> log 0.5) once, or at every function call? > > Every call. Clojure does not know that Math/log is a pure function. OK, then I'll use this near-trivial macro: (defmacro const "Evaluate the constant expression expr at compile time." [expr] (eval expr)) >> Can I check this somehow, >> i.e. look at the generated code, with reasonable effort? > > Currently there is no bytecode dump facility, but Java bytecode tools > should work on AOT compiled class files. I'll look at those one day; at the moment my knowledge of the JVM is still near zero... Wishing a great 2009 to Clojure and to everyone on this list, Konrad. --~--~-~--~~~---~--~~ 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: Exponentiation (expt / pow)
On 01.01.2009, at 01:19, Mark Engelberg wrote: > and pasted below. I'd like to hear some comments on whether I'm > utilizing multimethods correctly, I can't say, being new to multimethods as well, but... > and whether functions like this > would be beneficial for inclusion in the clojure contribs. If people > find this useful, there are a few other math functions which would > benefit from this sort of conversion as well. ... I think that this kind of routine is very useful and I'd appreciate having it in clojure-contrib. Konrad. --~--~-~--~~~---~--~~ 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: what's the new syntax for (dotimes _ (apply f [i]) (print "*")) ?
Thanks Chouser, Happy new year! sun On Jan 1, 12:37 am, Chouser wrote: > On Wed, Dec 31, 2008 at 11:41 PM, wubbie wrote: > > > Hi all, > > > what's the new syntax for this? > > It is part of the code below which was translation by Stu. > > That's a nifty little function. This just fixes the syntax: > > (defn plot [f min max step] > (doseq [i (range min max step)] > (dotimes [_ (apply f [i])] (print "*")) > (println))) > > But we can add features and tightens up the implementation a bit: > > (defn plot [f & range-args] > (doseq [i (apply range range-args)] > (println (apply str (replicate (f i) "*") > > This gets rid of the distracting _ and the extra 'println', and also > allows us to use the optional args for 'range': > > (plot #(* % %) 8) > > --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Emacs+SLIME+Clojure troubles
I got repl to start with a small change to swank-clojure: http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779ad6e79e37a44d84432 On Thu, Jan 1, 2009 at 1:44 AM, Mark Hoemmen wrote: > I've been having trouble with Emacs + SLIME + Clojure. I've been > using Bill Clementson's setup, and it was working when I fetched all > the required projects via his clj-build script. However, when I > fetched new versions using this script yesterday, Emacs gave me the > following error when I ran "run-clojure": > > error in process filter: Symbol's function definition is void: > slime-redirect-inferior-output > > I get an *inferior-lisp* buffer that works (is hooked to Clojure), and > I can evaluate Clojure buffers, but I don't get a SLIME REPL buffer, > nor does syntax highlighting work (I made sure that font-lock-mode is > set). All of those things worked before. I'm attaching a file > containing the relevant part of my .emacs file. The trouble seems to > be near the end, where the hook after slime connects calls > "slime-redirect-inferior-output". I can't find this function anywhere > in SLIME or in clojure-swank. If I comment out this call, I get > another error saying that > > error in process filter: Symbol's value as variable is void: > slime-repl-mode-map > > and the troubles stay. Anybody know how I could work around the > problem or even fix it altogether? > > mfh > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Macro question
Hello and happy new year, I've started this year with playing around with clojure macros and wrote a macro that behaves in a way I don't understand: (defmacro foo ([x] `(list ~x ~x)) ([x n] (if (<= n 0) `(foo ~x) `(foo ~(foo x) ~(- n 1) (foo :a 0) => (:a :a) ;; What I expected (foo :a 1) => nil ;; Here I would expect (foo (foo :a) 0) => (foo (list :a :a) 0) => '((:a :a) (:a :a)) (foo :a 2) => java.lang.NullPointerException Could someone please explain where my understanding of clojure macros is flawed ? Regards Poul --~--~-~--~~~---~--~~ 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: Macro question
Hello, just a follow up: I discovered that I sent the macro def twice and than applied the macro. If the first time the defmacro is evaluated then the resulting macro works as I expected. But when I send the same defmacro a second time to the interpreter, the macro behaves as described below. Can somebody explain why? Regards Poul synphonix schrieb: > Hello and happy new year, > > I've started this year with playing around with clojure macros and > wrote a macro that > behaves in a way I don't understand: > > (defmacro foo > ([x] `(list ~x ~x)) > ([x n] (if (<= n 0) >`(foo ~x) >`(foo ~(foo x) > ~(- n 1) > > (foo :a 0) => (:a :a) ;; What I expected > (foo :a 1) => nil ;; Here I would expect (foo (foo :a) 0) => (foo > (list :a :a) 0) => '((:a :a) (:a :a)) > (foo :a 2) => java.lang.NullPointerException > > Could someone please explain where my understanding of clojure macros > is flawed ? > > Regards > Poul --~--~-~--~~~---~--~~ 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: Macro question
On Jan 1, 2009, at 5:45 AM, synphonix wrote: > > Hello and happy new year, > > I've started this year with playing around with clojure macros and > wrote a macro that > behaves in a way I don't understand: > > (defmacro foo > ([x] `(list ~x ~x)) > ([x n] (if (<= n 0) > `(foo ~x) > `(foo ~(foo x) > ~(- n 1) > > (foo :a 0) => (:a :a) ;; What I expected > (foo :a 1) => nil ;; Here I would expect (foo (foo :a) 0) => (foo > (list :a :a) 0) => '((:a :a) (:a :a)) > (foo :a 2) => java.lang.NullPointerException > > Could someone please explain where my understanding of clojure macros > is flawed ? > Yes, as is so often the case, macroexpand(-1) can illuminate: Your problem is that when you say ~(foo x) you are running the macro during its own definition, rather than expanding into a call to itself: (macroexpand-1 '(foo :a 1)) -> (user/foo (:a :a) 0) ;oops What you want instead is to emit a call to the same macro in the expansion, ~(foo x) changed to (foo ~x): (defmacro foo ([x] `(list ~x ~x)) ([x n] (if (<= n 0) `(foo ~x) `(foo (foo ~x) ~(- n 1) (macroexpand-1 '(foo :a 1)) -> (user/foo (user/foo :a) 0) (macroexpand '(foo :a 1)) -> (clojure.core/list (user/foo :a) (user/foo :a)) (foo :a 1) -> ((:a :a) (:a :a)) (foo :a 2) -> (((:a :a) (:a :a)) ((:a :a) (:a :a))) 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Macro question
Thanks a lot. This year starts well (I learned something :-) Regards Poul --~--~-~--~~~---~--~~ 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: making code readable
I hesitate to extend this unpleasant thread, but here's a relevant post that definitely takes a stand on the commenting issue: http://steve-yegge.blogspot.com/2008/02/portrait-of-n00b.html As usual with Steve, it's a funny post, so I hope nobody takes it too seriously :) Hugh On Wed, Dec 31, 2008 at 9:49 AM, Tom Ayerst wrote: > "'Redundant comments are useless' is the mantra of the dilettante, the > amateur, and the cowboy."dilettante, the amateur, and the cowboy"", ouch. > Redundant comments are... redundant (hence the name), and a support overhead > and a source of misunderstanding if they are not updated in line with the > code. If you are writing code that will be read by people familiar with the > language and idioms and using meaningful names then a small number well > targeted comments are usually enough (Personally I do like a comment on each > function saying what it is for, doc strings look like the right solution for > this). > > Having said that; redundancy is a matter of context and I could use more > comments and meaningful variables in example code, I am acquainted with > Scheme so I can work my way through, but it is easy to get lost in the > homogeneous syntax and unfamiliar constructs and idioms. > > When trying something new the fewer gumption traps the better and it is > important to make sure information is to hand, this could be done through > repetition or by the application of a little more indirection; earlier in > the thread Mark asked if people would be aware of how to set up a clj > script, good question and a link to the place that explains how, when you > need it, would be very useful. > > Personally I don't think we need standards and stuff, what we need is some > more "code with training wheels" (lots comments and links taking you through > it very gently). That is not really Rich's job, he is to busy inventing the > thing, I think Mark's evolving example is great and a few more like it > covering other areas would be fine things and I hope to add to them myself > when I am a bit more familiar with Clojure. > > That was a bit more rambling than planned. > > Happy New Year > > Tom > > 2008/12/31 Simon Brooke >> >> On Dec 29, 3:15 am, Rich Hickey wrote: >> > On Dec 28, 8:13 pm, "Mark Volkmann" wrote: >> > >> >> > I'll not argue for making code harder to read, but I have to object to >> > most of your example. >> > >> > Making something 4x longer does not make it easier to read. >> > >> > Redundant comments are useless. >> >> This is the excuse continually trotted out by people too lazy to >> comment, or who think themselves superior to merely mortal programmers >> who have to work in teams and actually communicate with people. >> Redundancy in communication is almost never redundant; think of it as >> a checksum. >> >> ... >> >> 'Redundant comments are useless' is the mantra of the dilettante, the >> amateur, and the cowboy. >> > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Release of VimClojure 1.3.0
Dear vimming Clojurians, a long overdue release of VimClojure is available. This is mainly a bugfix and maintenance release. It brings the highlighting, indenting and completion up-to-date with current Clojure. Highlighting for contrib is there for a few modules, but it's far from being complete. One new feature worth mentioning is the conditional highlighting. Vim tries to figure at, which namespaces are required/used and dynamically adds highlighting for the included commands. Example: (ns foo.bar (:use [clojure.contrib.def :only (defvar)])) This adds highlighting for: - clojure.contrib.def/defvar and - defvar (But not for eg. defvar-!) (ns foo.bar (:require [clojure.contrib.def :as d])) This adds highlighting for: - clojure.contrib.def/defvar and - d/defvar and - d/defvar- (But not for defvar!) For multiple-file namespaces a similar :use/:require directive must be put in a comment at the file header for now. So it's still experimental. Thanks for all the feedback on issues and improvements! The release may be found at the usual spot: http://kotka.de/projects/clojure/vimclojure.html Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Constant expression optimization
HotSpot folds FP constants in a few rare cases, and I don't thing Math.log is one of them. For instance you can't fold "x+0.0" into "x" in case "x" happens to be negative 0. Math.log is a pure function so it would be possible, but I don't think it made the short-list of hot FP functions to optimize. Otherwise, the JDK is total specified and JVMs routinely optimize popular JDK calls. e.g. various String compare calls or x.getClass are totally inlined. Cliff On Dec 31 2008, 12:00 pm, "Mark H." wrote: > Folding constants in nontrivial floating-point expressions is an > aggressive optimization that can break some subtle code. For example, > when building LAPACK, the file that tries to determine parameters of > the floating-point units generally has to be compiled with no > optimization. I'd much rather keep that part of the optimization > turned off, or be very selective about when it gets turned on. > Furthermore, in some cases (FFTs on the Cell processor is the modern > example, if I recall correctly), it's better to recompute constants on > the fly then to look them up in a table. > > mfh --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
Yes, this does work too. I'll forward on your patch to Jeffrey. Thanks, Bill On Thu, Jan 1, 2009 at 5:55 AM, Remco van 't Veer wrote: > > I got repl to start with a small change to swank-clojure: > > > http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779ad6e79e37a44d84432 > > > On Thu, Jan 1, 2009 at 1:44 AM, Mark Hoemmen wrote: >> I've been having trouble with Emacs + SLIME + Clojure. I've been >> using Bill Clementson's setup, and it was working when I fetched all >> the required projects via his clj-build script. However, when I >> fetched new versions using this script yesterday, Emacs gave me the >> following error when I ran "run-clojure": >> >> error in process filter: Symbol's function definition is void: >> slime-redirect-inferior-output >> >> I get an *inferior-lisp* buffer that works (is hooked to Clojure), and >> I can evaluate Clojure buffers, but I don't get a SLIME REPL buffer, >> nor does syntax highlighting work (I made sure that font-lock-mode is >> set). All of those things worked before. I'm attaching a file >> containing the relevant part of my .emacs file. The trouble seems to >> be near the end, where the hook after slime connects calls >> "slime-redirect-inferior-output". I can't find this function anywhere >> in SLIME or in clojure-swank. If I comment out this call, I get >> another error saying that >> >> error in process filter: Symbol's value as variable is void: >> slime-repl-mode-map >> >> and the troubles stay. Anybody know how I could work around the >> problem or even fix it altogether? >> >> mfh >> >> > >> > > > > --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
It should be noted that (in order to use the new slime-repl mods (if you download the latest slime and apply Remco's patch), you will have to modify your .emacs startup to include the following: (slime-setup '(slime-repl)) - Bill On Thu, Jan 1, 2009 at 11:40 AM, Bill Clementson wrote: > Yes, this does work too. I'll forward on your patch to Jeffrey. > > Thanks, > Bill > > On Thu, Jan 1, 2009 at 5:55 AM, Remco van 't Veer wrote: >> >> I got repl to start with a small change to swank-clojure: >> >> >> http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779ad6e79e37a44d84432 >> >> >> On Thu, Jan 1, 2009 at 1:44 AM, Mark Hoemmen wrote: >>> I've been having trouble with Emacs + SLIME + Clojure. I've been >>> using Bill Clementson's setup, and it was working when I fetched all >>> the required projects via his clj-build script. However, when I >>> fetched new versions using this script yesterday, Emacs gave me the >>> following error when I ran "run-clojure": >>> >>> error in process filter: Symbol's function definition is void: >>> slime-redirect-inferior-output >>> >>> I get an *inferior-lisp* buffer that works (is hooked to Clojure), and >>> I can evaluate Clojure buffers, but I don't get a SLIME REPL buffer, >>> nor does syntax highlighting work (I made sure that font-lock-mode is >>> set). All of those things worked before. I'm attaching a file >>> containing the relevant part of my .emacs file. The trouble seems to >>> be near the end, where the hook after slime connects calls >>> "slime-redirect-inferior-output". I can't find this function anywhere >>> in SLIME or in clojure-swank. If I comment out this call, I get >>> another error saying that >>> >>> error in process filter: Symbol's value as variable is void: >>> slime-repl-mode-map >>> >>> and the troubles stay. Anybody know how I could work around the >>> problem or even fix it altogether? >>> >>> mfh >>> >>> > >>> >> >> >> >> > --~--~-~--~~~---~--~~ 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: making code readable
The amount of comments is difficult to balance and yes as you get more experience, you'd rather cram as much code lines in a screen shot as possible. 0 comments ? No that's not good. The other extreme he shows is also not viable. If maintaining the comments takes as much time as maintaining the code, productivity will inevitably suffer. We need to find a balance; short function synopsis, critical code section comments, ... These should be the basis from which we write comments and should be readable without the code so you get a minimal comprehension of what the code does without having to read the code entirely. It does not mean however that it should replace the code when looking for the details. Anything else that transcends the code modules should be in an external document. The other subject of Steve's post is much more important than the part about comments. He's absolutely right about meta data overkill... and there's nothing funny about it when you look at the overall situation. If I look back at the Java code my team wrote in the last 4 years, there is less human generated code lines than meta data configuration lines and generated code lines from this meta data. Typically written in XML which is so cumbersome that you need a schema sensitive editor to create valid files... A task by itself that has nothing to do with coding. Are these XML configuration files really self describing ? The number of frameworks out there with their specific configuration weirdness makes transitions from one to the other at best awkward. As soon as you hit a major bug or want to do something that is not supported or does not fit in a framework you're left nude on the ice bank. If you have invested heavily in configuration files and not in the code so your options are limited and require significant investments. In the life of a project, it's not good... At least if you are using code libraries you can modify the code locally to circumvent the problem. With frameworks it's much more complicated to do, do you have access to the code ? Do you have resources to fix the issue without compromising the framework ? What about maintenance ? Can you expect your fix to make it in the next release or is it too specific to your project to ever make it in the general code base ? All these options are far from fixing a limited code chunk in a library. People have been less and less polyvalent in the last 10 years. Those lucky enough to work deep enough with different technologies should make sure they keep that skill and open mind. I feel things will eventually change because the industry track record has not improved at all with this bureaucratic approach to software. The industry tried to replace intelligence (coders creating effective code) by some fabrication process driven by robots (writing endless configuration lines to generate code, specify behaviour, ...) while the anarchitects and DBA model the universe down to the atoms... Meanwhile the project time lines and budgets are busted and the pertinence of the code delivered drops. I've seen projects where intensive modelling made the performance so unbearable that some extra time was added at the end of the project to get rid of some of the modelling to get back some performance. Some of these projects were killed because there was no way you could retool them to remove the performance bottlenecks without redoing the project. Too much modelling kills but it does not mean that you do not need a model, you have to know when to stop. But that's out of reach for most of the model addicts out there. You do not need a modelling tool to built a flexible model, you need a minimal set of rules to which your system should stick to avoid failures. The industry replaced this common sense by these heavy tools that created the trend that you should model everything to ensure the code is "right". Tools like Rationale are the worst, they pretend that you can create code from a model without hand crafting the code... I've seen code generated by these tools and it's basically unreadable. Things are broke down to 10 lines classes, there is no way you can really understand the code except if you understand fully the model and hence what the modeler had in mind. The industry has been seeking the Holy Graal to replace the coder by some formal bureaucratic process since the end of 1970's and what we have seen in the last 10 years is another failure to reach that goal. Bureaucracy cannot replace intelligence. We see this in our respective governments and how they "manage" public services so why would we expect a better outcome in creating software the same way ? Is this thread unpleasant ? Looking at the world without pink glasses is not funny but taking the time to understand things gives you a sense of where we come from and where we might be going. As for Steve's post, it's about serious matters. Nonetheless, have a Happy New Year :))) and sorry for the heavy post... Luc
Re: Constant expression optimization
Konrad and Cliff -- both useful replies, thank you :-) Happy New Year everyone! mfh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Local mutually recursive functions?
Given that there's nothing like letrec in Clojure, and that let acts like let* in CL, I gather that local recursive functions are possible whereas local mutually recursive ones are not. Is that correct? If so, will they ever be in the future? Rock --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
nice article that mentions clojure in Technology Review
Hi! Just noticed nice article Parallel Universe in Technology Review which mentioned Clojure on page 4 http://www.technologyreview.com/computing/21806/page4/. Regards, DiG --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
On Jan 1, 5:55 am, "Remco van 't Veer" wrote: > I got repl to start with a small change to swank-clojure: > > http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779a... I changed that one line to say (defslimefn create-repl [target] '(user user)) and the SLIME repl works, but the following exception is thrown whenever the dynamic documentation for a function would be displayed: java.lang.Exception: Unable to resolve symbol: user in this context (NO_SOURCE_FILE: 0) [Thrown class clojure.lang.Compiler$CompilerException] Once I dismiss the exception, the repl itself works fine. Thanks y'all! mfh --~--~-~--~~~---~--~~ 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: Local mutually recursive functions?
On Thursday 01 January 2009 11:47, Rock wrote: > Given that there's nothing like letrec in Clojure, and that let acts > like let* in CL, I gather that local recursive functions are possible > whereas local mutually recursive ones are not. Is that correct? If > so, will they ever be in the future? > > Rock Aren't trampolines usable with anonymous functions? It seems like they would be. Randall Schulz --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
(Classname/staticField) is not the same as Classname/staticField
Hi, For some reason the Classname/staticField macro is not working properly for me. graphics=> (AudioSystem/getSystem) # graphics=> AudioSystem/getSystem java.lang.Exception: No such namespace: AudioSystem (NO_SOURCE_FILE:0) I'll try and demonstrate the problem using one of the standard libraries Java libraries instead of with JME. --~--~-~--~~~---~--~~ 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: (Classname/staticField) is not the same as Classname/staticField
On Jan 1, 10:19 pm, CuppoJava wrote: > Hi, > For some reason the Classname/staticField macro is not working > properly for me. > > graphics=> (AudioSystem/getSystem) > # > > graphics=> AudioSystem/getSystem > java.lang.Exception: No such namespace: AudioSystem (NO_SOURCE_FILE:0) getSystem is a function, not a field. --~--~-~--~~~---~--~~ 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: Constant expression optimization
According to this page: http://wikis.sun.com/display/HotSpotInternals/PerformanceTechniques Sun HotSpot is able to recognize constants in local variables, and I recall to have read somewhere that most if not all Math.* functions are intrinsic, so it should theoretically be possible. However, I don't think it happens. Clojure stores the 0.5 constant as an Object that is the result of RT.readString("0.5"). This Object then has to go through Number.doubleValue prior to the call to Math.log on every invocation of foo. I would *guess* that this is too much clutter for HotSpot to figure out that the result of the Math.log call is constant-foldable, but you'd probably need to look at the generated assembly to be sure - HotSpot is very aggressive with inlining, so it's possible that it can see through the type-boxing and the call to doubleValue. So much talk for not answering the question :) On Wed, Dec 31, 2008 at 5:49 PM, Konrad Hinsen wrote: > > Suppose I write > > (defn foo [x] > (let [f (. Math log 0.5)] > (* f x))) > > Does the Clojure compiler calculate the constant expression (. Math > log 0.5) once, or at every function call? Can I check this somehow, > i.e. look at the generated code, with reasonable effort? If it > doesn't optimize it, I'd have to write > > (let [f (. Math log 0.5)] > (defn foo [x] > (* f x))) > > which is fine as well for this minimal example, but less clear in > real-life code. I'd then rather write a small macro to evaluate the > constant expression, but before doing so I'd like to know if I really > have to. > > Konrad. > > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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: (Classname/staticField) is not the same as Classname/staticField
On Thursday 01 January 2009 14:02, pmf wrote: > On Jan 1, 10:19 pm, CuppoJava wrote: > > Hi, > > For some reason the Classname/staticField macro is not working > > properly for me. > > > > graphics=> (AudioSystem/getSystem) > > # > > > > graphics=> AudioSystem/getSystem > > java.lang.Exception: No such namespace: AudioSystem (NO_SOURCE_FILE:0) > > getSystem is a function, not a field. Well, if anything, it's a static method, not a function, right? But for some reason, it does not exist in my installation of JDK 1.6.0_11, neither in the output of (show ...) nor in the JavaDocs. What are you guys running? Randall Schulz --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Trivial use of pmap results in RejectedExecutionException ?
Hi there, I've been playing around with a few different approaches to writing concurrent programs in clojure, and I was surprised that a trivial use of pmap results in a RejectedExecutionException: (pmap #(* % %) (range 0 10)) This exception tends to happen in java when there is a thread pool executor which uses a bounded blocking queue - when the queue is full, instead of blocking insertions to the queue, it throws this exception instead. I haven't dug into the actual clojure agent behaviors to see what is happening at a lower level, but is anyone else seeing this? (Please note that if I use the alternate implementation of pmap on the "Refs and Transactions" page of clojure.org, it doesn't throw any exceptions.) --~--~-~--~~~---~--~~ 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: Local mutually recursive functions?
On Thu, Jan 1, 2009 at 2:47 PM, Rock wrote: > > Given that there's nothing like letrec in Clojure, and that let acts > like let* in CL, I gather that local recursive functions are possible > whereas local mutually recursive ones are not. Is that correct? If so, > will they ever be in the future? I assume you meant "are not possible". I think someone previously posted a letrec macro using something he called a "Y* combinator". I don't know what that is, but he said it was slow. Here's another way. Nothing about it is pretty, but it is a possibility: (let [my-even-atom (atom nil) my-even? (fn [i] (@my-even-atom i)) my-odd? (fn [i] (if (zero? i) false (@my-even-atom (dec i] (swap! my-even-atom (constantly (fn [i] (if (zero? i) true (my-odd? (dec i)) (my-odd? 4)) Ick. But perhaps a macro could make style less terrible to use? --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Trivial use of pmap results in RejectedExecutionException ?
On Thu, Jan 1, 2009 at 5:32 PM, Paul Mooser wrote: > > I've been playing around with a few different approaches to writing > concurrent programs in clojure, and I was surprised that a trivial use > of pmap results in a RejectedExecutionException: > > (pmap #(* % %) (range 0 10)) Works for me, SVN 1193 --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Trivial use of pmap results in RejectedExecutionException ?
>From a quick glance at the sources, I would not expect the scenario I described above to result in this. I'm going to see if I can wrangle a debugger into working with clojure (JSwat doesn't seem to perform well on my system, and I'm hoping I'll have better luck in Eclipse), and then see why specifically the executor used by the agents is having this issue on my system. --~--~-~--~~~---~--~~ 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: Trivial use of pmap results in RejectedExecutionException ?
Bingo - that fixed it. Sorry I didn't check that earlier. On Jan 1, 3:22 pm, Chouser wrote: > Works for me, SVN 1193 --~--~-~--~~~---~--~~ 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: Local mutually recursive functions?
On Thu, Jan 1, 2009 at 11:48 PM, Chouser wrote: > > On Thu, Jan 1, 2009 at 2:47 PM, Rock wrote: >> >> Given that there's nothing like letrec in Clojure, and that let acts >> like let* in CL, I gather that local recursive functions are possible >> whereas local mutually recursive ones are not. Is that correct? If so, >> will they ever be in the future? > > I assume you meant "are not possible". I think someone previously > posted a letrec macro using something he called a "Y* combinator". I > don't know what that is, but he said it was slow. > > Here's another way. Nothing about it is pretty, but it is a > possibility: > > (let [my-even-atom (atom nil) > my-even? (fn [i] (@my-even-atom i)) > my-odd? (fn [i] >(if (zero? i) > false > (@my-even-atom (dec i] > (swap! my-even-atom > (constantly (fn [i] > (if (zero? i) > true > (my-odd? (dec i)) > (my-odd? 4)) I don't get this listing. You define my-even? but do not use it? > > Ick. But perhaps a macro could make style less terrible to use? > > --Chouser > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
On Jan 1, 2009, at 4:05 PM, Mark H. wrote: Once I dismiss the exception, the repl itself works fine. Thanks y'all! I don't know how to fix it, but it appears to be related to the synchronization of the notion of the current namespace between swank and slime. This incantation works around it: ; SLIME 2009-01-01 user> (in-ns 'junk) # junk> (in-ns 'user) # user> After the first call, documentation is displayed correctly without an exception being thrown. The second call restores us to the user namespace. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Local mutually recursive functions?
On Thu, Jan 1, 2009 at 6:40 PM, Christian Vest Hansen wrote: > > On Thu, Jan 1, 2009 at 11:48 PM, Chouser wrote: >> >> On Thu, Jan 1, 2009 at 2:47 PM, Rock wrote: >>> >>> Given that there's nothing like letrec in Clojure, and that let acts >>> like let* in CL, I gather that local recursive functions are possible >>> whereas local mutually recursive ones are not. Is that correct? If so, >>> will they ever be in the future? >> >> I assume you meant "are not possible". I think someone previously >> posted a letrec macro using something he called a "Y* combinator". I >> don't know what that is, but he said it was slow. >> >> Here's another way. Nothing about it is pretty, but it is a >> possibility: >> >> (let [my-even-atom (atom nil) >> my-even? (fn [i] (@my-even-atom i)) >> my-odd? (fn [i] >>(if (zero? i) >> false >> (@my-even-atom (dec i] >> (swap! my-even-atom >> (constantly (fn [i] >> (if (zero? i) >> true >> (my-odd? (dec i)) >> (my-odd? 4)) > > I don't get this listing. You define my-even? but do not use it? Good point. I included a convenience function and forgot to use it. Replace the second "@my-even-atom" with "my-even?": (let [my-even-atom (atom nil) my-even? (fn [i] (@my-even-atom i)) my-odd? (fn [i] (if (zero? i) false (my-even? (dec i] (swap! my-even-atom (constantly (fn [i] (if (zero? i) true (my-odd? (dec i)) (my-odd? 4)) --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Local mutually recursive functions?
> I assume you meant "are not possible". I think someone previously > posted a letrec macro using something he called a "Y* combinator". I > don't know what that is, but he said it was slow. http://groups.google.com/group/clojure/browse_thread/thread/3259f09e08be4cfd/21f0e19fdce15ae9?lnk=gst&q=letrec#21f0e19fdce15ae9 MB provided a multi-loop macro which used recur to avoid growing the stack. --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
On Thu, Jan 1, 2009 at 1:05 PM, Mark H. wrote: > > On Jan 1, 5:55 am, "Remco van 't Veer" wrote: >> I got repl to start with a small change to swank-clojure: >> >> http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779a... > > I changed that one line to say > > (defslimefn create-repl [target] '(user user)) > > and the SLIME repl works, but the following exception is thrown > whenever the dynamic documentation for a function would be displayed: > > java.lang.Exception: Unable to resolve symbol: user in this context > (NO_SOURCE_FILE: > 0) > [Thrown class clojure.lang.Compiler$CompilerException] > > Once I dismiss the exception, the repl itself works fine. After downloading the latest slime and applying Remco's patch and modifying my .emacs file, I haven't been able to replicate this particular error. When you say that the "exception is thrown whenever the dynamic documentation for a function would be displayed", are you saying that the exception is occurring when you press "C-c C-d C-d" on a function name? It works fine for me. Or is there some other "dynamic documentation for a function" that you're referring to? - 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Emacs+SLIME+Clojure troubles
On Jan 1, 2009, at 7:57 PM, Bill Clementson wrote: Or is there some other "dynamic documentation for a function" that you're referring to? For me, it throws the exception when I type a space and SLIME tries to look up the arguments for the current function. For example, in a fresh SLIME repl: user> (a On typing a space after the "(a", the exception is thrown: java.lang.Exception: Unable to resolve symbol: user in this context (NO_SOURCE_FILE:0) [Thrown class clojure.lang.Compiler$CompilerException] --Steve smime.p7s Description: S/MIME cryptographic signature
Emacs + slime compile fail
I got the newest SVN version of Clojure and compiled it, and I installed Emacs and slime and everything like I was instructed (:p). The REPL and everything works fine, but when I use slimes "Compile File" button, it simply replies "Compilation failed: 0 errors 0 warnings 0 notes" and I can't figure out why, I tried using "Compile and Load file" and it says "Compilation finished: 0 errors 0 warnings 0 notes [0.01 secs]" but it doesn't generate a class file or anything. The code I'm using is straight off the wikibook. (ns okay.rayne (:gen-class)) (defn -main [& args] (println "application works")) 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 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: Emacs+SLIME+Clojure troubles
On Jan 1, 5:44 pm, "Stephen C. Gilardi" wrote: > On Jan 1, 2009, at 7:57 PM, Bill Clementson wrote: > > > Or is there some other "dynamic > > documentation for a function" that you're referring to? > > For me, it throws the exception when I type a space and SLIME tries to > look up the arguments for the current function. That's what I mean -- I should have been more specific. Oddly enough, the online documentation works fine when I'm coding in a non-REPL buffer (it doesn't throw an exception then), nor do I get an exception when I use C-c C-e to evaluate a one-line Clojure expression. I'll refetch everything, apply the Swank patch and try again -- mfh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
shelling out, convenience function for Runtime.exec()
I've added shell-out to clojure-contrib, with an 'sh' function that allows usage like: user=> (use '[clojure.contrib.shell-out :only (sh)]) nil user=> (print (sh "ls" "-l")) total 1316 drwxrwxr-x 5 chouser chouser4096 2008-12-16 11:32 classes drwxrwxr-x 3 chouser chouser4096 2008-12-02 11:46 clj nil user=> (print (sh "sed" "s/[aeiou]/oo/g" :in "hello there\n")) hoolloo thooroo nil It also has options for choosing the character encoding or returning stdout and stderr as an array of bytes to deal with binary data. What it does not provide is any kind of asynchronous interaction -- no passing of IO streams to or from the function. I will certainly consider adding these if there's enough demand, but that kind of interaction significantly complicates the API. I'd rather serve 80% of use cases with a dead-simple API and let the other 20% deal with the Runtime and Process classes themselves. --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clj-backtrace: more readable backtraces for Clojure
Hi all, I'm happy to announce an alpha release of clj-backtrace, a library for processing backtraces generated by Clojure programs. The library works by separating useful backtrace information from the noise generated by the Clojure compilation process, and also provides functions for pretty-printing these cleaned backtraces. You can see simple usage instructions and example backtrace output on the library's README page: http://github.com/mmcgrana/clj-backtrace/tree/master/README.textile If you've ever felt that backtraces in Clojure were difficult to read, I hope you'll give this library a try and let me know if it helps! - Mark --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Library's requirements and namespace name
Let's say that I have a parser library--let's call it FnParse--that I want to share with the world and let others use. If it requires another library, say, clojure.contrib.test-is, is there a way for me to indicate that that library is required? Or is the only thing I may do is indicate it in the library's documentation? Also, how should I create a name for the library's namespace? Is the clojure top-level domain reserved for clojure.core and clojure.contrib? Can I use something like "clojure.fnparse"? Or should I follow the Java package conventions and name it "name.smith.bob.fnparse" (after my .name domain, the only domain I have)? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
macro trouble
I'm trying to write a simple macro that will do CL-style call tracing for me. When I try to use it, however, I'm getting an "ExceptionInInitializerError." I don't know what this actually means, though I'm sure I'm just doing something very stupid. I was hoping someone on this list could help point out what I am doing wrong. I ran user=> (defmacro tracefn [function-name] "Creates trace logging of calls to a function." `(def ~function-name (let [old-function# ~(eval function-name)] (fn [& args#] (println args#) (print " ") (let [ret-val# (apply old-function# args#)] (println ret-val#) ret-val#) nil user=> (defn poor-mans-multiply [x y] (if (> x 0) (+ y (poor-mans-multiply (dec x) y)) 0)) #'user/poor-mans-multiply user=> (poor-mans-multiply 3 4) 12 user=> (tracefn poor-mans-multiply) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) user=> (tracefn 'poor-mans-multiply) java.lang.Exception: Second argument to def must be a Symbol (NO_SOURCE_FILE:370) user=> (poor-mans-multiply 3 4) 12 user=> What am I doing wrong? --Eric Tschetter --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
On Thu, Jan 1, 2009 at 6:02 PM, Mark H. wrote: > > On Jan 1, 5:44 pm, "Stephen C. Gilardi" wrote: >> On Jan 1, 2009, at 7:57 PM, Bill Clementson wrote: >> >> > Or is there some other "dynamic >> > documentation for a function" that you're referring to? >> >> For me, it throws the exception when I type a space and SLIME tries to >> look up the arguments for the current function. > > That's what I mean -- I should have been more specific. Oddly enough, > the online documentation works fine when I'm coding in a non-REPL > buffer (it doesn't throw an exception then), nor do I get an exception > when I use C-c C-e to evaluate a one-line Clojure expression. > > I'll refetch everything, apply the Swank patch and try again -- Looks like the correct patch to basic.clj should be: (defslimefn create-repl [target] '("user" user)) - 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Library's requirements and namespace name
On Jan 1, 2009, at 9:31 PM, samppi wrote: Let's say that I have a parser library--let's call it FnParse--that I want to share with the world and let others use. If it requires another library, say, clojure.contrib.test-is, is there a way for me to indicate that that library is required? Or is the only thing I may do is indicate it in the library's documentation? Your library source file should begin with an "ns" form that indicates its dependencies via ":require" and/or ":use" clauses. For example: (ns clojure.contrib.sql (:use clojure.contrib.except clojure.contrib.sql.internal)) Also, how should I create a name for the library's namespace? Is the clojure top-level domain reserved for clojure.core and clojure.contrib? Can I use something like "clojure.fnparse"? Or should I follow the Java package conventions and name it "name.smith.bob.fnparse" (after my .name domain, the only domain I have)? Following Java's convention is one good choice. I recommend treating the clojure top level "domain" as reserved. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Emacs+SLIME+Clojure troubles
On Jan 1, 2009, at 9:48 PM, Bill Clementson wrote: Looks like the correct patch to basic.clj should be: (defslimefn create-repl [target] '("user" user)) That works great for me. Thanks very much! --Steve smime.p7s Description: S/MIME cryptographic signature
What is this function called?
I want to get a seq of successive rests of the given seq: user> (defn f [seq] (if (empty? seq) nil (lazy-cons seq (f (rest seq) #'user/f user> (f '(1 2 3 4)) ((1 2 3 4) (2 3 4) (3 4) (4)) user> (take 10 (map #(take 5 %) (f (iterate inc 1 ((1 2 3 4 5) (2 3 4 5 6) (3 4 5 6 7) (4 5 6 7 8) (5 6 7 8 9) (6 7 8 9 10) (7 8 9 10 11) (8 9 10 11 12) (9 10 11 12 13) (10 11 12 13 14)) Does this fn already exist in clojure? If not what would an idiomatic name be for it from Haskell or CL? Andrew --~--~-~--~~~---~--~~ 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: shelling out, convenience function for Runtime.exec()
cool :) --~--~-~--~~~---~--~~ 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: Emacs+SLIME+Clojure troubles
On Jan 1, 6:48 pm, "Bill Clementson" wrote: > Looks like the correct patch to basic.clj should be: > (defslimefn create-repl [target] '("user" user)) That fixes everything -- thank you :-D mfh --~--~-~--~~~---~--~~ 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: (Classname/staticField) is not the same as Classname/staticField
Ah I see. Thanks for clearing that up for me. I didn't realize that functions and fields are resolved differently by that macro. Randall, that function is actually not part of the JDK, it's part of JME, a third-party graphics package. But thank you for helping. -Patrick --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Suggestion for new reader macros
What do you think about adding these new reader macros: !form => (complement form) #!(...) => (fn [args] (complement (...))) Two problems I see with these macros are the hassle to the reader with names that include '!' (e.g. set!, swap!), and the possible confusion of meaning with (not form) to people new to the language. I still think these are useful, clean, intuitive, and potentially frequent macros. Adding them would make code much more concise, elegant, and comfortable to write. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Adding user-defined state to classes created with (proxy ...)
(This is sort of a follow-up to this thread from last July: http://groups.google.com/group/clojure/browse_thread/thread/7f5cf3e78954b81d/aae7f082c51337c9?lnk=gst&q=proxy#aae7f082c51337c9.) Recently, I've been building a version of java.io.Writer that knows what the current column is on the output so it can handle tabs, etc. It would be pretty easy to do this with AOT, :genclass, etc. and just have a ref to the column number in my state, but life seems easier if you don't have to use AOT, so I considered doing it with a proxy. However, proxies *only* support the methods provided by their super- classes. They do this so that the proxy class can be compiled once, making proxy intances and variation super-cheap. I dug through the code in core_proxy.clj while trying to learn about this and it occurred to me that proxies could add state (similar to that created in :gen-class) with the following changes: 1) Add a __clojureProxyState field that points to a ref to a map, but is initialized to nil. 2) Add a getClojureProxyState() method to IProxy that returns the ref in question, lazily instantiating (ref {}) if necessary. Of course, the ref to a map thing is optional. The state could be left open as in :gen-class. This seems like it would add this capability without much problem. It has a few issues I can see: * We're a functional language so more places to add state are against the base philosophy. * The lazy instantiation could race (but that might be fixable). * The new names increase the chance of name collison. I'm interested to hear what folks think. If this was a capability that Rich and others agreed was a good addition, I'd be happy to build it and crank out a patch for 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 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: Adding user-defined state to classes created with (proxy ...)
Oops, sorry about the wrapping! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
update-values for clojure.contrib.sql
Hi, I was experimenting with clojure-contrib's sql features and found that there wasn't any update-values function. I've written my own and I'm sharing it here: (defn update-values [table where column-names & values] "Update columns of a table with values. columns-names is a vector of column names (strings or keywords) and the rest of arguments are the values for those columns." (let [columns (map #(str (the-str %) " = ?") column-names) template (if (seq column-names) (apply str (interpose "," columns)) "")] (apply do-prepared (format "update %s set %s where %s" (the-str table) template where) [values]))) It only send one set of values to do-prepared because of the where clause that would have to change according to each sets. I'm ready for your commentaries and/or suggestions. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---