www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

digitalmars.D - restriction in finally no catch

↑ ↓ ← Frank Benoit <keinfarbton nospam.xyz> writes:
Actually DMD has the restriction, that a catch in not allowed within a
finally block.

A very simple workaround:

try{
}
catch( Exception e){
}
finally(
  void block(){
    try{
    }
    catch( Exception e){
    }
  }
  block();
}

This is OK for the compiler.
I don't know the reason for this restriction, but
isn't it possible to get rid of it?
Oct 09 2006
↑ ↓ BCS <BCS pathlink.com> writes:
Frank Benoit wrote:
 Actually DMD has the restriction, that a catch in not allowed within a
 finally block.
 
 A very simple workaround:
 

another option: try { } catch( Exception e) { } finally { // delegate literal (){ try { } catch( Exception e) { } }(); // called directly }
Oct 09 2006
↑ ↓ → "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
So if there is a simple workaround like this, why not remove the
restriction?
Oct 22 2006