Home Tutorial Win32 API Reference Projects

Stony Brook Modula-2Stony Brook Modula-2 archive

Expressions

Scope of Names

In Modula-2 and Ada95 programs, and in most other programminglanguages, the interpretation of a name depends on where it is used in a program. The part of a program in which a name is valid is called the scope of the name.

The debugger uses the scope of names to interpret the names correctlywhile debugging. In this case, the scope is determined by where the programis in its execution. Names are interpreted according to the scope of the currentlocation.

For example, suppose you have two procedures, Alpha and Beta,both of which declare a variable called Value. Depending on where you are inthe execution of the program, different things might happen when you try to examineValue:

  • If neither Alpha nor Beta is the actively executing procedure, and Value is not defined elsewhere, SBD tells you the name is invalid.
  • If the Alpha procedure is currently executing, you will get the Value variable in Alpha.
  • If the Beta procedure is currently executing, you will get the Value variable in Beta.

When searching for a name, the debugger looks in two places:first, the currently executing procedure, and then, if not found there, in the modulethat contains the currently executing procedure.

You can also refer to names globally declared in a Modula-2 modulesand Ada95 packages by qualifying the name with the module or package name, as follows:

ModuleName.SymbolName

Expressions

Expressions are used for many purposes in debugging:

  1. To examine the value of variables and expressions
  2. To enter new values for variables
  3. To specify breakpoint conditions
  4. To specify breakpoint locations
  5. To specify the location of code to view

The debugger distinguishes between two types of expressions:

  • Items 1-3 above require data expressions, which are very much like the expressions you use in the Modula-2 language.
  • Items 4-5 require Code location expressions.

© Norman Black, Stony Brook Software. Reproduced with permission.