Re:Swift: Madness of Generic Integer
by viraptor on Tuesday March 03, 2015 @08:55PM
(#9142223)
> You shouldn't use generics to magically get the compiler to magically do low level things for you.
Why not?
> As Swift's Integers are built to prioritize performance and are fairly "close to the metal," this sort of problem is what you'd expect.
I don't understand how one follows from the other. This is stuff that should be expanded at compilation stage, there's no runtime overhead. Likely that whole function should be specialised for each usage and be small enough to inline it. Since the loop has a known number of iterations, I even wouldn't be completely surprised if it was just a few basic instructions with array check skipped in some cases.
Why not?
> As Swift's Integers are built to prioritize performance and are fairly "close to the metal," this sort of problem is what you'd expect.
I don't understand how one follows from the other. This is stuff that should be expanded at compilation stage, there's no runtime overhead. Likely that whole function should be specialised for each usage and be small enough to inline it. Since the loop has a known number of iterations, I even wouldn't be completely surprised if it was just a few basic instructions with array check skipped in some cases.