Deutsch   English   Français   Italiano  
<vj1h4i$335q1$2@dont-email.me>

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

Path: ...!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: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: question about linker
Date: Sat, 7 Dec 2024 13:04:20 +0000
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <vj1h4i$335q1$2@dont-email.me>
References: <vi54e9$3ie0o$1@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>
 <vifcll$1q9rj$1@dont-email.me> <vifiib$1s07p$1@dont-email.me>
 <87ldwx10gv.fsf@bsb.me.uk> <vimtt4$27vv$1@dont-email.me>
 <86ser1kgp5.fsf@linuxsc.com> <vit69t$1qfgg$1@dont-email.me>
 <87ldwtzlc0.fsf@nosuchdomain.example.com> <vitjgg$1tukq$2@dont-email.me>
 <vj1bss$325uo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 07 Dec 2024 14:04:19 +0100 (CET)
Injection-Info: dont-email.me; posting-host="92f4e16e4a21192eb5e2d0ba1a6ec304";
	logging-data="3249985"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/QTH9CRVLK2ER/CA2/V2TN"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:5tQfz5JOpmjge/THmgAcBjCptv0=
In-Reply-To: <vj1bss$325uo$1@dont-email.me>
Content-Language: en-GB
Bytes: 4019

On 07/12/2024 11:34, Janis Papanagnou wrote:
> On 06.12.2024 02:20, Bart wrote:

>> I used to be puzzled by this too: 'while' can both start a while
>> statement, and it can delimit a do-while statement. How is that possible?
> 
> A keyword (like 'while') is just a lexical token that can be used in
> different syntactical contexts.

Is it common to both start and end a statememt with the same keyword?


  (Even with different semantics, if a
> language designer thinks this is a good idea for his case.)
> 
> You may be less confused with using Pascal;

Now you are demonstrating my point about being treated like a beginner. 
And it is exasperating.

This is a point of language design. C's approach works - just. But it 
relies on some subtlety. 'while (cond)' both starts a statement, and can 
end a statement:

    do while(cond) do ; while (cond);

The second 'while' here starts a nested while-loop inside a do-while 
loop. Not confusing? It is to me! I couldn't finish my example as I got 
lost (but as it happens, this is valid code, partly by luck).

Of course, if you put aside all other matters and concentrate on the 
minutiae of the syntax details, then it is all 'obvious'. I think it 
needs to be a lot more obvious.

>    while positive-case do ...
>    until negative-case do ...
>    do ... while positive-case
>    do ... until negative-case
> (depending on language with this of similar syntax).
> 
> There's nothing wrong using the same keyword for the same type of
> condition, rather it's good to have it defined that way.

The problem here is exactly the same: how do you tell whether the 
'while' in 'do ... while' is ending this 'do'-loop, or starting a nested 
while-loop?

You don't think there is an element of ambiguity here?

Let's take my example again:

    do while(cond) do ; while (cond);

And make a small tweak:

    do ; while(cond) do ; while (cond);

It still compiles, it is still valid code. But now it does something 
utterly different. (One is two nested loops, the other is two 
consecutive loops - I think!)

OK, I get now that people just aren't that bothered about such matters.

Obviously they aren't language designers.