On Mon, Feb 19, 2018 at 9:24 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > On Mon, 19 Feb 2018 09:40:09 +0100, Alain Ketterlin wrote: > >> Tim Delaney <timothy.c.dela...@gmail.com> writes: >> >> [...] >>> As others have said, typing is about how the underlying memory is >>> treated. >> >> No. It is much more than that. Typing is about everything you can say >> about a given statement. > > "Everything"? Truly *everything*? > > Given: > > # engage the type system somehow... > # declare a, b, c: non-negative integers > a = abs(int(input("Give me an integer"))) > b = a*a > c = (a+1)*(a+1) > > can you give me an example of a type-system which is capable of telling > me that: > > if (c - b) % 2 == 1: > print("hello world") > else: > fire_missiles() > > will never fire the missiles? > > I'd be impressed enough with a type system that knew that a%2 was always > 0 or 1, although I suppose there could be some that already know that. > > Hell, I'd even be impressed if it could tell that c was not zero... >
A type system, per se? I don't think so. But static analysis CAN figure out that sort of thing (obviously, since we as humans can do it), and I wouldn't be surprised in the least if tools like Coverity could detect this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list