Wiki
Version 2 (modified by hopscc, 16 years ago)

--

Access Modifiers

Access Modifiers can be specified on Classes, Class (instance and class) variables and methods to set their visibility and accessibility
These are also called 'isNames' in the Cobra doc and Discussion since they're specified with a leading is keyword.

Method Access modifiers

virtual, public is default for methods

protected is default for class/instance variables with _ prefix on name
public is default for variables without _ prefix

Valid 'is' keywords are

  • fake - specifies item has no implementation - a placeholder
  • shared - Specifies Class (static) method or variable,
  • virtual, nonvirtual - on methods, specifies that the method overridable or not
  • override, new - on methods specifies that a method is overriding or replacing a baseclass method of same signature
  • public, protected, private, internal - specifies item visibility
  • abstract - specifies a template only, subclasses must define fully

Separate multiple modifiers with , e.g .... is protected, override

is fake
temporary for defining class/method api without implementation
e.g

class TextWriter
    is fake

    get newLine as String
        pass

is shared
on instance variable makes it a class variable (same as static (in Java))

is public/protected/private
on class or method(s) adjust visibility (default public)
is abstract
on class or method(s) Is a Template for subclasses to provide implementation of.
is virtual
method is redefinable (default)
is nonvirtual
method is not redefinable
is override
Specifies that this method implementation is a redefinition of an existing(shadowed virtual or abstract) method defined in a superclass
is new
Designate that this method is a new one that hides the one that would have been inherited from a baseclass. e.g
class Vehicle

    def drive is nonvirtual
        pass

class Car inherits Vehicle

    def drive is new
       pass

When a method, property or indexer has the same name and type signature as a base member, you must specify is override or specify is new or use base. in the implementation (which is an implicit is override)