Liste des Groupes | Revenir à cl c |
On 2025-04-12, bart <bc@freeuk.com> wrote:You still seem keen on making typespec syntax somehow match expression syntax. I think that's a mistake. Type syntax is not executed, not at this level of language.On 12/04/2025 14:43, David Brown wrote:You make a good point in that since the type constructing operators areOn 12/04/2025 03:27, bart wrote:>>C type syntax is famous for being difficult and confusing; I think>
most will agree about that. Even the creators said so.
I disagree with that claim. I think it is probably fair to say that
advanced, complicated and multi-layer types are difficult in any
programming language.
But a type that is a simple linear chain should be straightforward, and
usually is, just not in C. That was illustrated here:
>
array of 10 pointer to function taking int and returning int
1 2 3 4 5 6
unary (prefix or postfix), the derivation chain is linear and could be
linearized, without the need for any precedence parentheses.
It follows the use, though.
The function and array derivations are postfix. Only the pointer
derivation is prefix.
If we imagine a C with postfix pointer dereferencing, say using ^
(setting aside the xor meaning for a moment), like:
a[i]^(arg); // index into a at i, dereference, call with arg.
Then the declarator would be similar under declaration-follows-use:
int a[10]^(int); // same as int (*a[10])(int);Your example /still/ has type syntax that looks like an expression; they are easy to confuse. You WANT a type syntax that is more distinct.
Then, suppose if you didn't want an array of pointers, but
a pointer to an array, you would not add, remove or rearrange
precedence parentheses. You would just reorder the postfixes.
int a^[10](int) // same as int (*a)[10](int);Yes, you'd move 'pointer to' symbol along. Or just add a new one. With postfix deref, you don't need to bother with round brackets (which was always a bizarre idea to me; normally brackets are used around parameter lists only.
// Note: invalid! For syntactic discussion only!
This is a type not supported in C: array of functions.
You do have a point, but the fact that C declarations follow CI've tried for decades but still find them impossible without external help. Obviously for me it doesn't work.
expressions (even with the way suboptimal dereferencing is on the left)
is a good thing. The consistency makes it easy to learn declarations,
and also to visually check code for sanity: do declarations match uses.
If the DSL reinvents a lot of risky wheels, like doing everythingMy point was that a DSL is just another piece of custom software. But such software in general is not a toy because it has not been 'battle-tested'. It will have the usual testing processes so that it meets its specs for client's application.
from scratch, that could be the case. It takes some years to mature
something out of non-toy status at that level.
Les messages affichés proviennent d'usenet.