Earlier quoted context omitted.
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
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.
C implementation of Tic-Tac-Toe in a single call to printf
71–80 of 85 posts
Re: C implementation of Tic-Tac-Toe in a single call to printf
#72Earlier quoted context omitted.
>I think more companies should allow for their employees to have some plain old fun with no strings attached on a regular basis. Maybe we could call this additional 'holiday pay' or a longer 'weekend' and mandate it through law so that everyone benefits.
Ha, if I had a longer weekend my wife would demand I use it taking her out.
Re: C implementation of Tic-Tac-Toe in a single call to printf
#73> %n takes a pointer and writes (!!) the number of bytes printed so far. > Okay, everyone probably knows this. Let's get a bit more advanced. Ok, but I didn't know about that. What's the use?
Re: C implementation of Tic-Tac-Toe in a single call to printf
#74Re: C implementation of Tic-Tac-Toe in a single call to printf
#75Oddly enough I find that the #define macro soup detracts from the performance here. I was rather unimpressed at first because obfuscating C code by just #define'ing a bunch of code is a trivial and rather uninteresting way to write unreadable code. Of course you can make any arbitrary code look like a printf call with enough macros! But it's actually a lot more clever than that. I feel like this would be a lot more i…
Re: C implementation of Tic-Tac-Toe in a single call to printf
#76In case you're wondering (like me) how you'd get input from printf(): > We ab^H^Huse [the Turing-completeness of printf()] to implement a the logic of tic-tac-toe entirely within this one printf call (and a call to scanf() to read user input). So it should be "one printf() and one scanf()."
Should be "an infinite number of printf()s and scanf()s".
Re: C implementation of Tic-Tac-Toe in a single call to printf
#77Earlier quoted context omitted.
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
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
#78Earlier quoted context omitted.
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
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
#79Earlier quoted context omitted.
One time, I had to maintain C code That somebody had #define'd to look like FORTRAN. It was impressive.
"The determined Real Programmer™ can write FORTRAN in any language."