PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Dispose Blocks Pattern

Dispose Blocks Pattern

Dispose Blocks Pattern is a language feature.

To make the safe use of the dispose pattern less verbose, several languages have some kind of built-in support for resources held and released in the same block of code.

Languages without Dispose Blocks Pattern include Ruby

Languages with Dispose Blocks Pattern include Python, C#

Example from Python:

with resource_context_manager() as resource: # Perform actions with the resource. # Perform other actions where the resource is guaranteed to be deallocated.

Example from C#:

using (Resource resource = GetResource()) { // Perform actions with the resource. ... }

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub