on writing a while loop for rolling two dice

Grant Edwards grant.b.edwards at gmail.com
Tue Sep 7 10:53:29 EDT 2021


On 2021-09-06, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> "Avi Gross" <avigross at 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.




More information about the Python-list mailing list