1. Re: useless (?) return
- Posted by Michael Sabal <mjs at OSA.ATT.NE.JP>
Nov 28, 1998
-
Last edited Nov 29, 1998
Someone may have already replied to this, but I'm using the digest, so I =
won't know till tomorrow. Perhaps this little trace can explain the =
need for the return, although with Rob straightening out jumps in the =
next release, it just may become unnecessary.
1: main procedure calls function ltrim
2: character checked
3: Is it whitespace?
3a: No --> return to main procedure
3b: Yes --> shave it off and continue
4: function ltrim recursivly calls function ltrim
5: new set of pointers created
6: character checked
7: Is it whitespace?
7a: Yes --> shave it off and continue with step 4.
7b: No --> return to previous copy of ltrim *** here's the problem
8: End of function ltrim
8a: Have I returned a value?
8a1: Yes --> happily return to calling function/procedure
8a2: No --> crash
Even though the function returns in step 7b, it doesn't go all the way =
back to the original procedure. It must recursivly step back through =
each instance of ltrim, each time returning the value to the other =
copies of the variable so the correct answer is returned to the main =
procedure. Without the final return, the true answer fades away into =
unused memory as it's freed, and no true answer remains. Maybe Rob can =
explain this more clearly, and how the changes in Euphoria 2.1 will =
affect this.
Michael J. Sabal
mjs at osa.att.ne.jp
http://home.att.ne.jp/gold/mjs/index.html