Re: Ok.. live and learn.

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 10/28/04


Date: Thu, 28 Oct 2004 14:31:47 +0200


"L D Blake" <not@any.adr> wrote in message
news:oid1o0551lb06vkm8rip3dhv1qakpljrj8@4ax.com...
> On Thu, 28 Oct 2004 10:21:28 +0200, "Maarten Wiltink"
> <maarten@kittensandcats.net> wrote:
[...]
> I think you've missed my meaning...
>
> Delphi has embedded their SEH hadlers into the System unit. The
> guard frame created by TRY comes from the compiler itself. This
> creates a feature set that is so embedded into the language that,
> short of re-writing the compiler we are indeed stuck with it.

Programming languages _are_ the expression of a feature set.

What is your complaint? That you don't have access to every little
feature, with the freedom to redefine it, in the Delphi compiler?
In the end, Borland are selling a compiler to compile Object Pascal
into win32-compatible PE executables. Probably to give themselves
certain freedoms, the RTL is organised in a way that allows you some
subset of the freedoms they have. We didn't get the RTL source code
with Turbo Pascal and I never heard complaints about that.

It's clear that you don't like Delphi exception handling and want
Object Pascal programs to use Windows SEH. Through, essentially, some
fluke, you can - almost. Now follow this line of thinking a little
further. What's so great about Windows SEH? There is another layer
below it: raw machine code and frames on the stack. That must be
better still, then. Take those two dwords for program use in the
exception record. You already have an exception code, those two
dwords are useless. Bloat! Let's take them out; all it takes is a
few patches to the OS.

(No, I am *NOT*!!! making fun of you personally. Just challenging
the assumption that some things need to be challenged and others
don't.)

[...]
>> An exception is a cleanly defined event in Object Pascal. It creates
>> objects that we can access and it provides everything Windows does,
>> plus easy extensibility and the ability to structure exception types
>> into class hierarchies.
>
> And therein lies the bugaboo... It creates objects... requiring us
> to use objects to deal with it...

In its simplest form, an except clause simply contains code.

In its second-simplest form, it contains "on ExceptionClass do X;"
substatements. No objects are visible in the source code, and while the
selectors are class type identifiers, that's not so very different from
integer constants. You should be able to live with that; just don't
ever derive an exception class from another and its total effect is to
enforce named constants for each exception type.

[...]
> In that sense, they've entrapped us into a kind of programming that
> does not always best serve our needs. Not ALL programming needs to
> use objects.

And not all programming needs Delphi. People are still using Forth,
Fortran, COBOL, Perl, shellscripts, LISP, XSLT, Ada, Modula, Python,
REXX, SmallTalk, Eiffel,...

If you like Pascal but don't want objects, Turbo Pascal still works.
If you want Pascal and exceptions but no objects, you can ignore the
objects in Delphi (and the objects in Delphi exceptions - and you can),
or write some specialised code to interface with Windows SEH from
Turbo Pascal or Borland Pascal for Windows, or write your own compiler,
or patch an open-source one.

That you can patch Delphi is wonderful but it's not what you paid for
when you bought it. So there's not much use in complaining about that.
Borland, too, are just in it for the money. They sell development
environments, not compiler construction kits.

> As I've frequently discussed here, it's been my experience that the
> closer one gets to the OS the less advantage there is in using OOP.

That may well depend on the OS. Interfacing with the OS should be
easiest on its own terms, so if the OS is object-oriented, the platform
interface could be, too.

I remember an article about OS/2 and its scripting language REXX. There
was some inheritance in the objects used in the graphical user interface,
and one trick that could be played through REXX was to inject a class
_between_ two existing classes in the inheritance chain. This let you
add methods to existing classes, and could for example be applied by
a virus scanner to add context menu items in OS/2's Explorer equivalent
to many types of filesystem items (files, directories, drives) at once.
Should a newer version add for example symbolic links, then all methods
added in this way would automatically become available for them, too.
This sort of thing is the strength of the object-oriented paradigm.

>> The Object Pascal fragment is *not* reacting to the exception code.
>> It's reacting to the _class_ of the exception object. Really. That's
>> what happens at the Object Pascal level, which is allowed to be
>> different from how the layer below it sees things.
>
> And you think that's a good thing? I don't.

This is *fundamental*. Computers today are vastly more useable than
fifty years ago, and much of that is due to building ever more virtual
machines on top of each other. But in order to make progress, a
virtual machine _must_ have an interface that is different from its
implementation (the interface of the underlying virtual machine).
Otherwise, nothing would ever be gained.

Groetjes,
Maarten Wiltink



Relevant Pages

  • Re: Poll: Why you do not use Lisp?
    ... where neither my C compiler nor my JVM (more correctly, ... JBC-interpeter does its own internal exception handling, ... (FWIW, neither does SEH). ... partly implemented some of the mechanisms (I can unwind and do backtraces, ...
    (comp.programming)
  • Re: Try Finally...
    ... so one big part of Delphi SEH requires conversions for system ... >> Delphi SEH structures. ... Structured Exception Handling ... Windows SEH's format, placed there by Delphi". ...
    (comp.lang.pascal.delphi.misc)
  • Re: Ok.. live and learn.
    ... >> Delphi has embedded their SEH hadlers into the System unit. ... >> guard frame created by TRY comes from the compiler itself. ... The problem with Delphi is that it is always hard to say what is the ... What's so great about Windows SEH? ...
    (comp.lang.pascal.delphi.misc)
  • Re: Structured Exception Handling (was: Try Finally...)
    ... Structured exception handling is made available primarily through compiler ... other compilers provide this support as well. ... According to further MSDN topics the Delphi SEH support is equivalent to the MS ...
    (comp.lang.pascal.delphi.misc)
  • Re: Turbo Pascal to Delphi
    ... That only works if your in the IDE. ... You could use the compiler with that info and find out what was happening ... In Delphi, I know how to setup breaks and watches and stuff, but the error ... > with some arrow or something when an exception occurs. ...
    (alt.comp.lang.borland-delphi)