main program vars in stack

Wed, 9 Oct 1996 15:53:50 +0300 (EET DST)



On Tue, 8 Oct 1996, Peter Gerwinski wrote:

> I don't know why the stack is used, and I will change it (and use the
> data segment instead) unless somebody can tell me why the stack is 
> preferable for the main program.

	Peter, I recall that I had tough time to
	make non-local goto's back to the main program level
	work in gpc.

	In the beginning I made all routines in the 
	main program level appear as global symbols,
	and all variables go to the data area.
	This worked fine, except that the goto handling
	routines crashed the compiler when a non-local goto
	back to the main program level was made.
	I could not make this work with the goto's like this.

	The solution to the goto problem was to make all
	routines in the main program to be nested routines inside a
	"global main program scope" that can be jumped into
	from inside.

	This had the unfortunate side-effect that
	made main program variables go into the stack, which
	is sort of stupid for obvious reasons.

	However, MODULES are not treated like this, so currently if you
	have a large array, you can put it in a module, and it
	will go to the data area. (This is because you can not jump
	to the modules scope, so it does not cause problems :-)

	If you wish you can try to force all program vars back
	to the global scope. This would be fine (I think it
	is possible, I just did not do that, sigh).

					Juki
					jtv@hut.fi


Jukka Virtanen (jtv@cc.hut.fi)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es