David Vincent-Jones wrote:
> completes with x but is an error for y
You defined and invoked a MONADIC verb, hence the name x was not predefined
locally (but y was). A dyadic definition/invocation will barf on x too:
test =: 4 : 0 NB. Note: 4 , not 3
x=:3+4
y=:1+2
)
test''
|domain error: test
| test''
Roger, please consider creating a new exception for this error. "Domain error"
is overloaded already; it's even borne "valence error"'s responsiblity since
J5. Maybe:
9!:9 (<'assignment error') 14} 9!:8''
>Then allows both x and y
The assignment error is only possible within an explicit definition. It occurs
when the LHA of a global copula =: is already a local name. That usually
means it previously appeared on the LHS of a local copula =. in the
definition.
However, the names x y u v m n are special in an explicit definition. When an
explicit definition is invoked with arguments, J will automatically,
transparently and locally assign those arguments to some of these names.
Hence they become pre-defined local names, and cannot be reassigned globally.
Note that not all of these names are assigned locally in every explicit
definition; it depends on the class and invocation specifics of the explicit
definition.
Outside of an explicit definition (i.e. in immediate execution mode), the
concept of "local assignment" has no meaning. Local and global copulae have
the same meaning. Hence, the names x y u v m n are not special and can be
assigned (and reassigned) willy-nilly. This was also possible previously with
the names x.y.u.v.m.n. . Try x. =. 42 in the IJX window of J5. It works.
Regardless of the reasons, I agree with your conclusion. As a matter of
practice it's better to avoid using the "special" names as global, 'cause
they'll be sometimes they'll be shadowed by local names, and it'll be an
error-prone hassle, in general, to refer to their global counterparts.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm