Fixing C's Biggest Mistake

areYouSureAboutThat areYouSureAboutThat at gmail.com
Wed Jan 4 03:42:42 UTC 2023


On Wednesday, 21 December 2022 at 19:31:22 UTC, Walter Bright 
wrote:
>
> ....
> ......
>
> Checked C:
>
>     int a[5] = { 0, 1, 2, 3, 4};
>     _Array_ptr<int> p : count(5) = a;  // p points to 5 
> elements.
>
> My proposal for C:
>
>     int a[5] = { 0, 1, 2, 3, 4};
>     int p[..] = a;  // p points to 5 elements.
>

I've decieded that I like neither:

_Array_ptr<int> p
(nor)
int p[..] = a;

I prefer:

int a[5] = { 0, 1, 2, 3, 4};
@checked int p[] = a;  // p points to 5 elements.

@attributes would be a great way of extending the C language 
without introducing odd looking syntax, like Microsofts, that 
makes me wanna puke, or yours, that makes me look at it for 30 
mintutes, trying to work our .. what does [..] actually mean...



More information about the Digitalmars-d mailing list