anonymous functions and scope(exit)

Luis Luis.panadero at gmail.com
Sat Jul 3 22:04:04 UTC 2021


On Saturday, 3 July 2021 at 20:46:00 UTC, Steven Schveighoffer 
wrote:
> On 7/3/21 4:08 PM, frame wrote:
>> On Saturday, 3 July 2021 at 17:39:18 UTC, Steven Schveighoffer 
>> wrote:
>> 
>>> But in practice, the compiler does not have to clean up 
>>> anything when an `Error` is thrown. Whether it does or not is 
>>> defined by the implementation.
>> 
>> This should be really mentionend in the docs? "Guard", yeah...
>> 
>> 
>
> Yeah, there isn't a good discussion of the differences between 
> Error and Exception on that page.
>
> -Steve

On [The D Error Handling 
Solution](https://dlang.org/spec/errors.html#the_d_error_handling_solution), says :

> If code detects an error like "out of memory," then an Error is 
> thrown with a message
> saying "Out of memory". The function call stack is unwound, 
> looking for a handler for
> the Error. Finally blocks are executed as the stack is unwound. 
> If an error handler is
> found, execution resumes there. If not, the default Error 
> handler is run, which displays
> the message and terminates the program.

scope(exit) it's syntactic sugar for a classic `try {} finally 
{}` . The documentation says that must be executed.



More information about the Digitalmars-d-learn mailing list