[prev] [up] [next]

More Smalltalk

This document describes other important features and mechanisms which are part of the language or class library, but have been ignored until now.

Other Variable Types

Beside globals, method locals and instance variables, there are also:

Contexts

Block- and Methodvariables are stored in so called Contexts. These are created for every method- or block invocation. They have to major purposes:
  1. to remember the caller's context and keep the current pc (for proper return to the caller)
  2. to store local variables (method- and block variables)
  3. to provide space for intermediate values (expression evaluation stack)
In other programming languages, these would be called Stack Frame, and that's what they are most of the time. However, via the pseudo variable thisContext, they can be accessed at any time and treated like any other first class object: you can store them in other objects or return them as value.

C-programmers should notice that the Smalltalk runtime system makes sure that the memory space used by a context gets moved from the stack to the heap automatically, whenever required. As a programmer, this movement is completely transparent.


Continue in "More Smalltalk".

[stx-logo]
Copyright © 1996 Claus Gittinger Development & Consulting
Copyright © eXept Software AG

<cg at exept.de>

Doc $Revision: 1.8 $ $Date: 2021/03/13 18:24:49 $