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
Sorry if I’m sending these twice; my mailer automatically sends them only to you Jürgen, so I end up forwarding them to the mailing list.
On 13 Aug 2016, at 10:19, Juergen Sauermann < address@hidden> wrote: 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 exampleto increment a counter on every iteration of the lambda. Of course
one can criticize the wayAPL handles variables, but the limited number of function
arguments and return valuesmakes the scoping rules of APL almost inevitable. And I still
believe that it is a bad thingif 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 headerline 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 argumentsof the EACH operator and friends; for serious functions ⎕FX and ∇
have all the features that are missingin 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
On 13 Aug 2016 8:05 pm, "Juergen
Sauermann" < address@hidden>
wrote:
|