Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 13, 2002 throw | ||||
---|---|---|---|---|
| ||||
Why doesn't D allow throw statement without arguments? In C++ it rethrows the exception being processed, what's bad in it? |
March 13, 2002 Re: throw | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:a6mlkb$1ada$1@digitaldaemon.com... > Why doesn't D allow throw statement without arguments? In C++ it rethrows the exception being processed, what's bad in it? I just didn't think that added much of anything. |
March 13, 2002 Re: throw | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a6n1po$1fp3$1@digitaldaemon.com... > I just didn't think that added much of anything. Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: try { ... } catch (OutOfMemory) { // do something useful here throw; } |
March 13, 2002 Re: throw | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Pavel Minayev wrote: > "Walter" <walter@digitalmars.com> wrote in message news:a6n1po$1fp3$1@digitaldaemon.com... > > > I just didn't think that added much of anything. > > Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: > > try > { > ... > } > catch (OutOfMemory) > { > // do something useful here > throw; > } It's also useful for reporting errors of unrecognized exceptions: try { ... } catch(...) { printf("error in myfunc(): "); throw; }; -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] |
March 13, 2002 Re: throw | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3C8F83A7.6B5C1214@deming-os.org... > Pavel Minayev wrote: > > > "Walter" <walter@digitalmars.com> wrote in message news:a6n1po$1fp3$1@digitaldaemon.com... > > > > > I just didn't think that added much of anything. > > > > Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: > > > > try > > { > > ... > > } > > catch (OutOfMemory) > > { > > // do something useful here > > throw; > > } > > It's also useful for reporting errors of unrecognized exceptions: > > try > { > ... > } > catch(...) > { > printf("error in myfunc(): "); > throw; > }; Just use: catch(Object o) { ... throw o; } |
March 13, 2002 Re: throw | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a6o83v$208d$1@digitaldaemon.com... > Just use: > catch(Object o) > { > ... > throw o; > } > Yes, I remember that only objects can be thrown in D. Yet, "throw;" seems to be a convenient feature to me. Something that can be accomplished by other means, but just makes your life a bit easier. |
Copyright © 1999-2021 by the D Language Foundation