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 contr

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 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

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 wrote: > I've been having trouble with Emacs + SLIME + Clojure. I've been > using Bill Clementson's

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. Can

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 complete.

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 optim

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 wrote: > > I got repl to start with a small change to swank-clojure: > > > http://github.com/remvee/swank-clojure/commit/ed89d6997bce3c5076e779ad6e79e37a44d84432 > >

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 wrote: > Yes, th

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 co

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 un

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 G

Re: Emacs+SLIME+Clojure troubles

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

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) # 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 librari

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

2009-01-01 Thread pmf
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 f

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 d

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 wrote: > > Hi, > > For some reason the Classname/staticField macro is not working > > properly for me. > > > > graphics=> (AudioSystem/getSystem) > > # > > > > graphics=> AudioSystem/getSystem > > java.lang.Exception: N

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 e

Re: Local mutually recursive functions?

2009-01-01 Thread Chouser
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?

Re: Trivial use of pmap results in RejectedExecutionException ?

2009-01-01 Thread Chouser
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, SV

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 spec

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 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 emai

Re: Local mutually recursive functions?

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

Re: Emacs+SLIME+Clojure troubles

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

Re: Local mutually recursive functions?

2009-01-01 Thread Chouser
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 func

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. http://groups.google.com/group/clojure/browse_thread/thread/3259f09e08be4cfd/21f0e19fdce15ae9?lnk=gst&q=

Re: Emacs+SLIME+Clojure troubles

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

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 r

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 fig

Re: Emacs+SLIME+Clojure troubles

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

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

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 pretty-prin

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

macro trouble

2009-01-01 Thread Eric Tschetter
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 po

Re: Emacs+SLIME+Clojure troubles

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

Re: Library's requirements and namespace name

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

Re: Emacs+SLIME+Clojure troubles

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

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)

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 clojure+unsubscr...@googlegroups.c

Re: Emacs+SLIME+Clojure troubles

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

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=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

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

2009-01-01 Thread Tom Faulhaber
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+uns

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