[racket] Typed/Racket Runtime Optimized Bounded (Index) Increment Operation
On May 14, 2012, at 6:52 PM, Ray Racine wrote:
> I love seeing all them little green boxes informing me that Typed/Racket has elided runtime operation. Some of my recent code is doing a great deal of processing (Vectorof Float) with vector-ref / vector-set!.
>
> I'm wondering if there is benefit for some deep in the bowels of the Racket runtime optimized Index type increment operation, e.g., (: ++ (Index -> Index)).
>
> (add1 x) is of type Integer -> Integer,
Not only:
> (:query-result-type add1 Index)
(Byte -> Positive-Index)
> (:query-result-type add1 Byte)
(case-> (One -> Positive-Byte) (Zero -> One))
Vincent has experimented with narrower addition operations and types. It was found to be lacking in practical value, but for specifics, I will let him report when he gets back.
In general, you can use occurrence typing with Racket's numerical hierarchy to eliminate some bounds checks automatically but not all. We need to think harder and Performance Report may help you along these lines one day
-- Matthias