mode_z_ =: 2 : '([: v inv u hook v) finallyC (v inv) ' NB. v y must return y
finallyC_z_ =: 2 : 'u :: ((v)][:13!:12(''''[]))
hook_z_ =: 2 : ('u v y' ;':';'x u v y')
plus =: +
bizmode =: (3 : 0 :. (3 : 0))
plus =: +
y
)
plus =: *
y
)
this works as intended: mode switches definition of plus, then switches back
after executing u
3 plus mode bizmode 3
9
plus
+
The bug is in finallyC, (::) . I'd expect that if there is any error in u, it
should execute v, but:
3 +: mode bizmode 2
|domain error
| 3 +:mode bizmode 2
plus__a
*
Is the problem that hook is an explicit conjunction?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm