March 17, 2002 Interfaces and DBC | ||||
---|---|---|---|---|
| ||||
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 |
March 18, 2002 Re: Interfaces and DBC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Pederson | "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 |
Copyright © 1999-2021 by the D Language Foundation