Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 3 Forum
Date: Thu Sep 27 2001 12:42 pm
Author: Danish, Matt R. <mrd@cmu.edu>
Subject: Re: recursive

Recursion can involve calls to other functions (two or more functions can recursively call each other), but the real issue here is that Java's syntax is confusing you; think of it like this:

return Blah(this);
and
return Blah(someChild);
instead of
return this.Blah();
and
return someChild.Blah();

Some other Object-Oriented languages do not use the "." notation to denote the instance the method should be called on; rather they use ordinary function-call syntax and pass the instance as one of the arguments (as demonstrated above). It happens to be a much more flexible and powerful way of method-selection (think of several different classes' instances as arguments)

Having said all that, I should point out that your example of recursion is indeed "special", though perhaps not in the way you intended. Your example was in fact "tail-recursion" where the recursive call is the last thing done in the function. From what I've seen, it seems that the Java compiler we have handles "tail-recursion" properly; it can be optimized to the equivalent of a "goto" (or, in other words, iteration).

Post response

Go to the previous messageGo to the following message
Current Thread Detail:
recursive      Cipriani, Jason A.      Thu Sep 27 2001 9:55 am       
Re: recursive      White, David      Thu Sep 27 2001 12:08 pm       
Re: recursive      Yuen, John      Thu Sep 27 2001 12:15 pm       
Re: recursive      Danish, Matt R.      Thu Sep 27 2001 12:42 pm       
Re: recursive      Cipriani, Jason A.      Thu Sep 27 2001 4:16 pm       
Re: recursive      Danish, Matt R.      Thu Sep 27 2001 7:38 pm       
Re: recursive      Lee, Peter      Fri Sep 28 2001 9:44 am       
Re: recursive      Danish, Matt R.      Fri Sep 28 2001 11:35 am       
Re: recursive      Lee, Peter      Fri Sep 28 2001 12:43 pm       

Back to previous screen