Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vtk9k7$2fucn$1@dont-email.me>
Deutsch   English   Français   Italiano  
<vtk9k7$2fucn$1@dont-email.me>

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

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: do { quit; } else { }
Date: Tue, 15 Apr 2025 01:35:22 +0100
Organization: A noiseless patient Spider
Lines: 129
Message-ID: <vtk9k7$2fucn$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <vt31m5$2513i$1@dont-email.me>
 <vt3d4g$2djqe$1@dont-email.me> <vt3iqh$2ka99$1@dont-email.me>
 <vt5fed$ccri$1@dont-email.me> <vt5js2$g1t7$1@dont-email.me>
 <20250409142303.00004645@yahoo.com> <87ikndqabc.fsf@nosuchdomain.example.com>
 <20250410115501.000037a5@yahoo.com> <vt8ei8$2vn84$1@dont-email.me>
 <20250410080629.532@kylheku.com> <vt94q5$3jjod$1@dont-email.me>
 <vt9628$3hhr8$3@dont-email.me> <vtammh$174ev$1@dont-email.me>
 <vtavn9$1dp7m$3@dont-email.me> <vtb8nv$1plb2$2@dont-email.me>
 <vtba81$1qfbm$1@dont-email.me> <vtbc6o$1te2o$1@dont-email.me>
 <vtbhjv$24api$1@dont-email.me> <vtbn2k$293r1$1@dont-email.me>
 <vtc19j$2kqlj$1@dont-email.me> <87a58mqt2o.fsf@nosuchdomain.example.com>
 <vtc7mp$2q5hr$1@dont-email.me> <vtcqf6$3j95s$1@dont-email.me>
 <vtdh4q$b3kt$1@dont-email.me> <vtf7fe$1qtpg$1@dont-email.me>
 <vtgfuf$31ug1$1@dont-email.me> <20250413072027.219@kylheku.com>
 <vtgpce$39229$1@dont-email.me> <20250414155907.846@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 15 Apr 2025 02:35:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cec4580467d8bef69918f71b92c931ef";
	logging-data="2619799"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX194fWwLkthIICr+BDuuZG3Z"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1oXNHE330/OcbkioipX19kNsMMM=
In-Reply-To: <20250414155907.846@kylheku.com>
Content-Language: en-GB

On 15/04/2025 00:12, Kaz Kylheku wrote:
> On 2025-04-13, bart <bc@freeuk.com> wrote:

> The first time I encountered a C for loop used for non-numbers
> was a watershed moment for me. I rubbed my eyes once or twice.

I first time I saw this:

  for(i=0; i<N; ++)

was such a moment for me. I thought what crappy syntax is that? I'd been 
used to Algol and Pascal and even Fortran, and this looked prehistoric.

This would have been in either a book or magazine. I don't think my 
opinions about C ever picked.

(I see there's typo; I tend to leave those in to show the problems.)

> "Wow, wait, you can do that?"
> 
> It might have been in the source code of an IRC client I was
> compiling, where it had something like this:
> 
>     for (node = list; node; node = node->next)
> 
> I realized, OMG, this is a great way of defining a for loop
> construct. This is why for is the way it is.

But it's not a for-loop is it? This is a perfect candidate for a 
while-loop: you are repeating some body of code /while/ some expression 
is true.

Whereas 'for' implies a control variable which iterates over some bounds 
or values.

What C calls 'for' is little more than a crass feature like this:

   KEYWORD(A; B; C) D;

which is roughly transformed to:

    A;
    while (B) {
       {D}
       C;
    }

It's what you might use in a macro-assembler to crudely emulate HLL 
features.


> So much better than the crap languages I used before which restricted a
> dummy variable into going from one number to another.

I use these loops almost exclusively:

   Endless loop
   Repeat-N-times loop
   While loop
   Iterate over an integer range
   Iterate over a collection of values

It is incredibly rate that I need anything else. However I do have some 
extra kinds of loops which are a combination:

   docase           do case ... end end
   doswitch         do switch ... end end
   doswitchu/x      special forms used for fast dispatch loops in
                    interpreters

I can't see the attraction of trying to pack as much arbitrary junk into 
a for-loop header as possible, which just makes it harder to figure what
the hell kind of loop it is.

> That might have been the point after which I didn't look back.
> 
> Later I learned that much of the cool stuff around control flow
> and expressions in C actually came from Lisp.
> 
> - Ternary if:  (if test then else).

> - Expressions having values, even assignments:  (setq a (setq b (setq c 0)))
> 
> - Loops working with arbitrary data types.

For me most such stuff came from Algol68. Did that get it from Lisp? I 
guess nobody knows.

But let me ask you; in the presumably rare situations where you do 
actually want to iterate over 0 to N-1, what do feel about writing 13 or 
so tokens to express that instead of maybe 6?

You can create some crummy macro for it, sure, but how do you then feel 
about NEEDING to implement a fundamental feature in a language? A 
million programmers would have to the same thing in a 1000 different ways.

> No, it isn't, especially if you don't need once-only evaluation of the
> range points:
> 
> #define for_range (type, var, from, to) \
>     for (type var = from; var <= to; var++)
> 
> Anyway, languages should be programmable so you're not stuck with
> the loop that is built into the parser.

Help! So for-loops aren't flexible enough, we need every programmer to 
devise their own whacky creations!


> If I were to pick a non-C language for systems programming today, I
> would take a serious look at Thomas Mertes' Seed 7, probably.
> 
> It lets you define new statement and such.

That is seriously restricted:

* It doesn't have 'goto' for a start

* It doesn't like using libraries other than those written as Seed7

* It is anyway built on top of C, in that it depends on libraries 
written in C ...

* ... and it compiles to C.

Also, despite it allowing you to define new syntax, I don't think I've 
seen any Seed7 program look like anything other than Seed7.