bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of Local Variables in Lambdas (Direct Functions) ?


From: Dr . Jürgen Sauermann
Subject: Re: Use of Local Variables in Lambdas (Direct Functions) ?
Date: Sat, 10 Jul 2021 18:00:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Yes, indeed.

If a lambda is more than one line then something must be wrong with it.


On 7/10/21 4:40 PM, Chris Moller wrote:
Hey, isn't it one of the proper characteristics of APL that you can do /anything/ in one line--if you're clever enough?  😁

On 7/10/21 5:19 AM, Dr. Jürgen Sauermann wrote:
Hi,

in my opinion lambdas should be as close to defined functions as possible
and local variables are one aspect of that.

Many lambdas are simpler with ⎕IO←0 so localizing ⎕IO is a frequent simplification.

The primary reason why GNU APL does not support multi-line lambdas is that the multi-line lambdas of same other APL interpreters have a return value semantics (like: the first not-assigned value is the return value) that differs from the return value semantics of defined functions (like: the last assigned value to the return variable
is the return value).

I did not think that having different semantics for lambdas and for defined functions is a good idea in the first place and therefore I did not implement multi-line lambdas.
There are also other complications when a lambda has more than one line.

Best Regads,
Jürgen


On 7/10/21 1:37 AM, Russtopia wrote:
Hi, reading GNU APL documentation, in the section 2.7 "2.7 Direct Functions (Lambdas)",

It states that lambdas do not support multiple expressions (amongst other features). If this is the case, what purpose does allowing local variable declarations serve?

Allowing

SUM ← { ⍺ + ⍵ ;C;D }
.. but not allowing multiple statements prevents assigning to C or D, or really using them at all, so what is the purpose of allowing their declaration? Please forgive me if I am missing something obvious here.
Thanks,
-Russ






reply via email to

[Prev in Thread] Current Thread [Next in Thread]