Re: Libraries supporting 1.3&1.2 and bignums

2011-10-12 Thread Brian Marick
On Oct 12, 2011, at 3:13 AM, Meikel Brandmeyer (kotarak) wrote: > So the library has several options: Since the numeric changes in this area > are breaking changes, the library has to either a) take overflow policy into > its contract Midje's contract for 1.3 numerics is: if there are overflow

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-12 Thread Meikel Brandmeyer (kotarak)
Hi, yes. In 1.2 the ' will be not part of the symbol +, but it will be attached to the following 1, quoting it. The reader of 1.3 will consume the ' as part of the + symbol. To clarify this a little: 1.2 sees: [+ '1] (<=> [+ (quote 1)]) 1.3 sees: [+' 1] Too "outrageously clever" for my taste,

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-12 Thread Ivan Koblik
I feel myself silly, but could you explain how does this work? (def +M (first [+' 1])) Is it some kind of reader level trick? Cheers, Ivan. On 11 October 2011 04:25, Alan Malloy wrote: > (def +M (first [+' 1])) seems like it should work in both versions? > > On Oct 10, 4:28 pm, Brian Marick

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-12 Thread Meikel Brandmeyer (kotarak)
Hi Chas, someone specifying (roughly 9223372036854775804 5) also accepts 9223372036854775808 as a possible value. So she has to at least think a tiny bit about overflow. However you are right that she should not be concerned about the specific implementation of roughly. So the library has seve

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-12 Thread Meikel Brandmeyer (kotarak)
Hi, Besides the hack by Alan you might also want to think about an overflow save implementation for roughly: user=> (defn roughly [expected-value delta] (let [exp-pos? (pos? expected-value) upper(if (neg? delta) (- delta) delta) lower(- upp

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-11 Thread Brian Marick
On Oct 11, 2011, at 3:17 PM, Meikel Brandmeyer wrote: > Maybe I'm a bit bold, but shouldn't a 1.3 user be aware, that his limits do > overflow and specify a bigint to begin with? Consider someone who passes in a regular integer to the `roughly` checker. It's near the overflow boundary. That pl

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-11 Thread Chas Emerick
On Oct 11, 2011, at 4:17 PM, Meikel Brandmeyer wrote: > Hi, > > Am 11.10.2011 um 01:28 schrieb Brian Marick: > >> If the 1.3 user has taken care to use promoting-to-bignum arithmetic, it >> would be rude to blow up if `actual` happens to be a regular integer but >> adding `delta` to it causes

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-11 Thread Meikel Brandmeyer
Hi, Am 11.10.2011 um 01:28 schrieb Brian Marick: > If the 1.3 user has taken care to use promoting-to-bignum arithmetic, it > would be rude to blow up if `actual` happens to be a regular integer but > adding `delta` to it causes an overflow. Maybe I'm a bit bold, but shouldn't a 1.3 user be aw

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-11 Thread Brian Marick
On Oct 10, 2011, at 7:50 PM, Kevin Downey wrote: > (defmacro plus [] (if … (resolve (symbol "clojure.core/+")) (resolve > (symbol "clojure.core/+'" > > ((plus) actual delta) Thanks. On Oct 10, 2011, at 9:25 PM, Alan Malloy wrote: > (def +M (first [+' 1])) seems like it should work in both

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-10 Thread Alan Malloy
(def +M (first [+' 1])) seems like it should work in both versions? On Oct 10, 4:28 pm, Brian Marick wrote: > I may be missing something obvious. > > Midje has a checker that lets users say things like > >    (fact (my-computation) => (roughly 15  2)) > > Where the first number in `roughly` is th

Re: Libraries supporting 1.3&1.2 and bignums

2011-10-10 Thread Kevin Downey
(defmacro plus [] (if … (resolve (symbol "clojure.core/+")) (resolve (symbol "clojure.core/+'" ((plus) actual delta) On Mon, Oct 10, 2011 at 4:28 PM, Brian Marick wrote: > I may be missing something obvious. > > Midje has a checker that lets users say things like > >   (fact (my-computation)

Libraries supporting 1.3&1.2 and bignums

2011-10-10 Thread Brian Marick
I may be missing something obvious. Midje has a checker that lets users say things like (fact (my-computation) => (roughly 15 2)) Where the first number in `roughly` is the target number and the second is an acceptable range around that target. Part of what the checker does in 1.2 is this: