D - Interfaces and DBC
- Barry Pederson (15/15) Mar 17 2002 Since I was going on about the lack of documentation for the interface
- Walter (6/20) Mar 17 2002 conditions.
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
"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 theconditions.On a related note, I'd imagine abstract methods in a class could havepre/postconditions 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








"Walter" <walter digitalmars.com>