04-11-2016, 08:54 AM
stomachcontents Wrote:Hi guys,Agree, but if the compilers adds a workaround about it, then the overload of doing so will make the FOR for uByte very suobptimal. I mean, FOR with Ubyte is very fast, because it does not check many things.
For the simple case of for a=1 to 255, that should totally work as a byte. Both values are in range. Its intuitive, and not unreasonable and certainly possible to implement. If "everyone bumps their head on this" then doesnt it make sense to fix it? Even if the value of a is 0 after the loop thats ok. But bombing out should not be acceptable or something every zx basic coder needs to add to a list of "stuff that doesnt work as u expect" in their heads.
If however the type is too small to fit the range then yeah, thats the coders problem
Just my 2 cents.
Will think more of this. Maybe a compiler flag like --check_overflow for this will work: if the programmer enable it, the code will run slower but will detect this (this is already done for Arrays, BTW)