Why does EK9 reject None and self as identifiers?

← Getting Started · Ref: Q793

EK9 deliberately excludes the Python keywords 'None' and 'self' from the language.

NONE (E01079)

Python uses 'None' as its null equivalent. EK9 uses tri-state semantics (absent/unset/set) instead. The '?' operator checks whether a value is set. There is no null or None concept in EK9.

SELF (E01080)

Python uses 'self' as the explicit instance reference. EK9 uses 'this' (implicit in most contexts), consistent with Java, C++, and JavaScript conventions.

CORRECT PATTERNS

- Check if set: 'if userName?' (not 'if userName == None')
- Unset variable: 'userName <- String()' creates an unset String
- Instance reference: 'this.fieldName' (not 'self.fieldName')

See Q786 for other excluded keywords. See Q39-Q41 for tri-state semantics.

Example

defines module qa.gettingstarted.noneself

  defines program

    TriStateDemo()
      stdout <- Stdout()

      userName <- String()
      greeting <- "Hello"

      if userName?
        stdout.println(`${greeting} ${userName}`)
      else
        stdout.println("No user name set yet")

Common mistakes

E01079 — The identifier 'None' is an excluded Python keyword and cannot be used as a variable name in EK9. EK9 uses tri-state semantics (absent/unset/set) instead of None/null. See ek9 -h E01079 for details.

Incorrect:

      None <- String()

Correct:

      userName <- String()

E01080 — The identifier 'self' is an excluded Python keyword and cannot be used as a variable name in EK9. EK9 uses 'this' for instance references. See ek9 -h E01080 for details.

Incorrect:

      self <- "Hello"

Correct:

      greeting <- "Hello"
Other ways to ask this
  • What triggers E01079 None not supported?
  • Why can't I use self in EK9 like Python?
  • What is E01080 self not supported?

Coming from another language?

Python: None is the null equivalent, self is the instance reference. Java: null exists, this is the instance reference. Rust: no null (Option instead), no self keyword for instances. Kotlin: null with nullable types, this is implicit. Go: nil is the zero value, no self/this keyword. EK9: None and self are rejected at the grammar level with specific error messages guiding developers to EK9 alternatives.

Keywords: Python, tri-state, self, keyword, E01080, isSet, E01079, excluded, None