Missing warning?

Missing warning?

type
  TMyClass = class abstract (TObject)
     // Lots of methods, but none of them abstract;
  end;

  TMyImplementedClass = class(TMyClass)
    // Overrides some of the parent methods and adds new ones
   end;
...
var
   TFoo: TMyClass;
begin
   TFoo := TMyClass.Create;  *// WHAT!? No Warnings!?*
 
The XE2 to XE7 documentation states...
http://docwiki.embarcadero.com/RADStudio/XE7/en/Classes_and_Objects
states "Note: Delphi allows instantiating a class declared abstract, for backward compatibility, but this feature should not be used anymore." - which is all dandy, but not issuing a warning for such use, that seems wrong to me.

Interestingly, the XE version is different...
http://docwiki.embarcadero.com/RADStudio/XE/en/Classes_and_Objects
and says "If a class is marked abstract, then it cannot be instantiated directly using the Create constructor. "

When did they introduce this keyword - and why did they not stick with the XE design?  Go figure...

Is there a QP or QC for this?
http://docwiki.embarcadero.com/RADStudio/XE7/en/Classes_and_Objects

Comments

  1. David Millington Some things are fundamental, and need attention in the compiler. This would seem to be one of those. Really, this should be cause for embarrassment.

    ReplyDelete
  2. Bill Meyer True. But I'm sure Roman is looking out for useful checks he can add. Plus, he adds things to FixInsight faster than we get new compiler releases :p

    ReplyDelete
  3. Oh yes. Been there. Fell in the trap with my eyes wide open (:

    ReplyDelete
  4. Only different between XE and XE2 to XE7 is: The documentation was updated. You are still able to instatiate a abstact class in XE :-(

    ReplyDelete
  5. Say what? There is a good thing in XE ;-)

    ReplyDelete
  6. Fabian S. Biehn - Noted. 

    Anyone know when class abstract was added to the language?

    ReplyDelete
  7. David Millington Yes, I am sure Roman Yankovsky is likely to be faster. Sad.

    ReplyDelete
  8. http://qc.embarcadero.com/wc/qcmain.aspx?d=122525
    http://qc.embarcadero.com/wc/qcmain.aspx?d=24662

    Imo leaving wrong behavior in the name of backwards compatibility and just change doc is not the right decision. If anyone creates an abstract class in his code then he has to fix his broken code after an update, period!

    ReplyDelete
  9. Stefan Glienke - IMO, it needs to at least output a warning.  Isn't the whole idea of an abstract class, that it simply is a "template" for actual implementations to inherit from?

    ReplyDelete

Post a Comment