I’m not sure what you’re referring to as a “line of thinking”. I was recounting my recollection of something that had previously been determined as fact, and I stated up front that I could not recall the details.
Having looked through past threads, it appears that there was in fact, as I recalled, an objective and measurable optimization benefit to using computed, rather than stored, static constants.
This thread both documents the problem, and the fact that it was subsequently solved in a newer version of Swift: Static let vs static computed property, optimization differences
This thread talks about the extra work required by the compiler to prove that an expression resolves to a constant, and can thus be optimized away: Static computed property vs static let constant?
Thus, for more complex calculations involving function calls, it is conceivable that the compiler would not be able to prove constancy, and so would need to store the value for a let
(and recalculate it each time for a computed var
).
It seems that today, in the particular case of literal constants, the Swift compiler is smart enough to optimize away both stored and computed static properties. It did not used to be able to, as the first link shows, and for more complex expressions it may still not be able to, as the second link implies.