Silence WARNING: Long already refers to: class java.lang.Long in namespace: ... in aot compile compatible way

2015-04-27 Thread Scott Nielsen
I have a simplified scenario here: https://github.com/scizo/unmap-failure The problem is I am using ns-unmap to prevent a WARNING from being printed when shadowing java.lang.Long in a namespace. When this code is aot compiled, the namespace var referenced by 'Long is being created before the

Crazy Need: Embed JavaScript Structure in Clojure

2015-04-27 Thread JPatrick Davenport
Hello, So just to get it out: I do not want to evaluate the JavaScript, simply preserve it. I'm working on an ArangoDB driver. Part of the wonder that is ArangoDB is its ability to support transactions. This is done using JSON. Part of the REST object for a transaction is what I want to do in

Re: complex numbers in clojure

2015-04-27 Thread Alex Miller
I think it's unlikely that Clojure would add a complex number type. However, it might be possible to open up the system enough that new types could be created and integrated by others. I think this discussion and implementation from clojure-dev (about unsigned numbers) is pertinent:

[ANN] Ring-swagger 0.20.0, Compojure-api 0.20.0 other schema/web libs

2015-04-27 Thread Tommi Reiman
Hi all, We here at Metosin have been developing some open source libs, mostly stuff related to web. Most of the libs have got big new releases lately, so though of promoting them here too. Here goes: * *Ring-Swagger 0.20.0* (https://github.com/metosin/ring-swagger) - support lib for

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Andy-
You're right. I didn't check it enough. I did check out the source (and btw, was very impressed with the result) but it looks like the function call ended up doing nothing. I just put in a side effect and I got the following results: [a :one], (multi-test), 100 runs, 2933 msecs [a :one],

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread David Nolen
A quick glance at your benchmarking setup, it's not clear that you are benchmarking what you think you are benchmarking, and jsperf is not a suitable benchmarking harness (irrespective of it's popularity). Benchmarking is hard, benchmarking JavaScript is harder, and benchmarking JavaScript that

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Andy-
Looks like they're pretty slow compared to a simple case: http://jsperf.com/cljs-multimethods https://github.com/rauhs/cljs-perf On Saturday, April 25, 2015 at 10:33:18 AM UTC-4, Timur wrote: Hi everyone, There are situations where I want to dispatch functions using based on their

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Phillip Lord
I think that the answer is, it depends, and, there might be some surprises in store. In my own use, I found multimethods collapse in performance as a result of changes to the interface hierarchy in the library I was using (my tests cases went from 45s to over 4mins). I circumvented this by

Re: complex numbers in clojure

2015-04-27 Thread Mikera
Complex numbers are tricky because: - They need to be fast in order to be useful for numerical computing. The obvious implementations that you might create with boxed values, vectors/maps, multimethods and protocols are likely to be unacceptable for many use cases - You still want to be able to

Re: complex numbers in clojure

2015-04-27 Thread endbegin
I have been thinking along the lines of mikera and Maik - and it seems like there is no further progress here? I would like to take a crack at creating a complex number type, but implemented as a library to Clojure. I am not sure where to start, and if anyone here has suggestions, I'd be happy

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Phillip Lord
Alex Miller a...@puredanger.com writes: Sounds like you might have been running into the absence of multimethod caching for the default case (http://dev.clojure.org/jira/browse/CLJ-1429), which has been fixed in 1.7. No, I don't think; my default case was and is throw an exception.

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Alex Miller
Sounds like you might have been running into the absence of multimethod caching for the default case (http://dev.clojure.org/jira/browse/CLJ-1429), which has been fixed in 1.7. Just on a side note, that repo does not change the default lein :jvm-opts, which are bad for benchmarking. I

Re: complex numbers in clojure

2015-04-27 Thread Andy Fingerhut
Unless the Java Math library handles complex types already, I don't know of any way to extend it in a way that would let you get the answer you want from (Math/abs my-complex-number) in Clojure. If you want code that gives the correct answers, a library using vectors or maps for complex numbers

Re: complex numbers in clojure

2015-04-27 Thread Gary Verhaegen
As far as I understand, your example with Math/abs would need to be part of Java. You cannot extend the arithmetic operators in Java, and you will not be able to extend static Java methods like Math/abs. What you may be able to do is make your custom type play nice with Clojure operators, like

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Alex Miller
I fleshed out some of this a bit more in a blog post with perf numbers in case anyone's interested: http://insideclojure.org/2015/04/27/poly-perf/ On Saturday, April 25, 2015 at 9:39:06 PM UTC-5, Alex Miller wrote: On Saturday, April 25, 2015 at 9:33:18 AM UTC-5, Timur wrote: Hi everyone,

with-redefs does not work for macros

2015-04-27 Thread Vebjorn Ljosa
In one of my tests, I was trying to mock something (`clojure.tools.logging/warn`) that happened to be a macro. It had me puzzled for a while until I discovered that `with-redefs` resets the value of the vars after the body is executed, but does not reset the flag that says that the var is a

Re: complex numbers in clojure

2015-04-27 Thread endbegin
This is what I suspected. Of course, this is not just for abs, but really for any mathematical operation. Sqrt, Trig operations etc. I will study the Ratio type more closely, but note that something like (Math/abs (/ 22 7)) does not work. On Monday, April 27, 2015 at 12:45:32 PM UTC-4, Gary

Re: complex numbers in clojure

2015-04-27 Thread endbegin
As far as I know, Java Math does not have a complex number type. Some implementations of a complex number exist (such as Apache Commons Math), but they create a Complex class that implements Serializeable and a Commons specific interface. Modifying clojure.core itself is a bit daunting, and

Re: complex numbers in clojure

2015-04-27 Thread Andy Fingerhut
People frequently make their own modified versions of Clojure without having their changes made part of the core Clojure distribution. That is why I said depending upon your goals. If your goal is to try it out and learn from it, and you don't care whether it becomes part of the standard Clojure

Re: with-redefs does not work for macros

2015-04-27 Thread Vebjorn Ljosa
On Monday, April 27, 2015 at 12:34:14 PM UTC-4, Vebjorn Ljosa wrote: In one of my tests, I was trying to mock something (`clojure.tools.logging/warn`) that happened to be a macro. It had me puzzled for a while until I discovered that `with-redefs` resets the value of the vars after the

Re: complex numbers in clojure

2015-04-27 Thread Lee Spector
Just cheerleading: I, for one, would love for Clojure to have complex number support, however it can be arranged (built-in or through a library). I sometimes do quantum computing work and this issue has prevented progress on a couple of projects. I haven't tried to solve the problem myself,

Re: Crazy Need: Embed JavaScript Structure in Clojure

2015-04-27 Thread Atamert Ölçgen
Hi JPatrick, On Mon, Apr 27, 2015 at 11:50 PM, JPatrick Davenport virmu...@gmail.com wrote: Hello, So just to get it out: I do not want to evaluate the JavaScript, simply preserve it. I'm working on an ArangoDB driver. Part of the wonder that is ArangoDB is its ability to support

Re: [ANN] Clojure Applied: From Practice to Practitioner

2015-04-27 Thread Alex Miller
The second beta of Clojure Applied is now available. This version adds Chapter 8 (Clojure Testing) as well as a foreword by Russ Olsen, and fixes for many of the reported errata. https://pragprog.com/book/vmclojeco/clojure-applied If you've already bought the book, you should get an email to