News for hackers. Stuff that matters.
Re:C implementation of Tic-Tac-Toe in a single call to printf by russfink on Sunday June 07, 2020 @09:14AM (#23447097)
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
Re:C implementation of Tic-Tac-Toe in a single call to printf by gamegoblin on Sunday June 07, 2020 @03:56PM (#23450233)
Much of the original Bourne shell was written in C that had been macro'd to look like Algol [1].

E.g.

    /usr/src/cmd/sh/mac.h:
    #define IF      if(
    #define THEN    ){
    #define ELSE    } else {
    #define ELIF    } else if (
    #define FI      ;}
    
    #define BEGIN   {
    #define END     }
    #define SWITCH  switch(
    #define IN      ){
    #define ENDSW   }
    #define FOR     for(
    #define WHILE   while(
[1] https://research.swtch.com/shmacro
Re:C implementation of Tic-Tac-Toe in a single call to printf by bondarchuk on Sunday June 07, 2020 @06:12PM (#23451360)
Quite some time ago I saw a piece of C code (probably linked from here) in APL style, I have been trying to find it since, does anyone know what I mean?
Re:C implementation of Tic-Tac-Toe in a single call to printf by gmfawcett on Sunday June 07, 2020 @06:25PM (#23451485)
Might have been this. The style is usually attributed to Arthur Whitney:

https://code.jsoftware.com/wiki/Essays/Incunabulum

Re:C implementation of Tic-Tac-Toe in a single call to printf by simias on Sunday June 07, 2020 @09:30AM (#23447195)
I've had to deal with code like that, only poorly mimicking Lisp instead: `#define unless(_x) if (!(_x))` etc...

One of my favourite accidental features in Rust is that macros are so annoying and cryptic to write that people think twice before abusing them.

Re:C implementation of Tic-Tac-Toe in a single call to printf by TeMPOraL on Sunday June 07, 2020 @04:25PM (#23450485)
I understand the temptation. I keep catching myself on writing `unless( ... )` in C++ every couple days, and I've considered adding a macro for it, but ultimately decided against it, as the rest of the team would not understand why I need it.
Re:C implementation of Tic-Tac-Toe in a single call to printf by Gene_Parmesan on Sunday June 07, 2020 @02:16PM (#23449353)
Wouldn't be surprised if that was intentional, actually. The idea of making syntax a little unwieldy for things that you should really think twice before using is not a new one.
Re:C implementation of Tic-Tac-Toe in a single call to printf by keitmo on Sunday June 07, 2020 @04:03PM (#23450306)
"The determined Real Programmer™ can write FORTRAN in any language."
Re:C implementation of Tic-Tac-Toe in a single call to printf by a1369209993 on Sunday June 07, 2020 @09:06PM (#23452574)
Real Programmers write machine code in any language, thank you very much. (Which TFA rather nearly is, actually, though it's a bit macro-assemblery for a proper example.)

http://www.catb.org/jargon/html/story-of-mel.html

Re:C implementation of Tic-Tac-Toe in a single call to printf by codezero on Sunday June 07, 2020 @01:09PM (#23448791)
One time, I had to maintain FORTRAN code. Much of it was still in FORTRAN 66.