Moritz Beutel <"Moritz Beutel" <>> wrote:
> all the things that set Delphi apart of C (many of which are now shared
> by e.g. C#), e.g. subclassing polymorphism (for both classes and
> objects), anonymous methods and other kinds of syntactical sugar.
Why you might want to use anonymous methods: if you want to delay
evaluation of some kind, such as symbol table lookup, but not have to
write some elaborate fixup or callback mechanism (and possibly need to
worry about arguments). A simple list of closure references can work
nicely here, with variable capture transporting the arguments.
Subclassing polymorphism isn't a Delphiism distinct from C++, but it is
also very useful in compiler implementation, as any kind of interface
encapsulation would be in any system broken up into modules. For
example, consider porting a compiler across multiple different back ends
or platforms: substituting different implementations of a common
interface is far preferable to a liberal sprinkling of #ifdefs and
alternating linker command lines, relying of linker resolution for
different implementations of the same symbols, but without the type
safety.
> Sure. It's just that C++ /may/ offer advantages here that Delphi can't
> offer; mostly the flexibility of templates.
On the other hand, I see templates beyond generic data structure
definition and traversal of relatively little sensible use.
Pattern matching in the style of a functional language, or automatic
support for type equality and memoization, or garbage collection, on the
other hand, would provide large advantages for compiler implementation
over and above either Delphi or C++.
-- Barry
--
http://barrkel.blogspot.com/