Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [matlab] Entsprechung für "try finally" (https://www.delphipraxis.net/130507-%5Bmatlab%5D-entsprechung-fuer-try-finally.html)

sirius 9. Mär 2009 17:57


[matlab] Entsprechung für "try finally"
 
Gibt es in MatLab so etwas wie try..finally?

Ich finde nur try..catch, aber das entspricht ja try..except in Delphi.

Win32.API 9. Mär 2009 18:10

Re: [matlab] Entsprechung für "try finally"
 
Code:
try
 try_fkt();
finally
 finally_fkt();
end;
=>

Code:
try
{
 try_fkt();
}
catch (..)
{

}
finally_fkt();
Oder sehe ich das falsch?

Apollonius 9. Mär 2009 18:16

Re: [matlab] Entsprechung für "try finally"
 
Ein Finally stoppt die Exception nicht, sie wird weiter durchgereicht.

sirius 9. Mär 2009 18:21

Re: [matlab] Entsprechung für "try finally"
 
Zitat:

Zitat von Apollonius
Ein Finally stoppt die Exception nicht, sie wird weiter durchgereicht.

Genau.

Man kann das natürlich auch mit try..catch umgehen:
Code:
wb = waitbar(0,'Please wait...');
try
 ...
catch Exception
  close(wb);
  rethrow(Exception);
end;
close(wb);
Aber dann muss man das, was man normalerweise in Finally macht (hier: "close(wb)")zweimal schreiben.


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:25 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz