Skip to end of metadata
Go to start of metadata

clojure.lang.Numbers combines 3 things:

  1. a set of type based rules for math
  2. information about types
  3. 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.

Labels:
  1. Dec 21, 2012

    I have an example of what this might look like https://gist.github.com/4355733

    but the code in the gist:

    1. mucks with core.logic internals so is tied to a particular core.logic version
    2. doesn't make any attempt to generate the implementations of operations

    the code is logically in 3 pieces

    1. database about types
    2. predicates that consult database
    3. rules