Sujet : Re: technology discussion → does the world need a "new" C ?
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 12. Jul 2024, 12:51:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6r5bi$30q5c$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : Mozilla Thunderbird
On 11/07/2024 16:56, bart wrote:
The language could have helped a little by making this invalid:
int A[20];
void F(int B[20]) {}
The declaration does not correspond of the real type because there is no type to represent that.
In cake, I am thinking in create the type "pointer to the first element of N".
Then, if this was created in the past the syntax could be:
int A[20];
void F(int *.[20] B)
{
}
But nowadays we don't need to change the current syntax for parameters, just leave as it is.
The syntax "pointer to the first element of N" can be used in other situations.
In cake, I have a warning if you use B as pointer, for instance:
int A[20];
void F(int B[20]) {
B = 0; //warning
}
If the user wants to do that he can change the declaration to int *B.
But now the size is lost. The type "pointer to the first element of N" fixes that.