/!\ DRAFT DRAFT DRAFT /!\

Fix Local Names

This paper introduces fl, an adverb like f. which fixes only local names.

motivation

A long standing wish in the J community is for an adverb like f. which fixes a name (recursively) iff it is defined locally. The primary desires motivating the request are for:

  1. A safe method to pass around definitions containing local names, without changing the definitions otherwise: example.

  2. A way to decompose long definitions without cluttering the namespace or losing important relationships between (globally) named entities: example.

  3. The ability to fix (certain) definitions without breaking J's debug facilities: example.

Each of these desires could be satisfied if we had a mechanism to indicate which names we want fixed, and fix only those.

Fortunately, J provides an easy indication mechanism: local assignment. Local names are ephemeral by design; they will go out of scope. If the entities which depend upon them are to function outside of that scope, the local definitions must be fixed.

Unfortunately, J does not provide a native way to fix only local names (or even detect if a name is local). This paper addresses that need.

implementation

definitions

All the utilities discussed herein are defined by the namescope script. The script is still in early beta; please test it and report any bugs to me. When J602 and the attendent JAL are released, I will publish a 'fix locals' addon.

The definitions you'll find most useful are:

Examples are given in the next section.

examples

the problems

fread y : if. 1 = #y=. boxopen y do.

dat=. 1!:1
_1: fboxname y

else.

dat=. 1!:11
_1: (fboxname {.y),{:y

end. if. dat -: _1 do. return. end. if. (0=#x) +. 0=#dat do. dat return. end. dat=. (-(26{a.)={:dat) }. dat dat=. toJ dat if. 0=#dat do. $~ 0 $~ >:'m'e.x return. end. dat=. dat,LF -. {:dat if. 'b'e.x do. dat=. <;._2 dat elseif. 'm'e.x do. dat=. ];._2 dat end. )}}}

Of course, each of the bullets above could be addressed with some simple code changes, but that's only because they are contrived examples. The general solution is fl, as described in the next section.

the solution

caveats

notes

references

Requests for fl (or similar, or associated) behavior:

DanBron/Temp/Fix Locals (last edited 2008-12-08 10:45:37 by )