|New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-10-31)|
|Re: New Book: The School of Niklaus Wirth email@example.com (Sebastian Moleski) (2000-11-01)|
|Re: New Book: The School of Niklaus Wirth Martin.Ward@durham.ac.uk (2000-11-05)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (Mikael Lyngvig) (2000-11-05)|
|Re: Re: New Book: The School of Niklaus Wirth email@example.com (Orlando Llanes) (2000-11-05)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-07)|
|Re: New Book: The School of Niklaus Wirth email@example.com (jt) (2000-11-07)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-09)|
|Re: New Book: The School of Niklaus Wirth email@example.com (Gabor DEAK JAHN) (2000-11-11)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (Joachim Durchholz) (2000-11-11)|
|Re: New Book: The School of Niklaus Wirth email@example.com (Laurent Guerby) (2000-11-14)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-14)|
|Re: New Book: The School of Niklaus Wirth email@example.com (2000-11-14)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-11-16)|
|[6 later articles]|
|Date:||9 Nov 2000 12:09:10 -0500|
|Organization:||AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com|
|Posted-Date:||09 Nov 2000 12:09:10 EST|
"Orlando Llanes" <email@example.com> schreibt:
> C++ has its quirks, but when comparing C++ to OO Pascal, one of my
> pet peeves is that Pascal does not call its constructor or
> destructor automatically (it's incredibly annoying that your virtual
> functions cause a program crash because they were not initialized).
I'm not sure what you really mean. The obsolete Object type may have
such problems, but not the Class type. The Object type was an attempt
to add methods to Records - the problems with this approach have been
cured with the Class type.
In OOP it's required to call a constructor, in order to create an
object. If you forget to initialize a local variable, this can be
disastrous in every language. The first step in the creation of an
object in OOP includes the setup of the VMT reference, therefore I
cannot see any problem in using virtual methods even in the
OTOH I had much problems with C++ constructors, when the current
constructor didn't use the methods, introduced in more derived classes
of the actual object. When asking for a solution in C++ groups, the
usual answer is "create the object first, and initialize it
afterwards". Here OOP is very close to that solution, since every
constructor code executes only, after the object has been fully
created; this means after the memory has been allocated and
initialized, and after the object has been given the final (most
derived) type. OOP constructors are initializers, from the viewpoint
of C++ programmers.
Within an OOP constructor calls to virtual methods always invoke the
virtual method of the most derived class of the object, so that you
must not fear any "pure abstract method call" errors, when any derived
class overrides this method with some code.
>Also, why on Earth would anyone want
>multiple constructors or multiple destructors?
After the foresaid it should be clear, why multiple constructors make
sense in OOP programs - in fact they allow to initialize the just
created object with different sets of arguments, depending on the
actual environment of the object. Multiple destructors instead are of
no practical use, here I agree with you.
>Pascal is strict on type checking which does not allow for overloading.
In D4 overloaded procedures have been introduced. I cannot see any
reason, why a compiler should not allow for procedures of the same
name, but with different argument types.
When you are talking about Pascal and OO, then you should consider
*all* dialects of OOP, and should not revert to some Wirth
specifications of the original (non-OO) Pascal language. The original
Pascal language was designed to *teach* programming, not as a vehicle
to create meaningful programs at all. What's a programming language
worth, which has no interface to external (OS, API, library...)
procedures, no dynamic memory allocation, or (finally) no objects?
>One more Pascal pet peeve, why is there no unsigned
>integer (one of my biggest pet peeves)?
As mentioned above, at least Delphi has a Cardinal type, as the
unsigned counterpart of Integer, and more signed and unsigned integral
data types up to 64 bits in size.
Return to the
Search the comp.compilers archives again.