[jawsscripts] Re: Recursive Function Calls

  • From: Andrew Hart <ahart@xxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Wed, 27 Nov 2013 20:08:16 -0300

Gavin,

JAWS does not actually support recursive function calls.  when you call
code like your example, the SpeakTest function inside the body of your
function causes JAWS to look in the default scripts for a function
called SpeakTest and it calls that function.  If you put the SpeakTest
function in the default scripts, then it will look for a built-in
function called speakTest an dcall that SpeakTest if it exists.
Otherwise, it doe snothing.

However, to answer your question about recursive functions, in other
languages (not JAWS script), the code example you provided would execute
for ever.  If you also pass parameters to it, it would eventually cause
the pprocess running it to run out of memory, since each function call
pushes the parameters onto the stack so the recursively called function
can retrieve them.

To prevent this from happening, recursive functions need to include
termination conditions that guarantee the code will stop running at some
point.

Hth,
Andrew.

On 27/11/2013 7:24 PM, Gavin Grundlingh wrote:
> Hi all,
> 
> How exactly do recursive function calls work? From what I've read, a 
> recursive function is a function that calls itself. What I don't understand, 
> though, is how a function can call itself without going into an infinite 
> loop. Consider the following example:
> 
> Void Function SpeakTest ()
> SayString ("test")
> SpeakTest ()
> EndFunction
> 
> now when calling SpeakTest, the string "test" is not infinitely spoken. Has 
> anyone used this kind of function in a script before?
> 
> __________�
> 
> View the list's information and change your settings at 
> http://www.freelists.org/list/jawsscripts
> 
> 
> 


__________�

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: