Back: 1.2.5 Variable scope Forward: 1.2.5.2 local statements     FastBack: 1. Basic Ideas Up: 1.2.5 Variable scope FastForward: 2. Using Array Syntax         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document

1.2.5.1 extern statements

Suppose you want to write a function which sets the value of the theta array used by all the variants of the q_out function:

 
func q_out_domain(start, stop, n)
{
  extern theta;
  theta = span(start, stop, n);
}

Without the extern statement, theta will be a local variable, whose external value is restored when q_out_domain returns (thus, the function would be a no-op). With the extern statement, q_out_domain has the intended side effect of setting the value of theta. The new theta would be used by subsequent calls to q_out.

Any number of variables may appear in a single extern statement:

 
extern var1, var2, var3, var4;