There was someone a few weeks ago trying to port his Go game to Swift from (I 
believe) C++ and found out that the lack of fixed-size arrays was causing the 
move-computing algorithm to slow down significantly.

This is due to fixed arrays being able to live on stack, while "normal Array" 
is dynamically allocated on heap, etc.

10 000 may have been David's exageration, but imagine trying to form a 
chessboard using tuples - aside from the fact that you can't iterate over the 
tuple, the tuple type would be huge - instead of ChessPiece[8][8] (or similar 
syntax), you get:

((ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece),
(ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, ChessPiece, 
ChessPiece, ChessPiece))

And the practical use isn't just games - just think of any fixed-size matrices.

> On May 30, 2017, at 12:25 PM, Pavol Vaskovic via swift-evolution 
> <[email protected]> wrote:
> 
> On Tue, May 30, 2017 at 7:51 AM, David Sweeris <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> `(Int, Int, Int, Int)` isn't *that* horrible compared to "[Int x 4]", but 
> would you want to replace "[Int8 x 10000]" with the multipage-long tuple 
> equivalent?
> 
> 😳
> It would be really helpful to my understanding, if you spoke about a 
> practical use case. This reads as a contrived counterexample to me…
> 
> If your type really has 10 000 values in it, why does it have to be static, 
> why doesn't normal Array fit the bill?
> 
> --Pavol
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to