Re: Loops (was Re: do { quit; } else { })

Liste des GroupesRevenir à cl c 
Sujet : Re: Loops (was Re: do { quit; } else { })
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 25. Apr 2025, 14:19:12
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vug24g$gl4$1@dont-email.me>
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
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 24/04/2025 19:30, bart wrote:
On 24/04/2025 16:21, David Brown wrote:
On 24/04/2025 16:28, bart wrote:
On 24/04/2025 14:12, David Brown wrote:
On 23/04/2025 22:49, bart wrote:
>
Such libraries as I mentioned for embedded languages or syntax wrapping are clever, but usually impractical, unwieldy and inefficient.
>
And as usual, I question your basis for making such wild general claims.
>
>
If you want a new language, do it properly!
>
Let's compare alternatives here.  If I want to make a little bit of embedded language, with C macros I have :
>
     + The implementation is in a language I already know
>
No. It is in the C preprocessor language. It is quite different from C and requires special skills.
>
Sometimes you talk a lot of bollocks.
 Take a look at any ordinary C code of normal functions, statements etc.
 Then look at the kind of impenetrable macros that are needed to do ambitious things like emulate a new kind of syntax within a C file. That will be a long list of #defines.
 Can you honestly say that the person writing the former, and the one writing the latter, are coding in the same language?
Perhaps we are talking at cross-purposes here.
The C preprocessor supports a few directives - such as #define.  It is not a language - it is part of standard C.  It is not hard to learn or understand, though there are a few awkward issues.  Of course it can be /used/ in ways that are hard to understand.
You seem to be talking about some imaginary "language" made by using extensive C macros and compiling with a C compiler.  I have never heard of such a thing, other than perhaps people doing things for fun or the challenge of it and the occasional person who wants to make C look more like Pascal by using "#define begin {" and "#define end }".
Sometimes people use a bit more advanced macros for simplifying their code or avoiding duplication of code.  That can be things like wrappers for easily defining tree-like structs with common "left" and "right" pointers, or for defining lists of rules with a common format, or using "x-macros" to let you generate a simple command-line interface where you can get the instruction parser, enumerations, help text, etc., generated from one list of commands instead of duplicating them.  All these things are examples of good use of complicated macro setups.  All of them can also be handled in alternative ways such as using other languages or external scripts for generating the C code, or simply duplicating the C code manually.

 And can you honestly say that writing those complicated collections of macros requires no extra skill?
Writing more complicated code always requires more skill than writing less complicated code.

 If your answers are Yes then /you/ are the one talking bollocks.
 (Maybe you've forgotten that Preprocessing is a C compilation stage which performs a transformation from C with macro invocations, to pure C with those invocations expanded.
 To repeat, what I call a different language is the set of incantations that form the body of each #define. They do not exist in the pure C version.)
Please let me know if you are talking about writing macros as C programmers do regularly, or if you are talking about some very unusual usage of macro collections.  And if it is the later, please say if you are talking about developing such "macro libraries", or /using/ such macros.

 
Some will need a particular compiler or version because they rely on some very specific behaviour.
>
There is almost nothing compiler-specific about pre-processor directives.  I only know of two very minor extensions that gcc supports, for marginally nicer variadic macro support.  Of course the result of the macro expansion might be compiler-specific, just like any other C code you write without macros.
 C compilers used to vary quite a bit in how macro expansions were done.
Can you cite evidence of that?  Exclude any broken or non-standard compilers, or ones that only implement a bit of C, or ones written by people who haven't bothered reading the relevant parts of the C standards.  Also exclude any non-conformities around unrealistic situations (such as mixes of macro definitions across #include'd files).

Now there is less variance, maybe because they're sharing the one implementation that got it just right.
There are some C compilers that share front ends, but I expect that most will have their own pre-processors - either stand-alone, or, more often, integrated with the rest of the compiler.

 
It will also be incredibly confusing for someone looking at a source file with a .c extension.
>
I am not personally a fan of things like these macro packages - I'd rather just use C++.  But it's a matter of choice.  Even if you could argue that packages like "datatype99" are objectively bad in some sense (and you can't argue that), it would only be an argument against that use of macros, not C macros themselves or other use of them.
 You're trying to avoid agreeing with me, that C files containing constructs that emulate different syntax or different language elements, are going to be confusing.
I happily agree that confusing code is confusing.  That applies to confusing functions, confusing types, confusing macros, confusing comments, and anything else, in any language, using any feature.  I don't agree that there is something special about macros in C that are confusing.

 Remember I claimed such things to be 'impractical, unwieldy and inefficient' -'usually'.
If you are talking about C macros, which you regularly complain about, then you are wrong.  (I say "wrong", rather than "I disagree with you", because macros are used so often by so many C programmers that it is obvious they are neither impractical, unwieldy, nor inefficient.)
If you are talking about some hypothetical extra embedded language written in macros, then it's a non-starter - such things are not used in real code, except in very niche cases when they are used precisely because they are the most convenient, efficient and safe method in those niche situations.
And if you are talking about something like that "datatype99" macro library, then your opinion is worthless unless you can show some real-world usage of it, compare it to real code in C doing a similar job without the macro library (or equivalent macros), and demonstrate that the "datatype99" version is clearly inferior.
You are, of course, welcome to your opinions - but if you can't justify them or show that they are reasoned opinions, they are worthless.

 
If your best argument against C macros is that someone wrote a Brainfuck interpreter with them and it is inefficient, then I think you should retire from the discussion.
 You seem to advocating using C macros to make an embedded language, given that you say:
 "The suggestion that making your own language and tools instead of a macro library is clearly absurd."
Your imagination is running wild again.  Try reading what I wrote.
I have not advocated for making any kind of "embedded language" in C, in any sense.

 I gave an example of a tiny language needing 100 times as much source code to implement using C macros, as in a normal language, and another version of it that was hopelessy slow and inefficient.
No, you did not - in either case.

 And that's for a language which is normally as simple to implement, if not use, as they come.
 So, do you have an actual example of an embedded language that is implemented more reasonably using macros?
 By embedded 'language' I don't mean a library of function or macro definitions that you just call or invoked, as happens in any C program.
  

Date Sujet#  Auteur
4 Apr 25 * do { quit; } else { }625Thiago Adams
4 Apr 25 +* Re: do { quit; } else { }2bart
4 Apr 25 i`- Re: do { quit; } else { }1Thiago Adams
4 Apr 25 +* Re: do { quit; } else { }11Kaz Kylheku
4 Apr 25 i+* Re: do { quit; } else { }3Thiago Adams
4 Apr 25 ii`* Re: do { quit; } else { }2Kaz Kylheku
4 Apr 25 ii `- Re: do { quit; } else { }1Chris M. Thomasson
4 Apr 25 i+* Re: do { quit; } else { }4Kaz Kylheku
4 Apr 25 ii+* Re: do { quit; } else { }2Thiago Adams
4 Apr 25 iii`- Re: do { quit; } else { }1Thiago Adams
8 Apr 25 ii`- Re: do { quit; } else { }1candycanearter07
5 Apr 25 i`* Re: do { quit; } else { }3Janis Papanagnou
5 Apr 25 i +- Re: do { quit; } else { }1Janis Papanagnou
6 Apr 25 i `- Re: do { quit; } else { }1Michael S
4 Apr 25 +* Re: do { quit; } else { }608Tim Rentsch
4 Apr 25 i`* Re: do { quit; } else { }607Thiago Adams
6 Apr 25 i +* Re: do { quit; } else { }600Tim Rentsch
6 Apr 25 i i+* Re: do { quit; } else { }550Michael S
6 Apr 25 i ii`* Re: do { quit; } else { }549Tim Rentsch
6 Apr 25 i ii `* Re: do { quit; } else { }548Michael S
7 Apr 25 i ii  `* Re: do { quit; } else { }547Tim Rentsch
7 Apr 25 i ii   `* Re: do { quit; } else { }546Michael S
7 Apr 25 i ii    +* Re: do { quit; } else { }542bart
8 Apr 25 i ii    i`* Re: do { quit; } else { }541David Brown
8 Apr 25 i ii    i `* Re: do { quit; } else { }540bart
8 Apr 25 i ii    i  +* Re: do { quit; } else { }535David Brown
8 Apr 25 i ii    i  i`* Re: do { quit; } else { }534bart
8 Apr 25 i ii    i  i +* Re: do { quit; } else { }78Tim Rentsch
8 Apr 25 i ii    i  i i`* Re: do { quit; } else { }77bart
8 Apr 25 i ii    i  i i +* Re: do { quit; } else { }74Tim Rentsch
8 Apr 25 i ii    i  i i i`* Re: do { quit; } else { }73bart
9 Apr 25 i ii    i  i i i `* Re: do { quit; } else { }72Tim Rentsch
9 Apr 25 i ii    i  i i i  `* Re: do { quit; } else { }71bart
9 Apr 25 i ii    i  i i i   +- Re: do { quit; } else { }1Chris M. Thomasson
9 Apr 25 i ii    i  i i i   +- Re: do { quit; } else { }1Chris M. Thomasson
9 Apr 25 i ii    i  i i i   `* Re: do { quit; } else { }68Tim Rentsch
10 Apr 25 i ii    i  i i i    +* Re: do { quit; } else { }63bart
10 Apr 25 i ii    i  i i i    i+* Re: do { quit; } else { }61Kaz Kylheku
10 Apr 25 i ii    i  i i i    ii+* Re: do { quit; } else { }2Michael S
10 Apr 25 i ii    i  i i i    iii`- Re: do { quit; } else { }1Kaz Kylheku
10 Apr 25 i ii    i  i i i    ii`* Re: do { quit; } else { }58bart
10 Apr 25 i ii    i  i i i    ii +* Re: do { quit; } else { }43Keith Thompson
10 Apr 25 i ii    i  i i i    ii i+* Re: do { quit; } else { }39bart
10 Apr 25 i ii    i  i i i    ii ii+* Re: Endless complaints [was Re: do { quit; } else { }]16bart
10 Apr 25 i ii    i  i i i    ii iii+* Re: Endless complaints [was Re: do { quit; } else { }]14Janis Papanagnou
11 Apr 25 i ii    i  i i i    ii iiii`* Re: Endless complaints [was Re: do { quit; } else { }]13bart
11 Apr 25 i ii    i  i i i    ii iiii +- Re: Endless complaints [was Re: do { quit; } else { }]1Keith Thompson
11 Apr 25 i ii    i  i i i    ii iiii +- Re: Endless complaints [was Re: do { quit; } else { }]1Kaz Kylheku
11 Apr 25 i ii    i  i i i    ii iiii `* Re: Endless complaints [was Re: do { quit; } else { }]10David Brown
11 Apr 25 i ii    i  i i i    ii iiii  `* Re: Endless complaints [was Re: do { quit; } else { }]9bart
11 Apr 25 i ii    i  i i i    ii iiii   +* Re: Endless complaints [was Re: do { quit; } else { }]5Michael S
11 Apr 25 i ii    i  i i i    ii iiii   i`* Re: Endless complaints [was Re: do { quit; } else { }]4bart
11 Apr 25 i ii    i  i i i    ii iiii   i `* Re: Endless complaints [was Re: do { quit; } else { }]3Michael S
11 Apr 25 i ii    i  i i i    ii iiii   i  +- Re: Endless complaints [was Re: do { quit; } else { }]1Janis Papanagnou
11 Apr 25 i ii    i  i i i    ii iiii   i  `- Re: Endless complaints [was Re: do { quit; } else { }]1bart
11 Apr 25 i ii    i  i i i    ii iiii   +- Re: Endless complaints [was Re: do { quit; } else { }]1David Brown
11 Apr 25 i ii    i  i i i    ii iiii   +- Re: Endless complaints1Tim Rentsch
11 Apr 25 i ii    i  i i i    ii iiii   `- Re: Endless complaints [was Re: do { quit; } else { }]1Keith Thompson
10 Apr 25 i ii    i  i i i    ii iii`- Re: Endless complaints [was Re: do { quit; } else { }]1Keith Thompson
10 Apr 25 i ii    i  i i i    ii ii`* Re: do { quit; } else { }22Keith Thompson
11 Apr 25 i ii    i  i i i    ii ii `* Re: do { quit; } else { }21bart
11 Apr 25 i ii    i  i i i    ii ii  `* Re: do { quit; } else { }20Keith Thompson
11 Apr 25 i ii    i  i i i    ii ii   `* Re: do { quit; } else { }19Michael S
11 Apr 25 i ii    i  i i i    ii ii    +- Re: do { quit; } else { }1David Brown
11 Apr 25 i ii    i  i i i    ii ii    +* Re: do { quit; } else { }16Kaz Kylheku
11 Apr 25 i ii    i  i i i    ii ii    i+* Re: do { quit; } else { }2bart
11 Apr 25 i ii    i  i i i    ii ii    ii`- Re: do { quit; } else { }1Keith Thompson
13 Apr 25 i ii    i  i i i    ii ii    i`* Re: do { quit; } else { }13Michael S
12 May 25 i ii    i  i i i    ii ii    i `* Re: do { quit; } else { }12Tim Rentsch
12 May 25 i ii    i  i i i    ii ii    i  `* Re: do { quit; } else { }11David Brown
12 May 25 i ii    i  i i i    ii ii    i   `* Re: do { quit; } else { }10Keith Thompson
13 May 25 i ii    i  i i i    ii ii    i    `* Re: do { quit; } else { }9David Brown
14 May 25 i ii    i  i i i    ii ii    i     `* Re: do { quit; } else { }8James Kuyper
14 May 25 i ii    i  i i i    ii ii    i      +* Re: do { quit; } else { }6Keith Thompson
14 May 25 i ii    i  i i i    ii ii    i      i+* Re: do { quit; } else { }4James Kuyper
14 May 25 i ii    i  i i i    ii ii    i      ii`* Re: do { quit; } else { }3David Brown
14 May 25 i ii    i  i i i    ii ii    i      ii +- Re: do { quit; } else { }1Kaz Kylheku
15 May 25 i ii    i  i i i    ii ii    i      ii `- Re: do { quit; } else { }1James Kuyper
14 May 25 i ii    i  i i i    ii ii    i      i`- Re: do { quit; } else { }1David Brown
14 May 25 i ii    i  i i i    ii ii    i      `- Re: do { quit; } else { }1Tim Rentsch
11 Apr 25 i ii    i  i i i    ii ii    `- Re: do { quit; } else { }1Keith Thompson
6 May 25 i ii    i  i i i    ii i`* Re: do { quit; } else { }3Tim Rentsch
6 May 25 i ii    i  i i i    ii i `* Re: do { quit; } else { }2Keith Thompson
6 May 25 i ii    i  i i i    ii i  `- Re: do { quit; } else { }1Tim Rentsch
10 Apr 25 i ii    i  i i i    ii `* Re: do { quit; } else { }14Kaz Kylheku
10 Apr 25 i ii    i  i i i    ii  +* Re: do { quit; } else { }11bart
10 Apr 25 i ii    i  i i i    ii  i+* Re: do { quit; } else { }2Kaz Kylheku
11 Apr 25 i ii    i  i i i    ii  ii`- Re: do { quit; } else { }1bart
11 Apr 25 i ii    i  i i i    ii  i+* Re: do { quit; } else { }6Tim Rentsch
11 Apr 25 i ii    i  i i i    ii  ii`* Re: do { quit; } else { }5Keith Thompson
11 Apr 25 i ii    i  i i i    ii  ii `* Re: do { quit; } else { }4Tim Rentsch
11 Apr 25 i ii    i  i i i    ii  ii  `* Re: do { quit; } else { }3Keith Thompson
11 Apr 25 i ii    i  i i i    ii  ii   +- Re: do { quit; } else { }1bart
5 May 25 i ii    i  i i i    ii  ii   `- Re: do { quit; } else { }1Tim Rentsch
11 Apr 25 i ii    i  i i i    ii  i+- Re: do { quit; } else { }1Keith Thompson
11 Apr 25 i ii    i  i i i    ii  i`- Re: do { quit; } else { }1Keith Thompson
10 Apr 25 i ii    i  i i i    ii  +- Re: do { quit; } else { }1bart
10 Apr 25 i ii    i  i i i    ii  `- Re: do { quit; } else { }1Kaz Kylheku
11 Apr 25 i ii    i  i i i    i`- Re: do { quit; } else { }1Tim Rentsch
9 May 25 i ii    i  i i i    `* Re: do { quit; } else { }4Bonita Montero
9 May 25 i ii    i  i i i     `* Re: do { quit; } else { }3Richard Heathfield
9 Apr 25 i ii    i  i i +- Re: do { quit; } else { }1Richard Damon
9 Apr 25 i ii    i  i i `- Re: do { quit; } else { }1David Brown
9 Apr 25 i ii    i  i `* Re: do { quit; } else { }455David Brown
8 Apr 25 i ii    i  +- Re: do { quit; } else { }1Tim Rentsch
9 Apr 25 i ii    i  `* Re: do { quit; } else { }3Ike Naar
8 Apr 25 i ii    `* Re: do { quit; } else { }3Tim Rentsch
6 Apr 25 i i`* Re: do { quit; } else { }49Michael S
7 May 25 i `* Re: do { quit; } else { }6Wuns Haerst
6 Apr 25 +- Re: do { quit; } else { }1Lawrence D'Oliveiro
6 Apr 25 +- Re: do { quit; } else { }1David Brown
18 Apr 25 `- Re: do { quit; } else { }1Mikko

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal