From J Wiki
Jump to: navigation, search

>> <<   Back to: Vocabulary

u. and v. Implicit Locatives for u and v

Rank Infinity -- operates on x and y as a whole -- WHY IS THIS IMPORTANT?

u. executes the verb named u using the namespaces that were in effect before the current explicit definition was called. The namespaces comprise the private namespace of the caller, if any, and the implied locale in effect in the caller. If the value of u contains names, these names will be found in the caller's namespaces.

u. is equivalent to u except that if you use u. in your modifiers, users will be able to call your modifiers with operands including privately-defined names.

u. and v. are called implicit locatives because (a) they do what locatives do, namely set a new execution environment, execute a name, and reset the environment; (b) the environment they switch to is the caller of the current function.

Common uses

Allow a user-written modifier to accept locally-defined verbs from its caller.

   haslocalfn =: 3 : 0
localfn =. +:
(localfn exeu) y
   exeu =: 1 : 'u y'
   haslocalfn 10  NB. Tries to execute localfn in exeu where it is not defined
|value error: haslocalfn
|       u y
   exeu =: 1 : 'u. y'
   haslocalfn 10  NB. Executes localfn in haslocalfn

More Information

  1. u. and v. are primitive verbs with infinite rank.
  2. The corresponding name must defined as a verb in the local namespace.
    The local namespace must exist, i. e. u. and v. may not be executed from the console.
  3. u. and v. may be used in compounds, gerunds, etc.
  4. If the returned value of a modifier contains u. or v., u./v. will be replaced by its value.
    This is because the returned value will be executed in the caller, where u./v. would not have the correct meaning.
  5. u. and v. can be passed as operands to another modifier, either bare or in compounds. Execution of u..v. in the called modifier will result in execution of each verb in its proper environment.
  6. u. and v. should not be passed as operands whose modifiers execute their operand as u and v (or x and y for very old modifiers). Such modifiers will execute the verbs in the wrong environment.
  7. If u. or v. appears in a verb whose value is fixed using f., u./v. is replaced by its value and the implied locative is lost.



  1. The environment in the caller is the environment that was in place when the sentence the caller is executing was started.
  2. u. and v. cn be used even in ordinary verbs if values have been given to u./v.. This can be used to execute arbitrary sentences in the caller's environment:
   v =. 'coname'
   v. ''   NB. get name of caller's locale
   v =. ".
   v. 'j'  NB. get value of j in caller