On 02/07/18 23:13, Wolf wrote:
Not so long ago, Florian was proudly bragging about "Pascal does not
allow you to shoot yourself in the foot
<http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html>"
What about this little program:
program Project1;
var a,b: byte;
begin
a:=1;
b:=a*(-1);
writeln(b); // result: 255
end.
The result is obviously correct, given how the variables are declared.
But there are no compiler warnings / errors that the assignment
b:=a*(-1) is fishy, to put it mildly. And if you are serious about
strong typing, it ought to be illegal, with a suitable complaint from
the compiler.
Who is shooting whom in the foot?
Wolf
If you compile with range checks on, you get a runtime error.
Colin
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal