Here -
http://www.jsoftware.com/help/jforc/modular_code.htm#_Toc191734487 there is a following text: ----- We establish the search paths we want, and display the name of the current locale: ('loc1';'loc2';'z') 18!:2 <'loc3' ('loc2';'z') 18!:2 <'loc1' 18!:5 '' +----+ |base| +----+ Next we define two verbs. v1_z_ =: verb define 'Locale at start of v1 is %j' printf 18!:5 '' qprintf 'n1 ' v2_result =. v2_loc1_ n1 'Value returned by v2 is %s' printf <v2_result 'Locale in v1 after calling v2 is %j' printf 18!:5 '' qprintf 'n1 ' ) cocurrent <'loc2' v2 =: verb define 'Locale at start of v2 is %j' printf 18!:5 '' qprintf 'n1 y ' cocurrent <'loc2' qprintf 'n1 ' 'Locale at end of v2 is %j' printf 18!:5 '' n1 ) The verb v1 was defined in locale 'z' because it was an assignment to a locative; the verb v2 was defined in locale 'loc2' because it was an assignment to a simple name and the current locale at the time of its assignment was 'loc2' . cocurrent <'loc3' v2 =: [: Now the verb v2 is defined, with different values, in locales 'loc2' and 'loc3' . Next we define the noun n1 in each of our locales, so we can see which locale a name was found in: n1_loc1_ =: 'n1 in loc1' n1_loc2_ =: 'n1 in loc2' n1_loc3_ =: 'n1 in loc3' Now run the verbs. I will insert interpretation of the execution. v1 '' J searches for the simple name v1 in the current locale 'loc3'; not finding it there it looks in 'loc1', 'loc2', and 'z', finally finding it in 'z' . J executes the definition of the verb found in 'z', but without changing the current locale. Locale at start of v1 is loc3 Yes, the current locale is still 'loc3' ... n1=n1 in loc3 ...and a name lookup uses the current locale as the starting point. Locale at start of v2 is loc1v1 has executed v2_loc1_ . J starts searching for the name v2 in locale 'loc1' and its path, eventually finding it in 'z' . v2 is executed, using the definition found in 'z', but with the current locale set to the explicit locale of the locative, namely 'loc1' . ----- Question - why name v2 (last couple of lines), after being sought in 'loc1', is found in 'z' - and not in 'loc2'? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
