Wiki

Changes between Version 1 and Version 2 of Keywords

Show
Ignore:
Timestamp:
10/30/10 20:01:00 (14 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Keywords

    v1 v2  
    77In the compiler source code is an index of all keywords including name, "reserved" indicator, area (such as statement or contracts) and description. You can find this in !CobraWorkspace/Source/KeywordSpecs.cobra which you can [http://cobra-language.com/trac/cobra/browser/cobra/trunk/Source/KeywordSpecs.cobra view online]. 
    88 
     9Furthermore, there is a small utility program in !CobraWorkspace/Supplements/keywords.cobra that gives programmatic access to this reference data without having to reference the rest of the compiler. 
     10 
     11== Keywords as Member Names == 
     12 
     13A method can have the same name as a keyword: 
     14{{{ 
     15#!python 
     16class A 
     17 
     18    def print 
     19        print .toString 
     20 
     21    def main 
     22        .print   # invoking a method whose name coincides with a keyword 
     23}}} 
     24 
     25The methods and properties of a class, struct or interface can use keywords as their names. For example, you can create a property called "lock" or a method called "branch". This is possible because in Cobra, properties and methods are always accessed through a dot (.) such as "obj.foo", unless the member name starts with an underscore such "_foo" which can be invoked directly. Obviously a method that starts with an underscore will not coincide with any keyword above. 
     26 
    927== See Also == 
    1028