Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Rich Hickey
On Feb 20, 2:18 pm, Jason Wolfe wrote: > Hmmm, that is weird ... I would expect the sort to throw an exception, > but it seems to complete happily. (If you try it with a vector > instead of a list, it will error). > Fixed in svn 1298 - thanks for the report. Rich --~--~-~--~~---

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Chouser
On Fri, Feb 20, 2009 at 1:59 PM, Steffen Glückselig wrote: > > I was trying to use Clojure to verify the behavior some method in > Java. > > Namely I wanted to quickly check whether Collections.sort does the > sorting I need. > > So I came up with: > > (let [list '("1" "KB" "K6" "2" "EÜ" "EZ" "ES

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Jeffrey Straszheim
The Clojure collections are immutable, which is their entire reason for existing. However, there is nothing stopping you from creating a plain old Java collection in Clojure. (let [list (ArrayList. '("Fred" "mary" "sue")] (do (java.util.Collections/sort list) list)) Should work. On Fri

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Jason Wolfe
Hmmm, that is weird ... I would expect the sort to throw an exception, but it seems to complete happily. (If you try it with a vector instead of a list, it will error). Anyway, the typical way to do this would be to convert your Clojure data structure to a mutable Java type first, then convert i

Calling method in Java that mutates passed argument

2009-02-20 Thread Steffen Glückselig
I was trying to use Clojure to verify the behavior some method in Java. Namely I wanted to quickly check whether Collections.sort does the sorting I need. So I came up with: (let [list '("1" "KB" "K6" "2" "EÜ" "EZ" "ES")] (do (java.util.Collections/sort list) list)) But since Collect