digitalmars.D.learn - is there a way to define a pure base class that forces pureness of
- dennis luehring (4/4) Feb 02 2013 i've got something like an streaming/converter system
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (22/26) Feb 02 2013 That seems to be the case:
i've got something like an streaming/converter system and parts of the specialised converters are stateless other statefull is there any way to force pureness/stateless-ness through the base class or an interface in D?
Feb 02 2013
On 02/02/2013 02:23 AM, dennis luehring wrote:i've got something like an streaming/converter system and parts of the specialised converters are stateless other statefull is there any way to force pureness/stateless-ness through the base class or an interface in D?That seems to be the case: interface I { int foo() const pure; } int g; class C : I { int foo() const { return g; // ERROR: pure function 'deneme.C.foo' cannot access // mutable static data 'g' } } void main() { auto o = new C; o.foo(); } Note that there is no 'pure' on C.foo; it is inherited from I.foo. Ali
Feb 02 2013