www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - In/Out can't throw.

reply AJG <AJG_member pathlink.com> writes:
Hi,

For some reason, one can't throw exceptions within In/Out blocks. This seems
rather arbitrary; moreover, it's pointless because you can get around it with a
dummy function.

So, is this "by-design," or just an oversight?

Either way, it would be nice to eliminate this inconvenient restriction.

Thanks,
--AJG.
Aug 20 2005
parent reply Derek Parnell <derek psych.ward> writes:
On Sun, 21 Aug 2005 04:59:25 +0000 (UTC), AJG wrote:

 Hi,
 
 For some reason, one can't throw exceptions within In/Out blocks. This seems
 rather arbitrary; moreover, it's pointless because you can get around it with a
 dummy function.
 
 So, is this "by-design," or just an oversight?
 
 Either way, it would be nice to eliminate this inconvenient restriction.
At first, I thought this might be because contract failures are not meant to be recoverable, but from testing it seems you can catch an assert error coming from an out{} block. So I don't understand this restriction either. Is it documented? -- Derek Parnell Melbourne, Australia 21/08/2005 3:42:02 PM
Aug 20 2005
parent reply AJG <AJG_member pathlink.com> writes:
 For some reason, one can't throw exceptions within In/Out blocks. This seems
 rather arbitrary; moreover, it's pointless because you can get around it with a
 dummy function.
 
 So, is this "by-design," or just an oversight?
 
 Either way, it would be nice to eliminate this inconvenient restriction.
At first, I thought this might be because contract failures are not meant to be recoverable, but from testing it seems you can catch an assert error coming from an out{} block. So I don't understand this restriction either. Is it documented?
I haven't seen it anywhere. I say leave the docs alone, and just get rid of it ;). --AJG.
Aug 20 2005
parent =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

AJG schrieb:

For some reason, one can't throw exceptions within In/Out blocks. This seems
rather arbitrary; moreover, it's pointless because you can get around it with a
dummy function.

So, is this "by-design," or just an oversight?

Either way, it would be nice to eliminate this inconvenient restriction.
At first, I thought this might be because contract failures are not meant to be recoverable, but from testing it seems you can catch an assert error coming from an out{} block. So I don't understand this restriction either. Is it documented?
I haven't seen it anywhere. I say leave the docs alone, and just get rid of it ;).
There are two interesting question tough. http://www.digitalmars.com/d/dbc.html 1) Has "throw" side effects? 2) If "throw" has now side effects, what is the exception tree of the following code? a) Exception -> SomeException b) Exception -> {auto insert: InException} -> Exception **** class SomeException : Exception{ } void sample() in{ throw new SomeException; }body{ } Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDEJ/N3w+/yD4P9tIRAjR8AKDEfuTPxfByAlIl68DoDFDeK0438gCgg/lk Yp1VwuXPsArleHokvBsNRkI= =b97T -----END PGP SIGNATURE-----
Aug 27 2005