I actually ran into this while comparing nested data structures from two
different sources and spent a good part of my day figuring out what's
happening. While it is a good advice to avoid mixing floats and doubles, it
is inevitable that Clojure users will get bitten by this once in a while
and hou
I'm not. The Datomic Transactor is on one of our own hosts.
On Friday, January 23, 2015 at 12:43:28 AM UTC+1, Wei Hsu wrote:
>
> How are you running Datomic on Heroku?
>
> On Thursday, January 22, 2015 at 8:53:29 AM UTC-8, Henrik Mohr wrote:
>>
>> (still) a moderate load. Around 10-50 users online
Ghadi Shayban writes:
> I don't think satisfies? is worth optimizing as using ton of it seems
> antithetical to protocols. It signals to me that a caller does in fact
> care about the implementation, whereas protocols are about not
> caring. Like your PR, if you want to ensure a protocol's covera
Clojure is caching protocol implementations explicitly with extra
bytecodes, not the JVM. And it is very efficient.
I don't think satisfies? is worth optimizing as using ton of it seems
antithetical to protocols. It signals to me that a caller does in fact
care about the implementation, where
Wait isn't this caching?
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L480
On Thu Jan 22 2015 at 8:44:09 PM Bobby Eickhoff wrote:
> Clojure isn't doing the caching. The JVM is doing the caching. In this
> case, Clojure just has mechanical sympathy for how the
Clojure isn't doing the caching. The JVM is doing the caching. In this
case, Clojure just has mechanical sympathy for how the JVM operates.
On Thursday, January 22, 2015 at 11:10:56 PM UTC-5, Michael Blume wrote:
>
> It sounds like basically dispatch is fast because we bothered to make it
> fa
It sounds like basically dispatch is fast because we bothered to make it
fast (by caching) and satisfies? is slow because we didn't. Is it worth
throwing caching at satisfies? to make it fast or should satisfies? just
not be on the critical path for Clojure code?
(To give a motivating example, sat
Protocol call sites build an inline cache to optimize dispatch. The
benchmark is running many times and reaping benefit from the cache.
satisfies? looks up the object's class in the protocol's implementation
map [1], and the benchmark is stressing this. You'll see that code checks
if the pro
Extends seems to be defeated by superclassing. ie:
(extends? my-protocol (class {})) => false
because my-protocol is extended to IPersistentMap and (class {}) isn't
IPersistentMap it's PersistentArrayMap (which implements IPersistentMap but
extends? doesn't care)
On Thu Jan 22 2015 at 5:28:30 PM
The logic of extends? is much simpler, so try that. IIRC it's something
like "extends? returns true if any method on the protocol is implemented by
x", "satisfies? returns true if all methods of a protocol are implemented
by x".
The docs don't seem to give much help here, so play with it in the re
(defprotocol my-protocol
(foo [this]))
(extend-protocol my-protocol
clojure.lang.IPersistentMap
(foo [this] "hello from map"))
(criterium.core/quick-bench
(satisfies? my-protocol {}))
(criterium.core/quick-bench
(foo {}))
Simply calling foo on an empty map takes 7 ns,
but checking whe
macroexpand-1 is a good start, I'd also recommend using the (is (thrown?
...)) special form, so
(is (thrown? IllegalArgumentException (macroexpend-1 '(my-macro
(ill-formed-arguments ...)
On Thu Jan 22 2015 at 5:05:36 PM Ben Wolfson wrote:
> (try (macroexpand-1 '(my-macro (ill-formed-argumen
(try (macroexpand-1 '(my-macro (ill-formed-arguments ...)))
false ;; shouldn't get here
(catch Exception _ true)) ;; whole expression should be true
As long as you know that the *right* exception is being thrown.
On Thu, Jan 22, 2015 at 4:41 PM, Scott Rabin wrote:
> We have a few ma
We have a few macros in my employer's codebase that throw compile-time
errors when you've given them invalid configurations, and have generally
simply tested the result of these macros and not necessarily the direct
expansion of said macros. What we would like to do is *test* that the macro
blo
How are you running Datomic on Heroku?
On Thursday, January 22, 2015 at 8:53:29 AM UTC-8, Henrik Mohr wrote:
>
> (still) a moderate load. Around 10-50 users online at the same time. Not
> an extreme load on the Datomic Peer library since not a whole lot of data
> is stored per user (well, not fo
Part of what you wish were true is already true: Using = to compare a
double to a BigDecimal always returns false in Clojure, as does comparing a
float to a BigDecimal.
It is only (= float-value double-value) that can return true in Clojure,
even though hash does not guarantee the usual hash consi
On Thursday, January 22, 2015 at 2:12:52 PM UTC-5, Jozef Wagner wrote:
>
> As seen in CLJ-1372, this issue will probably cause some strong opinions.
> I think this is an example of a leaky abstraction and the current approach
> is to leave it as is, as there are some serious trade-offs and are th
## Registration ##
Tickets are on sale now for Clojure/West 2015 - Apr 20-22 in Portland,
Oregon!
- Register: http://clojurewest2015.eventbrite.com
- Early bird - $275 (and going fast)
- Regular - $350
## Workshops ##
We will also have workshops on the weekend prior to Clojure/West (Apr
18-19th)
As seen in CLJ-1372, this issue will probably cause some strong opinions. I
think this is an example of a leaky abstraction and the current approach is
to leave it as is, as there are some serious trade-offs and are there is no
rationale or real practical reason to fix this.
Current implementation
This is a different though related problem to
http://dev.clojure.org/jira/browse/CLJ-1315
That problem was trying to solve "require" un-necessarily importing
classes, your example is a type hint with a similar issue.
I do think you're correct, it looks like a reasonable change, but it would
requi
Just to follow up, doing the obvious (though perhaps naïve) fix of changing
forName to forNameNonLoading in the referenced maybeClass does seem to fix
the issue and I can now AOT compile my application without needing the
binaries for this machine. I don't know whether this change would have any
ot
I think I am seeing static initialisers being run at AOT time when the
class is used as a type hint tag. This isn't a regression from previous
versions of clojure, but with the forNameNonLoading changes that have gone
in recently I was under the impression that this shouldn't be a problem any
more.
(still) a moderate load. Around 10-50 users online at the same time. Not an
extreme load on the Datomic Peer library since not a whole lot of data is
stored per user (well, not for all users at least). But the server does a
lot of real time calculations all the time based on user actions.
And y
And how to you want to proceed knowing that floats and double can escape
elsewhere in your app and create the same chaotic effect like for example,
in some interop call to some obscure library ?
The best ... consistency here seems to reflect what's occurring underneath
instead
of giving the false
On the side of positive recommendations to avoid problems like this, here
is some advice:
+ Don't mix floats and doubles in the same Clojure program. Given that
Clojure uses double arithmetic by default, it is much easier to use doubles
everywhere than it is to try to use floats everywhere.
+ Do
On 22/01/2015 07:01, Henrik Mohr wrote:
OT: I'm supporting a production app with
Clojure/ClojureScript/Datomic/Ring/Sente etc. on a Heroku 2X dyno having
1 GB of RAM.
It works like a charm!
Best,
Henrik
What kind of load? Is a basic web app even do-able on a 1X dyno, ie.
512Mb RAM? It's jus
My one cent:
But I think (and it's just my humble opinion) is in the scope of Clojure
keep its consistency, am I right?
I mean, if doubles and floats are different, and they are, I think we
should always get equality test as false. Or always as true, if they're
nominally the same value.
Regards
>From the documentation:
(chan buf-or-n xform ex-handler)
"If a transducer is supplied a
buffer must be specified. ex-handler must be a fn of one argument -
if an exception occurs during transformation it will be called with
the Throwable as an argument"
Is there a reason the ex-handler fn does
"It is out of scope for Clojure to fix this for Java types Float/Double"
-- comments in CLJ-1036: http://dev.clojure.org/jira/browse/CLJ-1036
Andy
On Thu, Jan 22, 2015 at 5:53 AM, Nicola Mometto wrote:
>
> Not sure if this is intended behaviour:
> user=> (= (float 1.6) (double 1.6))
> false
>
Not sure if this is intended behaviour:
user=> (= (float 1.6) (double 1.6))
false
user=> (= (float 1.5) (double 1.5))
true
I.e. = (and ==) will return true when comparing floats with doubles IFF
the float's .doubleValue roundtrips to the same double it's comparing to.
user=> (.doubleValue (float
More on this behavior http://dev.clojure.org/jira/browse/CLJ-1036
On Thu, Jan 22, 2015 at 2:00 PM, Nicola Mometto wrote:
>
> Looking at the PHM impl, this looks like it's caused by (float 0.5) and
> (double 0.5) hashing differently.
>
> user=> (= (float 0.5) (double 0.5))
> true
> user=> (map ha
Looking at the PHM impl, this looks like it's caused by (float 0.5) and
(double 0.5) hashing differently.
user=> (= (float 0.5) (double 0.5))
true
user=> (map hash [(float 0.5) (double 0.5)])
(1056964608 1071644672)
Nicola Mometto writes:
> Looks like it's a bug in PersistentHashMap:
> user=> (
Looks like it's a bug in PersistentHashMap:
user=> (contains? (hash-map {:a (float 0.5)} 1) {:a (double 0.5)})
false
user=> (contains? (array-map {:a (float 0.5)} 1) {:a (double 0.5)})
true
Immo Heikkinen writes:
> (= (float 0.5) (double 0.5))
> => true
> (= #{(float 0.5)} #{(double 0.5)})
> =>
(= (float 0.5) (double 0.5))
=> true
(= #{(float 0.5)} #{(double 0.5)})
=> true
(= {:a (float 0.5)} {:a (double 0.5)})
=> true
(= #{{:a (float 0.5)}} #{{:a (double 0.5)}})
=> false
Tested with both 1.6.0 and 1.7.0-alpha5.
--
You received this message because you are subscribed to the Google
Gro
Even with inlining the code is rather silly ;)
[x] (if x false true)
so you'd get,
(if (if test false true) then else)
Which relies a bit too much on the JVM's JIT for my taste :D
I've always wondered what the reason for the original implementation is.
Keep closer to the implementation
35 matches
Mail list logo