clojure.lang.Numbers combines 3 things:
- a set of type based rules for math
- information about types
- actually implementations of the methods require for #1
an example of #1 is "if any args are floating point, the result is floating point" but this knowledge is spread through out a number of methods, and is only derivable if you know which types are floating point and work backwards from there.
A nicer approach would be to encode #1 as actually rules written up in core.logic, #2 as a database of information about types for a specific platform. I think #3 can also be generated from #1 and #2 but I am on shakier ground there.
From this approach we can use the rules with a different database of type information to generate a math runtime for a different platform (like the clr? beam?).
A possible fall out from this is generating a more consistent set of compiler intrinsics for math operations.
1 Comment
Hide/Show CommentsDec 21, 2012
Kevin Downey
I have an example of what this might look like https://gist.github.com/4355733
but the code in the gist:
the code is logically in 3 pieces