Wiki

Changes between Version 5 and Version 6 of AccessModifiers

Show
Ignore:
Timestamp:
01/14/14 11:09:35 (11 years ago)
Author:
hopscc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AccessModifiers

    v5 v6  
    11= Access Modifiers = 
    22 
    3 Access Modifiers can be specified  on Classes, class (instance and class) variables and methods to set their visibility and accessibility[[BR]] 
     3Access Modifiers can be specified  on Classes, (instance and class) variables and methods to set their visibility and accessibility[[BR]] 
    44These are also called 'isNames' in the Cobra doc and discussion since they're specified with a leading '''is''' keyword. 
    55 
    6 Method Access modifiers 
    7     '''virtual, public''' is default for methods[[BR]] 
    8  
    9     '''protected''' is default for methods and  class/instance variables with '''_''' prefix on name[[BR]] 
    10     '''private''' is default for methods and class/instance variables with '''_ _''' (double underscore) prefix on name[[BR]] 
    11     '''public''' is default for variables without any '''_''' prefix 
    126 
    137Valid 'is' keywords are  
    148 *       '''fake''' - specifies item has no implementation - a placeholder (deprecated in favor of '''extern''') 
    15  *       '''shared''' - Specifies Class (static) method or variable,  
     9 *       '''extern''' - item has no implementation and is defined elsewhere (outside a cobra file) (replaces/preferred to '''fake''') 
     10 *       '''shared''' - Specifies a Class (static) method or variable,  
    1611 *       '''virtual''',   '''nonvirtual''' -  on methods, specifies that the method is overridable or not  
    1712 *       '''override''', '''new'''         -  on methods specifies that a method is overriding or replacing a baseclass method of the same signature 
    1813 *       '''public''', '''protected''', '''private''', '''internal''' - specifies item visibility  
    19  *       '''abstract''' - specifies a template only, subclasses must define fully 
    20  *       '''extern''' - item has no implementation and is defined elsewhere (outside a cobra file) 
     14 *       '''abstract''' - specifies the class or method is a template only, subclasses must define fully 
    2115 *       '''partial''' - on class types - specifies that the type is defined across multiple files                                
    2216 *       '''readonly''' specifies that a variable or field cannot be modified.  
    23             It must be initialised as early as possible and cannot have its value modified after. 
     17         *   It must be initialised as early as possible and cannot have its value modified after. 
    2418 
    2519Separate multiple modifiers with ''',''' e.g    ....  is protected, override 
     20 
     21    '''protected''' is default for methods and  class or instance variables with '''_''' prefix on name[[BR]] 
     22    '''private''' is default for methods and class or instance variables with '''_ _''' (double underscore) prefix on name[[BR]] 
     23    '''public''' is default for variables without any '''_''' prefix 
     24 
     25 
     26 
     27== Class is-names == 
     28    classes  and interfaces are '''public''' by default[[BR]] 
     29 
     30 *       '''fake''' - specifies class has no implementation - a placeholder (deprecated in favor of '''extern''') 
     31 *       '''extern'''  - class has no implementation and is defined elsewhere (outside a cobra file) - replaces '''fake'''. 
     32 *       '''shared''' - Specifies that the entire class is made of static methods and  (class) variables,  
     33 *       '''public''', '''protected''', '''private''', '''internal''' - specifies the class visibility (default is '''public''')  
     34 *       '''abstract''' - specifies the class is a template only, subclasses must define fully 
     35 *       '''partial'''  - specifies that the type is defined across multiple files                                
     36 
     37== Method is-names == 
     38    methods are '''virtual, public''' by default[[BR]] 
     39 
     40    Methods prefixed with '''_''' on their names  are '''protected''' by default[[BR]] 
     41    Methods prefixed with   '''_ _''' (double underscore) on their names are '''private''' by default.[[BR]] 
     42    Methods with no underscore prefixes are '''public''' by default. 
     43 
     44 *       '''fake''' - specifies method has no implementation - a placeholder (deprecated in favor of '''extern''') 
     45 *       '''extern''' - method has no implementation and is defined elsewhere (outside a cobra file) (use instead of '''fake''') 
     46 *       '''shared''' - Specifies a class (static) method,  
     47 *       '''virtual''',   '''nonvirtual''' -  specifies that the method is overridable or not  
     48 *       '''override''', '''new'''         -  specifies that a method is overriding or replacing a baseclass method of the same signature 
     49 *       '''public''', '''protected''', '''private''', '''internal''' - specifies item visibility  
     50 *       '''abstract''' - specifies the method is a template only, subclasses must define fully 
     51 
     52== Type variables or fields is-names == 
     53 
     54    These are '''virtual, public''' by default[[BR]] 
     55 
     56    Type variables prefixed with '''_''' on their names  are '''protected''' by default[[BR]] 
     57    Type variables prefixed with   '''_ _''' (double underscore) on their names are '''private''' by default.[[BR]] 
     58    Type variables with no underscore prefixes are '''public''' by default. 
     59 
     60 *       '''shared''' - Specifies a class (static) variable (rather than an instance variable),  
     61 *       '''public''', '''protected''', '''private''', '''internal''' - specifies item visibility  
     62 *       '''readonly''' specifies that a variable or field cannot be modified once initialised.  
     63         *   It must be initialised as early as possible and cannot have its value modified after. 
     64 
    2665 
    2766 
     
    3069 
    3170Visibility (or accessibility) denotes the access to types or type variables (fields)  
    32  * public    -  the most permissive access level. There are no restrictions on accessing public members or public types. 
    33  * protected - access is limited to the containing class or types derived from the containing class. 
    34  * private   - access is limited to the containing type. 
    35  * internal  - access is limited to the current assembly (or packaging entity). 
     71 * '''public'''    -  the most permissive access level. There are no restrictions on accessing public members or public types. 
     72 * '''protected''' - access is limited to the containing class or types derived from the containing class. 
     73 * '''private'''   - access is limited to the containing type. 
     74 * '''internal'''  - access is limited to the current assembly (or packaging entity). 
    3675 
    3776These modifiers cannot always map exactly as specified to backend supported visibility layers so best to treat them as decreasing 
     
    4180 
    4281    * is extern:: 
    43        - temporary for defining class/method api without implementation 
     82       - temporary for defining a class/method API without implementation 
    4483e.g 
    4584{{{  
     
    5291    
    5392    * is shared:: 
    54         - on instance variable makes it a class variable. 
     93        - on a variable/field of a type makes it a class variable. 
    5594        - on method makes it a class method 
    5695        -     (effect is same as static (in C#, Java)) 
     
    64103 
    65104    * is public/protected/private/internal:: 
    66          - on class, instance variable or method(s) 
     105         - on class, type variable or method(s) 
    67106         - adjust visibility (default public) 
    68107 
     
    72111 
    73112    * is virtual:: 
    74        - method is redefinable/subclassable (default) 
     113        - on a method 
     114        - method is redefinable/subclassable (default) 
    75115 
    76116    * is nonvirtual::     
    77         - method is not redefinable, cannot be subclassed. 
     117        - on a method 
     118        - method is not redefinable, cannot be redefined or overridden. 
    78119 
    79120    * is override:: 
    80121        - on a method 
    81         - Specifies that this method implementation is a redefinition of an existing(shadowed virtual or abstract) method defined in a superclass 
     122        - Specifies that this method implementation is a redefinition of an existing(shadowed virtual or abstract) method defined in a base (or ancestor) class 
    82123 
    83124    * is new:: 
    84125       - on a method  
    85        - designate that this method is a new one that hides the one that would have  
     126       - designate that this method is a new one that hides the one (nonvirtual) that would have  
    86127        been inherited from a baseclass. 
    87128        e.g 
     
    93134        pass 
    94135 
     136    def steer # virtual by default 
     137 
    95138class Car inherits Vehicle 
    96139 
    97140    def drive is new  # replaces superclass method 
    98141       pass 
     142 
     143    def steer is override # is override must be specified to indicate planned override of virtual baseclass method 
    99144}}} 
    100145 
     
    105150 
    106151    * is partial:: 
    107        - on class types ( class, structures, interfaces) 
     152       - on class types (class, structures, interfaces) 
    108153       - indicates that the type is defined across multiple files. Each piece so defined must be so tagged.  
    109        - Idiomatically the first file compiled should have the full declaration (inheritance, attrinutes etc) and the remainder have only the access modifies ( including 'partial') 
     154       - Idiomatically the first file compiled should have the full declaration (inheritance, attributes etc) and the remainder have only the access modifies ( including 'partial') 
    110155 
    111156    * is readonly::