[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

Here is one other proof

Ramine

12/28/2015 4:23:00 AM

Hello....


Look at this example in FreePascal and Delphi:

===
program test;

var a:integer;


procedure test(b:Longword);
begin
writeln(b)
end;

begin

a:=3;

try
test(a);

except
writeln('problem!');
end;
end.

==


If you compile this example in FreePascal with the -Cr option for
range checking, the example above will generate an exception because
at runtime you are trying to pass a negative number to the function
that receive a Longword, that means that receive in C an unsigned long,
so this technic will scale to a much more complex software that
is wrote for realtime safety critical systems.. but in C++ and C you
can not do that, but you can just test for the range of the variables,
but if the software is more complex and you forgot to test the range of
some variables and it causes a catastrophe at runtime, that`s not ok!
but with the technic above in FreePascal, you can catch the exception
easily and you can try to avoid a catastrophe on the realtime safety
critical system.


This is why C and C++ are bad.





Thank you for your time.


Amine Moulay Ramdane.









2 Answers

Ramine

12/28/2015 4:27:00 AM

0



Sorry, here is the write example:


===
program test;

var a:integer;


procedure test(b:Longword);
begin
writeln(b)
end;

begin

a:=-3;

try
test(a);

except
writeln('problem!');
end;
end.

==

Ramine

12/28/2015 4:29:00 AM

0


Sorry, here is the right example....


===
program test;

var a:integer;


procedure test(b:Longword);
begin
writeln(b)
end;

begin

a:=-3;

try
test(a);

except
writeln('problem!');
end;
end.

==