currently the following code generates a domain error at the ('f') =: y
line.
testlocal =: 3 : 0
f =. 33
assign =. 4 : '(x) =: y'
'f' assign f + y
('f') =: f+y
NB. f =: f+y
f
)
testlocal 2
|domain error: testlocal
| ('f') =: f+y
f
35
the commented line also generates the same error.
My suggestion is that all of the above code lines should leave the global
variable f unchanged. The user benefit is being able to use external functions
that create assignments (can only use =:) with the "shaddowed" local variable.
Includes benefits of modifying x,y,u,v while only mentioning the parameter once
in a statement, and possibly allowing changes to values within tacit
expressions without relying on global/external variables.
I claim that there would not be any impact to existing user code, because =:
after =. is currently a domain error, and calling an external assignment
function on a name that duplicates a local assignment is more likely to be
unintended behaviour rather than a clever way around the domain error that
would occur under direct global assignment. Advice to function writers to name
their local variables differently than the globals they access is under their
control. Though the simple convention of not naming local variables to the
same names as accessed globals is quite sufficient, an additional workaround
could be made that a fully localed name would access the global.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm