W> 1. Ada. There is RANGE (of INTEGERS for example) subtype defined
W> here.
W> 2. Oberon-family. We use ASSERT.
Ada Issue AI95-00286, the "Assert pragma":
http://www.ada-auth.org/AI-SUMMARY.HTML
Very few would use Asserts to replace range checking.
W> Ada do check everywhere but in Oberon has more simple compiler
W> work.
W>
Ada has "pragma Suppress (Range_Check);" -- RM 11.5.
W> What is better?
Prof. Wirth has dropped Subranges on purpose in Oberon. M2 had. No
big benefit in supporting them and probably bloating the compiler and
slowing down the programs.
Range checking in Ada and Pascal can be useful, e.g. in allowing omitting
of bounds checking when indexing arrays, which produces faster
executables.
Notes follow. In GNAT Ada 95:
* Range checking on discrete integer subtypes is automatically omitted
if the compiler can deduce that it is safe to do that. Of course the
algorithm would have a simple outline: compare 4 numbers:
subtype TA is Ingeger range P .. Q;
subtype TB is Ingeger range R .. S;
V : TB := TA (U); -- Skip checks when: R<=P, S>=Q
* So speed improvements occur if the programmer makes the checking
stricter. While the language might pull the plug in range checking,
the programmer would try to maximise the strictness of the checking
to get the speed up.
Eliminating range checking is easy to explain: the languages were not
designed to satisfy the public.
A hypothesis is this (in its entirety):
The designer of Oberon had an aim of omitting 'pragma Suppress'
features.
Range checking would still allow the "W32.Sasser.A" port 445 virus:
http://www.microsoft.com/security/incident/sasser.asp
"[it] exploits the Local Security Authority Subsystem Service (LSASS)"
Maybe the NSA, & etc., causes the security weaknesses; and later the
FBI leans on some programmers and get the benign viruses produced.
- Craig Carey
(Downloads: ftp://ftp.cs.nyu.edu/ , http://gcc.gnu.org/ ,
http://libre.act-europe.fr/ )