E01078: 'elif' does not exist in EK9 - use 'else if' (two words)

Category: E01xxx Parsing and excluded constructs · Reported in phase: SYMBOL_DEFINITION · Classification: ELIF_NOT_SUPPORTED · All error codes

What went wrong

The 'elif' keyword does not exist in EK9.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 786 (Which keywords from other languages are excluded from EK9?)

Rationale

EK9 uses 'else if' as two separate words:

  • More readable and explicit
  • Consistent with natural English
  • No abbreviations to memorize

How to fix it

Replace 'elif' with 'else if' (two words).

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/flowControl.html#if_elseif_else https://ek9.io/forAI.json#$.excludedFeatures.features[?(@.keyword=="elif")]

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E01078: 'elif' does not exist in EK9 - use 'else if' (two words)

#!ek9
defines module error.e01078.bad

  defines constant
    Big <- 10
    Medium <- 5

  defines function

    describeSize()
      -> size as Integer
      stdout <- Stdout()
      if size > Big
        stdout.println("big")
      elif size > Medium
        stdout.println("medium")

Fixed: Write 'else if' as two words

#!ek9
defines module error.e01078.good

  defines constant
    Big <- 10
    Medium <- 5

  defines function

    describeSize()
      -> size as Integer
      stdout <- Stdout()
      if size > Big
        stdout.println("big")
      else if size > Medium
        stdout.println("medium")
      else
        stdout.println("small")

Questions and answers

These Q&A entries show E01078 and its fix:

Found a problem?

If EK9 reported E01078 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.