E01080: 'self' does not exist in EK9 - use 'this' keyword
What went wrong
The 'self' keyword does not exist in EK9.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 793 (Why does EK9 reject None and self as identifiers?)
Rationale
EK9 uses 'this' instead of 'self':
- Consistent with Java, C++, JavaScript conventions
- EK9 targets developers from multiple language backgrounds
- 'this' is implicit in most contexts
How to fix it
Replace 'self' with 'this', or omit it entirely when unambiguous.
See also
- E01077: 'def' not supported (EK9 uses function name directly)
- E01078: 'elif' not supported (use 'else if')
- E01079: 'None' not supported (use tri-state semantics)
- E01080: 'self' not supported (use 'this')
- E01081: list comprehensions not supported (use stream pipelines)
https://ek9.io/classes.html https://ek9.io/forAI.json#$.excludedFeatures.features[?(@.keyword=="self")]
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E01080: 'self' does not exist in EK9 - use 'this' keyword
#!ek9 defines module error.e01080.bad defines class Person name as String: "Steve" greeting() <- rtn as String: "I am " + self.name default operator ?
Fixed: Use 'this', or just the property name when that is unambiguous
#!ek9 defines module error.e01080.good defines class Person name as String: "Steve" greeting() <- rtn as String: "I am " + this.name shortGreeting() <- rtn as String: "I am " + name default operator ?
Questions and answers
These Q&A entries show E01080 and its fix:
Found a problem?
If EK9 reported E01080 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.