O.K., let me try another tack.
If an inexperienced J user could add features of tacit J gradually,
the J learning curve would be smoother, tacit programming would
have broader use and J would have broader appeal. I am going to
propose one addition in an attempt to do this.
The verb compositions work equally well in both forms of J.
For example, in regular J:
%: 3 +&*: 4
5
%: +/*:(- +/ % #) 2 4 9 6
5.17204
(- +/ % #) is a monadic verb expression that takes in the
argument from its right and passes on the result as the argument
of the monadic verb on its left, "*:" Despite the fact that the verbs
within do not follow the right to left rule, the complete expression does.
.
A problem arises when other code comes between this verb
composition and the argument it wants. For example, when we try to
calculate standard deviation:
%: (+/ *: (- +/ % #)) % <: # 2 4 9 6
|domain error
| %: (+/*:(-+/%#))%<:#2 4 9 6
The argument passed to (- +/ % #) is not the 2 4 9 6 we want, but the
whole expression to its right: % <:# 2 4 9 6. The only way we can ensure
that the argument for (- +/ % #) is 2 4 9 6, is to enclose the whole
expression in parentheses:
( %: (+/*:(- +/ % #)) % <:#) 2 4 9 6
|domain error
| (%:(+/*:(-+/%#))%<:#)2 4 9 6
Unfortunately, this doesn't work either, because the outer parentheses
cause J to treat all contents between these parentheses as a train of
forks and hooks instead of right to left J code. To compensate, we need
"@:" and "[:" conjunctions.
([: %: +/@:*:@:(- +/ % #) % <:@#) 2 4 9 6
2.98608
The parentheses around the whole expression do two things:
1) They define the where the argument for the tacit expression (- +/ % #)
is to be found.
2) They define the content within the parentheses to be a train of forks
and hooks.
What would make the transition to tacit J easier for inexperienced J
J users would be the first outcome without the second, to define
where the argument can be found while allowing the total expression to
remain right to left J code. One way of doing this would be to include
the whole expression within Inside-out parentheses:
)%: (+/*:(- +/ % #)) % <:#( 2 4 9 6
We now have:
1) a regular right to left expression
2) containing a verb composition of combined forks an hooks, for which
3) we have defined where the right argument is to be found
- to the right of the "("
4) where the left argument would have been found - to the left of the ")"
- if there had been a left argument,
5) the opportunity to begin using tacit J incrementally.
6) no change in J for experienced users - who can continue using J
exactly as they do now.
We can now assign a name to this expression:
sd=: )%: (+/*:(- +/ % #)) % <:#(
The conjunctions "@:" and "[:" are still needed by the inexperienced
user in fork/hook compound verbs as they expand their tacit experience,
but the point is that the change can be made gradually.
There is one disadvantage. We have one extra set of parentheses. "@:"
does act in lieu of parentheses. However, as the inexperienced user
gains more experience, he/she has the choice of converting when ready.
Don Watson
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm