Fixing C's Biggest Mistake

areYouSureAboutThat areYouSureAboutThat at gmail.com
Thu Jan 5 09:37:18 UTC 2023


On Thursday, 5 January 2023 at 09:07:57 UTC, Dom DiSc wrote:
> On Wednesday, 21 December 2022 at 19:31:22 UTC, Walter Bright 
> wrote:
>> My proposal for C:
>>
>>     int a[5] = { 0, 1, 2, 3, 4};
>>     int p[..] = a;  // p points to 5 elements.
>
> I would wish you first implement this for D:
>
> ```d
> uint[] x = [1,2,3]; // create a dynamic array with initial size 
> 3
> uint[..] y = [1,2,3]; // create a static array with automatic 
> size (not possible now)
> ```

Neither proposal will get into C.

One of the design goals of C, is actually to resist change (no, 
I'm no kidding).

I think that is a good thing.

As for D, yes, it sure is surprising the compiler cannot 
automatically size a static array by the number of arguments 
being provided to it.

But I'm not a fan of this syntax [..]

Everytime I see it, I think, wtf is that!

It's also confusing as it uses syntax from slices [1..$]

maybe I'd settle on int[T] array = [1,2,3];

now, as a programmer, I already know that T is a token that will 
get automatically replaced with something meaningful.






More information about the Digitalmars-d mailing list