And a third email about lambda locals.
IMHO, a solution could be to introduce an extra assignment arrow which denotes explicit
global assignment, and make the usual assignment arrow denote assignment which is
local to lambdas (or have it the other way around).
If the standard doesn’t allow something like this, maybe something along the lines of ⎕FX
like:
‘A’ ⎕LC data
‘A’ ⎕GL data
to denote explicit global or local assignment useful in lambdas or other places, whichever
is not chosen to be denoted by the already existing arrow, could be used.
I would argue that the current arrow be used for local assignment, because (aside from
personal taste) global assignment is more “dangerous” if inadvertently used. As in,
a person who wants to just throw together a quick lambda doesn’t usually want
or need the effects of global assignment unless they can explicitly say so.
Louis
Hi,
the problem is that there is no syntactical means to "state
otherwise".
I personally find it convenient to assign to variables outside the
lambda, for example
to increment a counter on every iteration of the lambda. Of course
one can criticize the way
APL handles variables, but the limited number of function
arguments and return values
makes the scoping rules of APL almost inevitable. And I still
believe that it is a bad thing
if the scoping rules of lambdas are different from the scoping
rules of "normal" defined functions.
So the only room for changes that remains is to have a way of
adding local variables to the header
line of lambdas. Something along the lines of:
FUN←'A B C'
⎕LOCALIZE { ... }
where A B and C would become local variables in the named lambda
FUN.
I would also argue that lambdas are only a quick-and-dirty hack
for specifying the function arguments
of the EACH operator and friends; for serious functions ⎕FX and ∇
have all the features that are missing
in GNU APL lambdas.
/// Jürgen
On 08/13/2016 02:11 PM, Elias Mårtenson
wrote:
With regards to lack of local variables for lambda
functions, I've observed that local is the typical case, and
nonlocal is somewhat rare.
Wouldn't it make sense to make all variable
assignments local for lambda functions local, unless stated
otherwise?
Regards,
Elias