Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-03

Exception dialog

33 messages · 14 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

Is there a reason why the default exception dialog has a cancel button to kill the application ?

We often use an exception to signal wrong entry of data or so, because it stops all further processing.

If the user then uses the cancel button, the program is simply ended, which is not what we (or better: the users) want. And I imagine many others use this technique.

I have overridden the OnException handler of TApplication, so it's no longer a problem, but I was curious as to why this is done like this by default ?

Michael.

Reply by email

Paul Ishenin
to Michael Van Canneyt
Michael Van Canneyt wrote 10 lines
Is there a reason why the default exception dialog has a cancel button to kill the application ? We often use an exception to signal wrong entry of data or so, because it stops all further processing. If the user then uses the cancel button, the program is simply ended, which is not what we (or better: the users) want. And I imagine many others use this technique.

This is strange for me too and I also often clicked cancel to just cancel that notification but it closed my application :) I suggest to replace it with simple notification dialog with one button (like ShowMessage).

Best regards,
Paul Ishenin.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Is there a reason why the default exception dialog has a cancel button to kill the…
Michael Van Canneyt wrote
Is there a reason why the default exception dialog has a cancel button to kill the application ?

I have been wondering that for 5 years (since I moved from Delphi), but was to shy to ask. ;-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Samuel Herzog
to Michael Van Canneyt: Is there a reason why the default exception dialog has a cancel button to kill the…

Oh, good point to discuss about the use of exceptions.

I use exceptions only for really "unexpected" things. That a user will sometimes input wrong data must be expected by a programmer so I do not treat this as an exception.

With unexpected things I mean all the things that are outside my code.
e.g.
  try
    FExcel := GetActiveOleObject('Excel.Application');
  except
     //do something
  end;

Reply by email

Michael Van Canneyt
to Samuel Herzog
Samuel Herzog wrote
> Oh, good point to discuss about the use of exceptions. I use exceptions only for really "unexpected" things.

Well, Borland introduced specially the 'Abort' exception to let the programmer 'jump out' of routines in case of need. It's never shown, but execution continues as the event loop is further handled...

Michael.

Reply by email

Sergei Gorelkin
to Michael Van Canneyt: Is there a reason why the default exception dialog has a cancel button to kill the…

Michael Van Canneyt ?????:

Show quoted text 16 lines
Hello, Is there a reason why the default exception dialog has a cancel button to kill the application ? We often use an exception to signal wrong entry of data or so, because it stops all further processing. If the user then uses the cancel button, the program is simply ended, which is not what we (or better: the users) want. And I imagine many others use this technique. I have overridden the OnException handler of TApplication, so it's no longer a problem, but I was curious as to why this is done like this by default ?

I remember discussions on this topic long ago. It was like GTK (GTK 1 at that time) isn't tolerant to exceptions that occur in its signal handlers (read: in LCL and user's code), and it wasn't possible to expect program stability after an exception was raised. That explains the need for 'terminate' button.

The things may have changed since then, however.

Regards,
Sergei

Reply by email

Alexander Klenin
to Paul Ishenin: This is strange for me too and I also often clicked cancel to just cancel that…
Paul Ishenin wrote 15 lines
Michael Van Canneyt wrote: > Is there a reason why the default exception dialog has a cancel > button to kill the application ? > > We often use an exception to signal wrong entry of data or so, > because it stops all further processing. > > If the user then uses the cancel button, the program is simply > ended, which is not what we (or better: the users) want. > And I imagine many others use this technique. > This is strange for me too and I also often clicked cancel to just cancel that notification but it closed my application :) I suggest to replace it with simple notification dialog with one button (like ShowMessage).

Terminating application on exception is useful sometimes too, so please do not drop this functionality. I agree that it should not be the default.
I suggest to rename buttons "Continue" and "Terminate", with first being _both_ default and "cancel",
so neither pressing "Enter" not "Esc" would terminate application.

Alexander S. Klenin

Reply by email

Hans-Peter Diettrich
to Michael Van Canneyt: Is there a reason why the default exception dialog has a cancel button to kill the…
Is there a reason why the default exception dialog has a cancel button to kill the application ?

An unhandled exception IMO is due to some software bug, which the user cannot cure in any way.

We often use an exception to signal wrong entry of data or so, because it stops all further processing.

That's okay, if you also implement appropriate exception handling. Exceptions are fine in error situations, that cannot be cured at the place of their occurence. It's up to the program designer to find the best place for handling every intentional exception.

If the user then uses the cancel button, the program is simply ended, which is not what we (or better: the users) want. And I imagine many others use this technique.

No, hopefully not :-(

I have overridden the OnException handler of TApplication, so it's no longer a problem, but I was curious as to why this is done like this by default ?

Insert your exception handler in an more appropriate place, depending on the concrete application. The user can expect a diagnosis of what went wrong, and a chance for correcting his preceding input.

DoDi

Reply by email

Luca Olivetti
to Hans-Peter Diettrich

En/na Hans-Peter Diettrich ha escrit:

Insert your exception handler in an more appropriate place, depending on the concrete application. The user can expect a diagnosis of what went wrong, and a chance for correcting his preceding input.

For data aware components (and probably for others too), Application.OnException is the only place, otherwise you cannot trap exception that are no caused by your program flow but by intrinsic processing by the component (e.g. during post the database could reject the data due to failed constraints, you could trap BeforePost or AfterPost but not DuringPost).

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 (Ext.133) Fax +34 93 5883007

Reply by email

Michael Van Canneyt
to Hans-Peter Diettrich: An unhandled exception IMO is due to some software bug, which the user cannot cure in any…
Hans-Peter Diettrich wrote 7 lines
Michael Van Canneyt schrieb: > Is there a reason why the default exception dialog has a cancel > button to kill the application ? An unhandled exception IMO is due to some software bug, which the user cannot cure in any way.

That's a very restrictive definition of exception. An exception is a way to stop the normal logic and flow of the program. In a GUI application, you rely on the program's event loop to catch the exception (so it is definitely handled) and to show it to the user. If you don't want it to be shown, use the Abort exception.

Borland explains this use in detail in chapter 14 of the Delphi 7 manual.

Michael.

Reply by email

waldo kitty
to Michael Van Canneyt
Michael Van Canneyt wrote 18 lines
On Mon, 16 Mar 2009, Hans-Peter Diettrich wrote: > Michael Van Canneyt schrieb: > >> Is there a reason why the default exception dialog has a cancel >> button to kill the application ? > An unhandled exception IMO is due to some software bug, which the user > cannot cure in any way. That's a very restrictive definition of exception. An exception is a way to stop the normal logic and flow of the program. In a GUI application, you rely on the program's event loop to catch the exception (so it is definitely handled) and to show it to the user. If you don't want it to be shown, use the Abort exception. Borland explains this use in detail in chapter 14 of the Delphi 7 manual.

while i tend to agree wholeheartedly with both side, i have to suppress a LOL at the last statement because this ain't borland's code or definition of "pascal" in any flavo(u)r... this is FPC's definition and even moreso, lazarus' definition at least as far as lazarus is concerned with the code that it compiles ;)

hopefully that's taken in the spirit it is offered from an old TP2/TP3 coder :)

NOTE: NEW EMAIL ADDRESS!! _\/ (@@) Waldo Kitty, Waldo's Place USA __ooO_( )_Ooo_____________________ telnet://bbs.wpusa.dynip.com _|_____|_____|_____|_____|_____|_____ http://www.wpusa.dynip.com ____|_____|_____|_____|_____|_____|____ ftp://ftp.wpusa.dynip.com _|_Eat_SPAM_to_email_me!_YUM!__|_____ wkitty42 -at- windstream.net

Reply by email

Hans-Peter Diettrich
to Michael Van Canneyt: That's a very restrictive definition of exception. An exception is a way to stop the…
Show quoted text 5 lines
> An unhandled exception IMO is due to some software bug, which the user > cannot cure in any way. That's a very restrictive definition of exception. An exception is a way to stop the normal logic and flow of the program.

ACK. And try-except clauses are the way to catch exceptions.

In a GUI application, you rely on the program's event loop to catch the exception

I never did so, for my own or otherwise expected exceptions.

(so it is definitely handled) and to show it to the user. If you don't want it to be shown, use the Abort exception.

Please don't confuse exception catching and handling. Only catching exceptions can (mostly will) leave the application in an invalid state, so that an abort is the only reasonable "handling".

DoDi

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: That's a very restrictive definition of exception. An exception is a way to stop the…
Michael Van Canneyt wrote
Borland explains this use in detail in chapter 14 of the Delphi 7 manual.

Or chapter 13 in the Kylix 3 Developers Guide. ;-) [...at least I still have one use for Kylix... It's help files and documentation.]

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Martin Friebe
to Michael Van Canneyt: That's a very restrictive definition of exception. An exception is a way to stop the…
Michael Van Canneyt wrote 19 lines
On Mon, 16 Mar 2009, Hans-Peter Diettrich wrote: > Michael Van Canneyt schrieb: > > >> Is there a reason why the default exception dialog has a cancel >> button to kill the application ? >> > An unhandled exception IMO is due to some software bug, which the user > cannot cure in any way. > That's a very restrictive definition of exception. An exception is a way to stop the normal logic and flow of the program. In a GUI application, you rely on the program's event loop to catch the exception (so it is definitely handled) and to show it to the user. If you don't want it to be shown, use the Abort exception.

there is a different between an "unhandled exception" and an "exception"

An exception is indeed a very valid thing, that can and maybe should occur within many applications. But any exception should have some code, that handles it.
And this handling code should not be the build-in Lazarus-exception dialog. Because the build-in dialog does not know what the exception meant and what should be done. It could not clean-up, it could not make sure that any memory allocated and referred only by local variables is freed.

So an *unhanded* exception is a software bugs. an unhandled exception in most languages will simply crash the application. The fact that a Lazarus app does ask the user, if he wants to try and continue (and maybe be able to save his work) is a benefit.
But never the less ending up there is a bug. The user doesn't know if he hit an exception for which the programmer intended to fall back on the build-in dialog (and therefore that the app will still run stable); or if this was an exception the programmer did not foresee, and the app will no be unstable, more exceptions may happen, data be corrupted.....

"In a GUI application, you rely on the program's event loop" .... Well, in my very personal opinion: This is just a bad design idea. If I throw an exception, I write a handler for it.

Best regards
Martin

Reply by email

Martin Friebe
to Luca Olivetti: En/na Hans-Peter Diettrich ha escrit: For data aware components (and probably for others…
Luca Olivetti wrote 15 lines
En/na Hans-Peter Diettrich ha escrit: > Insert your exception handler in an more appropriate place, depending on > the concrete application. The user can expect a diagnosis of what went > wrong, and a chance for correcting his preceding input. > For data aware components (and probably for others too), Application.OnException is the only place, otherwise you cannot trap exception that are no caused by your program flow but by intrinsic processing by the component (e.g. during post the database could reject the data due to failed constraints, you could trap BeforePost or AfterPost but not DuringPost).

If a component throws an exception outside any call from your code (which you can place in a "try except end"), a place like OnDataReceived which is triggered automatically, then this component has a bug (IMHO). The component *should* have something like an OnError event on which it can call your code. Or it should have a flag/state, on which it said that an error occurred.
An Exception may be, if an OnError event is provided, but not assigned.

Best Regards
Martin

Reply by email

Michael Van Canneyt
to Martin Friebe
Martin Friebe wrote 23 lines
Luca Olivetti wrote: > En/na Hans-Peter Diettrich ha escrit: > > >> Insert your exception handler in an more appropriate place, depending on >> the concrete application. The user can expect a diagnosis of what went >> wrong, and a chance for correcting his preceding input. >> > > For data aware components (and probably for others too), > Application.OnException is the only place, otherwise you cannot trap > exception that are no caused by your program flow but by intrinsic > processing by the component (e.g. during post the database could reject > the data due to failed constraints, you could trap BeforePost or > AfterPost but not DuringPost). > If a component throws an exception outside any call from your code (which you can place in a "try except end"), a place like OnDataReceived which is triggered automatically, then this component has a bug (IMHO). The component *should* have something like an OnError event on which it can call your code. Or it should have a flag/state, on which it said that an error occurred. An Exception may be, if an OnError event is provided, but not assigned.

Why ?

In the OnValidate event of a TField, you are supposed to throw an exception to stop the user from entering wrong data in the field. This exception can only be caught by the program event loop. This is so by design, and the recommended way by Borland.

Michael.

Reply by email

Michael Van Canneyt
to Martin Friebe: there is a different between an "unhandled exception" and an "exception" An exception is…
Martin Friebe wrote 6 lines
Michael Van Canneyt wrote: > On Mon, 16 Mar 2009, Hans-Peter Diettrich wrote: "In a GUI application, you rely on the program's event loop" .... Well, in my very personal opinion: This is just a bad design idea. If I throw an exception, I write a handler for it.

You cannot always do so. See the TField.OnValidate example in my other mail.

And if Borland designed it so, why not use it ?

Michael.

Reply by email

Hans-Peter Diettrich
to Martin Friebe: If a component throws an exception outside any call from your code (which you can place…
If a component throws an exception outside any call from your code (which you can place in a "try except end"), a place like OnDataReceived which is triggered automatically, then this component has a bug (IMHO).

ACK. Asynchronous operations never should throw exceptions, breaking the control flow of the main application in unrelated places.

DoDi

Reply by email

Martin Friebe
to Michael Van Canneyt: Why ? In the OnValidate event of a TField, you are supposed to throw an exception to stop…
Michael Van Canneyt wrote 17 lines
> If a component throws an exception outside any call from your code > (which you can place in a "try except end"), a place like OnDataReceived > which is triggered automatically, then this component has a bug (IMHO). > The component *should* have something like an OnError event on which it > can call your code. Or it should have a flag/state, on which it said > that an error occurred. > An Exception may be, if an OnError event is provided, but not assigned. > Why ? In the OnValidate event of a TField, you are supposed to throw an exception to stop the user from entering wrong data in the field. This exception can only be caught by the program event loop. This is so by design, and the recommended way by Borland.

I have to admit, I have limited knowledge of the exact details of the data-aware components, and rather was making a general case about my perception of proper exception use.
I just googled => can you point me to some documentation on it?

Following you description, I have no problem if an OnValidate allows the code to use an exception to signal the component some-error state. IMHO the component should have a well defined behaviour on getting this exception.
and IMHO the component should then handle it instead of passing it on (that may require the exception to be of a defined class, so the component knows that the exception is meant for the component)

I wonder what the benefit of passing such an exception to the main-loop is?

If I want to do anything else (anything except signalling the component / anything like informing the user....): It would be far easier to do this where I detect the problem (in the OnValidate Method). Example: different TField.OnValidate may point do different onValidate handlers. each knows what to tell the user, and which options to present to the user.
- If they throw an Exception to stop the Component from writing to the DB => fine
- If they throw an exception, to have the mainloop handling the user-error => that would mean, they have to pack all the information required for error handling into the exception? Why bother, if you can handle the exception locally?

There would be a benefit, if you want to handle exceptions from various OnValidate handlers in one place. Then you could use an exception-class that is not caught by the component. BUT then it was your decision that the exception should go to the main class. It would not be a default

Anyway, the point is, if we are looking at the original source of the discussion (the build-in exception dialog) => that is at best the most limited case of handling an exception (It is simply displaying it). It does not check any need for cleanup, or other actions, or user-help ...... So then you would want to use Application.OnException or similar.

The point with the build in dialog is. that even for Exceptions that have otherwise been handled (like try/finally) and that only need to be displayed. This should be done by your own code, or the Exception should in some other way be marked as "handled, display needed only". Otherwise if you relay on the build-in dialog to do this work for you, you mix up 2 crucially different cases:
1) The just described display-only exception => which wants an "OK" button only
2) Any exception that occurs, that was not expected, and eaves the application potentially unstable. => Which should warn the user, to save his work, and quit the app asap. And that should display a "terminate app now" button

Reply by email

Graeme Geldenhuys
to Martin Friebe: I have to admit, I have limited knowledge of the exact details of the data-aware…

Please note, I don't use db-aware components, but here follows the help from Kylix 3.

Martin Friebe wrote 10 lines
I have to admit, I have limited knowledge of the exact details of the data-aware components, and rather was making a general case about my perception of proper exception use. I just googled ?=> can you point me to some documentation on it? Following you description, I have no problem if an OnValidate allows the code to use an exception to signal the component some-error state. IMHO the component should have a well defined behaviour on getting this exception.

==========[ Kylix 3 help ]================
OnValidate event (TField)
-------------------------
Occurs just before the data is written to the record buffer.

Delphi syntax:
property OnValidate: TFieldNotifyEvent;
C++ syntax:
__property TFieldNotifyEvent OnValidate = {read=FOnValidate, write=FOnValidate};

Description

Write an OnValidate event handler to validate changes made to the data in the field, just before the data is written to the current record buffer. The EditMask property allows validation of the data on a character by character basis while it is being entered by the user. OnValidate allows an application to validate the data as a whole.

When the value of a field component is assigned programmatically, validation by the EditMask is bypassed, since there is no data-aware control to enforce adherence to the mask. OnValidate allows an application to validate such data before it is posted to the database table.

To reject the current value of the field from the OnValidate event handler, raise an exception.

When writing the value of a field to the current record buffer, the following steps occur:
1. The OnValidate event handler is called to validate the data.
2. If the OnValidate event handler does not raise an exception, the data is written to the current record buffer.
3. If writing the data does not raise an exception, the OnChange event handler is called to allow a response to the change. ==========================

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Martin Friebe: I have to admit, I have limited knowledge of the exact details of the data-aware…
Martin Friebe wrote 5 lines
Anyway, the point is, if we are looking at the original source of the discussion (the build-in exception dialog) => that is at best the most limited case of handling an exception (It is simply displaying it). It does not check any need for cleanup, or other actions, or user-help ...... So then you would want to use Application.OnException or similar.

In the case of the TField.OnValidate, I tend to agree with you. I would image that to stop the system from writing data to the db you need to raise a more specific exception like a custom EMyAppValidationError instead of simply Exception. That way you can display it correctly in the Application.OnException with a simple OK button. Anything else "unknown" can use the default dialog - which signifies that the system is now in a possible unstable state. For the latter, application termination is probably the best choice for the user.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Martin Friebe
to Graeme Geldenhuys: Please note, I don't use db-aware components, but here follows the help from Kylix 3.…
Graeme Geldenhuys wrote 22 lines
Please note, I don't use db-aware components, but here follows the help from Kylix 3. On Tue, Mar 17, 2009 at 3:46 PM, Martin Friebe wrote: > I have to admit, I have limited knowledge of the exact details of the > data-aware components, and rather was making a general case about my > perception of proper exception use. > I just googled => can you point me to some documentation on it? > > Following you description, I have no problem if an OnValidate allows the > code to use an exception to signal the component some-error state. > IMHO the component should have a well defined behaviour on getting this > exception. > ==========[ Kylix 3 help ]================ OnValidate event (TField) ------------------------- Occurs just before the data is written to the record buffer.

.....

To reject the current value of the field from the OnValidate event handler, raise an exception.

Then to me the Delphi/Kylix implementation is flawed. Because it forces me to do TWO things, even if I want to do only one of them. There should be:
- an ExceptionClass TDataValitaionException (or whatever) which can be used to abort writing the data, but not defer error handling to the mainloop
- any other exception, that aborts the write, and transfers error handling to the main loop

There are usages for both scenarios, so they should both be possible.

Best Regards
Martin

Reply by email

Michael Van Canneyt
to Martin Friebe
Martin Friebe wrote 37 lines
Graeme Geldenhuys wrote: > Please note, I don't use db-aware components, but here follows the > help from Kylix 3. > > On Tue, Mar 17, 2009 at 3:46 PM, Martin Friebe wrote: > >> I have to admit, I have limited knowledge of the exact details of the >> data-aware components, and rather was making a general case about my >> perception of proper exception use. >> I just googled => can you point me to some documentation on it? >> >> Following you description, I have no problem if an OnValidate allows the >> code to use an exception to signal the component some-error state. >> IMHO the component should have a well defined behaviour on getting this >> exception. >> > > > ==========[ Kylix 3 help ]================ > OnValidate event (TField) > ------------------------- > Occurs just before the data is written to the record buffer. > ..... > To reject the current value of the field from the OnValidate event > handler, raise an exception. > > Then to me the Delphi/Kylix implementation is flawed. Because it forces me to do TWO things, even if I want to do only one of them. There should be: - an ExceptionClass TDataValitaionException (or whatever) which can be used to abort writing the data, but not defer error handling to the mainloop - any other exception, that aborts the write, and transfers error handling to the main loop There are usages for both scenarios, so they should both be possible.

This may be so, but given the implementation as it is in Delphi, hopefully you can now understand my problem with the Lazarus exception dialog :-)

Michael.

Reply by email

Martin Friebe
to Michael Van Canneyt
Michael Van Canneyt wrote 23 lines
On Tue, 17 Mar 2009, Martin Friebe wrote: >> To reject the current value of the field from the OnValidate event >> handler, raise an exception. >> >> >> > Then to me the Delphi/Kylix implementation is flawed. Because it forces > me to do TWO things, even if I want to do only one of them. > There should be: > - an ExceptionClass TDataValitaionException (or whatever) which can be > used to abort writing the data, but not defer error handling to the mainloop > - any other exception, that aborts the write, and transfers error > handling to the main loop > > There are usages for both scenarios, so they should both be possible. > This may be so, but given the implementation as it is in Delphi, hopefully you can now understand my problem with the Lazarus exception dialog :-)

Yes, and no:

Yes I can, if you leave those exception to be handled by the build-in dialog.
Which means that you do not intend to provie any helps or options to the user, but only want to display the message and leave it to the user.

No,
because IMHO you still want to handle it in OnException or similar, and it would therefore be easy to write your own MessageDlg

leaving it to the build-in means you assume it is *impossible* that any other exception can ever occur in your app, and also end up with the same dialog => because if that happens, the user of your application has no way to tell, which of the exceptions are "ok" ; and which indicate that the app just had an internal crash and will now be unstable and data may be lost

In other words: I believe the build-in dialog should feature the text: " The application has just crashed. You may press continue and try to save any data before you quit the application."

Best Regards
Martin

Reply by email

Michael Van Canneyt
to Martin Friebe
Martin Friebe wrote 34 lines
Michael Van Canneyt wrote: > On Tue, 17 Mar 2009, Martin Friebe wrote: > >>> To reject the current value of the field from the OnValidate event >>> handler, raise an exception. >>> >>> >>> >> Then to me the Delphi/Kylix implementation is flawed. Because it forces >> me to do TWO things, even if I want to do only one of them. >> There should be: >> - an ExceptionClass TDataValitaionException (or whatever) which can be >> used to abort writing the data, but not defer error handling to the mainloop >> - any other exception, that aborts the write, and transfers error >> handling to the main loop >> >> There are usages for both scenarios, so they should both be possible. >> > > This may be so, but given the implementation as it is in Delphi, > hopefully you can now understand my problem with the Lazarus > exception dialog :-) > > Yes, and no: Yes I can, if you leave those exception to be handled by the build-in dialog. Which means that you do not intend to provie any helps or options to the user, but only want to display the message and leave it to the user. No, because IMHO you still want to handle it in OnException or similar, and it would therefore be easy to write your own MessageDlg

Well, that's what I did of course :-)

Michael.

Reply by email

svaa
to Hans-Peter Diettrich: ACK. And try-except clauses are the way to catch exceptions. I never did so, for my own…

Hello:

A little off-topic and probably just a stupid idea.

I have wondered many times why there are two different sentences to handle an exception and to clean objects etc. I have missed many times in database work.

I mean:

try
  try
   ......
  except
   <handle>
  end;
finally
  <clean>
end;

It would cleaner if it could be written:

try
   ......
except
  <handle>
finally
  <clean>
end;

I suppose there is a misconception in my idea and it is deadly stupid, because Borland must have had good reasons to design it with two separated blocks, but I can't guess why.

Santiago A.

Reply by email

David W Noon
to svaa
svaa wrote
A little off-topic and probably just a stupid idea.

Not a stupid idea. It is what the Python grammar permits for exception handling.

It seems to be a limitation of the Object Pascal grammar -- and a wholly unnecessary introducing such a change to Object Pascal would require a compiler change, it is probably better to discuss it in the development mailing list, rather than the Lazarus list.

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Reenen Laurie
to Hans-Peter Diettrich

Why can't we (FPC) support all of it? I have absolutely no idea what the implications would be...

You could have it only available with certain compiler directives, defaulting to not supporting it?

Hans-Peter Diettrich wrote 23 lines
svaa schrieb: > It would cleaner if it could be written: > > try > ...... > except > <handle> > finally > <clean> > end; There was such a discussion in a Delphi group, some time ago. I don't remember the arguments, but finally the consens was *not* to combine except and finally into one try block. DoDi _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090317/8521d223/attachment.html

Reply by email