Assignment versus binding

Steve D'Aprano steve+python at pearwood.info
Tue Oct 4 20:34:23 EDT 2016


On Wed, 5 Oct 2016 06:10 am, Marko Rauhamaa wrote:

> Steve D'Aprano <steve+python at pearwood.info>:
> 
>> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:
>>
>>> Haskell defines let (it's version of multiple mutually recursive
>>> bindings) in terms of the least fix point of a lambda function whose
>>> (pattern) parameter binds the expressions in the definitions.
>>
>> It binds *the expression* itself? Not the value of the expression?
> 
> Don't know about Haskell, but in a truly functional programming language
> it wouldn't make a difference.

Unfortunately, there is no such thing as a "truly functional language",
because:

> A truly functional programming language wouldn't have side effects (in
> this case, it wouldn't sleep).

any real language[1] must perform computation, and computation has side-
effects: memory is used, power is consumed, the CPU warms up, and most
relevant to my example, calculations take time.

If you don't like my example of time.sleep(60) or 1, replace it by a very
long, very difficult, very time-consuming calculation that eventually
returns 1.

The point is, as Rustom explained, Haskell's evaluation strategy is
call-by-need which delays the evaluation of the expression but then caches
the result so it need only be evaluated once.



[1] That is, an interpreter or compiler for a programming language.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list