Of what use is 'lambda'???

Duncan Booth duncan at rcp.co.uk
Wed Sep 27 04:31:10 EDT 2000


kragen at dnaco.net (Kragen Sitaker) wrote in <8Z5A5.22404$ve5.1005839 at news-
east.usenetserver.com>:

>"Strict" languages are those that use applicative-order reduction: they
>evaluate the arguments to a function before calling the function.
>Essentially all nonfunctional languages are strict. 

Not entirely true. Some Algol variants used call by name. In the version I 
was exposed to, parameters could be passed by value, result, value result, 
or the default if you didn't specify any of these was to pass them by name.

Call by name, for those that have been fortunate enough to escape it, 
allows you to give an expression as the argument to a function, but delays 
the evaluation of the expression until it is used. A typical example if 
python supported call-by-name might look like:

def addup(i, j):
    total = 0
    while i < 10:
        total = total + j
        i = i + 1
    return total

vals = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
index = 0
print addup(index, vals[index])

Python, thankfully, returns 90 as the result. If it used call by name, it 
would return 45.



More information about the Python-list mailing list