As far as I know this comptime function will be “splitted” in two dedicated functions.
In reality my function is more complicated and longer and I cannot really move the local value inside the “false” version of this function, without a lot of copy paste.
Normally you get a warning “unused variable” from the compiler but not here.
Will the local value in the “true” version of this function be eliminated from the stack? Disappear into nothingness?
fn do_something(comptime calc: bool) u16
{
var value: u16 = 0;
if (calc)
{
// calculate local value...
return value;
}
else
{
return some_cached_value;
}
}
It looks like it’s still getting called with the passed parameters, but just returns the cached value rather than doing anything with them. I’m not sure why that is.