mastaraymond
2010-05-09 14:13:37
We should stop using the type Byte when there is no explicit reason you should use it. Why?
Well there are 2 'bugs' with using Bytes.. First of all PascalScript (the interpreter inside SCAR&Simba) doesn't handle them too well.
When you add up 2 bytes, it will result a byte.. Even if you expect it to return an Integer.. See the following code:
Yes, I know that SRL wrongly uses Bytes in several places. I will try to change this accordingly when I've got some time.
Well there are 2 'bugs' with using Bytes.. First of all PascalScript (the interpreter inside SCAR&Simba) doesn't handle them too well.
When you add up 2 bytes, it will result a byte.. Even if you expect it to return an Integer.. See the following code:
program New;
var
x,y : byte;
z : integer;
begin
x := 200;
y := 100;
z := x + y;
writeln(inttostr(x+y));
Writeln(inttostr(z));
end.Second of all bytes cannot hold a negative number, which isn't a problem in most cases.. However, it's common for functions to return a negative number if the function fails. So when using a byte, this negative number will be translated into some semi-random positive number and therefore ruin your script.Yes, I know that SRL wrongly uses Bytes in several places. I will try to change this accordingly when I've got some time.