Define a primitive data type: Difference between revisions

Line 245:
There is a more serious downside. It is stated in [[#Ada|the Ada section]] that the Ada compiler is smart enough to know when to leave out bounds checks. In contrast, the ATS compiler will ''reject'' the program, unless it ''knows'' it can ‘leave out bounds checks’.
 
On the other hand, ''if you have no proof'' that a value is within the bounds 1..10, you must avoid attempting the assignment; but you can instead put something like '''if 1 <= k then if k <= 10 then n := k else abort() else abort()'''. In other words, you ''can'' insert a bounds check. It is often done, and there is an '''assertloc''' macro for doing so. The compiler lets you know you need the bounds check, but will not do it for you.
 
(You can also seriously cheat by using something like '''$UNSAFE.prop_assert''', but that is another topic. I mention it to encourage individual enquiry.)
 
=={{header|C sharp|C#}}==
1,448

edits