Advanced Computing Environment
Hosted by SourceForge
brix-os project page

Previous: Constructors ----- Up: Contents ----- Next: Accessors


Resources need a gaurantee that they will be released when the object is garbage collected. The resource_interface defines a release property that uses the special `destructor flag which registers the property with the garbage collector. This allows the GC to invoke the property and release the resource before deallocating the object.

	resource_interface := deftype ()
	  `destructor release = def (r:Self);

Resource Scopes
The WITH extension takes a single resource declaration or multiple inside a list and each resource is released when exiting the block.

WITH declarations -> body
  • declarations -- unwrapped list of resource declarations
  • -> -- required syntax
  • body -- single or block expression
	with a = openFile("foo"), b = openFile("bar") -> {

Previous: Constructors ----- Up: Contents ----- Next: Accessors