Re: TIB: A Disadvantage in TI-82 Basic, Modular Format


[Prev][Next][Index][Thread]

Re: TIB: A Disadvantage in TI-82 Basic, Modular Format




minman@juno.com schrieb:
> 	Recently, I have been working on a group program for TI-82 Basic.
>  I am deliberately avoiding the use of the Goto statement (for reasons
> you do not need to be informed of); therefore, programming it as a group
> program is ideal for my purposes.
> 	However, I have just been presented with a slight problem.  
> 	My main program (called "B") has one "Repeat" loop and one "While
> 1" loop---one for the things that will happen most often and one for the
> things that will happen least often (I do not want to have too many
> subprograms, therefore, I decided on using the "two-loop" method instead
> of making a separate program for the things that happen least often and
> using "Return" in that subprogram).  In the second loop (the "While 1"
> loop, in which the things that happen least often are coded), all
> commands end with:
>
> :prgmB
>
> 	Thus, this restarts the main program (prgmB) again *within* the
> main program (prgmB).  It works correctly; however, I have noticed a
> slight, sometimes gradual decrease in speed whenever it does this.  What
> is doing this, and what can I do to correct this?  Keep in mind that I
> run prgmB off of prgmA (which is a small subprogram used to inititiate
> everything and store values to variables).
> 	I would really appreciate any helpful response.
>
> 	Thanks,
> 	minman
That's not too surprising. You call program :prgmB from inside that program 
which is a recursive call. The computers allocates memory each time you call 
prgmB so decreases your free memory space in saving the actual state ( 
variables, looping environments etc ) somewhere and, matching a return, frees 
that memory again. Due to the decreased memory the computer is more often forced 
to do a Garbage-Collection( it throws away or tries to throw away unnessesary 
variables..), this is, what slows down your computer. Try to run prgmB from 
inside its body often enough, so you will end at: Not enough memory-error.
You should try to resolve the recursive programming style to an iterative one.
		AK


References: