[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)
felixcca at yahoo.ca
Thu Jan 28 18:28:47 CST 2016
I don't like how similar-but-not-quite-the-same it is as the array declaration syntax. That would make it Int for a fixed-size array and [Int] for an array of dynamic size.
I like that (4 x Int) is inside parentheses, which is code for "tuple" right now.
Related question: can you initialize a uniform tuple/contiguous variable with an array literal?
> Le 28 janv. 2016 à 19:04:50, Haravikk via swift-evolution <swift-evolution at swift.org> a écrit :
>> On 28 Jan 2016, at 22:37, Joe Groff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Jan 28, 2016, at 2:36 PM, Jacob Bandes-Storch <jtbandes at gmail.com <mailto:jtbandes at gmail.com>> wrote:
>>> I like this idea, but the syntax seems dangerously close to a call site for "func *(lhs: Int, rhs: Any.Type)" (which is obviously ill-advised, but it is allowed).
>>> Maybe we could take advantage of something which would be very invalid under the current grammar, namely (n T) rather than (n * T):
>>> let values: (4 Int) = (1, 2, 3, 4)
>> Sure, or we could lift (4 x Int) from LLVM IR's syntax.
> How about:
> let values:Int = (1,2,3,4)
> While it looks a bit like a subscript, it doesn’t make sense in a type declaration at present, so could be a good way to define restrictions of this type (we could even extend it to collections later). If the similarity is too close then:
> let values:(Int) = (1,2,3,4)
> Could work too? Just some alternatives anyway, as I like the idea.
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution