[swift-evolution] [Planning][Request] "constexpr" for Swift 5

Tino Heth 2th at gmx.de
Mon Jul 31 04:16:24 CDT 2017

> OTOH, if the compiler can prove that a local array is never resized, why *shouldn't* it get all the benefits of a fixed-sized array without having to use a special syntax? Put another way, why shouldn't fixed-size be one of those optional attributes for arrays, like ownership will be for variables, that users can opt into for more performance but is otherwise automatically worked out by the compiler?
I think it's a good idea in general, but I don't think I'd notice if this feature would exist, so just to save some work for the compiler (and Core), I'd prefer to first get the feature itself, and improve it later.
So from my high-level perspective, I think the order should be
0) Add support for value literals as generic parameters
1) Add Array<T, size: UInt>
2) Add support for generic parameters that are evaluated at compile time
3) Make everything fast ;-)
n) Add useful additions like detecting arrays that aren't declared as fixed length, but could

I think the alternative to macros (don't care much how hygienic they are ;-) could be even more beneficial, but it's a topic that stands on its own (not sure wether this thread is more for fixed size arrays or metaprogramming… ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170731/b390777b/attachment.html>

More information about the swift-evolution mailing list