Friday, July 02, 2021

Re: C style in OpenBSD

On Fri, 2 Jul 2021 15:09:42 +0959
Reuben ua Bríฤก <u5644051@anu.edu.au> wrote:

> > Some languages do not have ternaries.
>
> in C:
> ternary EXPRESSION: A ? B : C
> ternary STATEMENT: if (A) B; else C;
>
> i will define some macros to highlight the similarity:
>
> […snip…]
>
> #define exif(e) e ?
> #define exel :
>
> search.argmode =
> exif (strcmp(progname, BINM_MAN) == 0)
> ARG_NAME exel
> exif (strcmp(progname, BINM_APROPOS) == 0)
> ARG_EXPR exel
> exif (strcmp(progname, BINM_WHATIS) == 0)
> ARG_WORD exel
> exif (strncmp(progname, "help", 4) == 0)
> ARG_NAME exel
> ARG_FILE;

Good grief… a bad coding style gets worse. Yes, it's our favourite,
the C Pre-processor macro!

> > It actually isn't… you can add braces to the if-else, and put
> > for/while/switch/if statements inside those braces to do more complex
> > logic if the need arises. Only mathematical expressions can be used
> > in ternaries.
>
> because they are EXPRESSIONS, not STATEMENTS.

var = expression; // ← statement

As I said before, if you think it's such a great idea, take a software
patent out on the idea.

In the mean time, you're proposing an idea that:
1. fixes nothing as nothing was broken
2. makes code readability and maintainability worse

The horse is dead… and has been flogged so hard every bone in its limp
body has been turned to powder. When do you stop? You trying to make
a horse smoothie one whip crack at a time?
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

No comments:

Post a Comment