Embedding an inner tacit definition within an explicit definition allows
the tacit definition to use local names where were it written as explicit
the local names are not visible.
doit0=:3 : 0
a=.'abc'
t=.{&a
t y
)
doit1=:3 : 0
a=.'abc'
t=.3 : 'y{a'
t y
)
doit0 1
b
doit1 1
|syntax error: t
| t y
Of course, the fun happens when the value of the local name changes between
the tacit definition and its use.
doit2=:3 : 0
a=.'abc'
t=.{&a
a=.'def'
t y
)
doit2 1
b
It's neat to put things on the forum. I struggled trying to avoid creating
a global name then Dan tosses out another approach just off the top of his
head.
On Sun, Jun 1, 2014 at 12:01 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:
> I don't know what you mean by " A tacit definition can reference the
> caller's local names"
>
> Do you mean the values in base, or there is a way to access local
> variables inside another function?
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm