Fixing C's Biggest Mistake

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


On Wednesday, 21 December 2022 at 19:09:37 UTC, Walter Bright 
wrote:
> https://news.ycombinator.com/edit?id=34084894
>
> I'm wondering. Should I just go ahead and implement [..] in 
> ImportC?

I'd much rather see @attributes strategically' incorporated into 
D's betterC.

e.g.

module test;

extern(C) void main()
{
     import core.stdc.stdio : printf;

     //  Accesses to this array will be bounds checked at runtime.
     @checked int[5] arr = [ 0, 1, 2, 3, 4];

     for (int i = 0; i < 10; i++) // runtime will catch this error.
     {
         printf("%d\n", arr[i]);
     }

}


and btw, i really hate having to constantly change my C syntax:
i.e.

int arr[5] = { 0, 1, 2, 3, 4}; // C syntax
(into)
int[5] arr = [ 0, 1, 2, 3, 4]; // betterC syntax

That is just plain annoying.



More information about the Digitalmars-d mailing list