4 ms·
This is very interesting. My immediate thought was what this could do for languages with arbitrary sized integer. Those are generally implemented using tagged
by FullyFunctional 11y ago
This is very interesting. My immediate thought was what this could do for languages with arbitrary sized integer. Those are generally implemented using tagged pointers for small integers and "changes types" when arithmetic on them overflows.
If BBV can determine type operands are tagged integers then arithmetic only have to worry about overflow and not the type checking.
I don't know if anyone has tried to do anything similar.
- maximecb 11y agoJavaScript is typically implemented with small integers that overflow into doubles. Higgs is very effective at eliminating type tests on numerical values. It's difficult to eliminate overflow checks in general, but Higgs uses BBV to do some primitive overflow check elimination that can take care of the "for (i=0;i<n;i++)" case.
- FullyFunctional 11y agoI'll take that as a confirmation of feasibility. Among the languages who integer types default to unbounded, I can think of Python, Erlang, and Scheme (Others? Haskell has both Int and Integer), but it doesn't appear that BBV has been tried outside of Higgs. I guess I could get close by changing something like https://github.com/peterolson/BigInteger.js https://github.com/peterolson/BigInteger.js to use native JavaScript numbers for small integers. One of these days.