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

John McCall rjmccall at apple.com
Wed Aug 2 11:33:47 CDT 2017

> On Aug 2, 2017, at 12:17 PM, Félix Cloutier <felixcloutier at icloud.com> wrote:
> `[Int x N]` solves all of the problems that I mentioned, and I'm happy with that syntax. In fact, I'm championing its merits versus an approach that doesn't include the number of elements. :)
> Unless I got things wrong this entire time, the proposed spelling <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170731/038341.html> was `fixed [Int]`, with no mention of the number of elements.

I agree that an array with a dynamic, value-specific but fixed bound seems basically pointless.  It's more of a minor optimization hint than a real type.


> Félix
>> Le 2 août 2017 à 09:00, John McCall <rjmccall at apple.com <mailto:rjmccall at apple.com>> a écrit :
>>>> var foo = fixed [Int]()
>>>> for i in 0..<param {
>>>> 	foo.append(i)
>>>> }
>>> Arrays can't work if elements don't have a fixed size. How big is an element in this example?
>> This is not the idea.  The idea is more like
>>   let n = ...
>>   var foo = [Int x n](repeating: 13)
>> The bound value is still fundamentally part of the type of the variable; it's just that the actual value is not known statically.
>> John.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170802/c7a57719/attachment.html>

More information about the swift-evolution mailing list