In this context, I think the J implementation of a "lambda" would be what
we call an "explicit verb". It's not the same as Scheme, nor K2.8 - more
like K4. In J you can have tacit verbs which which have full access to the
names in explicit verbs. But that's not because they are "sub functions" -
it's just a reflection of how name resolution works. Each explicit verb
gets its own local context for its names, while tacit verbs in the general
case do not have names. (I could make this more technically precise but I
think that's enough for your issue.)

In Scheme, you have the concept of nested blocks which inherit context from
their containers. J doesn't do that. Instead, if you want that in J, you
use locales (which are roughly equivalent to the K tree, except only one
level deep, and with a per-locale concept of a search path for resolving
otherwise undefined names).

If you want to search for things other people have written about this
subject in the context of Scheme, I'd try searching on "scheme closure" or
"lexical closure".

See also: http://www.jsoftware.com/jwiki/Guides/Lexical%20Closure

Thanks,

-- 
Raul



On Fri, Mar 21, 2014 at 10:47 AM, Tom Szczesny <[email protected]> wrote:

> My question concerns lambdas, implict parameters, and scoping.
> (I'm not sure what lambdas are called in J.  In some languages, like K,
> they are called subfunctions.)
>
> We are working on issue in Kona, see
> https://github.com/kevinlawler/kona/issues/220
> and I need to check how other languages (like J or Scheme) handle the
> issue.
>
> Suppose lambdas are supported and implicit parameters for functions are
> supported.
> An example in K would be {{[a]a,x}}[1][2]
> Let's call the parent function f, and the child function g.
>
> f has 2 parameters: [1] and [2]
> f has no arguments at the parent level to bind to any parameters.
>
> g has 2 arguments: one explicit [a], and one implicit [x], but no
> parameters at the subfunction level
> g simply catenates the arguments a and x.
>
> K3.2 (and K2.8) yields 2 1 as a result.
> Kona yields (2;) as a result (a heterogeneous list of 2 elements: 2 and
> null)
> There are arguments for both approaches (which are outlined in the issue
> discussion thread).
>
> Question: Can a similar case occur in J, and what does J yield as a result?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to