Re: [Python-ideas] Thunks (lazy evaluation) [was Re: Delay evaluation of annotations]

2016-09-26 Thread אלעזר
You already know I want this for contracts etc.. Here some things that I consider important: 1. There should be some way to bind the names to function parameters, as in @contract def invert(x: `x != 0`) -> float: return 1 / x @contract def invertdiff(x: int, y: `x != y`) -> float

Re: [Python-ideas] Thunks (lazy evaluation) [was Re: Delay evaluation of annotations]

2016-09-26 Thread Joseph Jevnik
Hello everyone, this idea looks like something I have tried building already: https://github.com/ll/lazy_python. This project implements a `thunk` class which builds up a deferred computation which is evaluated only when needed. One use case I have had for this project is building up a larg

Re: [Python-ideas] Thunks (lazy evaluation) [was Re: Delay evaluation of annotations]

2016-09-26 Thread Sjoerd Job Postmus
On Mon, Sep 26, 2016 at 10:46:57PM +1000, Steven D'Aprano wrote: > Let's talk about lazy evaluation in a broader sense that just function > annotations. > > If we had syntax for lazy annotation -- let's call them thunks, after > Algol's thunks -- then we could use them in annotations as well as

Re: [Python-ideas] Thunks (lazy evaluation) [was Re: Delay evaluation of annotations]

2016-09-26 Thread Steven D'Aprano
On Mon, Sep 26, 2016 at 10:46:57PM +1000, Steven D'Aprano wrote: > Let's talk about lazy evaluation in a broader sense that just function > annotations. > > If we had syntax for lazy annotation -- let's call them thunks, after > Algol's thunks Er, that should be lazy evaluation. Or at least de

[Python-ideas] Thunks (lazy evaluation) [was Re: Delay evaluation of annotations]

2016-09-26 Thread Steven D'Aprano
Let's talk about lazy evaluation in a broader sense that just function annotations. If we had syntax for lazy annotation -- let's call them thunks, after Algol's thunks -- then we could use them in annotations as well as elsewhere. But if we special case annotations only, the Zen has something

Re: [Python-ideas] Delay evaluation of annotations

2016-09-26 Thread אלעזר
Thank you all. I think this thread is pretty much close by now. I understand at least most of your concerns and I will take time to shape my idea. I wanted to note one last thing, though, regarding my claim that annotations are not actually standard expressions: Guido had once expressed his concer