Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: possible to write translate program from recursive C to no recursive C?

Author: Peter Fendrich

Date: 02:53:40 09/15/03

Go up one level in this thread


On September 15, 2003 at 03:39:33, Uri Blass wrote:

>On September 15, 2003 at 02:56:24, Reinhard Scharnagl wrote:
>
>>Hi Uri,
>>
>>>Can programmers write a program that take a code with recursive functions and
>>>translate it to a code without recursive functions that does the same thing?
>>>
>>>Do not answer me that the compiler does it by translating it to assembler
>>>because the translation should be done to a program in the same computer
>>>language so a C source should be translated to another C source.
>>
>>it could be done by locally implementing a kind of a stack. You have
>>therefore to think about maximum call limits. Sometimes a simple loop
>>already will do the aimed task.
>>
>>But what is the reason for such a non recursiv approach? What is
>>wrong with using recursion?
>>
>>Regards, Reinhard.
>
>I read that recursion is bad for parallel program and there is information
>that I practically remember twice so maybe it is not good also for non parallel
>program.
>
>If I want to check if the king was in check 2 plies earlier then I need to look
>at a special array for that purpose and I understand that with non recursive
>approach I can get the information without remembering it twice.

I can't really see the differrence in this respect. If you don't use recursion
you will instead use an iteration (while or for). IMO a very inelegant
solution...
Anyway, You have to put basically all data used locally by the former recursive
function in an array indexed by plynumber. In order to check if the king was in
check 2 plies up you still need to look in the array with the index ply-2.
Am I missing something? "Remember it twice" doesn't make sence to me...

>Uri



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.