grauzone:
> That's all gone in modern Pascal dialects. Delphi is very similar to D; 
> it's practically a Pascal version of D. The OOP features are the same, 
> except for some small differences, which make Delphi a bit more flexible 
> (virtual and named constructors...).

And as you know, C# was partially designed by the same people :-)

About Delphi virtual constructors:
http://www.felix-colibri.com/papers/oop_components/delphi_virtual_constructor/delphi_virtual_constructor.html

About Delphi named constructors:
http://stackoverflow.com/questions/1758917/delphi-pascal-overloading-a-constructor-with-a-different-prototype/1759217#1759217

In Table 2-1 shows a list of some Delphi features:
http://oreilly.com/catalog/delphi/chapter/ch02.html
Beside virtual methods there are dynamic methods too, that are unrelated to 
dynamic methods of C#:
>Instead of using the virtual directive, you can also use the dynamic 
>directive. The semantics are identical, but the implementation is different. 
>Looking up a virtual method in a VMT is fast because the compiler generates an 
>index directly into a VMT. Looking up a dynamic method is slower. Calling a 
>dynamic method requires a linear search of a class's dynamic method table 
>(DMT). If the class does not override that method, the search continues with 
>the DMT of the base class. The search continues with ancestor classes until 
>TObject is reached or the method is found. The tradeoff is that in a few 
>circumstances, dynamic methods take up less memory than virtual methods. 
>Unless you are writing a replacement for the VCL, you should use virtual 
>methods, not dynamic methods. See Chapter 3 for a complete explanation of how 
>dynamic and virtual methods are implemented.<


There are even metaclasses (from the same document):
>A class, too, is a distinct entity (as in Java, but unlike C++). Delphi's 
>representation of a class is a read-only table of pointers to virtual methods 
>and lots of information about the class. A class reference is a pointer to the 
>table. (Chapter 3, Runtime Type Information, describes in depth the layout of 
>the class tables.) The most common use for a class reference is to create 
>objects or to test the type of an object reference, but you can use class 
>references in many other situations, including passing class references as 
>routine parameters or returning a class reference from a function. The type of 
>a class reference is called a metaclass.<

In C++/D to do something similar to metaclasses you use templates:
http://marcin.wudarczyk.pl/education/tipstricks/metacls.htm


> The only thing that was really lacking in Delphi are templates. But for 
> compensation, it had powerful RTTI.

About Delphi RTTI, this document is not new (it seems updated to Delphi 4, 
that's a bit ancient) but it looks well written:
http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm

Bye,
bearophile

Reply via email to