Deutsch   English   Français   Italiano  
<87mshhsrr0.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.misty.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: question about linker
Date: Fri, 29 Nov 2024 12:35:15 -0800
Organization: None to speak of
Lines: 98
Message-ID: <87mshhsrr0.fsf@nosuchdomain.example.com>
References: <vi54e9$3ie0o$1@dont-email.me> <vi6sb1$148h7$1@paganini.bofh.team>
	<vi6uaj$3ve13$2@dont-email.me>
	<87plmfu2ub.fsf@nosuchdomain.example.com>
	<vi9jk4$gse4$1@dont-email.me> <vi9kng$gn4c$1@dont-email.me>
	<87frnbt9jn.fsf@nosuchdomain.example.com>
	<viaqh0$nm7q$1@dont-email.me>
	<877c8nt255.fsf@nosuchdomain.example.com>
	<viasv4$nm7q$2@dont-email.me> <vibr1l$vvjf$1@dont-email.me>
	<vic73f$1205f$1@dont-email.me> <20241129142810.00007920@yahoo.com>
	<vicfra$13nl4$1@dont-email.me> <20241129161517.000010b8@yahoo.com>
	<vicque$15ium$2@dont-email.me> <vid110$16hte$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 29 Nov 2024 21:35:16 +0100 (CET)
Injection-Info: dont-email.me; posting-host="f64fae3639db49189bd8f4bb24b9887f";
	logging-data="1300414"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19+MUQQ/4VGdWe2I0QApuE+"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:LTCHvMslaIvn6vuzmIkRD0ujhac=
	sha1:R+XYdSH8ABe0BEcOzKz30vHNpf8=
Bytes: 5315

Bart <bc@freeuk.com> writes:
[...]
> C's syntax allows a 14-parameter function F to be declared in the same
> statement as a simple int 'i'.

Yes (except that it's a declaration, not a statement) :

    int i = 42, F(int, int, int, int, int, int, int,
                  int, int, int, int, int, int, int);

Are you under the impression that anyone here was not already aware of
that?  Would you prefer it if the number of parameters were arbitrarily
restricted to 13?

Do you think that anyone would actually write code like the above?

C generally doesn't impose arbitrary restrictions.  Because of that,
it's possible to write absurd code like the declaration above.  99% of
programmers simply don't do that, so it's not a problem in practice.

> I'd say that F and i are different types! (Actually I wouldn't even
> consider F to be type, but a function.)

Neither F nor i is a type.  i is an object (of type int), and F is a
function (of type int(int, int, int, int, int, int, int, int, int, int,
int, int, int, int)).

> That F(1, 2, 3.0, "5", "six", seven, ...) might yield the same type as
> 'i' is irrelevant here.

It's relevant to the syntax.  i and F can be declared in the same
declaration only because the type of i and the return type of F happen
to be the same.  If F returned void, i and F would have to be declared
separately.

Which, of course, is a good idea anyway.

You're posting repeatedly trying to convince everyone that C allows
ridiculous code.  We already know that.  You are wasting everyone's time
telling us something that we already know.  Most of us just don't obsess
about it as much as you do.  Most of us recognize that, however
convoluted C's declaration syntax might be, it cannot be fixed in a
language calling itself "C".

Most of us here are more interested in talking about C as it's
specified, and actually trying to understand it, than in complaining
about it.

> Usually, given these declarations:
>
>   int A[100]
>   int *B;
>   int (*C)();
>
> people would consider the types of A, B and C to be array, pointer and
> function pointer respectively. Otherwise, which of the 4 or 5 possible
> types would you say that D has here:
>
>   int D[3][4][5];
>
> It depends on how it is used in an expression, which can be any of &D,
> D, D[i], D[i][j], D[i][j][k], none of which include 'Array' type!

No, the object D unambiguously has type int[3][4][5], or as cdecl
explains it "array 3 of array 4 of array 5 of int".  The *expression* D
may have type int[3][4][5] or int(*)[3][4] ("pointer to array 3 of array
4 of int"), depending on the context.

In particular, in &D, the subexpression D is of array type.

You just need to know about implicit array-to-pointer conversions.
Of course you know all about that, but you don't mention it so it
seems more confusing.  You know this better than you pretend to.

> Here's another puzzler:
>
>   const int F();
>
> why is 'const' allowed here? There is no storage involved. It's not as
> though you could write 'F = 0' is there was no 'const'.

You're right that "const" isn't meaningful in that particular context.
I suspect that it's allowed because adding a rule to forbid it would
have made the standard slightly more complicated with no particular
benefit.

Would you write "const int F();"?  Or would you omit the "const"?  How
does the fact that "const" is allowed inconvenience you?

[...]

Once again, everyone here already knows that C's declaration syntax can
be confusing, and perhaps other languages do it better.  Most of us
would rather try to understand it than whine about it.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */