Re: making code readable

2008-12-31 Thread Luc Prefontaine
It was our own initiative. 4 of us integrated an existing team of developers and they were required to spit out detailed specs at every release. This was a real-time redundant system to control production and transportation of electricity in the province of Quebec. That system had to show up 99.99

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

2008-12-31 Thread Chouser
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 [_

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

2008-12-31 Thread wubbie
Hi all, what's the new syntax for this? It is part of the code below which was translation by Stu. ; using dotimes instead of repeat from cl (defn plot [f min max step] (doseq i (range min max step) (dotimes _ (apply f [i]) (print "*")) (println))) Thanks, Sun --~--~-~--~

Re: How to encapsulate local state in closures

2008-12-31 Thread Timothy Pratley
> On Dec 30, 2008, at 6:29 PM, Mark Engelberg wrote: > Use Case #1: Implementing classic imperative algorithm (GDC) I replaced your (atoms) using (with-local-vars) and the function runs perfectly fine. The local vars are not closed over, so they cannot leak, and the code is cleaner. So this examp

Re: Emacs+SLIME+Clojure troubles

2008-12-31 Thread Bill Clementson
Hi Mark, On Wed, Dec 31, 2008 at 4:44 PM, 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

Re: making code readable

2008-12-31 Thread Joseph Jones
On Dec 31, 2008, at 1:29 PM, Luc Prefontaine wrote: > In the mid 80's I and others in a Fortran dev. team created a super > javadoc. This beast was spitting out a FULL > document in the editor used by office people. > > You would write comments in the code that were extracted and you > would

Emacs+SLIME+Clojure troubles

2008-12-31 Thread Mark Hoemmen
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

Exponentiation (expt / pow)

2008-12-31 Thread Mark Engelberg
As I posted a couple weeks ago, I've been finding it awkward that Clojure doesn't have too many math functions that know how to "do the right thing" with the various numeric types it uses. The one that's been bothering me the most is the lack of an expt function. Calling Math/pow automatically co

Re: making code readable

2008-12-31 Thread Luc Prefontaine
My two cents... Comments are worse since Javadoc came to life, up to date or not. Most of the time they do not describe the behaviour of the class in depth and you have to get the source code on your screen. We replaced quality by quantity. If I want to find the signature of a function I can al

Re: How to encapsulate local state in closures

2008-12-31 Thread Luc Prefontaine
I have not yet written thousands of line of parallel code in Clojure (I am in this learning curve as of now while experimenting with Terracotta). However I can compare with other frameworks I've used in the past: ASTs, Event Flags,... on VMS, semaphores, condition variables, mutexes, ... in libthr

Re: making code readable

2008-12-31 Thread Mark H.
On Dec 31, 8:13 am, "Mark Volkmann" wrote: > Suppose you had been studying Clojure for one week before coming > across this code. Would you know what was going on here? Let's see ... > we've got an anonymous function that uses an anonymous function which > iterates some number of times calling do

Re: Constant expression optimization

2008-12-31 Thread Mark H.
On Dec 31, 8:49 am, 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? Folding constants in nontrivial floating-point expres

Re: How to encapsulate local state in closures

2008-12-31 Thread Rich Hickey
On Dec 31, 1:20 pm, "Mark Engelberg" wrote: > On Wed, Dec 31, 2008 at 6:27 AM, Rich Hickey wrote: > > I also think that your use cases for atoms for local mutation are a > > mismatch. atoms are about sharing. You really want something else for > > private/local mutable references, and I have s

Re: Stumped - Java hangs when using Swing in Slime

2008-12-31 Thread CuppoJava
And Xemacs has the same problem... so it might be a problem with Windows then =( --~--~-~--~~~---~--~~ 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

Re: Stumped - Java hangs when using Swing in Slime

2008-12-31 Thread CuppoJava
After some more tinkering, I think the problem lies somewhere in the way Emacs handles IO from the buffers. 1) The System command prompt works perfectly. 2) Inferior-Lisp mode hangs 3) Slime hangs 4) Running a windows shell from within Emacs, and running Java from within the shell also hangs. Sy

Re: How to encapsulate local state in closures

2008-12-31 Thread Mark Engelberg
On Wed, Dec 31, 2008 at 6:27 AM, Rich Hickey wrote: > I also think that your use cases for atoms for local mutation are a > mismatch. atoms are about sharing. You really want something else for > private/local mutable references, and I have some ideas for that. You're right that I'm basically as

Re: Constant expression optimization

2008-12-31 Thread Randall R Schulz
On Wednesday 31 December 2008 09:56, Dave Griffith wrote: > Can't find the chapter and verse, but a bit of googling shows that > GCJ does this optimization > http://gcc.gnu.org/ml/gcc-patches/2003-05/msg02312.html Yes, but you claim that this guarantee is in the language specification and that

Re: Constant expression optimization

2008-12-31 Thread Dave Griffith
Can't find the chapter and verse, but a bit of googling shows that GCJ does this optimization http://gcc.gnu.org/ml/gcc-patches/2003-05/msg02312.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Constant expression optimization

2008-12-31 Thread Randall R Schulz
On Wednesday 31 December 2008 09:10, Dave Griffith wrote: > No, but the semantics of java.lang classes are fully specified in the > Java spec, Can you quote chapter and verse to this effect? I'm not finding it, at least not in "The Java™ Language Specification, Third Edition." There's an index

Re: Constant expression optimization

2008-12-31 Thread Randall R Schulz
On Wednesday 31 December 2008 09:10, Dave Griffith wrote: > No, but the semantics of java.lang classes are fully specified in the > Java spec, and JVM implementers are allowed to rely on them. It's > entirely possible that there are special case optimizations for > java.lang.Math calls. Beyond t

Re: Constant expression optimization

2008-12-31 Thread Dave Griffith
No, but the semantics of java.lang classes are fully specified in the Java spec, and JVM implementers are allowed to rely on them. It's entirely possible that there are special case optimizations for java.lang.Math calls. --~--~-~--~~~---~--~~ You received this mes

Re: Constant expression optimization

2008-12-31 Thread Randall R Schulz
On Wednesday 31 December 2008 09:03, Dave Griffith wrote: > Note, however, that your JVM may very well know that > java.lang.Math.log (0.5) is a constant, and optimize the calculation > out of the JIT compiled code. This wouldn't show up in the > bytecode, and is extremely difficult to actually

Re: Constant expression optimization

2008-12-31 Thread Dave Griffith
Note, however, that your JVM may very well know that java.lang.Math.log (0.5) is a constant, and optimize the calculation out of the JIT compiled code. This wouldn't show up in the bytecode, and is extremely difficult to actually check. Whether or not any JVM actually does this probably depends

Re: Constant expression optimization

2008-12-31 Thread Rich Hickey
On Dec 31, 11:49 am, 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? Every call. Clojure does not know that Math/log is a

Constant expression optimization

2008-12-31 Thread Konrad Hinsen
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

Re: Stumped - Java hangs when using Swing in Slime

2008-12-31 Thread sroll...@gmail.com
On Dec 30, 10:38 pm, CuppoJava wrote: > I would like to add that nope... installing SLIME didn't seem to help. > > I'm on Clojure rev. 1160, and the latest SLIME and Swank sources as of > December 30 2008. I experience a similar issue on windows, but not linux. The first time I create a JFrame i

Re: making code readable

2008-12-31 Thread Daniel Eklund
> 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.

Re: Some code review for clj-record?

2008-12-31 Thread John D. Hume
Hi Brian, On Tue, Dec 30, 2008 at 11:41 AM, Brian Doyle wrote: > (ns com.example.user) > (clj-record.core/init-model) > > but when I do that I get the error: > > java.lang.ClassNotFoundException: clj-record.core ... > (first (reverse (re-split #"\." (name (ns-name *ns*) > > and could be ch

Re: making code readable

2008-12-31 Thread Mark Volkmann
I'd like to focus the attention back to a specific example. See the first code snippet at http://clojure.org/concurrent_programming. (import '(java.util.concurrent Executors)) (defn test-stm [nitems nthreads niters] (let [refs (map ref (replicate nitems 0)) pool (. Executors (newFixed

Re: making code readable

2008-12-31 Thread Weiqi Gao
Simon Brooke wrote: > 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 co

Re: making code readable

2008-12-31 Thread Tom Ayerst
"'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 cod

Re: making code readable

2008-12-31 Thread Rich Hickey
On Dec 31, 9:42 am, Simon Brooke wrote: > 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

Compiling Clojure code with Maven

2008-12-31 Thread Mike DeLaurentis
I'm working on a project that has both Java and Clojure sources. We use Maven as our build system, and I'd like to use it to compile the Clojure sources. Has anyone done that before? I can think of a few ways to do it, such as using maven to run an ant task or writing a plugin, but I'm not sure wh

Re: making code readable

2008-12-31 Thread 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

Re: How to encapsulate local state in closures

2008-12-31 Thread Rich Hickey
On Dec 31, 2008, at 12:30 AM, Mark Engelberg wrote: > > On Tue, Dec 30, 2008 at 8:38 PM, Rich Hickey > wrote: >> There's simply no value for Clojure to add to a simple mutable box. >> Clojure does provide the tools for low-level mutation - access to >> Java. You can wrap that in whatever func

Re: swank-clojure license

2008-12-31 Thread lpetit
OOps, I'm losing memory, I answered twice to the e-mail ;-) On 31 déc, 11:16, lpetit wrote: > Yes, this is what I remember from LGPL. But anyway, swank-clojure is > not LGPL, it's GPL. > > I re-read my original post, and it seems clear to me : I stated I wish > to embed swank-clojure files into

Re: Parallel words frequency ranking

2008-12-31 Thread Konrad Hinsen
On 30.12.2008, at 22:24, Mark H. wrote: > On Dec 30, 9:18 am, Mibu wrote: >> In an ideal world, standard functions like map, sort, reduce, filter, >> etc. would know when to parallelize on their own, or even better, the >> compiler will do it for them. > > The former is easier than the latter ;-

Update for Gorilla available

2008-12-31 Thread Meikel Brandmeyer
Dear vimming Clojurians, the latest SVN versions of Clojure and Clojure Contrib broke Gorilla. So now a compatibility release is available to bring Gorilla back up-to-date. Note: this release is only necessary if you use Clojure >= SVN rev1192 and Contrib >= SVN rev331. Revisions before those me

Re: swank-clojure license

2008-12-31 Thread lpetit
Yes, this is what I remember from LGPL. But anyway, swank-clojure is not LGPL, it's GPL. I re-read my original post, and it seems clear to me : I stated I wish to embed swank-clojure files into clojure-dev plugin. Anyway, I'll rephrase my question differently : Given that : - Clojure-dev's (an