What variable names ARE allowed in EK9 despite the naming rules?
← Variable Naming Rules and Conventions · Ref: Q923
EK9 allows three categories of names that might seem like they would be banned:
1. SINGLE-CHARACTER NAMES: x, y, z, i, j, k, n, t — always allowed for math variables, loop counters, generic type parameters.
2. COMPOUND WORDS containing banned roots: connectionState, dataProcessor, bufferSize, inputValidator, configPath — the banned word is part of a larger descriptive name.
3. MATH/SCIENCE VARIABLES: theta, radius, alpha, delta — domain-specific short names that carry clear meaning in context.
EK9 bans exactly 12 non-descriptive names (E11031): temp, tmp, flag, flg, data, dat, object, obj, value, val, buffer, buf. These are case-insensitive. Names like str, num, item, result, input, output, count, index, list, map, set, key, status, state, type, config, param, arg, var, ret, res are NOT banned.
Separately, E11032 bans operator keywords as variable names: empty, length, contains, abs, sqrt, close, matches.
The rule is simple: bare generic names from the 12-name list are banned, but descriptive names (including compound words) are always fine.
Example
defines module qa.naming.allowedexceptions defines function <?- Shows math variables — single-char and short science names. -?> computeHypotenuse() as pure -> x as Float y as Float <- hypotenuse as Float: sqrt(x * x + y * y) defines program AllowedExceptionsDemo() stdout <- Stdout() // ALLOWED: single-character math variables x <- 3.0 y <- 4.0 z <- computeHypotenuse(x, y) stdout.println(`Hypotenuse: ${z}`) // ALLOWED: single-character loop counters i <- 1 j <- 2 k <- 3 stdout.println(`Counters: ${i}, ${j}, ${k}`) // ALLOWED: compound words with banned roots connectionState <- "active" dataProcessor <- "xml" bufferSize <- 4096 configPath <- "/etc/app.conf" stdout.println(`State: ${connectionState}`) stdout.println(`Processor: ${dataProcessor}, Size: ${bufferSize}`) stdout.println(`Config: ${configPath}`) // ALLOWED: math/science domain names theta <- 1.57 radius <- 10.0 stdout.println(`Theta: ${theta}, Radius: ${radius}`)
Common mistakes
E11031 — The bare name 'dat' is banned (E11031), but the compound word 'connectionState' is allowed because it describes what kind of state.
Incorrect:
dat <- "active" dataProcessor <- "xml" bufferSize <- 4096 configPath <- "/etc/app.conf" stdout.println(`State: ${dat}`)
Correct:
connectionState <- "active" dataProcessor <- "xml" bufferSize <- 4096 configPath <- "/etc/app.conf" stdout.println(`State: ${connectionState}`)
Other ways to ask this
- What exceptions exist to EK9 naming rules?
- Can I use single-letter names in EK9?
- Are compound words with banned roots allowed?
Keywords: compound, E11031, math, naming, allowed, exception, single-char