On Fri, May 25, 2012 at 7:16 PM, David Rajchenbach-Teller <
dtel...@mozilla.com> wrote:

> On Fri May 25 18:01:25 2012, Patrick Walton wrote:
> > On 05/25/2012 08:43 AM, Kevin Cantu wrote:
> >> This conversation reminds me of Alexandrescu's talk about D's scope
> >> keyword:
> >>
> http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D
> >>
> >>
> >> It looks like a graceful syntax for handling all sorts of nested error
> >> and failure cleanup...
> >
> > I like the scope keyword, FWIW. It'd be even better if you didn't have
> > to provide a variable name if all you want to do is execute some code
> > at the end of the block.
> >
> > This would provide a facility like Go's "defer" keyword, but more
> > general since it also admits C++ RAII patterns.
> >
> > Patrick
>
> What's the difference between |scope| and Rust's resources, exactly?
>
> Cheers,
>  David
>
> --
> David Rajchenbach-Teller, PhD
>  Performance Team, Mozilla
>
>
> Regarding adding logs to the errors:

- Boost.Exception has something similar: you can add class instances to the
exception using the error info mechanism [1]
- It also reminds me of what happens in case of failures using the "note"
expressions, I believe the same notes could be reused in case of
exceptions/errors to provide additional logs.

Of course, there is a difference between the two schemes. Boost's is
somewhat more powerful because it does not consist of adding simple strings
but full-blown objects (which could be conditionned to be printable), and
thus allow inspection of structured data at the error-handling site. It may
be thought of as overkill too...


Regarding D's scope keyword [2]

There are several statements based on it:

 - scope(exit) xxxx where xxxx is executed on exit, no matter what
 - scope(failure) xxxx where xxxx is executed on exit if the previous
statement failed
 - scope(success) xxxx where xxxx is executed on exit if the previous
statement succeeded

On the other hand, it kind of look like a hack, maybe it is an issue of
getting used to it though.


 [1]:
http://www.boost.org/doc/libs/1_49_0/libs/exception/doc/error_info.html
 [2]: http://dlang.org/exception-safe.html
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to