Liste des Groupes | Revenir à cl c |
On 12/04/2025 13:39, David Brown wrote:C is a flexible language, and also caters for those that have heretical opinions. I have no use of a function type in a language that does not treat functions as first class objects - you cannot pass a function as a parameter, return one from a function, or even have a function object. You always deal with pointers to functions. Thus IMHO the pointer should be part of the typedef since you always need it.On 12/04/2025 01:13, bart wrote:But... but... but...!!!On 11/04/2025 22:36, Keith Thompson wrote:>bart <bc@freeuk.com> writes:>
[...]Rubbish. Everyone finds C declaration syntax a nightmare.>
Rubbish. I find C declaration syntax annoying, not a "nightmare".
>
Annoying would be having to get letter case or punctuation just right.
>
But C typepecs can go far beyond it. I can just about do arrays of pointers, or pointers to arrays. Anything more complicated is pretty much trial and error.
>
In an example in my post which I then deleted (DB will just ignore examples), I wanted to create an array of 10 pointers to functions that take an int and return an int.
If only C had a way to make that simple and clear.
Oh, wait - it does....Finally!
typedef int (*FIntInt)(int);Just one tiny point, though. I've never been a fan of hiding pointers behind typedefs. I would much prefer:
>
FIntInt funcs[10];
typedef int FIntInt(int);
FIntInt *funcs[10];
Better to have those *s out in the open, where we can keep an eye on them.
Les messages affichés proviennent d'usenet.