[Python-ideas] One more time... lambda function <--- from *** signature def.

Masklinn masklinn at masklinn.net
Thu Mar 6 00:07:06 CET 2014


On 2014-03-05, at 22:51 , Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Masklinn wrote:
>> On 2014-03-04, at 23:31 , Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>>> But Algol has the benefit of static typing 
>> That's not really a blocker though, Haskell thunks are implicit and not
>> type-encoded. A name may correspond to a (unforced) thunk or to a strict
>> value
> 
> That comes at the expense of making *everything* a thunk
> until its value is needed.

Of course not, Haskell allows explicitly forcing a thunk and the
compiler/runtime pair can use strictness analysis and not create thunks
in the first place.

> This would be a big, far-reaching
> change in the way Python works.

Having Haskell-type thunks does not mean using the same default as
Haskell. Python would have the opposite one, instead of creating thunks
by default it would create them only when requested.

> Also, Haskell has the advantage of knowing that the value
> won't change

I do not see why that would be relevant to thunks. The result of the
thunk may be mutable, so what?

> so it can replace the thunk with its value
> once it's been calculated. Python would have to keep it
> as a thunk and reevaluate it every time.

See above, I do not see why that would happen. Consider that a thunk is
a deferral of an expression's evaluation, why would said expression's
evaluation happen more than once? The only thing which changes is *when*
the actual evaluation happens.

> And Haskell doesn't have to provide a way of passimg the
> thunk around *without* evaluating it.

Well no, instead it takes the sensible option to force thunks when they
need to be forced (or when their forcing is explicitly requested e.g.
using ($!) or "bang pattern" extensions, but the need for those is
mostly because haskell defaults to creating thunks I would say). Why
would passing a reference around force a thunk in the first place?


More information about the Python-ideas mailing list