[swift-evolution] [Planning][Request] "constexpr" for Swift 5
darylew at mac.com
Sun Jul 30 22:43:13 CDT 2017
The parameters for a fixed-size array type determine the type's size/stride, so how could the bounds not be needed during compile-time? The compiler can't layout objects otherwise.
Or do you mean that the bounds are integer literals? (That's what I have in the design document now.)
Sent from my iPhone
On Jul 30, 2017, at 8:51 PM, John McCall <rjmccall at apple.com> wrote:
>> On Jul 29, 2017, at 7:01 PM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
>> The “constexpr” facility from C++ allows users to define constants and functions that are determined and usable at compile-time, for compile-time constructs but still usable at run-time. The facility is a key step for value-based generic parameters (and fixed-size arrays if you don’t want to be stuck with integer literals for bounds). Can figuring out Swift’s story here be part of Swift 5?
> Note that there's no particular reason that value-based generic parameters, including fixed-size arrays, actually need to be constant expressions in Swift.
More information about the swift-evolution