Deutsch   English   Français   Italiano  
<vidnuj$1aned$1@dont-email.me>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: question about linker
Date: Sat, 30 Nov 2024 00:57:56 +0000
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <vidnuj$1aned$1@dont-email.me>
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> <87mshhsrr0.fsf@nosuchdomain.example.com>
 <vidd2a$18k9j$1@dont-email.me> <8734j9sj0f.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 30 Nov 2024 01:57:56 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ac41a7c23ced312f4a6135274646b7ca";
	logging-data="1400269"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/isLZ6vZAOSxx+7wlxDUag"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:oEmeNBLig6u3LVX2jjANlANbJ+g=
In-Reply-To: <8734j9sj0f.fsf@nosuchdomain.example.com>
Content-Language: en-GB
Bytes: 5153

On 29/11/2024 23:44, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 29/11/2024 20:35, Keith Thompson wrote:

>> (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!)
> 
> Yes, of course D and E have different types.  I'm certain he's
> 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).

>>> 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.
> 
> In C, declarations can declare objects, functions, types, etc.

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 a
>> function declaration (or the start of a function definition) from a
>> variable declaration.
> 
> It's not as hard as you insist on pretending it is.  A function
> 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.