Sujet : Re: do { quit; } else { }
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 11. Apr 2025, 12:51:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtavn9$1dp7m$3@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 24
User-Agent : Mozilla Thunderbird
On 11/04/2025 10:17, David Brown wrote:
On 10/04/2025 21:27, bart wrote:
On 10/04/2025 20:05, David Brown wrote:
C rarely makes things more complicated without a good reason.
>
C usually makes things more complicated without a good reason!
Nope.
>
Here's one example, of dozens, of perfectly legal C:
>
long unsigned const long const const typedef int A;
int long unsigned const long const const typedef A;
long unsigned const long const typedef int A;
.....
>
That is not more complicated, nor is it without good reason.
Huh? That demonstrates several things:
1 That the same identifier can be redeclared multiple times
2 That 'typedef' needn't be on the left, but can be anywhere in the middle of a type spec
3 That 'const' can also be anywhere inside the type spec
4 That duplicate 'const's are tolerated
5 That the three tokens ('int', 'unsigned' and two 'long's) denoting the type can be be any order (and mixed up with other attributes)
I missed out:
6 'int' can be optionally omitted in this case.
That makes it pretty complicated to me! And I can't see that any of these are necessary. A syntax like this:
typedef A = const unsigned long long int;
which is only allowed once; typedef always on the left; 'const' only once; and the token order must be as specified, will achieve everything that needs to be achieved.
I haven't remarked on:
7 That you need 3/4 tokens to specify a simple u64 type.
since you suggest that 'uint64_t' used. However, that adds to the complication:
8 A u64 type can be denoted as either 'uint64_t' OR as some combination of the tokens (long, long, unsigned, [int])