Thread overview
throw
Mar 13, 2002
Pavel Minayev
Mar 13, 2002
Walter
Mar 13, 2002
Pavel Minayev
Mar 13, 2002
Russ Lewis
Mar 13, 2002
Walter
Mar 13, 2002
Pavel Minayev
March 13, 2002
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
"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
"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
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
"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
"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.