The point, as Raul has pointed out, is that 'execution' of the conjunction is not what you think it is. Raul said that conjunctions are executed twice, which is not quite right: the conjunction is executed once, to produce an anonymous verb, and then that verb is executed, at which time the text of the conjunction is interpreted.

Consider

vb =: + c_loc_ -

Assume c_loc_ is defined like
c_loc_ =: 2 : 0
u@v y
)

What is vb?

Answer: it is the result of executing c_loc_ . It is a verb, which contains the +, -, and text of c_loc_, saved for interpretation when vb is executed. The text of c_loc_ has not been executed.

What is the locale of vb?

Answer: whatever locale was in effect when it was defined. The loc locale has nothing to do with vb.

Why doesn't
   vb 3
execute in loc?

Answer: Why should it? c_loc_ has been executed and is a distant memory. vb contains the text that was in c_loc_, but it is not c_loc_, and is not in the loc locale.

What about
(+ c_loc_ -) 3
?  What locale does it execute in?

Answer: The locale that was in effect. Now there is no name vb, but the idea is the same: the verb (+ c_loc_ -) is an /anonymous verb/ and it is defined in the locale in effect. It executes in that locale.

Given
   vb_loc1_ =: + c_loc_ -
   vb_z_ =: vb_loc1_
   vb 3
what locale is in effect when the text of vb is executed?

Answer: loc1. Again, c_loc_ is long gone, and executing vb_loc1_ sets the locale to loc1.

Isn't this a bug?

Answer: No. To say otherwise would be to say that a derived verb must inherit locale from its components. Then there is a whole new set of problems:
  vb =: (+ adv_loc1) @ (- adv_loc2)
What would be the locale of vb?
  vb =: (+ adv_loc1) (- adv_loc2) (- adv_loc3)
What would be the locale of vb?

The current definition is clear and crisp, and hasn't revealed any insuperable problems.

JfC discusses this in more detail.

Henry Rich

On 11/16/2013 10:39 PM, Raul Miller wrote:
The issue, I think, is that (except for verbs) names are resolved to
their definitions before their definitions are used.

    require 'trace'
    trace 'verb_dog_ conj_cat_ %'
  --------------- 4 Conj -------
  verb_dog_
  2 : 'u&.(v inv)'
  %
  verb_dog_&.(%^:_1)
  ==============================

Notice how the verb is named and the conjunction is not.

I remember there being an explanation for this but I do not remember
if that was grounded in "efficiency concerns" or in dictionary.

Thanks,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to