Liste des Groupes | Revenir à cl c |
On 29/11/2024 23:44, Keith Thompson wrote:Bart <bc@freeuk.com> writes:>On 29/11/2024 20:35, Keith Thompson wrote:Yes, of course D and E have different types. I'm certain he's
(So it would have a different type from E declared on in the same
declaration:
>
int D[3][4][5], E;
>
? In that case tell that to David Brown!)
aware of that.
Apparently the quibble is about the meaning of 'totally different'. I
would have thought that 'incompatible' would have covered it.
But it looks like, for the sake of argument, types aren't 'totally'
different if they have even the slightest point of similarity. So an
'int' type, and a bloody great function, not even a real type, must be
considered somewhat identical if the latter happens to returns an int?
In my language which you despise but provides a great perspective,
variables declared in the same declaration have 100% the same type. If
they are even 1% different, then that is a separate type and they need
their own declarations. They are no gradations!
What "range of types" do you think D can have?>
If DB is talking about the type of D[i][j][k], then it is also
necessary to consider the types of D, D[i] etc. That's why it's not
useful to talk about anything other than the type of the value stored
in D (and in C, before D is used in any expression).
>In C, declarations can declare objects, functions, types, etc.Would you write "const int F();"? Or would you omit the "const"? How>
does the fact that "const" is allowed inconvenience you?
It's another point of confusion. In my language I don't treat function
declarations like variable declarations. A function is not a
variable. There is no data storage associated with it.
Actually types would be another category, that can also start off
looking like a variable declaration.
to see how your language is relevant.>
Because it's confusing in C. The perspective of a quite different
syntax /for the same class of language/ makes that extra clear to me.
>
In C all declarations are based around the syntax as used for
variables, even function definitions.
>In C it is unfortunate, as it makes it hard to trivially distinguish aIt's not as hard as you insist on pretending it is. A function
function declaration (or the start of a function definition) from a
variable declaration.
declaration includes a pair of parentheses, either empty or
containing a list of parameters or parameter types.
Yes it is, I'm not pretending at all.
>
Perhaps you can post a trivial bit of C code which reads in C source
code and shows the first lines of all the function definitions, not
prototypes nor function pointers. It can assume that each starts at
the beginning of a line.
However each may start with a user-defined type or there may be a
macros in any positions.
>
I can tell that in my syntax, function definitions start with a line
like this ([...] means optional; | separates choices):
>
['global'|'export'] 'func'|'proc' name ...
>
Which one do you think would be easier? (Function declarations are
generally not used.)
Function declarations outside header files are valid, but tend to be>
rare in well-written C code.
Function declarations are everywhere. They are usually needed for
static function otherwise you will have hundreds of function
definitions that must be written and maintained in a specific order.
Les messages affichés proviennent d'usenet.