Mark Shannon wrote: > Unless of course, others may have a different idea of what the "type of > a variable" means. > To me, it means it means that for all assignments `var = expr` > the type of `expr` must be a subtype of the variable, > and for all uses of var, the type of the use is the same as the type of > the variable. I think it means that, at any given point in time, the value of the variable is of the type of the variable or some subtype thereof. That interpretation leaves the type checker free to make more precise inferences if it can. For example, in... > def foo()->int: > x:Optional[int] = bar() > if x is None: > return -1 > return x ...the type checker could notice that, on the branch containing 'return x', the value of x must be of type int, so the code is okay. -- Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4