www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Design by Contract - some questions

reply =?ISO-8859-1?Q?S=e9rgio_Agostinho?= <sergioag di.fct.unl.pt> writes:
Hi there,

I am doing a master thesis on Design by Contract, and as part of it, I am doing
a survey on DbC solutions. I have found the D programming language very
interesting, and one of the few real attempts to bring DbC to mainstream
programming.

After reading the site documentation, there are a couple of questions that I
have, that you might be able to answer, namely:
* is it possible to specify pre/postconditions in constructors and private
methods?
* is it possible to declare local variables within the 'in', 'out' or
'invariant' scope?
* is there any concurrency insurance in contract execution (if the method is
declared as 'synchronized', will the contract also be thread-safe)?

Regarding the D authors' design options, I also have some questions:
* has the 'old' construct been considered?
* have interface contracts been considered (since D does not support
multiple-inheritance)?
* has (automatic) documentation generation support for contracts been
considered?
* has a finer grain of checking been considered, other that development/on and
release/off (the ability to specify that contract checking for specific classes
and/or specific assertion types)?

Thank you for your time,

Sérgio Agostinho
Jan 27 2007
parent BCS <ao pathlink.com> writes:
Reply to Sérgio_Agostinho,

 
 * is it possible to specify pre/postconditions in constructors and
 private methods?
I'm no expert, but I would assume so (I haven't checked)
 
 * is it possible to declare local variables within the 'in', 'out' or
 'invariant' scope?
 
again I would assume so
 Regarding the D authors' design options, I also have some questions:
 
 * have interface contracts been considered (since D does not support
 multiple-inheritance)?
I has been proposed, but hasn't gone anywhere. I'd like to see it and an interface unittest that is run for any class that implements the interface.
 
 * has a finer grain of checking been considered, other that
 development/on and release/off (the ability to specify that contract
 checking for specific classes and/or specific assertion types)?
 
not explicitly, but you could get that effect with the version construct.
 Thank you for your time,
 
 Sérgio Agostinho
 
Your welcome, and I hope you enjoy D
Jan 27 2007