Scott Meyers' DConf 2014 keynote "The Last Thing D Needs"
Ali Çehreli via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu May 29 07:32:48 PDT 2014
On 05/29/2014 03:00 AM, Jonathan M Davis via Digitalmars-d-announce wrote:
> On Thu, 29 May 2014 01:31:44 -0700
> Ali Çehreli via Digitalmars-d-announce
>> Note that there is no such thing as a multi-dimensional array in C,
>> C++, or D. Hence, there is no reading from any direction; there is a
>> simple and consistent syntax.
>
> ??? C, C++, and D all have multi-dimensional arrays. e.g.
I think we finally see the cause of the disagreement. Those languages do
not provide a construct called multi-dimensional array.
Multi-dimensional arrays emerge as an application artifact when the
programmer defines an array where the element type is an array.
Being able to create arrays of arrays by the following syntaxt does not
change that fact. The followin syntax is just a convenience:
auto bar = new int[][][](6, 5, 4);
> int a[5][6]; // C/C++
> int[6][5] a; // D
> int** a; // C/C++
That is a single pointer to a single pointer. Using it as an array is
faith-based programming but what can one do? :)
> int[][] a; // D
> int* a[5]; // C/C++
That is an inconsistency in C and C++. See, how the element type is on
the left of the identifier? That is not the case when the element type
is an array. Coping from above:
> int a[5][6]; // C/C++
Do you see the problem there? It is not written with the same syntax
when the element type was a pointer:
int[6] a[5]; // not legal C or C++ syntax
There: C and C++ are inconsistent.
> int[5][] a; // D
>
> I don't see how you could argue that they don't have
multi-dimensional arrays.
Their specs don't have such a thing. It is possible to have arrays where
elements are arrays but that does not make those concepts language
constructs.
This whole issue goes well with Scott's presentation: If it is simple to
describe then we ded right. Repeating myself, the following is all one
needs for the array definition syntax in D:
Type[length] identifier;
(And of course even this: 'Type[] identifier;')
Done. Now we can go wild with it to define more complex types.
That's not the case with C arrays: One needs to learn a new syntax for
arrays of arrays there.
Ali
More information about the Digitalmars-d-announce
mailing list