Monday, December 28, 2015

Digest for comp.lang.c++@googlegroups.com - 25 updates in 9 topics

Ramine <ramine@1.1>: Dec 28 12:54PM -0800

Hello.....
 
 
Here is the exception that you can catch in FreePascal if
you compile with the -Co option:
 
 
try
 
except
on EIntOverflow do HandleIntOverflow;
end;
 
 
And that's better than C++ and C, because on a more complex realtime
safety critical systems if you forget to test the overflow or underflow
you can risk more , but in FreePascal you can also catch the
EIntOverflow exception and this exception works for both
signed and unsigned 32 bit or 64 bit variables for multiplication
division and add etc. and that's better than C++ and C.
 
 
 
Thank you,
Amine Moulay Ramdane.
bleachbot <bleachbot@httrack.com>: Dec 28 02:22AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 02:27AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 02:28AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 02:30AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 02:39AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 03:05AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 03:09AM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 03:43AM +0100

ram@zedat.fu-berlin.de (Stefan Ram): Dec 28 03:43AM

-- off topic --
 
>> program test;
>In original Pascal, as I recall, you had to indicate in the above
>statement that you'd be using the standard input and output streams.
 
I only see »writeln« below, if that's all,
»PROGRAM test( output );« should suffice.
 
>"Longword" was not an original Pascal type. I doubt that it's part of
>standard Pascal.
 
»Standard Pascal«? Do you refer to ISO 7185:1990 or
ISO 10206:1990? Well, you do not have to bother to answer,
as probably both of them do not contain »Longword«.
bleachbot <bleachbot@httrack.com>: Dec 28 06:23PM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 06:42PM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 06:54PM +0100

Ramine <ramine@1.1>: Dec 28 12:24PM -0800

Hello.....
 
 
How can you test for signed int overflow..
 
Here is how you can do it in C and C++:
 
===
#include <limits.h>
int a = <something>;
int x = <something>;
if ((x > 0) && (a > INT_MAX - x)) /* `a + x` would overflow */;
if ((x < 0) && (a < INT_MIN - x)) /* `a + x` would underflow */;
/* ... same thing for subtraction, multiplication, and division */
===
 
 
But notice with me that this method in C and C++ is not
acceptable for realtime safety critical systems, because
on a more complex software for realtime safety critical systems,
you can forget to test for overflow of the integer and this can have a
bad consequence and even a catastrophe, so C++ and C are bad.
 
But with the Delphi mode of the FreePascal compiler you can do this:
 
Compile with -Cr(for range checking) and compile with -Co(for Integer
overflow checking), so even if on a more complex software for realtime
safety critical system you have forgot to test for for overflow of a
signed int or an unsigned integer , you can effectively catch the
exception of the overflow signed int or unsigned int with a Try Except
End; in the Delphi mode of FreePascal if you compile block with -Cr and
-Co, and that's better in FreePascal for realtime safety critical
systems, note also that i have just tested FreePascal with -Co and it
works for both overflow of a signed int or an unsigned int.
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 28 12:42PM -0800

Hello....
 
 
I have just tested -Co compiler option of the FreePascal
compiler, it will throw an exception that you can catch
from the software for both overflow and underflow.
 
 
Thank you,
Amine Moulay Ramdane.
David Brown <david.brown@hesbynett.no>: Dec 28 01:15PM +0100

On 22/12/15 07:46, StuartRedmann wrote:
 
>> Wouter
 
> C# has named parameter association, and C# was intended to be a
> successor of C++ (although I have no source for this):
 
C# was created as MS's alternative to Java after MS fell out with Sun.
It was never meant to replace or succeed C++ (though MS encouraged
people to write their Windows programs in C# rather than C++, in order
to promote lock-in).
serge.robyns@gmail.com: Dec 28 02:51AM -0800

On Saturday, 26 December 2015 11:15:32 UTC+1, Paavo Helde wrote:
> should use Ada.
 
> Cheers
> Paavo
 
This Amine guy has been spamming the Ada newsgroup too and all his post have been flagged as spam. I've proven his statement wrong and his code behaves the same in Ada as in C++. He's just ignorant of good C++ programming like he doesn't know Ada any much better, I'm wondering if he understand the difference between an Ada "type" and "subtype". Having looked as his code, it is full of untyped pointers (like void* or char*) and generic integrals like int32 or int64. It will require a lot of rework to compile properly in any strong typed language if strong typing is what he wants. He's hoping that wearing a safety belt would make him safer but he remains a reckless driver. His spitting his anger in the form of infamy on C++ because C++ failed to catch his own design mistakes.
Ramine <ramine@1.1>: Dec 27 08:22PM -0800

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.
Ramine <ramine@1.1>: Dec 27 08:27PM -0800

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 <ramine@1.1>: Dec 27 08:28PM -0800

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.
 
==
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 28 04:22AM +0100

On 12/28/2015 5:22 AM, Ramine wrote:
 
> Look at this example in FreePascal and Delphi:
 
Oh, Pascal. Pascal was roughly my 3rd main language, after a special
dialect of Basic (before GW-Basic) and Intel 8080 assembly. Well unless
you count TI 57 calculator programming, in which case Pascal came third.
I used a lot of dialects of Pascal, and had the whole syntax memorized
so I could draw syntax diagrams for the whole of Jensen & Wirth Pascal,
and most of UCSD p-Pascal and some others. But truth be told I didn't
make any interesting programs in 8080 assembly, I just tried to figure
out how that worked, and was surprised when a HLT instruction didn't
return me to the machine's built-in command interpreter, like STOP did
in Basic!
 
Delphi is interesting because it was the continuation of Borland Pascal,
which was the big brother of Turbo Pascal, which was the brainchild of
Anders Hejlsberg, who later design C#, mentioned below.
 
 
> ===
> program test;
 
In original Pascal, as I recall, you had to indicate in the above
statement that you'd be using the standard input and output streams.
 
 
> var a:integer;
 
> procedure test(b:Longword);
 
"Longword" was not an original Pascal type. I doubt that it's part of
standard Pascal. It was probably introduced with Turbo Pascal.
 
 
> begin
> writeln(b)
> end;
 
Oh the joys of Pascal's semicolon-as-DELIMITER. :-)
 
Anyway, systematic indentation is Good Idea™, in Pascal and most every
programming language.
 
 
 
> a:=3;
 
> try
> test(a);
 
But the above semicolon (and formal null-statement) is a bit
inconsistent with the earlier lack of semicolon.
 
General consistency is also Good Idea™, not just for indentation, in
Pascal and most every programming language.
 
 
> 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,
 
I'm not so sure that the type identification you make here is valid in
general. I would guess that FreePascal's `Longword` is a 32-bit unsigned
integer. In contrast, a C `unsigned long` can in practice be 32 or 64
bits, depending on the C compiler (in Windows it's 32 bits always), and
formally it can be any size equal or larger than 32 bits.
 
 
> 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,
 
Oh, it's easy to make a range-checked type, for safety, in C++.
 
In contrast, it's difficult or practically impossible to make a
not-range-checked type, for efficiency, in Pascal.
 
C#, as a more modern language, has an IMHO better approach where you can
turn off or on range checking via its `checked` keyword. See <url:
https://msdn.microsoft.com/en-us/library/74b4xzyw.aspx> for details.
 
 
> 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.
 
Hm. Did you read up on the Ariane failure, as I advised you to?
 
 
> This is why C and C++ are bad.
 
That does not follow from the above.
 
 
> Thank you for your time.
 
No problem, glad to help. ;-)
 
 
Cheers,
 
- Alf
Ian Collins <ian-news@hotmail.com>: Dec 28 05:15PM +1300

Alf P. Steinbach wrote:
> On 12/28/2015 5:22 AM, Ramine wrote:
 
>> Look at this example in FreePascal and Delphi:
 
...
 
Please stop responding to the Ramine-bot!
 
--
Ian Collins
Ramine <ramine@1.1>: Dec 27 09:44PM -0800

Hello.....
 
 
You have to understand me Sir and Madam, you have seen
me explaining to you why C++ and C are bad for realtime
safety critical systems, here is another proof that
makes C++ and C not suitable for realtime safety critical systems,
The c++11 have a weak software memory model and that`s not acceptable
for safety critical systems, simply because with this weak spftware
memory model you risk more , so the weak software memory model doesn`t
follow the spirit of Ada and Delphi and FreePascal, so this is why
FreePascal and Delphi follows the Strong memory model of the x86
architecture on an x86 architecture and that simplify the reasonning
about synchronization algorithms etc and that`s good for Realtime safety
critical systems.
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 27 09:09PM -0800

Hello.....
 
You have to understand me Sir and Madam, if you look
at my previous proof, you will say that you can
rely on the good enginneers to avoid the problems
of C++ and C, but in realtime safety critical systems that`s
not the way it is, you have to have a programming language that
scales for safety ! so when you saw me giving you an example
in FreePascal and Delphi this example do scale for this kind
of safety for more complex softwares for realtime safety critical
systems, so you can not just rely on good engineers to
not make mistakes or to not test for the range of some variables,
so you have to have a kind of technic that scales easily
and that avoid a catastrophe to the realtime safety critical
systems, and you have seen me giving you a technic in FreePascal
and Delphi that scales for a kind of safety and that you can not do in
C++ or C, that`s the spirit of the Ada language also, Ada has all kinds
of ways and technics that scale very well for safety for realtime safety
critical systems, so hope you have understood the spirit of Ada and the
Spirit of FreePascal and Delphi.
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 27 09:06PM -0800

Hello...
 
You have to understand me Sir and Madam, if you look
at my previous proof, you will say that you can
rely on the good enginneers to avoid the problems
of C++ and C, but in realtime safe critical systems that`s
not the way it is, you have to have a programming language that
scales for safety ! so when you saw me giving you an example
in FreePascal and Delphi this example do scale for this kind
of safety for more complex softwares for realtime safety critical
systems, so you can not just rely on good engineers to
not make mistakes or to not test for the range of some variables,
so you have to have a kind of technic that scales easily
and that avoid a catastrophe to the realtime safety critical
systems, and you have seen me giving you a technic in FreePascal
and Delphi that scales for a kind of safety and that you can not do in
C++ or C, that`s the spirit of the Ada language also, Ada has all kinds
of ways and technics that scale very well for safety for realtime safety
critical systems, so hope you have understood the spirit of Ada and the
Spirit of FreePascal and Delphi.
 
 
 
Thank you,
Amine Moulay Ramdane.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: