Bug? Definline arguments multiply evaluated.

2009-07-30 Thread John Harrop
user=> (definline addsq [a b] `(+ (* ~a ~a) (* ~b ~b))) #'hxr.clj.util/addsq user=> (addsq (do (println "a evaluated") 1) 1) a evaluated a evaluated 2 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Exit delay from java when lazy?

2009-07-30 Thread mwillson
On Jul 29, 8:17 pm, Michael Wood wrote: > 2009/7/29 mwillson : > > > > I was experimenting with Clojure and XML and stumbled upon a lengthy > > hang when exiting java which was tracked down to the use of > > clojure.contrib.lazy-xml.  Here's a toy example which exhibits the > > issue: > > I haven

Re: java 1.4 class files

2009-07-30 Thread Frank Koenig
Thank you Stuart and Daniel for the help. I think I have to step back from the idea to use clojure on this Java 1.4 project :-( Let's hope my next Java project addresses a less archaic Java version. --~--~-~--~~~---~--~~ You received this message because you are s

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Rich Hickey
On Jul 30, 1:29 am, John Harrop wrote: > user=> (definline addsq [a b] `(+ (* ~a ~a) (* ~b ~b))) > #'hxr.clj.util/addsq > user=> (addsq (do (println "a evaluated") 1) 1) > a evaluated > a evaluated > 2 You write the expansion, so you are in control of multiple evaluation. Rich --~--~-

Bug? Primitives get boxed if passed out of let.

2009-07-30 Thread Rich Hickey
On Thu, Jul 30, 2009 at 1:28 AM, John Harrop wrote: > user=> (loop [i 0 j (double 1.0)] >   (if (= i 1) j (recur 1 (+ j j > 2.0 > user=> (loop [i 0 j (double 1.0)] >   (if (= i 1) j (recur 1 (let [a j b j] (+ a b) > # java.lang.IllegalArgumentException: recur arg for primitive local: j mus

Re: Possible bug report

2009-07-30 Thread Rich Hickey
On Jul 29, 6:09 pm, Jason Wolfe wrote: > Is this a bug? > > user> (eval `(make-array ~Byte/TYPE 2)) > ; Evaluation aborted. (ExceptionInInitializerError) > > Compare: > > user> (eval `(make-array ~Byte 2)) > # > > user> (eval `(make-array Byte/TYPE 2)) > # > > user> (make-array (eval Byte/TYPE)

Re: Possible bug report

2009-07-30 Thread Aaron Cohen
At my day job, we've always used a custom classloader to get around that asymmetry. -- Aaron On Thu, Jul 30, 2009 at 9:51 AM, Rich Hickey wrote: > > > > On Jul 29, 6:09 pm, Jason Wolfe wrote: > > Is this a bug? > > > > user> (eval `(make-array ~Byte/TYPE 2)) > > ; Evaluation aborted. (Exceptio

Re: java 1.4 class files

2009-07-30 Thread Sean Devlin
This is slightly unrelated, but... How much work would it be to run the old code on a Java 5/6 VM? I didn't get into Java until 5, so I'm not sure how much work is actually involved w/ upgrading a JVM installation. On Jul 30, 7:07 am, Frank Koenig wrote: > Thank you Stuart and Daniel for the h

Re: Possible bug report

2009-07-30 Thread Jason Wolfe
On Jul 30, 2009, at 6:51 AM, Rich Hickey wrote: > On Jul 29, 6:09 pm, Jason Wolfe wrote: >> Is this a bug? >> >> user> (eval `(make-array ~Byte/TYPE 2)) >> ; Evaluation aborted. (ExceptionInInitializerError) >> >> Compare: >> >> user> (eval `(make-array ~Byte 2)) >> # >> >> user> (eval `(make-ar

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Nicolas Oury
Hello, I am not sure to agree. If I get it right, definline is used to replace defn for function that we want to be inlined. So replacing defn by definline should have no impact on the semantic of the program. Best regards, Nicolas. On Thu, 2009-07-30 at 05:34 -0700, Rich Hickey wrote: >

Good memory profilers (program or human)?

2009-07-30 Thread Andy Fingerhut
I'm gradually adding a few more Clojure benchmark programs to my repository here: git://github.com/jafingerhut/clojure-benchmarks.git The one I wrote for the "reverse-complement" benchmark is here: http://github.com/jafingerhut/clojure-benchmarks/blob/4ab4f41c6f963445e1e0973a668ac64939be1c7f/rc

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Rich Hickey
On Thu, Jul 30, 2009 at 1:26 PM, Nicolas Oury wrote: > > Hello, > > I am not sure to agree. > > If I get it right, definline is used to replace defn for function that > we want to be inlined. > > So replacing defn by definline should have no impact on the semantic of > the program. > The docs for

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Laurent PETIT
BTW, is definline still considered experimental (I know it is still mentioned in the doc, just asking whether it's up to date or not) ? 2009/7/30 Stuart Halloway > > The documentation is explicit that definline observes defmacro-like > semantics. > > A.K.A. "What Rich said" :-) > > Stu > > > He

struct-map niggle

2009-07-30 Thread Richard Newman
I understand what's going on here (and I don't regard it as a bug that needs fixing) but I thought I'd share something that caught me off- guard, and perhaps should be mentioned in the docs for struct-maps. Clojure 1.0.0- user=> (defstruct foo :bar :baz) #'user/foo user=> (def foo-bar (accesso

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Stuart Halloway
The documentation is explicit that definline observes defmacro-like semantics. A.K.A. "What Rich said" :-) Stu > Hello, > > I am not sure to agree. > > If I get it right, definline is used to replace defn for function that > we want to be inlined. > > So replacing defn by definline should hav

Re: struct-map niggle

2009-07-30 Thread ataggart
The problem is you aren't quoting the forms fed to eval. This: (eval (struct foo 1 2)) mean this: (eval {:bar 1 :baz 2}) And small literal maps are eval'd as a PersistentArrayMap Now if instead you do: (eval '(struct foo 1 2)) then eval is eval'ing the form (struct foo 1 2), thus t

Re: struct-map niggle

2009-07-30 Thread Richard Newman
> The problem is you aren't quoting the forms fed to eval. That was intentional. Imagine a broader example, where I want to read in a form, examine/print/etc. parts of it, then evaluate it. Printing a struct-map produces map syntax. Reading the output produces a literal map with unevaluated c

Re: struct-map niggle

2009-07-30 Thread Chouser
On Thu, Jul 30, 2009 at 4:20 PM, Richard Newman wrote: > > The scenario here, though, is different: given an *existing* struct- > map (which prints as {:foo 1 :bar 2} -- not a form), one cannot print > it in such a way that the struct-map-ness is preserved when it is re- > read. You can discover t

Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread David Plumpton
I'm trying to find an idiomatic way to read through a text file (e.g. a Git history log) where an object will be represented by several lines of text, and when we find a line that starts a new entry we create the old entry and continue. For example here's my first clumsy attempt. Can anybody advis

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread Meikel Brandmeyer
Hi, I would suggest to have a look at fnparse[1]. It's really cool. A commit-log parser might look like this: (def linebreak (alt (conc (opt (lit \return)) (lit \newline)) (lit \return))) (def hex-digit (alt-lit-seq "0123456789abcdef")) (def checksum (semantics (rep+ hex-digit) #(

Re: struct-map niggle

2009-07-30 Thread Richard Newman
> Are you aware of *print-dup* ? It causes the printer to > preserve more of the specific type information than normal > printing: It's one of those things that hasn't yet crept close enough on my radar for me to absorb. This is the impetus... > Having said that, it's important to note it doe

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread Richard Newman
On 30 Jul 2009, at 2:26 PM, David Plumpton wrote: > I'm trying to find an idiomatic way to read through a text file (e.g. > a Git history log) Sidenote: I'm hacking on this: http://github.com/rnewman/clj-git/tree/master I haven't got to commit messages etc. yet -- I'm primarily using git as

Re: Bug? Definline arguments multiply evaluated.

2009-07-30 Thread Rich Hickey
On Thu, Jul 30, 2009 at 2:52 PM, Laurent PETIT wrote: > BTW, > > is definline still considered experimental (I know it is still mentioned in > the doc, just asking whether it's up to date or not) ? > Yes, still experimental. Rich > 2009/7/30 Stuart Halloway >> >> The documentation is explicit

Re: struct-map niggle

2009-07-30 Thread Stuart Sierra
On Jul 30, 5:03 pm, Chouser wrote: > Are you aware of *print-dup* ?  It causes the printer to > preserve more of the specific type information than normal > printing: > > user=> (binding [*print-dup* true] (prn (hash-map :a 1, :b 2))) > {:a 1, :b 2} > nil > user=> (binding [*print-dup* true] (prn

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread Aaron Cohen
What is this convention you are using with the -> ? Are you coming from a C or C++ background or is this something lispy I haven't seen before? -- Aaron On Thu, Jul 30, 2009 at 7:56 PM, Richard Newman wrote: > > On 30 Jul 2009, at 2:26 PM, David Plumpton wrote: > > > I'm trying to find an idio

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread Richard Newman
> What is this convention you are using with the -> ? > > Are you coming from a C or C++ background or is this something lispy > I haven't seen before? A fair proportion of Common Lispers do that (though I've witnessed debates about its merit, usually in the context of low-level code where

Re: Keyword not serializable

2009-07-30 Thread Chas Emerick
It turns out that a framework we've been using is able to serialize *any* Java class, whether it implements Serializable or not -- so, we've been happily serializing keywords without them explicitly supporting it for some time. However, making Keyword formally Serializable has other benefits, spe

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-30 Thread Daniel Lyons
On Jul 30, 2009, at 7:24 PM, Aaron Cohen wrote: > Are you coming from a C or C++ background or is this something lispy > I haven't seen before? I first ran into this in Scheme, where I think its use is somewhat more idiomatic than in CL. As the author observes, it's generally used instead