Has this come up before.
In the example below an explicit verb itself contains the definition
of explicit verb, but assigned to a local name.
This local explicit verb sets the value of a global variable.
The container verb references this global variable.
The container verb throws a value error on the first invocation - but
not on the second and subsequent invocations.

Is this a  bug - or perhaps it is documented somewhere...
(behaves same in previous version)

NB. contents '1.ijs'

invocation=:0
4!:55<'r'
foo=: 3 : 0
2(1!:2)~ 'invocation=';invocation=:>:invocation
goo 2
)

goo=: 3 : 0
poo=. 3 :'r=:''value of r ='';y+1999'  NB. r is global;poo is local
(100+y);r;poo 1
)

NB-----------------------------------------------------------------------

   load 'C:\Documents and Settings\david\j602-user\temp\1.ijs'
   foo 3
+-----------+-+
|invocation=|1|
+-----------+-+
|domain error: goo
|   (100+y);r    ;poo 1


NB. variable has been assigned within verb poo
   r
+------------+----+
|value of r =|2000|
+------------+----+



   foo 3
+-----------+-+
|invocation=|2|
+-----------+-+
+---+-------------------+------------+----+
|102|+------------+----+|value of r =|2000|
|   ||value of r =|2000||            |    |
|   |+------------+----+|            |    |
+---+-------------------+------------+----+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to