On Sat, Aug 08, 2020 at 08:13:53PM -0400, David Mertz wrote:

> Yes, this is absolutely doable! I guess my argument in several posts is
> that this simple level of analysis of "possible bounds violation" is rarely
> useful (at least in a Python context[*]). Vastly more complicated formal
> proofs might be useful... But, y'know, way more work for tools.
> 
> [*] For languages with bounded data types, this is more compelling. If I
> think a variable will *definitely* fit in a uint8, having the static tool
> tell me it might not is powerful.

    uint8 = int[0:256]

So if it's useful to know that something might violate the type uint8, 
surely it is just as useful to know that it might violate the range 
int[0:256].

For what it's worth, I have often had IndexErrors from indexing into a 
list or string that were a bugger to debug. But it is one thing to have 
a static checker that can tell me if i might exceed the bounds 0...256 
and another that can tell me if i might exceed the bounds 0...N where N 
is not known until runtime. I suppose this is why bounds checking so 
often gets turned into runtime checks, but Python already has that: you 
get an IndexError, not a seg fault.


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7XOKPBIRTJG7VCCQS4L7NTCDENMAOUDT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to