Lock Definition {R}←{X}⎕LOCK Y

Y must be a simple character scalar, or vector which is taken to be the name of a defined function or operator in the active workspace. ⎕LOCK does not apply to dfns or derived functions.

The active referent to the name in the workspace is locked.  Stop, trace and monitor settings, established by the ⎕STOP, ⎕TRACE and ⎕MONITOR functions, are cancelled.

The optional left argument X specifies to what extent the function code is hidden. X may be 1, 2 or 3 (the default) with the following meaning:

  1. The object may not be displayed and you may not obtain its character form using ⎕CR, ⎕VR or ⎕NR.
  2. Execution cannot be suspended with the locked function or operator in the state indicator. On suspension of execution the state indicator is cut back to the statement containing the call to the locked function or operator.
  3. Both 1 and 2 apply. You can neither display the locked object nor suspend execution within it.

Locks are additive, so that

      1 ⎕LOCK'FOO' ⋄ 2 ⎕LOCK'FOO'     

is equivalent to:

      3 ⎕LOCK'FOO' 

The shy result R is the lock state (1,2 or 3) of Y.

A DOMAIN ERROR is reported if Y is ill-formed.

Examples

      ⎕FX'r←foo' 'r←10'
      ⎕NR'foo'  
  r←foo r←10
      ⍴⎕NR'foo'
2
      ⎕LOCK'foo'
      ⍴⎕NR'foo'
0