I believe the docs would suggest not to use the types as you’ve put them. Performance Tips · The Julia Language
Here is what I would do that addresses both concerns
function paramsfun(a,b)
@assert 0 < b < 1 "b is must be between 0 and 1"
return (; a, b, bsq=b^2)
end
Because you are only working with a few scalar values, creating named tuples is going to be lightweight and easy. You don’t have to worry about working “in place”. This thing will also place nicely with AD and lots of other neat tools for free.