Menu

keywords-destructor

Will Pittenger

Destructors are a special command your types can declare to assist the garbage collector with cleaning up and deallocating instances of your class and your static members when you type is unloaded. Each type can have two destructors: one for the instances and one for static members. Destructors are always private and never take parameters. Destructors can only be called by the garbage collector. Most types don't need destructors. An example of one that might would be a type with an open file with data that needs flushed to the file. The destructor could flush the file. With both types of destructors, your base type's destructor will be called when your returns. If your type has multiple base types, their destructors will be called in the order your type lists them when it was declared in its extends clause.

Instance destructors

If your class lacks an instance destructor, the compiler will provide a one for you.

\destructor\
  ' Clean up

Static destructors

A destructor that's static is called automatically when the module containing your type is unloaded. If your class lacks an static destructor, the compiler will provide a one for you.

\static\ \destructor\
  ' Clean up

Related

Wiki: Attributes
Wiki: Keywords
Wiki: keywords-extends