Fixing C's Biggest Mistake
matheus
matheus at gmail.com
Wed Jan 4 17:21:34 UTC 2023
On Wednesday, 4 January 2023 at 03:42:42 UTC, areYouSureAboutThat
wrote:
> 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...
In fact this seems reasonable, and with this what about changed
it to: __checked, then:
C programmers use #define when needed, i.e:
#define __checked ;
__checked int p[] = a; // p points to 5 elements.
Of course using #IF #ELSE for defining it when compiling in C vs
D.
Matheus.
More information about the Digitalmars-d
mailing list