> Le 30 mai 2017 à 12:42, Charlie Monroe via swift-evolution 
> <swift-evolution@swift.org> a écrit :
> 
> 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.

Really ? Isn’t it due to the value semantic of swift arrays ?

If this is the former, its algorithm can probably be tweak to reuse the array 
and require less allocations.

Unless if you algorithm is eager in memory allocation/deallocation, you 
shouldn't get a significant difference between static array and dynamic array.


> 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 
>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>> 
>> On Tue, May 30, 2017 at 7:51 AM, David Sweeris <daveswee...@mac.com 
>> <mailto:daveswee...@mac.com>> 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
>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to