www.digitalmars.com         C & C++   DMDScript  

D - Interfaces and DBC

reply Barry Pederson <barryp yahoo.com> writes:
Since I was going on about the lack of documentation for the interface 
feature, I got to wondering...

What role, if any, do interfaces have in DBC?  Can you specify pre/post 
contracts for the interface functions?  If so, that'd definitely be worth 
mentioning in the docs.

I was thinking of something like this for example:

interface OutputStream
     {
     void write(ubyte[] b, int offset, int length)
         in {assert(offset >= 0);}	
     }

where the interface doesn't supply a body, but does specify the conditions.

On a related note, I'd imagine abstract methods in a class could have pre/post 
conditions without a body? (something else to cover in the docs).

	Barry
Mar 17 2002
parent "Walter" <walter digitalmars.com> writes:
"Barry Pederson" <barryp yahoo.com> wrote in message
news:3C952B6B.6070603 yahoo.com...
 Since I was going on about the lack of documentation for the interface
 feature, I got to wondering...

 What role, if any, do interfaces have in DBC?  Can you specify pre/post
 contracts for the interface functions?  If so, that'd definitely be worth
 mentioning in the docs.

 I was thinking of something like this for example:

 interface OutputStream
      {
      void write(ubyte[] b, int offset, int length)
          in {assert(offset >= 0);}
      }

 where the interface doesn't supply a body, but does specify the
conditions.
 On a related note, I'd imagine abstract methods in a class could have
pre/post
 conditions without a body? (something else to cover in the docs).
Abstract functions, like functions in interface declarations, can't have pre and post conditions. They probably should. -Walter
Mar 17 2002