Section 8.2.3

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Section 8.2.3

The111
"After the called function returns, the caller’s memory segments argument, local, static, this, that, and pointer are the same as before the call, and the temp segment is undefined."

Shouldn't the word static be omitted from that list?  If the static variables are accessible to all functions, then it is possible that the called function modified it, and it won't be the same... is that right?
Reply | Threaded
Open this post in threaded view
|

Re: Section 8.2.3

cadet1620
Administrator
Johnson wrote
"After the called function returns, the caller’s memory segments argument, local, static, this, that, and pointer are the same as before the call, and the temp segment is undefined."

Shouldn't the word static be omitted from that list?  If the static variables are accessible to all functions, then it is possible that the called function modified it, and it won't be the same... is that right?
This is saying that the pointers to the function's memory segments will be unchanged after the called function returns. 'static 3' will reference the same memory after the call as it did before.

In the standard VM implementation as described in the book the 'static' segment doesn't use a pointer, so there is nothing physical to save and restore; it's just an abstract concept.

Note that there is a different 'static' segment for each .vm file. Thus, each class has its own static variables. There are no global variables.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Section 8.2.3

The111
Understood.  Thanks for the quick response.