Scope

@implicitNotFound(msg = "Resource acquisition requires a scope.")
trait Scope

Scoped implicit lifetime.

The main idea behind the Scope is to encode resource lifetimes through a concept of an implicit scope. Scopes are necessary to acquire resources. They are responsible for disposal of the resources once the evaluation exits the demarkated block in the source code.

See https://www.youtube.com/watch?v=MV2eJkwarT4 for details.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def acquire(res: Resource): Unit

Push resource onto the resource stack.

Push resource onto the resource stack.

def close(): Unit

Clean up all the resources in FIFO order.

Clean up all the resources in FIFO order.