This is an interesting thread of discussion.
Whether the original example:
public int Blah() { return someChildofThis.Blah(); }
is recursive depends on whether the child instance inherits this same implmentation of Blah() or not. There isn't enough of the code here to know for sure, but it certainly could be recursive because of inheritance. (For those of you who are still fuzzy on inheritance, just hold on --- we'll be spending more lecture time on this concept.)
As for tail-recursion, it turns out that Matt is not quite right about Java. Matt hinted that tail-recursive method calls can be implemented as direct goto's. While this is true for many languages, it is expressly disallowed in Java, for security reasons. The java 2 security manager requires the presence of all stack frames for all methods to appear on the run-time stack.
I don't think we will be getting into the details of the security manager in this course, but I do hope to explain more about tail recursion later. If not, then 15-212 goes into this in great detail. |