(def +M (first [+' 1])) seems like it should work in both versions?

On Oct 10, 4:28 pm, Brian Marick <mar...@exampler.com> 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 the target number and the second is an 
> acceptable range around that target. Part of what the checker does in 1.2 is 
> this:
>
>       (<= expected (+ actual delta))
>
> Now, Midje is a service. 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. 
> I should use promoting-to-bignum addition. In Clojure 1.3, thats +'. In 1.2, 
> it's +.
>
> I can't use the token +' because it doesn't exist in 1.2:
>
> > java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to 
> > java.lang.Number (NO_SOURCE_FILE:0)
>
> I can't use the token + because that blows up in the boundary case under 1.3 
> (but not under 1.2).
>
> One thought is variations of code like this:
>
> > (if (clojure-1-3?)
> >     (def +M +')
> >     (def +M +)
>
> This causes amusing results because of the quote. I haven't found a variation 
> that works.
>
> So what should a library writer who wants to honor the choices of his users 
> do?
>
> -----
> Brian Marick, Artisanal Labrador
> Now working athttp://path11.com
> Contract programming in Ruby and Clojure
> Occasional consulting on Agile

-- 
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