| 9 | Furthermore, 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 | |
| 13 | A method can have the same name as a keyword: |
| 14 | {{{ |
| 15 | #!python |
| 16 | class 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 | |
| 25 | The 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 | |