[fpc-pascal]Delphi "9" language features...

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Wed Aug 11 23:03:57 CEST 2004

On Wed, 11 Aug 2004, Olle Raab wrote:

> 04-08-11 21.08, skrev Michael.VanCanneyt at Wisa.be följande:
> > 
> > But the IEnumerated interface part is really over the top. It requires the
> > compiler to have 'knowledge' of certain complex types, which is a bad
> > thing and totally arbitrary.
> > The last time they did that was with Variants, which has been a dirty
> > mess every since. It destroys the beauty and strict typing of Object
> > Pascal...
> Isn't this the same with exception handling, which requires knowledge of
> Exception class.

No, because you can raise an exception with any TObject. 
By default, the 'Exception' class is used as a base class, 
because it allows to set some standard message. There is no way for
the RTL to know how to 'show' a TObject. In SysUtils, Exception is defined,
and can be shown because it's 'message' property is known. SysUtils also
sets a handler so the RTL can 'show' an Exception.

home: >ppc386 testp.pp 
home: >./testp
Runtime error 217 at $08052074

home: >cat testp.pp
{$mode objfpc}
program testp;

  Raise TObject.Create;

So the compiler is 'agnostic' when it comes to exceptions. TObject is the
base of all classes, so it is not arbitrary, it's part of the Object Pascal
language specification.

I would prefer the compiler to stay agnostic when it comes to complex types
such as variants, interfaces or whatever. At Borland, they obviously don't.

I remember making a remark once to a Borland Employee saying that "it is
heresy to introduce Variants in a strongly typed language such as Pascal"
to which I got the reply 'Yes, but the OS (=Win32) uses it, so...' :)

Reading the answer you got to the question of ordering, you hit the nail on
the head. There is no way the compiler can guarantee the order of a 
certain IEnumerable interface. It depends entirely on the implementation...

It's of course something to show off with on developer conferences with a
an audience of VB or Java programmers :-)


More information about the fpc-pascal mailing list