By wasting my time I mean if it is clear goog.math.integer is a bad idea it
would be great if someone who knows would help a brother out and tell me.
:-)
I we are slowly moving a large google closure codebase into clojurescript
so I have significantly more experience on the closure side.
goog.math.integer and goog.math.long apear to have about the same
performance characteristics when one of our programmers tested a year and a
half ago.
my naive thought make the bigint cast and use the op' so people realize
they are taking the performance hit.

(ns myjs
  (:require [goog.math.Integer :as gInteger]))

(defn bigint

  "Coerce to BigInt"
  [x] (cond
       (= (type x) goog.math.Integer) x
       (number? x) (Integer/fromInt x)
       (string? x) (Integer/fromString x);string may be a bad idea but
it at least keeps javascript numbers from loosing information
       ))


Then we could make an arbitrary precision version of all the number
related functions

(defn +'
  "Returns the sum of nums. (+) returns 0."
  ([] 0)
  ([x] (bigint x))
  ([x y] (.add (bigint x) (bigint y)))
  ([x y & more] (reduce +' (.add (bigint x) (bigint y)) more)))

I am not that familiar with clojurescript yet,but could probably do an
extend type on goog.math.Integer
to support iequiv with js/numbers?


On Wed, Aug 15, 2012 at 1:15 PM, David Nolen <dnolen.li...@gmail.com> wrote:

> On Tuesday, August 14, 2012, dspiteself wrote:
>
>> I have extensive google closure experience, but little low level
>> clojurescript experience.
>> Could we use the clojure library's Integer or long type. It will likely
>> not be as fast but when you need it you need it.
>>
>> http://closure-library.googlecode.com/svn/docs/closure_goog_math_integer.js.html
>>
>> http://closure-library.googlecode.com/svn/docs/closure_goog_math_long.js.html
>> If you can tell me if I would be wasting my time or not I will start
>> working on a comprehensive design.
>>
>
> What do you mean by "wasting your time"?
>
> David
>
> --
> 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 unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Tyler Tallman
Project Manager
Breeze EHR
(m) (337) 205-2142

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to