[OPINION] - does language really matter if they alldothe samething?

Terry Reedy tjreedy at udel.edu
Sun Jan 25 21:13:50 EST 2004


"Dietrich Epp" <dietrich at zdome.net> wrote in message
news:D3AD8358-4F90-11D8-BCE5-0003934ACDEC at zdome.net...
>
> On Jan 24, 2004, at 9:30 AM, Terry Reedy wrote:
>
> > I slightly prefer my Python version, but I suspect you will not, so you
> > remain safe.
>
> You prefer infinite recursion?

Given that my incomplete, you-fill-in-the-blanks, "Maybe something like"
this, Python code, translated directly from your Lisp code, would not even
compile, and that we were talking about the relative convenience and
aethestics of equivalent code in different languages, this response strikes
me as a bit odd.  Oh well.

As I understood your lisp version of random_sword_magic_power(quality),
recursive calls are only needed when quality = good, while the two
recursive calls then made would only be made with quality = medium, hence
the recursion would (should) stop one level down.  To make this happen with
the Python version, add a first statement "something like"

    double = (quality == good) and (random_sword_magic_power(medium) +
         random_sword_magic_power(medium)) or None

and substitute double for the double call in the argument list for
choose-random-assoc().

I assume that in your code, the same recursion base-casing is hidden within
the no-source-given choose-random-assoc macro, by how it rewrites the text
of its 'arguments'.  I suspect that if choose-random-assoc were an
ordinarily lisp function, including in CL, with arguments evaluated before
the call, then random_sword_magic_power() would have to explicitly
conditionalize its recursive call, just as in other languages.  If so, then
one very much does have to know that c-r-a is a macro in order to use it
efficiently and not write a redundant base-case check.

Terry J. Reedy







More information about the Python-list mailing list