On Tue, 07 Sep 2021 14:53:29 +0000, Grant Edwards wrote: > On 2021-09-06, Stefan Ram <r...@zedat.fu-berlin.de> wrote: >> "Avi Gross" <avigr...@verizon.net> writes: >>> In languages like C/C++ there are people who make up macros like: >>>#define INDEFINITELY_LOOP while (true) >>>Or something like that and then allow the preprocessor to replace >>>INDEFINITELY_LOOP with valid C code. >> >> Those usually are beginners. >> >>>So, how to do something like that in python, is a challenge left to the >>>user >> >> Such a use of macros is frowned upon by most C programmers, >> because it renders the code unreadable. > > I remember engineering manager I worked with about 35 years ago who used > a set of C macros to try to make his code look as much like BASIC as > possible: > > #define IF if ( #define THEN ) { #define ELSE } else { > #define ENDIF } > ... > > IIRC he copied them out of a magazine article. > > He then proceeded to try to implement a tree search algorithm (he didn't > actually know that's what he was doing) using his new "language" without > using recursion (which he had never heard of and couldn't grok) by > keeping track of state using an array. It did not go well and made him a > bit of a laughingstock. IIRC, he had first tried to write it in actual > BASIC, but gave up on that before switching to C and his ridiculous > macro set.
1 Simple rule, if you are programming in language 'a' then write Language 'a' Code it. Just because you can do something doesn't mean you should -- Help! I'm trapped in a Chinese computer factory! -- https://mail.python.org/mailman/listinfo/python-list