What is a 'gated type' in EK9 and which types are currently gated?

← Package Capability Security · Ref: Q1273

A GATED TYPE is a built-in EK9 type that represents access to a system resource — network sockets, filesystem, environment variables, standard streams, clocks, signals, and so on. Every gated type is defined in 'org.ek9.lang' and requires a matching entry in a publishable package's 'capabilities' list.

The full gated-type list (from GatedTypeMapping.java) groups related types under a single primary capability. Declaring the primary automatically covers the related types.

NETWORK

  org.ek9.lang::TCP           covers TCP, TCPConnection, TCPHandler
  org.ek9.lang::UDP           covers UDP, UDPPacket
  org.ek9.lang::NetworkProperties — covered by declaring either TCP or UDP

HTTP

  org.ek9.lang::HTTPRequest
  org.ek9.lang::HTTPResponse

FILESYSTEM

  org.ek9.lang::File
  org.ek9.lang::TextFile
  org.ek9.lang::FileSystem
  org.ek9.lang::FileSystemPath

STANDARD STREAMS

  org.ek9.lang::Stdin
  org.ek9.lang::Stdout
  org.ek9.lang::Stderr

SYSTEM AND ENVIRONMENT

  org.ek9.lang::EnvVars
  org.ek9.lang::OS
  org.ek9.lang::Signals

TIME AND CLOCKS

  org.ek9.lang::Clock
  org.ek9.lang::SystemClock

SENSITIVE DATA

  org.ek9.lang::Sensitive

GROUPING RULES

Declaring the primary type covers all associated types in its group. For example, 'capabilities <- ["org.ek9.lang::TCP"]' is sufficient to use TCPConnection, TCPHandler, and NetworkProperties in the module. You do not need to list each related type individually.

NetworkProperties is a special case: it is shared between TCP and UDP, so declaring either one covers it.

MULTI-CAPABILITY EXAMPLE

A package that uses HTTP, writes to stdout, and reads environment variables declares three capabilities:

  capabilities <- [
    "org.ek9.lang::HTTPRequest",
    "org.ek9.lang::HTTPResponse",
    "org.ek9.lang::Stdout",
    "org.ek9.lang::EnvVars"
    ]

WHAT IS NOT GATED

Everything else — String, Integer, Float, Boolean, Date, DateTime, List, Dict, Optional, Result, and every user-defined type. Pure-computation code uses only these and needs no capability declarations.

See Q1271 for declaration syntax. See Q1272 for the rationale. See Q1277 for error E12010. See Q1276 for pure-computation libraries that need no capabilities.

Example

defines module qa.packagecapabilities.gatedtypeslist

  defines package
    version <- 1.0.0-0
    description <- "Publishable package demonstrating multiple gated type declarations"
    license <- "MIT"
    publicAccess <- true
    capabilities <- ["org.ek9.lang::Stdout", "org.ek9.lang::Stderr"]

  defines function

    useBothStreams()
      stdout <- Stdout()
      stderr <- Stderr()
      stdout.println("standard output goes here")
      stderr.println("error output goes here")

Common mistakes

E12010 — The module uses both Stdout and Stderr. Declaring only Stdout leaves the Stderr usage uncovered and fires E12010. Each gated type used must have a matching entry — declaring one gated type does not cover any other. See ek9 -h E12010.

Incorrect:

    capabilities <- ["org.ek9.lang::Stdout"]

Correct:

    capabilities <- ["org.ek9.lang::Stdout", "org.ek9.lang::Stderr"]
Other ways to ask this
  • Which EK9 types require a capability declaration in publishable packages?
  • Show me the list of gated types and their groupings.
  • Do I need to declare TCPConnection separately from TCP?
  • What are all the system types the compiler considers gated?

Coming from another language?

Java SecurityManager (deprecated): runtime permission checks via AccessController; no compile-time visibility. .NET Code Access Security (deprecated): similar runtime-only model. Rust: no standard-library capability model; unsafe blocks flag memory safety but not I/O. Go: no capability metadata. Haskell IO monad: types carry effects but no package-level declaration. EK9: compile-time gated-type list with grouped related types, each declared explicitly in the package block.

Keywords: grouping, org.ek9.lang, gated type, TCP, list, File, Stdout, EnvVars