D - more or less power than C++?
Sean Kelly
sean at f4.ca
Sat Mar 4 15:08:14 PST 2006
Walter Bright wrote:
> "Andrew Fedoniouk" <news at terrainformatica.com> wrote in message
> news:dubfs7$95p$1 at digitaldaemon.com...
>>
>> 1) Again, what will happen if on_scope_success will throw?
>
> I believe I answered that. Throwing in on_scope is like throwing in a
> destructor or in a finally block. It's a very bad idea, and will probably
> produce a double fault exception. The same issue exists with C++.
DMD will throw the new exception and the old one will be discarded.
.NET (or C# at any rate) has the same basic behavior, though it may be
the the original exception that is retained in .NET, I can't remember
offhand. I think the current approach is arguably better than a call to
terminate, as the C++ approach reduces the general utility of RAII.
>> 2) As I said before, implementation of on_scope_success
>> seems like artificial to D. In syntax and in implementation.
>
> If by that you mean it is unique to D, then yes, it is. But it is based on
> work done by experts in the field who have attempted to bash C++ into doing
> it, and those experts have reviewed on_scope. They've helped me understand
> what the issues are, and what the solution should look like, and I've
> implemented that solution. So I have a lot of confidence that it is the
> right solution.
>
> I know that it's unfamiliar, and it took me a while to get it.
For what it's worth, Andrei has put all of his articles online at
http://erdani.org/publications/ His original article on ScopeGuard is
well worth reading. A direct link is here:
http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm
Sean
More information about the Digitalmars-d
mailing list