Modules with No Arguments

The previous section emphasized that modules with arguments are given a local symbol table. In contrast, a module that has no arguments shares the global symbol table. All variables in such a module are global, which implies that if you modify the value of a matrix inside the module, that change persists when the module exits.

The following example shows a module with no arguments:

/* module without arguments, all symbols are global.  */
proc iml;
a = 10;                                /* a is global      */
b = 20;                                /* b is global      */
c = 30;                                /* c is global      */
start Mod1;                            /* begin module     */
   p = a+b;                            /* p is global      */
   c = 40;                             /* c already global */
finish;                                /* end module       */

run Mod1;                              /* run the module   */
print a b c p;

Figure 6.3: Output from Module with Global Variables

a b c p
10 20 40 30


Notice that after the module exits, the following conditions exist:

  • a is still 10.

  • b is still 20.

  • c has been changed to 40.

  • p is created, added to the global symbol table, and set to 30.