Derek,
Let me start off by clarifying one thing: In that last reply it would have been better to state that a CompositePart class is constrained so that it must have 2 or more Parts (SimplePart and/or CompositeParts) inside it.
Yes, each time a method calls down to an object method that is one level, if that object recurses down another level it just adds one level to the call stack. Recursion is simply defined as a function/method that calls itself. The limit is imposed by how many levels VFP allows to the call stack.
define class Part as custom
procedure CalculateCost()
endproc
enddefine
define class SimplePart as Part
procedure CalculateCost()
return this.nCost
enddefine
define class CompositePart as Part
procedure CalculateCost()
local lnCost
lnCost = 0
for each oPart in this.oCollection
lnCost = lnCost + oPart.CalculateCost()
endfor
return lnCost + this.nCost
enddefine
For every level of Part nesting inside an instance the above code would have one level in the callstack.
Like Doug said it's pretty hard to imagine that you'd ever practically run out of 127 call stack levels. The only time I've hit it was in a a multi-linked list data structure during it's destruction. To avoid this I had to use a single linked-list through the all of the allocated nodes so I could use a non-recursive method during the destruction.
>Lets say I have an object called Part that has a link to another object called Subassembly.
>Subassembly contains an object collection. It has a method called loopThruCosts() that will go thru the collection and will call the calculateCost() method of all the objects in its collection. The collection can contain an ObjectID for another Part object.
>Now Part has a method called calculateCost() that first checks for a link to Subassembly, and if so then calls the Subassembly.loopThruCosts() and so on.
>Now my question is with this scenereo, does VFP6 consider this recursion?