EXPOSE

           +------------+
           V            |
>>-EXPOSE----+-name---+-+--;-----------------------------------><
             +-(name)-+

EXPOSE causes the object variables identified in name to be exposed to a method. References to exposed variables, including assigning and dropping, access variables in the current object's variable pool. (An object variable pool is a collection of variables that is associated with an object rather than with any individual method.) Therefore, the values of existing variables are accessible, and any changes are persistent even after RETURN or EXIT from the method.

Any changes a method makes to an object variable pool are immediately visible to any other methods that share the same object variable scope. All other variables that a method uses are local to the method and are dropped on RETURN or EXIT. If an EXPOSE instruction is included, it must be the first instruction of the method.

If parentheses enclose a single name, then, after the variable name is exposed, the character string value of name is immediately used as a subsidiary list of variables. Whitespace characters are not necessary inside or outside the parentheses, but you can add them if desired. This subsidiary list must follow the same rules as the original list, that is, valid variable names separated by whitespace characters, except that no parentheses are allowed.

Variables are exposed in sequence from left to right. It is not an error to specify a name more than once, or to specify a name that has not been used as a variable.

Example:

/* Example of exposing object variables */
myobj = .myclass~new
myobj~c
myobj~d         /* Would display "Z is: 120"                 */

::class myclass /* The ::CLASS directive                     */
                /* (see ::CLASS)                             */
::method c      /* The ::METHOD directive                    */
                /* (see ::METHOD)                            */
  expose z
  z = 100       /* Would assign 100 to the object variable z */
  return

::method d
  expose z
  z=z+20        /* Would add 20 to the same object variable z */
  say "Z is:" z
  return

You can expose an entire collection of compound variables (see Compound Symbols) by specifying their stem in the variable list or a subsidiary list. The variables are exposed for all operations.

Example:

expose j k  c. d.
/*  This exposes "J", "K", and all variables whose            */
/*  name starts with "C." or "D."                             */
c.1="7."        /*  This sets "C.1" in the object             */
                /*  variable pool, even if it did not         */
                /*  previously exist.                         */