February 25, 2013 Abstract class contracts | ||||
---|---|---|---|---|
| ||||
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
--
Кто везде - тот нигде.
|
February 25, 2013 Re: Abstract class contracts | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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 |
Copyright © 1999-2021 by the D Language Foundation