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

Félix Cloutier felixcloutier at icloud.com
Wed Aug 2 11:17:58 CDT 2017


`[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.

Félix

> Le 2 août 2017 à 09:00, John McCall <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/82acae30/attachment.html>


More information about the swift-evolution mailing list