From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public From: clodius@hotspec.lanl.gov (William Clodius) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/08 Message-ID: #1/1 X-Deja-AN: 173118232 sender: clodius@hotspec.lanl.gov references: <31FBC584.4188@ivic.qc.ca> organization: Los Alamos National Laboratory newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-08-08T00:00:00+00:00 List-Id: There is one special case of recursion, fortunately the most commonly encountered case, where it is "ridiculously" easy for a compiler to see that the recursion can be replaced by iteration. The recursive code must call itself directly on only one branch of the control of flow and is the last call before returning on that control of flow. Conventionally it is placed on the last branch of the control of flow for clarity, hence the name "tail" recursion. Quoting the NEW Hackers dictionary "tail recursion: n. If you aren't sick of it already, see tail recursion." which is essentially equivalent to tail recursion: n. while you aren't sick of it, read "tail recursion: n. If you aren't sick of it already, see tail recursion." There are other more subtle cases (where indirect recursion is invoked (A calls B which calls A), multiple recursion (A calls A more than once), etc.) where recursion elimination is possible, but significantly more difficult to detect and implement. For example, B could be inlined into A and result in tail recursion for the new version of A. It is doubtfull that any compiler will recognize all special cases, but there are several that can handle more than just tail recursion. -- William B. Clodius Phone: (505)-665-9370 Los Alamos National Laboratory Email: wclodius@lanl.gov Los Alamos, NM 87545