Below is a little playing around with adverbs and verbs created with the
adverbs. It shows when the adverbs execute and when they don't, depending
on the type of verb created. It also shows that the adverbs finish before
the created verbs run as local names in the adverbs are not used in the
created verbs.

There are two adverbs - insertim which creates a tacit verb and insertex
which creates an explicit verb.

I just read through what I pasted to make sure it's okay. But as reading
through it I couldn't decide if testex is really explicit or tacit. Oh well!



   erase 'lim gim lex gex'
1 1 1 1

   insertim=:1 : 0
echo 'Insertim runs'
lim=.11 12 13
gim=:14 15 16
u/
)

   insertex=:1 : 0
echo 'Insertex runs'
lex=.21 22 23
gex=:14 15 16
u/y
)

   NB. Defines for inserts done

   4!:0 ;:'lim gim lex gex'
_1 _1 _1 _1

   testim=:+insertim
Insertim runs

   NB.Defined a verb using insertim

   4!:0 <'lim'   NB. is not defined
_1
   4!:0 <'gim'   NB. is defined but resultant verb did not execute
0
   gim
14 15 16

   gim=:1 2 3
   testim NB. The result is an implicit verb.
+-+-+
|+|/|
+-+-+
   gim    NB. insertim did not run
1 2 3

   lim=:1 2 3
   testim lim    NB. The value of lim is not localized
6
   gim           NB. gim unaltered
1 2 3

   +insertim lim
Insertim runs
6
   NB. The value of lim set in insertim is not used
   NB. and insertim ended before the created verb ran
   gim           NB. This time insertim runs
14 15 16

   gim=:100 200 300

   testim lim
6
   gim    NB. insertim did not run
100 200 300

   erase 'lim gim lex gex'
1 1 1 1

   NB. Now try with insertex

   4!:0 ;:'lim gim lex gex'
_1 _1 _1 _1

   testex=:+insertex
   NB. insertex did not run yet because it needs y

   NB.Defined a verb using insertex

   4!:0 <'lex'   NB. is not defined
_1
   4!:0 <'gex'   NB. is not defined
_1

   gex=:1 2 3
   testex NB. The result is an explicit verb which includes insertex.
+-+--------------------------+
|+|+-+-+--------------------+|
| ||1|:|echo 'Insertex runs'||
| || | |lex=.21 22 23       ||
| || | |gex=:14 15 16       ||
| || | |u/y                 ||
| |+-+-+--------------------+|
+-+--------------------------+
   gex    NB. insertex did not run
1 2 3

   lex=:1 2 3
   testex lex    NB. The value of lex is not localized
Insertex runs
6
   gex           NB. gex is altered as insertex ran
14 15 16

   gex=:1 2 3
   +insertex lex
Insertex runs
6
   NB. The global value of lex instead of lex in insertex
   gex
14 15 16

   gex=:100 200 300

   testex lex
Insertex runs
6
   gex    NB. insertex did run
14 15 16
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to