(no title)
G4E
|
3 years ago
Even the first argument "no hidden control flow" is disingenuous :
either the object you are summing are complex and you have to call a custom function to define what "summing" means in that case (you need to provide the summing function), or those are a primitive type and you're just calling a function builtin the language itself. In every case, you are calling a function ...
messe|3 years ago
You’re thinking at a different level of abstraction to the Zig developers. Summing a primitive type is going to be turned into a couple of machine opcodes (but no branch instruction) and will usually be constant time, whereas an explicit function call will require pushing pc to the stack and jumping elsewhere, executing any number of instructions once there, taking an arbitrarily long time, making it more difficult to reason about.
mh7|3 years ago
Because on your typical arm mcu, x/y is a function call to a definitively non-constant time function.
And lets not forget soft-fp. Every single floating point op is a function call...
tosihakkeri|3 years ago