Eiffel like reports for Design by Contract contracts

Brother Bill brotherbill at mail.com
Fri Jul 25 10:11:05 UTC 2025


In Eiffel, it is trivial to get a report for Subject Matter 
Experts (SMEs) that will provide feedback that the DbC contracts 
are what they agreed to.

It would be nice to have this in D.

Does D already have this, or should this be added to DIP Ideas 
forum?

Imagine a sample contract for Vats (not Value Added Tax, but 
liquid containers.
A vat can be open, closed, full, empty, etc.

     A contract for fill() might be
     ```
     in {
       assert(!full, "vat cannot be full");
     }
     out {
       assert(full' "vat is full");
     }
     ```

     It would be nice to extend the assert statement to add a 
label such as:
     ```
     in {
       not_full: assert(!full, "vat cannot be full");
     }
     out {
       full: assert(full, "vat is full");
     }
     ```

     It would be nice to generate a report for SMEs that would 
look like:
     fill method
       require
         not full: not full, "vat cannot be full"
       ensure
         full: full, "vat is full"

Note the conversion of C style operators to Eiffel wordy 
operators.

The benefit is for Architects to be able to use D language for 
architecture, similar to what is done in Eiffel.

Of course, this will need to do it without Eiffel Multiple 
Inheritance, using D single inheritance and Interfaces.  (I do 
believe that D Interfaces support DbC).


More information about the Digitalmars-d-learn mailing list