6 ms·
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
by russfink 6y ago
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
- simias 6y agoI'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.
- Gene_Parmesan 6y agoWouldn'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.
- TeMPOraL 6y agoI 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.
- codezero 6y agoOne time, I had to maintain FORTRAN code. Much of it was still in FORTRAN 66.
- gamegoblin 6y agoMuch 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 https://research.swtch.com/shmacro
- bondarchuk 6y agoQuite 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?
- gmfawcett 6y agoMight have been this. The style is usually attributed to Arthur Whitney: https://code.jsoftware.com/wiki/Essays/Incunabulum https://code.jsoftware.com/wiki/Essays/Incunabulum
- keitmo 6y ago"The determined Real Programmer™ can write FORTRAN in any language."
- a1369209993 6y agoReal 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 http://www.catb.org/jargon/html/story-of-mel.html