Writing Bug-Free C/D Code

Derek Parnell derek at nomail.afraid.org
Wed Mar 21 00:45:14 PDT 2007


On Wed, 21 Mar 2007 00:35:46 -0800, David B. Held wrote:

> Derek Parnell wrote:
>> [...]
>> The trouble is that D's typedef does not allow you to extend the semantics
>> of the base type, but that's what structs and classes are for, no?
>> 
>> The Euphoria language has a slightly different type construction mechanism
>> which has its good side and bad side, but maybe something like it could be
>> used to extend D's typedef mechanism.
>> [...]
> 
> My understanding is that Contracts in D allow you to implement Ada-like 
> SubRanges.  This is actually one of the things I really liked about the 
> DbC support.  Is that not the case?

Contracts are optional. That is, if something is compiled with the -release
switch, then contract code is not inserted into the executable. You cannot,
and must not, rely on contract code for 'production' editions of software.
It is only meant to be used during the development phases of an
application, thus you should not use contracts to try and detect invalid
input data for a function. Contract code should be used to detect logic
errors and not data errors.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Justice for David Hicks!"
21/03/2007 6:41:57 PM



More information about the Digitalmars-d mailing list