Liste des Groupes | Revenir à cl c |
On 06/11/2024 20:38, Bart wrote:[Functions vs. procedures]
(The last two might be wrong interpretations of the C. I've stared at the C code for a minute and I'm still not sure.void F();
void (*G);
void *H();
void (*I)();
>
OK, 4 things declared here. Are they procedures, functions, variables, or pointers to functions? (I avoided using a typedef in place of 'void' to make things easier.)
>
I /think/ they are as follows: procedure, pointer variable, function (returning void*), and pointer to a procedure. But I had to work at it, even though the examples are very simple.
>
I don't know about you, but I prefer syntax like this:
>
proc F
ref void G
ref proc H
func I -> ref void
It is not the use of a keyword for functions that I disagree with, nor am I arguing for C's syntax or against your use of "ref" or ordering. I simply don't think there is much to be gained by using "proc F" instead of "func F -> void" (assuming that's the right syntax) - or just "func F".I use the same syntax for my dynamic language where type annotations are not used, including indicating a return type for a function. That means that without distinct keywords here:
But I think there is quite a bit to be gained if the func/proc distinction told us something useful and new, rather than just the existence or lack of a return type.
Les messages affichés proviennent d'usenet.