Re: Constant expression optimization

2009-01-01 Thread Konrad Hinsen
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

Re: Exponentiation (expt / pow)

2009-01-01 Thread Konrad Hinsen
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

Re: what's the new syntax for (dotimes _ (apply f [i]) (print *)) ?

2009-01-01 Thread wubbie
Thanks Chouser, Happy new year! sun On Jan 1, 12:37 am, Chouser chou...@gmail.com wrote: On Wed, Dec 31, 2008 at 11:41 PM, wubbie sunj...@gmail.com 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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Remco van 't Veer
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 mark.hoem...@gmail.com wrote: I've been having trouble with Emacs + SLIME + Clojure. I've been

Macro question

2009-01-01 Thread synphonix
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)

Re: Macro question

2009-01-01 Thread synphonix
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.

Re: Macro question

2009-01-01 Thread Rich Hickey
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)

Re: Macro question

2009-01-01 Thread synphonix
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

Re: making code readable

2009-01-01 Thread Hugh Winkler
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,

Release of VimClojure 1.3.0

2009-01-01 Thread Meikel Brandmeyer
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

Re: Constant expression optimization

2009-01-01 Thread cliffc
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.

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Bill Clementson
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 rwvtv...@gmail.com wrote: I got repl to start with a small change to swank-clojure:

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Bill Clementson
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

Re: making code readable

2009-01-01 Thread Luc Prefontaine
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

Re: Constant expression optimization

2009-01-01 Thread Mark H.
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

Local mutually recursive functions?

2009-01-01 Thread Rock
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

nice article that mentions clojure in Technology Review

2009-01-01 Thread DiG
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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Mark H.
On Jan 1, 5:55 am, Remco van 't Veer rwvtv...@gmail.com 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

Re: Local mutually recursive functions?

2009-01-01 Thread Randall R Schulz
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?

(Classname/staticField) is not the same as Classname/staticField

2009-01-01 Thread CuppoJava
Hi, For some reason the Classname/staticField macro is not working properly for me. graphics= (AudioSystem/getSystem) #OpenALSystem com.jmex.audio.openal.openalsys...@ec6b00 graphics= AudioSystem/getSystem java.lang.Exception: No such namespace: AudioSystem (NO_SOURCE_FILE:0) I'll try and

Re: (Classname/staticField) is not the same as Classname/staticField

2009-01-01 Thread pmf
On Jan 1, 10:19 pm, CuppoJava patrickli_2...@hotmail.com wrote: Hi, For some reason the Classname/staticField macro is not working properly for me. graphics= (AudioSystem/getSystem) #OpenALSystem com.jmex.audio.openal.openalsys...@ec6b00 graphics= AudioSystem/getSystem

Re: Constant expression optimization

2009-01-01 Thread Christian Vest Hansen
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

Re: (Classname/staticField) is not the same as Classname/staticField

2009-01-01 Thread Randall R Schulz
On Thursday 01 January 2009 14:02, pmf wrote: On Jan 1, 10:19 pm, CuppoJava patrickli_2...@hotmail.com wrote: Hi, For some reason the Classname/staticField macro is not working properly for me. graphics= (AudioSystem/getSystem) #OpenALSystem com.jmex.audio.openal.openalsys...@ec6b00

Trivial use of pmap results in RejectedExecutionException ?

2009-01-01 Thread Paul Mooser
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

Re: Trivial use of pmap results in RejectedExecutionException ?

2009-01-01 Thread Chouser
On Thu, Jan 1, 2009 at 5:32 PM, Paul Mooser taron...@gmail.com 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))

Re: Trivial use of pmap results in RejectedExecutionException ?

2009-01-01 Thread Paul Mooser
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

Re: Trivial use of pmap results in RejectedExecutionException ?

2009-01-01 Thread Paul Mooser
Bingo - that fixed it. Sorry I didn't check that earlier. On Jan 1, 3:22 pm, Chouser chou...@gmail.com wrote: Works for me, SVN 1193 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Local mutually recursive functions?

2009-01-01 Thread Christian Vest Hansen
On Thu, Jan 1, 2009 at 11:48 PM, Chouser chou...@gmail.com wrote: On Thu, Jan 1, 2009 at 2:47 PM, Rock rocco.ro...@gmail.com 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

Re: Local mutually recursive functions?

2009-01-01 Thread Chouser
On Thu, Jan 1, 2009 at 6:40 PM, Christian Vest Hansen karmazi...@gmail.com wrote: On Thu, Jan 1, 2009 at 11:48 PM, Chouser chou...@gmail.com wrote: On Thu, Jan 1, 2009 at 2:47 PM, Rock rocco.ro...@gmail.com wrote: Given that there's nothing like letrec in Clojure, and that let acts like

Re: Local mutually recursive functions?

2009-01-01 Thread Timothy Pratley
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.

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Bill Clementson
On Thu, Jan 1, 2009 at 1:05 PM, Mark H. mark.hoem...@gmail.com wrote: On Jan 1, 5:55 am, Remco van 't Veer rwvtv...@gmail.com 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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Stephen C. Gilardi
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

Emacs + slime compile fail

2009-01-01 Thread Rayne
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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Mark H.
On Jan 1, 5:44 pm, Stephen C. Gilardi squee...@mac.com 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

shelling out, convenience function for Runtime.exec()

2009-01-01 Thread Chouser
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-backtrace: more readable backtraces for Clojure

2009-01-01 Thread Mark McGranaghan
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

Library's requirements and namespace name

2009-01-01 Thread samppi
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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Bill Clementson
On Thu, Jan 1, 2009 at 6:02 PM, Mark H. mark.hoem...@gmail.com wrote: On Jan 1, 5:44 pm, Stephen C. Gilardi squee...@mac.com 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

What is this function called?

2009-01-01 Thread Andrew Baine
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

Re: shelling out, convenience function for Runtime.exec()

2009-01-01 Thread Timothy Pratley
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

Re: Emacs+SLIME+Clojure troubles

2009-01-01 Thread Mark H.
On Jan 1, 6:48 pm, Bill Clementson billc...@gmail.com 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

Re: (Classname/staticField) is not the same as Classname/staticField

2009-01-01 Thread CuppoJava
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

Suggestion for new reader macros

2009-01-01 Thread Mibu
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

Adding user-defined state to classes created with (proxy ...)

2009-01-01 Thread Tom Faulhaber
(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=gstq=proxy#aae7f082c51337c9.) Recently, I've been building a version of java.io.Writer that knows what the current column is on the output

update-values for clojure.contrib.sql

2009-01-01 Thread budu
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