Hello...
We have to be more smart about C++
I think that C++ as it is, is not well suited for realtime systems
and realtime critical systems.. you have to add over it
Extended static checking (ESC) etc. so that C++ be acceptable
or here is one of my other solution to the problem that i have
talked about: As you have noticed i have spoken before about the how to
disallow conversion from negative signed to positive unsigned, here is
my solution with variants, also you can extend this solution with
objects contains variants that represent different types and the
functions that works with them like Add and Multiply and Divide etc :
Here is the solution that works also with C++Builder , since
C++Builder has a good implementation of variants
As you know i am working with Delphi and FreePascal and C++..
And now about Software Reliability:
Extended static checking (ESC) can identify a range of errors which are
currently outside the scope of a type checker, including division by
zero, array out of bounds, integer overflow and null dereferences,
this can be done with Delphi and FreePascal compilers.
Furthermore, extended static checking aims to report errors by
exploiting user-supplied specifications, in the form of pre- and
post-conditions, loop invariants and class invariants, this can
be done by assertions in Delphi and FreePascal.
Read more here:
http://whiley.org/2010/06/26/what-is-extended-static-checking/
Also read this about Software reliability:
"Both Rust and Spark languages implement a number of static and dynamic
checks directly in the language definition. For example, they implement
strict-type safety; that is, objects can’t be implicitly converted from
one type to the next. The following doesn’t compile in SPARK"
Read more here:
http://www.electronicdesign.com/industrial/rust-and-spark-software-reliability-everyone
Here is how you can have strict-type safety in Delphi and FreePascal,
here is a Delphi program that shows an example using variants:
--
program test;
uses VARIANTS,SYSUTILS;
var f:double;
a:integer;
FUNCTION ASSIGN(a,B:VARIANT):VARIANT;
begin
IF VARTYPE(A)=VARTYPE(B) THEN
BEGIN
A:=B;
RESULT:=A;
END
ELSE RAISE EXCEPTION.CREATE('ASSIGNEMENT NOT OK');
end;
begin
a:=2;
f:=a;
A:=ASSIGN(F,A);
end.
--
Here is the Vartype function:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Variants_VarType.html
Thank you,
Amine Moulay Ramdane.