Re: Why I have chosen not to employ clojure

2010-03-25 Thread Laurent PETIT
Yes, or CodeMirror (maybe more lightweight ?) 2010/3/26 Mark Derricutt : > I was thinking it might be interesting to see if we could integrate Bespin > Embedded in labrepl, having a nice web based syntax highlighting editor > thats consistent on platforms could be quite cool. > -- > Pull me down u

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
On Fri, Mar 26, 2010 at 12:59 PM, Chas Emerick wrote: > > On Mar 26, 2010, at 12:59 AM, Per Vognsen wrote: > >> On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick >> wrote: >>> >>> Because they're common processes that are ideally built once, and then >>> reused with minor variation.  Library reuse i

Re: Choosing a Clojure build tool

2010-03-25 Thread Antony Blakey
On 26/03/2010, at 4:37 PM, Rayne wrote: > I don't think I've ever seen a language in which part of the community > shunned build tools written in the language itself. It's quite > hilarious. People aren't shunning anything because it's written in Clojure. I think that reinventing all that Maven

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Meikel Brandmeyer
Hi, construct the JPanel outside the atom, add all the listeners and then add the panel to structure in the atom. (let [panel (JPanel. ..)] (add-listener-stuff panel the-atom) (swap! the-atom assoc :SpiffyPanel panel)) Side-effecting things shouldn't be done inside the swap! since it can be

Re: Choosing a Clojure build tool

2010-03-25 Thread Antony Blakey
On 26/03/2010, at 4:37 PM, Rayne wrote: > I don't think I've ever seen a language in which part of the community > shunned build tools written in the language itself. It's quite > hilarious. I've seen many examples where an overwhelming Not-Invented-Here attitude lead to failure. Antony Blakey

Re: Choosing a Clojure build tool

2010-03-25 Thread Rayne
I'll have to agree with Brain here. As of now, all I need is Leiningen. It does what I want. Lein is a new project, and I'm fairly certain that it will be much more useful in the future. I don't think I've ever seen a language in which part of the community shunned build tools written in the langu

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
On Mar 26, 2010, at 12:59 AM, Per Vognsen wrote: On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick wrote: Because they're common processes that are ideally built once, and then reused with minor variation. Library reuse is generally considered to be a good thing in software development, so

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick wrote: > Because they're common processes that are ideally built once, and then > reused with minor variation.  Library reuse is generally considered to be a > good thing in software development, so it strikes me as odd that many think > that such pra

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
Because they're common processes that are ideally built once, and then reused with minor variation. Library reuse is generally considered to be a good thing in software development, so it strikes me as odd that many think that such practices should stop at the build's edge, as it were. T

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
You can put a user.clj file in your class path. -Per On Fri, Mar 26, 2010 at 11:42 AM, Douglas Philips wrote: > On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote: > >> Look at clojure.contrib.repl-utils/add-break-thread!: >> >> http://richhickey.github.com/clojure-contrib/repl-utils-api.html > > Ni

Re: concurrency and rand-int

2010-03-25 Thread Chas Emerick
I was going to suggest something similar using seque in an atom, but in neither case (using an atom or a ref) is the contention going to be minimized -- just shifted from the AtomicLong in java.util.Random to the now-app-level atom or ref. - Chas On Mar 26, 2010, at 12:30 AM, Andrzej wrote

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Douglas Philips
On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote: Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html Nice. Now I have to figure out how to get a clojure rc file! :) -Doug -- You received this message because you are subscribe

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
One of the weirdest things coming to the Java world is to witness what strange things people take for granted should be in the build tool. All the example features you mention in your article are convenient, but I don't see why they belong in the build tool. They should be completely separate piece

Re: concurrency and rand-int

2010-03-25 Thread Andrzej
As others have pointed out using per-thread java.util.Random objects is probably the best way to go in this particular case. However, I'm curious if the following code could give any speed gain on your machine: (defn rand-seq [] (repeatedly #(. Math (random (def rand-seq-ref (ref (rand-seq)))

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html -Per On Fri, Mar 26, 2010 at 10:20 AM, Douglas Philips wrote: > I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I > type Control-C, it kills closure

^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Douglas Philips
I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I type Control-C, it kills closure and dumps me back at my shell. Is that what is supposed to happen? Is there some other keystroke I should be using that will interrupt clojure and put me back at the clojure top-leve

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
Ah, right, this is the function called from swap!. So move the listener stuff out of your swap function and into the function that calls swap! instead? On Thu, Mar 25, 2010 at 11:02 PM, Josh Stratton wrote: >> I would just pass the atom and move the @ inside the function... > > But the non-atom

Re: concurrency and rand-int

2010-03-25 Thread Anniepoo
As for the problems debugging code that calls nextInt, call setSeed with an arbitrary number at startup. After setting setSeed the sequence of ints returned will be the same every run. You may have trouble if you don't have any synchronization between threads. It could still have race conditions f

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Josh Stratton
> I would just pass the atom and move the @ inside the function... But the non-atom is automatically dereferenced and sent to the respective function when I use swap! So unless there's another function to alter atoms, I'm going to have the dereferenced version there no matter what, right? > > On

Re: concurrency and rand-int

2010-03-25 Thread Chas Emerick
Hi Lee, Indeed -- from the docs for Math.random(): "This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-numbe

Re: concurrency and rand-int

2010-03-25 Thread Per Vognsen
Clojure calls out to Java's java.lang.Math.Random: "This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number genera

concurrency and rand-int

2010-03-25 Thread Lee Spector
I'm trying to track down the reason that I sometimes see a lot of concurrency in my system (up to 1200% CPU utilization on a dual quadcore mac that also has some kind of hyperthreading, allegedly allowing a maximum of 1600% CPU) while other times it gets stuck at around 100-200%. My system (a g

Re: converting long string to number

2010-03-25 Thread Richard Newman
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. Clojure doesn't have a us

Re: converting long string to number

2010-03-25 Thread Per Vognsen
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. -Per On Fri, Mar 26, 2010

Re: converting long string to number

2010-03-25 Thread Mark Engelberg
Another unadvertised function that is useful to be aware of is clojure.lang.Numbers/reduce which will simplify a number to its most simple type. I often find that I want to use some BigInteger function, but then it is important to turn it back into a "typical Clojure number" at the end. For examp

Re: converting long string to number

2010-03-25 Thread Richard Newman
Of course, it might also pose a bit of a security threat: user> (read-string "#=(println \"I OWN YOU NOW!\")") I OWN YOU NOW! nil :) user=> (binding [*read-eval* false] (read-string "#=(println \"I OWN YOU NOW!\")")) java.lang.RuntimeException: java.lang.Exception: EvalReader not allowed w

Re: converting long string to number

2010-03-25 Thread Per Vognsen
Though it might not be the best option here, the Clojure reader is always ready to serve: user> (type (read-string "123")) java.lang.Integer user> (type (read-string "123123123123123")) java.lang.Long user> (type (read-string "123123123123123123123123123123123123")) java.math.BigInteger Of course

Re: Choosing a Clojure build tool

2010-03-25 Thread Mark Derricutt
For whats it worth here - IntelliJ IDEA will automatically add maven dependencies to you pom.xml file for unknown classes ( in java source, not the clojure plugin - yet), for example if you type "com.cemerick.Foo" in your source, and its an unknown class, the intention dialog gives you options of "

Re: Choosing a Clojure build tool

2010-03-25 Thread Seth
I am in complete agreement! Clojure continues to hinder itself by not providing an official executable. java -cp clojure.jar was good enough for Clojure 0.9, but that's not where it is anymore. Even simple things like submitting bug reports would be helped by having a default "clj" executable. It

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
I would just pass the atom and move the @ inside the function... On Thursday, March 25, 2010, strattonbrazil wrote: > I have a function that I use for adding a JPanel to a ui atom.  When I > call swap! that ui atom is sent to that function I call with the swap! > on and is dereferenced inside the

referencing an atom inside a function used for swapping

2010-03-25 Thread strattonbrazil
I have a function that I use for adding a JPanel to a ui atom. When I call swap! that ui atom is sent to that function I call with the swap! on and is dereferenced inside the function so I don't need to call @ui on it. However, I want to add listeners to my JPanel that can affect that atom, but I

Re: Choosing a Clojure build tool

2010-03-25 Thread Mark J. Reed
On Thu, Mar 25, 2010 at 6:17 PM, Brian Carper wrote: > > Ruby: gem install X > Perl: perl -MCPAN -e shell, then "install X" If you're just installing CPAN module X, then on most installations all you need to run is this: cpan X You can still go into the interactive shell if you want, usually

Re: Why I have chosen not to employ clojure

2010-03-25 Thread Mark Derricutt
I was thinking it might be interesting to see if we could integrate Bespin Embedded in labrepl, having a nice web based syntax highlighting editor thats consistent on platforms could be quite cool. -- Pull me down under... On Wed, Mar 24, 2010 at 4:26 AM, Stuart Halloway wrote: > You also get t

Re: Why I have chosen not to employ clojure

2010-03-25 Thread Timothy Pratley
Clojure can be used in so many different ways. I can't think of any other language where I have so many varied "integration options". The flexibility is confusing and frustrating, but I much prefer its presence than absence. :) I'm glad I stuck with it. -- You received this message because you ar

Re: Help optimizing array-to-integer operation?

2010-03-25 Thread Raph
On Mar 24, 10:57 am, "Mark J. Reed" wrote: > On Tue, Mar 23, 2010 at 8:19 PM, Raph wrote: > > (My opinion, anyway.I think a byte should be 8 bits and I should be able to > > use all of them.) > > Er, it is, and you can.  A Java byte still gives you all 8 bits' worth > of 256 different possible

Re: converting long string to number

2010-03-25 Thread Chas Emerick
Glen, You want (java.math.BigInteger. "2342343..."). java.lang.Integer is limited to 2^31-1. - Chas On Mar 25, 2010, at 6:40 PM, Glen Rubin wrote: I am trying to convert a long string of numbers to a number, but get a java.lang.numberformatexception My long string of numbers has new lin

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
Brian, FWIW, I'd claim that maven does deliver on all five points you list. Of note is that it absolutely is IDE-agnostic (I used NetBeans in the screencast because that's what I use -- you can load up maven-defined projects in Eclipse and IntelliJ just as easily). I'm not an emacs user

converting long string to number

2010-03-25 Thread Glen Rubin
I am trying to convert a long string of numbers to a number, but get a java.lang.numberformatexception My long string of numbers has new line characters in it, so I am filtering out the newline characters before converting it back to a string. Then I try to use Integer. on it but get the above e

Re: Choosing a Clojure build tool

2010-03-25 Thread Heinz N. Gies
On Mar 25, 2010, at 19:55 , Chas Emerick wrote: > I published a blog post earlier today, along with a short screencast that > might be of interest: > > "Like any group of super-smart programmers using a relatively new language, a > lot of folks in the Clojure community have looked at existing

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
On Mar 25, 2010, at 6:08 PM, Rob Wolfe wrote: No, XML is not the worst thing (at least for me). The real problem is here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html I'm not sure what you're referring to there. :-) Let's suppose that from time to time I'd

Re: Choosing a Clojure build tool

2010-03-25 Thread Brian Carper
On Mar 25, 11:55 am, Chas Emerick wrote: > I published a blog post earlier today, along with a short screencast   > that might be of interest: > > "Like any group of super-smart programmers using a relatively new   > language, a lot of folks in the Clojure community have looked at   > existing bui

Re: Choosing a Clojure build tool

2010-03-25 Thread Rob Wolfe
Chas Emerick writes: > I published a blog post earlier today, along with a short screencast > that might be of interest: > > "Like any group of super-smart programmers using a relatively new > language, a lot of folks in the Clojure community have looked at > existing build tools (the JVM space i

Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
I published a blog post earlier today, along with a short screencast that might be of interest: "Like any group of super-smart programmers using a relatively new language, a lot of folks in the Clojure community have looked at existing build tools (the JVM space is the relevant one here, me

Re: Clojure/LLVM

2010-03-25 Thread Jeff Heon
I know it's not Clojure, but you can at least scratch the Lisp on the iP* itch. Scheme for the iPhone: http://jlongster.com/software/iphone/scheme-iphone-example/ http://jlongster.com/blog/2010/02/23/farmageddon/ -- You received this message because you are subscribed to the Google Groups "Cloju

Re: database management: curing lock issues

2010-03-25 Thread Scott
thanks for your suggestions two clear options 1) agents and queued transactions 2) MVC enabled databases (postgresql, h2 (neat project)) Ill try the first option and see how it scales, and worst case move to the second Thanks again Scott On Mar 25, 12:47 pm, prhlava wrote: > > Is it as simple

Re: database management: curing lock issues

2010-03-25 Thread prhlava
> Is it as simple as moving to a better database, such as > mySQL? PostgreSQL is considerably better (even than MySQL, which still uses locks AFAIK) for anything concurrent. The PostgreSQL is using multiple version concurrency (MVC) approach - the same approach the clojure STM is using. The Postg

Re: database management: curing lock issues

2010-03-25 Thread Joonas Pulakka
I would suggest using a more concurrency-aware database. I've had luck with H2 (http://www.h2database.com/). It supports mixed local and remote connections in a thread-safe manner. Additionally it supports simple clustering, sounds like you could have use for such. Best Regards, Joonas -- You re

Re: Beginning Clojure. Recursion

2010-03-25 Thread jfr
Ok, I just looked at "frequencies" as Miki suggested. (reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} ["One" "Two" "Two" "Three" "Three" "Three"]) would be more like it. Thanks for the infos... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Beginning Clojure. Recursion

2010-03-25 Thread jfr
Thanks I will take a look at it .Neverless, the idea was to write my own code ;-) > You can also use "frequencies" from c.c.seq-utils (http:// > richhickey.github.com/clojure-contrib/seq-api.html#clojure.contrib.seq/ > frequencies) > > HTH, > -- > Miki -- You received this message because you ar

Re: database management: curing lock issues

2010-03-25 Thread Meikel Brandmeyer
Hi, maybe you can put finished work packages into a Queue and have a (different) thread reading them from the queue and writing them to the database linearly. So the workers don't have to know about the database and the DB writer doesn't have to care for the computation. Since you can't write to t

Re: database management: curing lock issues

2010-03-25 Thread Per Vognsen
Are the writes commutative? Since you are using pmap, I presume so. In that case, you could funnel the writes through an agent serving as a queue. -Per On Thu, Mar 25, 2010 at 9:59 PM, Scott wrote: > id prefer best practices if possible > > typically, cheating has consequences down the line > >

Re: database management: curing lock issues

2010-03-25 Thread Scott
id prefer best practices if possible typically, cheating has consequences down the line On Mar 25, 10:43 am, Joop Kiefte wrote: > Isn't programming not all about cheating the computer in doing what you want > it to do? In the book programming clojure you can find an example with locks > as well.

Re: database management: curing lock issues

2010-03-25 Thread Joop Kiefte
Isn't programming not all about cheating the computer in doing what you want it to do? In the book programming clojure you can find an example with locks as well. 2010/3/25 Scott > Question on best practices on handling SQL database concurrency issues > > I am "pmap"ping a evaluation to a long l

database management: curing lock issues

2010-03-25 Thread Scott
Question on best practices on handling SQL database concurrency issues I am "pmap"ping a evaluation to a long list (which calls a computationally intense script) from within clojure. The script itself is designed to be completely free of concurrency side-effects. During the evaluation, several ca

Re: Parsing parameters in clojure.core

2010-03-25 Thread Sean Devlin
I agreed with you until I had to go over every single line of the thing, in order. It actually reads pretty well from top to bottom. Then again, some functions are by necessity just plain nasty. On Mar 25, 2:02 am, Per Vognsen wrote: > It would be nice if the compiler handled these things with g

Re: Nubie Question

2010-03-25 Thread Mark J. Reed
Right. Let's make this clear: outside of the Java interoperability stuff, you cannot change the value of a variable in Clojure. Ever. All the data types are immutable; you can only build new values on top of existing ones, not modify the old ones. When you conj something onto a vector, it doesn'

Re: web starting clojure apps without Java code

2010-03-25 Thread Eugen Dück
I fixed a couple of other issues, most of which show only on Windows. You should see Kanjis now on the right-hand side when drawing. Eugen On Mar 23, 5:30 pm, Zmitro Lapcjonak wrote: > On Mar 17, 4:56 pm, Eugen Dück wrote: > > > The complete jnlp can be found athttp://dueck.org/kanshiki-boom/.

Re: Named arguments in HEAD and prettier default arguments for :keys destructuring

2010-03-25 Thread Laurent PETIT
Hi, Interesting. Seems more readable, more DRY, indeed. Especially if this becomes idiomatic for optional named arguments ... And the general case could be: (defn funkymonkey [x y z & {:keys [[a -1] [b -2] [c -3]], d :d, e [:e -4], :or {b -3, g -6}} [x y z a b c]) ? Which leads to the question

Re: Can't call public method of non-public class

2010-03-25 Thread Mark J. Reed
That's the one. But the solution given by the bug reporter doesn't address the case that came up on this thread, since it's not the class of the invocant but the types of the parameters that prevent the match from being found. On Thu, Mar 25, 2010 at 7:06 AM, atucker wrote: > Is this it? > http:

Benefit of declarative functional UI in Clojure?

2010-03-25 Thread Sophie
Would a Clojure app benefit sigificantly from a declarative functional UI along the lines of Lunascript http://www.asana.com/luna or FlapJax http://www.flapjax-lang.org/ ? The results look quite impressive ... but I don't have much to compare to in Clojure. I am relatively new to both Clojure and

Re: Named arguments in HEAD and prettier default arguments for :keys destructuring

2010-03-25 Thread Stefan Kamphausen
Hi, I've no idea whether this is reasonable but when I read your post suddenly the following thought appeared... What if defn would accept either a vector for the parameters or a map? (defn foo {:dont "know" :what "for"} ;; ... ) I did no deeper thinking on this at all, er, skip the "deeper"

Re: Nubie Question

2010-03-25 Thread Per Vognsen
On Thu, Mar 25, 2010 at 6:52 PM, WoodHacker wrote: > I thank all the people who have sent me solutions to my Conj > problem.   Unfortunately, none of them seem to work. > > The issue is adding a value to a defined vector - (def savedColors > [black, white]) > > One solution was given as:  (swap! s

Re: Nubie Question

2010-03-25 Thread WoodHacker
I thank all the people who have sent me solutions to my Conj problem. Unfortunately, none of them seem to work. The issue is adding a value to a defined vector - (def savedColors [black, white]) One solution was given as: (swap! savedColors conj newcolor) This produces still the following run

Re: Can't call public method of non-public class

2010-03-25 Thread atucker
Is this it? http://www.assembla.com/spaces/clojure/tickets/259 On Mar 23, 8:26 pm, "Mark J. Reed" wrote: > As far as I can tell, you're doing nothing wrong and just hitting a > bug in Clojure.  Which is still in 1.2.0-master... > > > > On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Barskiy > wrot

Re: Beginning Clojure. Recursion

2010-03-25 Thread Jarkko Oranen
jfr wrote: > Hello, > > I've just started to play a little bit with clojure to get a feel for > the language. It seems to be quite interesting (and it's a relief to > leave my clumsy IDE behind and use Emacs). Concerning immutable data: > Is the following code ok or should (must) I use transients

Re: ANN: labrepl, making Clojure more accessible

2010-03-25 Thread Rob Wolfe
On 25 Mar, 01:16, Mark Engelberg wrote: > I tried following Rob Wolfe's zip file instructions.  The bin\lein deps > command seemed to work fine, but when I then invoked bin\repl, I got the > following error: [...] > brepl-0.0.1.jar;C:\labrepl-package\core\leiningen-1.1.0-standalone.jar";.;C >