Why do references need a module qualifier with :: in EK9?

← Syntax and Structure Rules · Ref: Q851

References in EK9 must include the module qualifier with the '::' separator. A bare type name without a module path is invalid and raises E01010.

WHY MODULE QUALIFIERS ARE REQUIRED

EK9 uses explicit module references to avoid ambiguity. Two modules might define a type with the same name. The module qualifier ensures the compiler resolves the correct type. Without it, the reference is ambiguous and meaningless.

CORRECT SYNTAX

  references
    some.module::SomeType
    another.module::AnotherType

INCORRECT SYNTAX

  references
    SomeType           // E01010: no module qualifier
    ::SomeType         // E01010: missing module name

See Q10 for module structure. See Q12 for module naming. See Q852 for reserved module names.

Example

defines module qa.syntax.reference.qualifier

  defines function

    <?-
      Simple function demonstrating correct module code.
      References use the format: module.name::SymbolName
    -?>
    formatGreeting() as pure
      -> name as String
      <- rtn as String: `Hello, ${name}!`

  defines program

    ReferenceDemo()
      stdout <- Stdout()

      //Correct references use: module.name::SymbolName
      //Bare names like 'SomeType' without module:: cause E01010
      stdout.println(formatGreeting("Steve"))

Common mistakes

E01010 — References must include the full module path followed by :: and the symbol name. Bare type names without a module qualifier are invalid. See ek9 -h E01010 for details.

Incorrect:

defines module qa.syntax.reference.qualifier

  references
    SomeType

Correct:

defines module qa.syntax.reference.qualifier
Other ways to ask this
  • What is E01010 in EK9?
  • How do I reference types from other modules?
  • What is the correct reference syntax in EK9?
  • Why does a bare type name in references cause an error?

Coming from another language?

Java: import statements use dot notation (java.util.List). Python: import uses dot notation (from os.path import join). Rust: use statements with :: (std::collections::HashMap). Go: import with path strings. EK9: references use module.name::SymbolName with :: separator, E01010 if module qualifier missing.

Keywords: separator, syntax, namespace, qualifier, import, E01010, module, symbol, structure, reference