Re: non virtual interfaces

2013-09-20 Thread Alexandr Druzhinin
20.09.2013 23:09, Jonathan M Davis пишет: You can use NVI with classes just fine just so long as you use protected rather than private, but making it private there won't work either, because private is never virtual (and it wouldn't really help you any if it were, because while the base class pri

Re: non virtual interfaces

2013-09-20 Thread Jonathan M Davis
On Friday, September 20, 2013 22:40:48 Alexandr Druzhinin wrote: > 20.09.2013 12:45, Ali Çehreli пишет: > > On 09/19/2013 10:31 PM, Alexandr Druzhinin wrote: > > > if I use protected instead of private in interface like: > > private member functions are non-virtual. > > But I just use code exampl

Re: non virtual interfaces

2013-09-20 Thread Alexandr Druzhinin
20.09.2013 12:45, Ali Çehreli пишет: On 09/19/2013 10:31 PM, Alexandr Druzhinin wrote: > if I use protected instead of private in interface like: private member functions are non-virtual. But I just use code example from TDPL russian edition. And TDPL says clearly that (un)transmogrify() are

Re: non virtual interfaces

2013-09-19 Thread Ali Çehreli
On 09/19/2013 10:31 PM, Alexandr Druzhinin wrote: > if I use protected instead of private in interface like: private member functions are non-virtual. > interface Transmogrifier > { > final void thereAndBack() > { > transmogrify(); > untransmogrify(); > } > >

Re: non virtual interfaces

2013-09-19 Thread Alexandr Druzhinin
if I use protected instead of private in interface like: interface Transmogrifier { final void thereAndBack() { transmogrify(); untransmogrify(); } protected: void transmogrify(); void untransmogrify()

non virtual interfaces

2013-09-19 Thread Alexandr Druzhinin
Hello all. I try to use NVI and failed with a snippet from TDPL: interface Transmogrifier { final void thereAndBack() { transmogrify(); untransmogrify(); } private: void transmogrify(); void untransm

Re: Non-Virtual Interfaces

2011-03-04 Thread Aleksandar Ružičić
> > In D, the public function would have to be final to make it non-virtual/non- > overridable, and the function it calls would have to be protected, since you > can't override private functions ( > http://d.puremagic.com/issues/show_bug.cgi?id=4542 ). In this case, you're > trying to override fina

Re: Non-Virtual Interfaces

2011-03-04 Thread Aleksandar Ružičić
> > What you may want to consider is an abstract class instead of NVI, as long > as you don't need multiple inheritance, it should be fine. > > -Steve > Well, I've decided to give NVI a try just because multiple inheritance would be best way to do what I want (aldo I hate that feature of C++ and j

Re: Non-Virtual Interfaces

2011-03-04 Thread Jonathan M Davis
On Friday, March 04, 2011 02:17:00 Aleksandar Ružičić wrote: > I'm trying to use NVI idiom but i keep getting errors from dmd. > > This is my setup: > > module test; > > import std.stdio; > > interface IBase { > void foo(); > void bar(); > } > > interface IBar : IBase { > fin

Re: Non-Virtual Interfaces

2011-03-04 Thread Steven Schveighoffer
On Fri, 04 Mar 2011 05:17:00 -0500, Aleksandar Ružičić wrote: I'm trying to use NVI idiom but i keep getting errors from dmd. This is my setup: module test; import std.stdio; interface IBase { void foo(); void bar(); } interface IBar : IBase { final void bar() {

Non-Virtual Interfaces

2011-03-04 Thread Aleksandar Ružičić
I'm trying to use NVI idiom but i keep getting errors from dmd. This is my setup: module test; import std.stdio; interface IBase { void foo(); void bar(); } interface IBar : IBase { final void bar() { writefln("IBar.bar()"); } } class Foo : IBar