Compile-Time Constant Expressions for Swift

I was thinking specifically about using compiler evaluable expressions as arguments to non-type generic parameters and using those values in subsequent compiler evaluable expressions in the generic context. It isn't clear to me after reading the document whether that is something that would eventually be supportable or not, especially if the type of the non-type generic parameter was itself generic, such as: struct FixedArray<Size: UnsignedInteger, size: Size> {}.

I was also thinking about limitations on compiler evaluable expressions in generic contexts more generally after reading the section Intentional limitation: Constant expressions of generic type. It seems likely to me that generic code is the context where I would most frequently to want to take advantage of compile time evaluation. I hope there is a way to make the interpreter and the generic system work well together (in the fullness of time of course).

1 Like