digitalmars.D - Abstract class contracts
- H. S. Teoh (15/15) Feb 25 2013 Why does D require that in-contracts on a class method must have a
- Timon Gehr (4/17) Feb 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=6549
Why does D require that in-contracts on a class method must have a method body? Based on my understanding of TDPL, in-contracts are supposed to be inherited by derived classes, aren't they? Currently I can't seem to convince DMD to accept an in-contract on an abstract base class method: abstract class Base { abstract int method(int j) in { assert(j < 10); }; // <-- compile error } What's the rationale for this? Doesn't it defeat the purpose of DbC (I want the abstract base class to "set the rules" as to what are acceptable parameters to methods)? T -- Кто везде - тот нигде.
Feb 25 2013
On 02/25/2013 08:36 PM, H. S. Teoh wrote:Why does D require that in-contracts on a class method must have a method body? Based on my understanding of TDPL, in-contracts are supposed to be inherited by derived classes, aren't they? Currently I can't seem to convince DMD to accept an in-contract on an abstract base class method: abstract class Base { abstract int method(int j) in { assert(j < 10); }; // <-- compile error } What's the rationale for this? Doesn't it defeat the purpose of DbC (I want the abstract base class to "set the rules" as to what are acceptable parameters to methods)? ...http://d.puremagic.com/issues/show_bug.cgi?id=6549 Even more annoying is the following issue: http://d.puremagic.com/issues/show_bug.cgi?id=6856
Feb 25 2013