dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.56k forks source link

Allow multidimensional arrays in Dart #11715

Closed DartBot closed 9 years ago

DartBot commented 11 years ago

This issue was originally filed by pau....@gmail.com


Currently Dart does not support multidimensional arrays which are very common in most modern programming languages such as C/C++, Java or C#.

The multidimensional arrays have two very important properties: 1- High performance accessing memory given a sequence of indexes 2- Syntax sugar when willing to represent matrix-like data structures.

Currently in dart it is not possible to get high performance and syntax at the same time. This means that programs that make extensive use of linear algebra (videogames, video/audio editing, CAD...) should either choose code readability or high performance.

To exemplify it, in the context of Matrices, it is possible to develop a Matrix class using the following approaches:

a) Define a "Matrix" class, subtype of a List of Float[64/32] Lists.

This adds syntax sugar but not high performance.

b) Define a "Matrix" class that has a Float[64/32]List with ROWSxCOLUMNS elements and also has a [] operator for the row index. Then the [] can return an object of a class "MatrixIndex" that also has the [] operator but for the column index. In the last operator, it is possible to directly compute the index of the Float[64/32]List that is referenced by the [row][column] composed index.

This adds syntax sugar but not high performance.

c) Define a "Matrix" class that has a Float[64/32]List of ROWSxCOLUMNS elements and use a "get(int row, int column) => double" method. To be able to emulate this code:  "c[rowC][columnC ] = a[rowA][columnA] b[rowB][columnB]" one should instead use this 'ugly' code:  "c.set(rowC, columnC , a.get(rowA, columnA) b.get(rowB, columnB))"

This adds high performance but not syntax sugar.

iposva-google commented 11 years ago

Added Area-Language, Triaged labels.

gbracha commented 10 years ago

FTR, Java does not have multi-dimensional arrays. Neither does Dart, and it isn't very likely that it will.


Set owner to @gbracha. Removed Type-Defect label. Added Type-Enhancement, NotPlanned labels.