Unfortunately I have to add another bit of complication, after which you will know everything.

What does it mean to "execute a@b"?

There are actually two things going on: the execution of the CONJUNCTION @ and the execution of the VERB (a@b).

@ is a conjunction. It takes two operands, which can be nouns or verbs. Execution of @ produces a verb.

When the interpreter sees

a @ b

in an executable position (defined below), it executes @ . Stop and think about this. There is not a noun in sight. Executing @ does not produce a noun result.


What does it produce?
  A verb.

What verb?
  The verb (a@b).

What does that verb do?
It operates according to the rules of the Dictionary, and executes b followed by a. It also has a rank, defined by the Dictionary.

Does this verb have a name?
  No.

Suppose I want to use this verb somewhere else?
  You must assign it to a name.

What if I don't assign it to a name?
  It disappears after it has been used.

Can I display this verb-with-no-name?
Yes, just type a@b as a sentence by itself. The result of this sentence is the anonymous verb we're talking about, and Roger displays the value - which is a verb.

I did that.  The display is just  "a@b".  What does that mean?
  It means, "the verb that does what the dictionary says a@b will do."

That doesn't tell me anything I didn't know.
  You got a better idea?


ONCE a@b HAS BEEN "EXECUTED", producing the anonymous verb, the sequence (a@b) is replaced by the anonymous verb. What should we call that verb? Usually we just write it as "a@b", using the description to take the place of the missing name. For this discussion we'll call this anonymous verb "av1".

So our original

((a@b)@c)@d

has turned into

(av1@c)@d

and next is to execute

(av1@c)

to create a second anonymous verb "av2" that is described as (av1@c). Finally we execute

av2@d

to produce "av3" described as (av2@d).

av3 is a verb. We have still not executed any verb, or seen any noun. If we assign av3 to a name, the whole sentence could end without ever seeing a noun, and the result would be the verb created by the executions of all those @'s.


FINALLY we can talk about executing the verb av3. To do this we would have a noun to its right, as in

a@b@c@d 12

which, after executing the @'s as described above looks like

av3 12

NOW av3 executes. It is "the verb that does d followed by av2", and so its execution will result in executing d, av2, and ultimately c, b, and a.

That's execution in J. Execution of modifiers and verbs, in the correct order.

But what specifies the correct order? What is the 'executable position' mentioned above? This is what the parsing rules specify.

Let's look at

a@b@c@d 12

Parsing goes right to left.  Pretty soon the parser is looking at

... c @ d 12

Hey, that's a verb followed by a noun, like (<'a').  Can we execute (d 12)?

No, because what we have is

verb conj verb noun

and the parsing table calls for

[end =. =: ( adv verb noun] verb verb noun

No match, so we keep looking. How about executing c@d to produce a verb? The parser would be working on

... @ c @ d

which is

conj verb conj verb

but the parsing table needs

[end =. =: ( adv verb noun] [verb noun] conj [verb noun]

Our first word is @, a conj, which doesn't match the first word of the line. No match. If it were

... / c @ d

it would execute the @ .  As it is, we have to keep looking.

Eventually the parser gets to

end a @ b

And that matches, as end verb conj verb . @ is executed, and now the sentence looks like

end av1 @ c

which also matches, and thus the sequence a@b@c@d gets parsed, leaving

end av3 12

which matches the line of the parsing table

[end =. =: (] verb noun anything

and finally, av3 12 is executed: the one and only time in this sentence that the parsing table executes a verb. All the other verbs are executed by the execution of av3.

On 1/22/2016 1:49 PM, Brian Schott wrote:
The original message was correct, not this one.
I am very sorry for the confusion.

​Henry and Raul,

Thanks for your replies to the message.
I am still trying to sort out the examples with the MIDDLE TINE and am
optimistic with dissect and the detail Henry gave. However, it sounds like
magic or double talk to say the following because the parenthesis part
suggest a@b is parsed first ​but that execution starts with d. It never
occurred to me that execution could be in a different order from parsing.
WOW.

​"Thus, a@b@c@d is parsed as ((a@b)@c)@d

"Then, when it's executed, ((a@b)@c)@d executes d first, followed by c, b,
a; so you get right-to-left execution of the verbs.​"


On Fri, Jan 22, 2016 at 10:55 AM, Brian Schott <[email protected]>
wrote:

[Sorry, that was a mistake. This is a resend]

    #@:>@:;:'a man a plan a canal'     NB. 1
6
    #@:>@;:'a man a plan a canal'     NB. 2
6
    #@>@;:'a man a plan a canal'     NB. 3


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

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

Reply via email to