Menu

Members and methods

Will Pittenger

Below are some keywords you can apply to various types of members and methods. You are required to specify an access qualifier for each member except creators and destructors (for which it's implied).

Keyword What it can be applied to Meaning
private Any member or method except static constructors and creators The member or method isn't accessible outside this class—even to derived classes.
protected Any member or method except static constructors and creators The member or method isn't accessible outside this except for classes derived from this class.
public Any member or method except static constructors and creators The member or method is accessible from any code anywhere.
virtual Any method or property except constructors and creators Derived classes can override this method or property.
override Any method or property declared as virtual in the base class Use this to override the base class method or property.
new Anything other than constructors and creators that would hide a member in the base class The parser should consider anything hiding something in the base class an error unless the override (virtual items only) or new keywords are present.
abstract Any method or property except constructors and creators This class doesn't implement this method or property and must be implemented by derived classes that aren't abstract
const Any var that's a reference type Creates a variable where the reference can be changed, but the instance can't
const Any immutable data member that isn't a var (use const instead of var) Creates a named constant that really only exists during compilation.
const Any method or property get accessor Indicates the method or property get accessor won't change self.
readonly Any data member Prevents changes once initialized. With reference types, this affects the reference and not what the reference is pointing to. If you want both be be readonly, use readonly and const.

Complex statements as methods

Any type of procedure, including commands, functions, and complex statements can be methods. Below is a foreach written as a method:

class MyClass
  public statement foreach var out index%
    ' step through the instances and call **instructions** for each one

You'd call it with this:

MyClass instance = new MyClass

instance.foreach var index%
  ' Do something with it

Any qualifier can be applied to a complex statement method. Complex statements can be methods inside interfaces too.


Related

Wiki: Commands
Wiki: Home
Wiki: When is it a procedure, command, function, property, property accessor, method, complex statement, or type cast?
Wiki: keywords-final
Wiki: keywords-instructions
Wiki: keywords-private
Wiki: keywords-protected
Wiki: keywords-public
Wiki: keywords-var
Wiki: keywords-virtual