Newsgroups: comp.lang.apl
Path: watmath!watserv1!70530.1226@compuserve.com
From: Mike Kent <70530.1226@CompuServe.COM>
Subject: Packages / PACKAGEd WSs / namescope isolation
Message-ID: <920523210605_70530.1226_CHC47-1@CompuServe.COM>
Sender: root@watserv1.waterloo.edu (Operator)
Organization: University of Waterloo
Date: Sat, 23 May 1992 21:06:05 GMT
Lines: 39

The packages provided in Sharp APL are indeed a nice facility, _but_ they
don't really help with namescope isolation.  Suppose you have a function
FN and a package PKG in your ws:  " 'FN' []PDEF PKG "brings the package
version of FN into the active ws ... overwriting the original version.
I have seen (and written) schemes to get around this by []FXing a fn
where all the names from a package (actually, an emulation under APL2)
are localized, the []PDEF is doen, and then the real work gets underway.
This does _some_ of what is needed, but you really ought to grab 
[]NL 2 3 4 and localize all those names too, plus examining all the fns
in the package and localize any globals which they assign ... can you
imagine doing this for any but the most trivial cases?

The IBM packaged-workspace solution (not the PC exectable-file builder,
but rather the mainframe load module builder) OTOH, provides for
controlled visibility of names in both directions.  By default, all the
names in the load-module-ized WS can be made visible (that is, you can 
associate to them via []NA), but you can supply a list at packaging time
which will restrict the potentially visible names to only what you want to
make accessible.  In any case, in the outer world (where you do the []NA
from) names in the inner world are _not_ visible until you do the []NA,
and " left_arg []NA 'ALIAS REAL_NAME' " lets you select the name by which
an accessible entity is to be known.  Assignment of globals, creation of
new fns/ops, etc. produces entities which are _not_ reachable (except by
trickery) from the base namescope.  

Going in the other direction, names don't "leak" into the inner scope
either.  There are ways (" 0 []NA ... " and the EXP supplied external 
function) for reaching back to the base or to the previous name scope, 
but only that which you explicitly ask for is accessed.

I said about a week ago that this is, IMO, the most significant
enhancement to APL since general arrays.  That may be a little exagerated;
the whole issue of access to the external-to-APL environment (in the 
IBM case via the original []NA, in the STSC case via []CALL/[]XP/[]NA,
in the IPSA case via something else) is probably more important.  But this
true namescope isolation with selective permeability is not very much
less so.  I wish it were available with APL2/PC ...


