🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4306

Re: Recursion (was PROLOG in the "real" world?)

#4306
From: Lee Naish
Date: Wed, 16 Oct 1991 16:36
28 lines
2638 bytes
In article <1991Oct04.142838.29652@eng.umd.edu> clin@eng.umd.edu (Charles Lin) writes:
>   Recursion isn't that easy anyway.  Since it is based on induction, and since
>normal folks tend to have a problem with induction, then it isn't surprising
>that recursion is not the easiest concept to understand.

Induction is not necessary for writing iterative code, but if you want
*correct* code then it is rather useful.  How do you write correct
iterative code?  You maintain invariants, and invariants are induction
hypotheses.

Sure, normal people tend to have a problem with induction.  They tend to
have a problem writing correct code.  We all do!  Learning to reason
(think) more formally is helpful no matter what style of programming is
eventually employed.  Once you learn such things, recursion becomes less
scary/confusing and more attractive.

Previous postings have said that recursion yeilds more elegant programs.
There is actually nothing nasty about iteration.  The "problem" is
destructive assignment.  Unfortunately, iteration without destructive
assignment is not very powerful :-).  Separating the different versions
of a variable (eg, before and after assignment) makes a program closer
to the reasoning behind it (eg, some induction).  In a recursive
program, the formal parameters of a procedure are distinct from the
actual parameters in a recursive call to the procedure.  This is true
even if it is a tail recusive call and the implementation actually uses
exactly the same memory cells for both sets of parameters.

	lee
Technical Details
Message-ID: <1991Oct16.163624.19739@ecrc.de>
Path: arc1-ca.pugleaf.net!gmdzi!unido!ecrc!lee
References: <1991Sep26.031311.836@monu6.cc.monash.edu.au> <1991Oct02.193655.16492@chome.ruhr.de> <1991Oct3.180209.3023@athena.cs.uga.edu> <1991Oct04.142838.29652@eng.umd.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f907c,2ad8401e5c040397
X-Google-Attributes: gidf907c,public
X-Google-Thread: f43e6,2ad8401e5c040397
X-Google-Attributes: gidf43e6,public
X-Google-Thread: 102449,2ad8401e5c040397
X-Google-Attributes: gid102449,public
X-Google-Thread: 10db24,2ad8401e5c040397
X-Google-Attributes: gid10db24,public
X-Google-Thread: 10461e,2ad8401e5c040397
X-Google-Attributes: gid10461e,public
X-Google-ArrivalTime: 1991-10-24 21:30:01 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!ecrc!lee
From: lee@ecrc.de (Lee Naish)
Newsgroups: comp.lang.prolog,comp.software-eng,comp.edu,comp.ai,aus.ai
Subject: Re: Recursion (was PROLOG in the "real" world?)
Message-ID: <1991Oct16.163624.19739@ecrc.de>
Date: 16 Oct 91 16:36:24 GMT
References: <1991Sep26.031311.836@monu6.cc.monash.edu.au> <1991Oct02.193655.16492@chome.ruhr.de> <1991Oct3.180209.3023@athena.cs.uga.edu> <1991Oct04.142838.29652@eng.umd.edu>
Sender: news@ecrc.de
Reply-To: lee@ecrc.de (Lee Naish)
Organization: European Computer-Industry Research Centre, Munich
Lines: 28