Re: Can resultset-seq blow the stack?

2010-09-19 Thread Stephen C. Gilardi
On Sep 19, 2010, at 3:45 PM, Shantanu Kumar wrote: > I simulated a similar recursive call and found it > throws StackOverflowError at 5508 levels deep on a 32-bit Sun JVM (not > server mode) on Windows 7. Did your similar recursion include the lazy-seq form that wraps the (apparently) recursive

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Sean Corfield
That also sounds pretty useful for development. I may try that as an exercise... This weekend has been a journey through The Joy of Clojure. I read about 100 pages on Friday evening (easy going), 150 pages on Saturday (harder going - more complex topics). Today I read another 50 pages, skipped cha

Re: Is reflection free clojure code possible?

2010-09-19 Thread Per Vognsen
With XNA running on the Xbox 360, reflection is the least of your worries. The runtime uses a very poor non-generational mark-and-sweep collector. At the rate of memory allocation in a typical Clojure program, you would be faced with constant GC hitches. Even people writing XNA games in C# (where i

Is reflection free clojure code possible?

2010-09-19 Thread Jarl Haggerty
Since there appears to be a version of clojure being made for .Net I was interested in the possibility of programming Xbox games in clojure. I imagine the Xbox doesn't have many of the same limitations that mobile devices have but as I understand it the version of .Net on the Xbox is a compact ver

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread jlk
Not sure how practical it is, but a while back I was playing around with a macro redefining defn so that it stored the function source in the meta-data of the function. I can't find it now but remember it being fairly trivial to implement. - lachlan On Sep 20, 10:29 am, Hozumi wrote: > If you

Making Clojure really work with Google App Engine

2010-09-19 Thread Constantine Vetoshev
I recently spent some time trying to abstract away some of the incidental complexity of using Google App Engine with Clojure. Right now, setting up interactive development and understanding what to do requires reading several blog posts, and pasting in a lot of boilerplate code. I ended up making a

Re: why the big difference in speed?

2010-09-19 Thread Tim Daly
> But is the way Clojure works so opaque we need to see byte codes? > I was hoping someone on the list would have some intuition about > how the expressions get implemented. In fact I hope it's pretty > close to what I would naively guess from just reading the code > as is. One of the advantages

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Hozumi
If you use emacs, incremental back search is handy. Typing "C-r defn", you may jump to the defnition of a function. Next time, you need to type only "C-r C-r". -- Takahiro Hozumi On 9月19日, 午前6:39, Sean Corfield wrote: > OK, this feels like a really dumb question... > > I'm playing around in the R

Re: trace facility?

2010-09-19 Thread Mike Meyer
On Sun, 19 Sep 2010 16:33:54 -0700 (PDT) TimDaly wrote: > In common lisp I can say (trace foo) and it will print out the > arguments > and the return value of calls to foo. Would it be possible to create > such > a facility in clojure, perhaps by defining a new class loader? Java > knows > the ty

trace facility?

2010-09-19 Thread TimDaly
In common lisp I can say (trace foo) and it will print out the arguments and the return value of calls to foo. Would it be possible to create such a facility in clojure, perhaps by defining a new class loader? Java knows the types of the arguments and the return values so it should be possible to w

Re: Keyword namespaces

2010-09-19 Thread Kyle Schaffrick
On Sun, 19 Sep 2010 23:07:55 +0200 Meikel Brandmeyer wrote: > Hi, > > Am 19.09.2010 um 22:59 schrieb ataggart: > > > Also note that the namespace portion of a keyword does not get > > resolved against the current aliases. E.g., > > user=> (require '[clojure.java.io :as io]) > > nil > > user=>

Re: why the big difference in speed?

2010-09-19 Thread Jason Wolfe
Microbench is a little utility I wrote that executes a piece of code for awhile to warm up, then records timings for as many runs as will fit in a preset time limit and reports statistics. So the numbers you see are min/median/max milleseconds per run, and number of runs that fit in 3 seconds of r

Re: why the big difference in speed?

2010-09-19 Thread Mike K
What is the definition of microbench? -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscrib

Isn't STM good at building an ant colony?

2010-09-19 Thread Hozumi
Hi. I posted following question. The more threads that changes the Clojure's ref are, the more does the rate of retries per threads rise? http://stackoverflow.com/questions/3746893/the-more-threads-that-changes-the-clojures-ref-are-the-more-does-the-rate-of-re I think increasing retries in O(thre

Re: why the big difference in speed?

2010-09-19 Thread Jason Wolfe
Hi Ranjit, The big perf differences you're seeing are due to reflective calls. Getting the Java array bits properly type-hinted is especially tricky, since you don't always get good reflection warnings. Note that aset is only fast for reference types: user> (doc aset) - c

Re: why the big difference in speed?

2010-09-19 Thread Jason Wolfe
Hi Ranjit, The big perf differences you're seeing are due to reflective calls. Getting the Java array bits properly type-hinted is especially tricky, since you don't always get good reflection warnings. Note that aset is only fast for reference types: user> (doc aset) - c

Re: Keyword namespaces

2010-09-19 Thread Meikel Brandmeyer
Hi, Am 19.09.2010 um 22:59 schrieb ataggart: > Also note that the namespace portion of a keyword does not get > resolved against the current aliases. E.g., > user=> (require '[clojure.java.io :as io]) > nil > user=> (= :io/foo :clojure.java.io/foo) > false It does with ::. user=> (= ::io/foo :

Re: Keyword namespaces

2010-09-19 Thread ataggart
Considering that the only effect of adding a namespace to keyword is to ensure it doesn't inadvertently equal some other keyword (e.g., :a- ns/foo doesn't equal :foo nor :b/foo), I'm not clear on what kind of conflation you're concerned about. Also note that the namespace portion of a keyword does

Re: why the big difference in speed?

2010-09-19 Thread Ranjit
I'm seeing a big difference in speed for each function run only once, so I guess any Hotspot optimization isn't happening right? But is the way Clojure works so opaque we need to see byte codes? I was hoping someone on the list would have some intuition about how the expressions get implemented. I

Re: Keyword namespaces

2010-09-19 Thread Kyle Schaffrick
On Sun, 19 Sep 2010 12:22:54 -0700 (PDT) ataggart wrote: > Unlike symbols, keywords just evaluate to themselves. The keyword :foo > will not collide with a var foo, likewise keyword :my-ns/foo will not > collide with var my-ns/foo. So, if I understand you correctly, :xsl/ > value-of would work j

Can resultset-seq blow the stack?

2010-09-19 Thread Shantanu Kumar
Hi, While looking at the implementation of clojure.core/resultset-seq function, I found there is a recursive call to 'thisfn' which isn't loop-recur'ed. I simulated a similar recursive call and found it throws StackOverflowError at 5508 levels deep on a 32-bit Sun JVM (not server mode) on Windows

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Sean Corfield
On Sun, Sep 19, 2010 at 10:24 AM, Stephen C. Gilardi wrote: > The clojure repl is very customizable. It's possible to add this feature in a > custom repl to experiment with the idea: Awesome. I'll see if I can generalize that to keep a longer history and a nice easy way to view / retrieve past e

Re: Keyword namespaces

2010-09-19 Thread ataggart
Unlike symbols, keywords just evaluate to themselves. The keyword :foo will not collide with a var foo, likewise keyword :my-ns/foo will not collide with var my-ns/foo. So, if I understand you correctly, :xsl/ value-of would work just fine. On Sep 19, 11:56 am, Kyle Schaffrick wrote: > Would it

Keyword namespaces

2010-09-19 Thread Kyle Schaffrick
Would it be correct to say that the namespace portions of keywords are semantically opaque? In other words, if I have a keyword :my-ns/foo and a symbol 'my-ns/foo, obviously the namespace in the symbol has semantic meaning to the language when it's evaluated (or syntax-quoted), but the namespace o

Re: why the big difference in speed?

2010-09-19 Thread Alessio Stalla
On 19 Set, 19:34, Tim Daly wrote: >   In common lisp I use the (disassemble) function which generally > gives back an assembler listing of the code that would be executed. > Is there a Java function which will return the byte codes that get > executed? In general there isn't. In the particular si

Re: Macro closing over atom gives "Can't embed object in code" error.

2010-09-19 Thread Nathan Sorenson
I think I understand; the unquote operator is not providing a reference to the underlying object itself, but is rather a procedure that translates the object into a code representation. Thank-you for the explanation. On Sep 19, 6:53 am, Stuart Sierra wrote: > A macro is a function which returns

Re: why the big difference in speed?

2010-09-19 Thread Stuart Halloway
You can use "javap -c" out of the JDK to get the bytecodes that are handed to the VM. However, HotSpot does amazing things with the bytecodes after the code begins to run, so a disassembly can be quite misleading. I measure far more often than I view bytecode. Stu > In common lisp I use the (

Re: why the big difference in speed?

2010-09-19 Thread Tim Daly
In common lisp I use the (disassemble) function which generally gives back an assembler listing of the code that would be executed. Is there a Java function which will return the byte codes that get executed? Could this be used to create a (disassemble) function for Clojure? Having such a functio

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Stephen C. Gilardi
On Sep 19, 2010, at 11:45 AM, Steven E. Harris wrote: > Moritz Ulrich writes: > >> I think this would be a very nice extension for the repl - Saving the >> forms for later-retrieval. > > As precedent, the Common Lisp reader uses the +, ++, and +++ variables¹ > to store the last three forms read

Re: why the big difference in speed?

2010-09-19 Thread Ranjit
Hi Nicholas, Thanks for the advice. I already tried (set! *warn-on-reflection* true), but it doesn't generate any warnings for any of these functions. I tried adding ^doubles in gaussian-matrix1 as you suggested but that didn't really change the speed at all. And changing next-gaussian to a macro

Re: practical clojure

2010-09-19 Thread David J
I definitely have. I'm in the middle of trying to port some stats test from R over to Incanter, notably the Wicoxon Rank Sum test. I just meant I hope this catches on with statisticians, now that R's creator has admitted its flaws. On Sep 18, 9:09 pm, Jeff Heon wrote: > On Sep 17, 8:23 pm, David

Re: Using macro to generate part of fn

2010-09-19 Thread Konrad Hinsen
On 19 Sep 2010, at 07:21, Stuart Campbell wrote: In this method, the first two parameters may be null. So, my fn looks like this: (defn exported-keys ([table] (exported-keys nil table)) ([schema table] (exported-keys nil schema table)) ([catalog schema table] (fetch-metad

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Steven E. Harris
Moritz Ulrich writes: > I think this would be a very nice extension for the repl - Saving the > forms for later-retrieval. As precedent, the Common Lisp reader uses the +, ++, and +++ variables¹ to store the last three forms read. Footnotes: ¹ http://www.lispworks.com/documentation/HyperSpec/

Re: why the big difference in speed?

2010-09-19 Thread Nicolas Oury
A first good start is to put (set! *warn-on-relection* true) at the start of the file and removes all reflective access. Before the 1.3 release, function cannot receive/returns primitive so you might consider (defmacro next-gaussian [] `(.nextGaussian ^Random r)) (^Random is here to make sure

why the big difference in speed?

2010-09-19 Thread Ranjit
Hi, I'm trying learn Clojure to see if I can use it in my simulations, and one thing I need to do is generate arrays of normally distributed numbers. I've been able to come up with the following two ways of doing this. gaussian-matrix2 is a lot faster than gaussian-matrix1, but I'm not sure why.

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Moritz Ulrich
I think this would be a very nice extension for the repl - Saving the forms for later-retrieval. On Sun, Sep 19, 2010 at 3:54 PM, Stuart Sierra wrote: > On Sep 18, 5:39 pm, Sean Corfield wrote: >> Is there something easy within the REPL to show the source of >> something you defined earlier? > >

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Stuart Sierra
On Sep 18, 5:39 pm, Sean Corfield wrote: > Is there something easy within the REPL to show the source of > something you defined earlier? No. The REPL does not preserve what you type in. -S -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Macro closing over atom gives "Can't embed object in code" error.

2010-09-19 Thread Stuart Sierra
A macro is a function which returns a data structure representing code to be compiled. All literals (String, Integer, symbol, etc.) and basic data structures (lists, maps, etc.) can be compiled, as can functions. Most other non-literal objects *cannot* be compiled. What you probably want is not

Genetic Algorithm Example

2010-09-19 Thread Goran Jovic
Hi everyone! I started learning Clojure earlier this year (as a part of MSc studies from this discussion: http://groups.google.com/group/clojure/browse_thread/thread/a8aa5ac26d9761da?hl=en&tvc=2#) I was initially shocked with lispy syntax, given the fact I previously mostly used languages with C