[Coco] Basic09 local variable storage

Willard Goosey goosey at virgo.sdc.org
Tue Jan 26 16:26:42 EST 2010


On Tue, Jan 26, 2010 at 11:22:00AM -0600, CoCo Mongrel wrote:

> So variables are local to procedures in Basic09, right?  Does that mean that
> the storage is allocated dynamically?  

Yes to both.

>If I have a couple procedures that
> are called at different times with their own local variables, could Basic09
> reuse the same memory for local variables?

possibly, if the stack is in the same place each time.  Not something
you can count on, though.
> The undeclared 'x' variables in each procedure are 'automatic' INTEGERs, is
> that right?  

Well, they're automatic.  Not sure about the exact default type.

>Should I worry about the storage for them?  Would it use less
> memory to declare an 'x' in the main procedure and pass it to the
> subprocedures by reference, or does Basic09 allocate the memory dynamically
> for each procedure call?  

It's all on the stack.  Pushing an int onto the stack or pushing a
pointer onto the stack comes out the same, memory-usage wise.

Willard
-- 
Willard Goosey  goosey at sdc.org
Socorro, New Mexico, USA
I search my heart and find Cimmeria, land of Darkness and the Night.
  -- R.E. Howard



More information about the Coco mailing list