Re: Abstract functions in child classes

2011-12-05 Thread Christophe
FWIW, I agree with Addam. One of the things I like in D is that the langage is designed so that interpretations are made based on what you intend, and what you intend to do is checked. That is exactly what is done by using overwrite keyword. If you intend to make a non-abstract class, the

Re: Abstract functions in child classes

2011-12-05 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 17:28:33 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, December 02, 2011 21:13:45 Adam wrote: Anyway, I have my answer, and I know that D *does* have a reason for this implicitism. Okay. Maybe I've been skimming over this thread too much, but I don't

Re: Abstract functions in child classes

2011-12-02 Thread bearophile
mta`chrono Wrote: Even if the current behavior (what Adam mentioned) is not a bug, I think it seems to be a pitfall for std::programmer. The language/compiler should be more restrictive in this case. If you think so, then write it in Bugzilla :-) Bye, bearophile

Re: Abstract functions in child classes

2011-12-02 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 03:06:37 -0500, mta`chrono chr...@mta-international.net wrote: Even if the current behavior (what Adam mentioned) is not a bug, I think it seems to be a pitfall for std::programmer. The language/compiler should be more restrictive in this case. No, this is not a matter

Re: Abstract functions in child classes

2011-12-02 Thread Adam
To sort of put my two cents back in, and also to be one of those D should be like Java! advocates, the problem is largely that a class that inherits from an abstract and does *not* override some abstract member becomes implicitly (to the user) abstract. The way abstracts work in Java is that, in

Re: Abstract functions in child classes

2011-12-02 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 09:54:10 -0500, Adam a...@anizi.com wrote: To sort of put my two cents back in, and also to be one of those D should be like Java! advocates, the problem is largely that a class that inherits from an abstract and does *not* override some abstract member becomes implicitly

Re: Abstract functions in child classes

2011-12-02 Thread Adam
I'm not sure how the fact that a class can be abstract with defined functions impacts the case either way. It's caught at compile time, but it requires explicitly testing that any given time is or is not instantiable - how else would you test for this particular case? It seems to be adding an

Re: Abstract functions in child classes

2011-12-02 Thread Jonathan M Davis
On Friday, December 02, 2011 14:54:10 Adam wrote: To sort of put my two cents back in, and also to be one of those D should be like Java! advocates, the problem is largely that a class that inherits from an abstract and does *not* override some abstract member becomes implicitly (to the user)

Re: Abstract functions in child classes

2011-12-02 Thread Adam
Ok, let me give a more *specific* case of why this is a problem. Suppose we have our Parent and Child cases from before Parent exists in Library A Child exists in my library, B Library C, used by some developer, uses my library, B. My Child is not meant to be abstract - it's intended to me

Re: Abstract functions in child classes

2011-12-02 Thread Andrej Mitrovic
How can you put out a library where you don't even test your classes? That's just bad programming, period.

Re: Abstract functions in child classes

2011-12-02 Thread Adam
Ok, fine, let me put it THIS way. Suppose I use a parent library, and *I* don't update it. The USER of my library provides an updated version for some unrelated reason. So, NOT testing that something is instantiable or not - JUST that it's instantiable - is bad programming... ...but requiring

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:24:11 -, Adam a...@anizi.com wrote: Ok, fine, let me put it THIS way. Suppose I use a parent library, and *I* don't update it. The USER of my library provides an updated version for some unrelated reason. So, NOT testing that something is instantiable or not - JUST

Re: Abstract functions in child classes

2011-12-02 Thread Adam
I grant you that I should test it, and I never said otherwise. If I'm attacking a strawman, it's the same one that was just put in front of me as a misinterpretation of my argument. What I contest and addressed was a test for the sole purpose of determining if my class, assumed to be non-abstract,

Re: Abstract functions in child classes

2011-12-02 Thread Adam
Or I provide it as source, in which case, D *can* check it. But it means that when the parent is changed, my class type and instantiability implicitly changes, too.

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:24:11 -, Adam a...@anizi.com wrote: Ok, fine, let me put it THIS way. Suppose I use a parent library, and *I* don't update it. The USER of my library provides an updated version for some unrelated reason. So.. the user has: Parent.dll Your.dll Their.exe and

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:43:04 -, Adam a...@anizi.com wrote: I grant you that I should test it, and I never said otherwise. If I'm attacking a strawman, it's the same one that was just put in front of me as a misinterpretation of my argument. Well, I believe I understand your argument and I

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:44:44 -, Adam a...@anizi.com wrote: Or I provide it as source, in which case, D *can* check it. But it means that when the parent is changed, my class type and instantiability implicitly changes, too. True. This is a case I hadn't considered before. In this case

Re: Abstract functions in child classes

2011-12-02 Thread Adam
Well, I believe I understand your argument and I admit that I did find it odd that the error was not detected until the class was instantiated. But, once I thought about it I understood why this is the case, and I believe you understand it as well. I also understand that you'd rather it

Re: Abstract functions in child classes

2011-12-02 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 11:05:00 -0500, Adam a...@anizi.com wrote: I'm not sure how the fact that a class can be abstract with defined functions impacts the case either way. It's caught at compile time, but it requires explicitly testing that any given time is or is not instantiable - how else

Re: Abstract functions in child classes

2011-12-02 Thread Adam
Your presumption is that someone is required to run tests just to ensure that their class definition is what they expect. If I define a class and it's concrete (because I've defined everything), and later someone changes the parent class, my class is no longer concrete (it no longer conforms to my

Re: Abstract functions in child classes

2011-12-02 Thread Timon Gehr
On 12/02/2011 05:05 PM, Adam wrote: To step back a bit, what is the *benefit* of not requiring a class to be declared abstract if it does not override an abstract member? It introduces implicit behavior and the potential for an additional test case (in *what* sane world should I even HAVE to

Re: Abstract functions in child classes

2011-12-02 Thread Adam
A second possible use case: class C(T): T{ // some declarations } Now you really want that template to be instantiable with T being either an abstract or a concrete class. Anything else is bound to become extremely annoying. Could you expand on this case a bit? I'm not sure I

Re: Abstract functions in child classes

2011-12-02 Thread Timon Gehr
On 12/02/2011 08:10 PM, Adam wrote: A second possible use case: class C(T): T{ // some declarations } Now you really want that template to be instantiable with T being either an abstract or a concrete class. Anything else is bound to become extremely annoying. Could you expand on

Re: Abstract functions in child classes

2011-12-02 Thread Timon Gehr
On 12/02/2011 09:05 PM, Timon Gehr wrote: On 12/02/2011 08:10 PM, Adam wrote: A second possible use case: class C(T): T{ // some declarations } Now you really want that template to be instantiable with T being either an abstract or a concrete class. Anything else is bound to become

Re: Abstract functions in child classes

2011-12-02 Thread Adam
So this pattern allows you to provide partial implementations of an abstract, and use template specialization to provide a sort of multiple inheritance rather than strict class definition / extension. That's important in Scala because of the lack of multiple inheritance (as I understand it). Am I

Re: Abstract functions in child classes

2011-12-02 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 14:06:00 -0500, Adam a...@anizi.com wrote: Your presumption is that someone is required to run tests just to ensure that their class definition is what they expect. If I define a class and it's concrete (because I've defined everything), and later someone changes the parent

Re: Abstract functions in child classes

2011-12-02 Thread Adam
You're being a bit dramatic, no? The code didn't compile, the compiler caught it, and you have invented this theoretical case (which did *not* occur) to try and make your point. I don't deny that requiring 'abstract' has some value, but what I question is how much is that value? Since a

Re: Abstract functions in child classes

2011-12-02 Thread Timon Gehr
On 12/02/2011 09:27 PM, Adam wrote: So this pattern allows you to provide partial implementations of an abstract, and use template specialization to provide a sort of multiple inheritance rather than strict class definition / extension. That's important in Scala because of the lack of multiple

Re: Abstract functions in child classes

2011-12-02 Thread Steven Schveighoffer
On Fri, 02 Dec 2011 16:13:45 -0500, Adam a...@anizi.com wrote: You're being a bit dramatic, no? The code didn't compile, the compiler caught it, and you have invented this theoretical case (which did *not* occur) to try and make your point. I don't deny that requiring 'abstract' has

Re: Abstract functions in child classes

2011-12-02 Thread Jonathan M Davis
On Friday, December 02, 2011 21:13:45 Adam wrote: Anyway, I have my answer, and I know that D *does* have a reason for this implicitism. Okay. Maybe I've been skimming over this thread too much, but I don't understand what forcing the programmer to mark an abstract class as abstract would do.

Abstract functions in child classes

2011-12-01 Thread Adam
Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so that even though they must be overridden, they can still provide �base class functionality.� So, they must

Re: Abstract functions in child classes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child; } also produces the (expected) error. Basically dmd was letting you get away with the abstract class

Re: Abstract functions in child classes

2011-12-01 Thread Adam
I saw that a few minutes after posting as well, but if the only time it's going to actually check the definition is if I instantiate it, well... that's not so good for me if I'm writing implementations to be used at a later date. Hm. Guess we'll see. :)

Re: Abstract functions in child classes

2011-12-01 Thread Simen Kjærås
On Thu, 01 Dec 2011 18:50:48 +0100, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so that even though they must be overridden,

Re: Abstract functions in child classes

2011-12-01 Thread Steven Schveighoffer
On Thu, 01 Dec 2011 12:58:24 -0500, Regan Heath re...@netmail.co.nz wrote: On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child; } also produces the

Re: Abstract functions in child classes

2011-12-01 Thread Adam
I can see the case for a grand-child, but if a class does not provide a definition for an abstract member, is that class not, by association, abstract? Classes become abstract if they are defined within an abstract attribute, or if any of the virtual member functions within it are declared as

Re: Abstract functions in child classes

2011-12-01 Thread Adam
Because the function in this case has no definition in the base abstract class (Parent), but is referenced / called by Parent's members. I did not want Parent to provide a default definition for the function precisely because a large point of the abstract was that method.

Re: Abstract functions in child classes

2011-12-01 Thread Simen Kjærås
On Thu, 01 Dec 2011 19:19:49 +0100, Adam a...@anizi.com wrote: I can see the case for a grand-child, but if a class does not provide a definition for an abstract member, is that class not, by association, abstract? Of course. That's what I said. Or meant, at any rate. Classes become

Re: Abstract functions in child classes

2011-12-01 Thread Jacob Carlborg
On 2011-12-01 19:18, Steven Schveighoffer wrote: On Thu, 01 Dec 2011 12:58:24 -0500, Regan Heath re...@netmail.co.nz wrote: On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child;

Re: Abstract functions in child classes

2011-12-01 Thread Jacob Carlborg
On 2011-12-01 19:14, Simen Kjærås wrote: On Thu, 01 Dec 2011 18:50:48 +0100, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so