Sujet : Re: do { quit; } else { }
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 15. Apr 2025, 00:12:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250414155907.846@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-13, bart <
bc@freeuk.com> wrote:
On 13/04/2025 15:34, Kaz Kylheku wrote:
On 2025-04-13, bart <bc@freeuk.com> wrote:
On 13/04/2025 03:27, Janis Papanagnou wrote:
On 12.04.2025 13:00, bart wrote:
>
But I also 100% hate its syntax and various other bits and pieces. (OK,
about 80% then.)
>
(I also don't like its syntax too much. I think I'm just complaining
less than you about that. BTW, I've got the impression that all the
shortcomings of "C" are well known by most regulars here; they just
handle these facts in discussions differently than you.)
>
The shortcomings are downplayed considerably. Especially in discussions
involving me because they don't like it whenever someone states the obvious.
>
But also, most here have to use it professionally, so have learned to
work around it.
There are lots of examples of people just liking C.
>
C itself, or the things that C allowed you to do?
Me, I like C. I use C in side projects. I will code in C no matter what
I use at work.
C is the only acceptable non-Lisp.
Well, given Knuth's own language was MIX (assembly for a made-up
machine), it is not surprising he prefers C.
He wrote TeX in Pascal though. The Web system includes a Pascal to C
translator. (I don't know the details.)
C has spawned imitation in the form of "C like" languages, that all
started as grenfield projects that could have chosen any syntax
they wanted.
>
Some of this is to be expected: if they started off using brace syntax,
then their language will use braces. But some of the things they copy
are odd, like this for-loop from JS:
>
for(let i = 1; i <= 36; i++) {
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.
"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.
So much better than the crap languages I used before which restricted a
dummy variable into going from one number to another.
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.
Is it that hard to provide a proper for-loop where you don't have to
spell out every single detail? Fortran managed it in the 1950s!
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.
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.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca