How do I name function parameters without using banned names?

← Variable Naming Rules and Conventions · Ref: Q924

Function parameters follow the same banned name rules as all variables. Use names that describe what the parameter represents in the problem domain.

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 input, output, param, arg, str, num, item, result, count, index, list, map, set, key, status, state, type, config, var, ret, res are NOT banned.

Separately, E11032 bans operator keywords as variable names: empty, length, contains, abs, sqrt, close, matches.

INSTEAD OF BANNED PARAMS:

- 'val' -> 'price', 'threshold', 'measurement'
- 'tmp' -> 'swapHolder', 'intermediateResult'
- 'dat' -> 'payload', 'sensorReading'
- 'buf' -> 'readChunk', 'outputAccumulator'

ALWAYS ALLOWED EXCEPTIONS:

- Single-character: x, y, z, i, j, k (math variables, loop counters)
- Compound words: inputValidator, outputFormat, parameterCount
- Descriptive: customerName, orderTotal, maxRetries

Example

defines module qa.naming.infunctions

  defines function

    <?-
      Shows descriptive parameter naming in functions.
    -?>
    formatUserGreeting() as pure
      ->
        customerName as String
        loyaltyTier as Integer
      <-
        greeting as String: String()

      goldThreshold <- 5
      tierLabel <- loyaltyTier > goldThreshold <- "Gold" : "Silver"
      greeting :=? `${customerName} (${tierLabel})`

    calculateShippingCost() as pure
      ->
        orderWeight as Float
        destinationZone as Integer
      <-
        shippingCost as Float: orderWeight * #^ destinationZone * 0.5

  defines program

    InFunctionsDemo()
      stdout <- Stdout()

      // GOOD: descriptive parameter names
      greeting <- formatUserGreeting("Alice", 7)
      stdout.println(`Greeting: ${greeting}`)

      shippingCost <- calculateShippingCost(2.5, 3)
      stdout.println(`Shipping: ${shippingCost}`)

      // Single-char math vars: ALLOWED
      x <- 5.0
      y <- 10.0
      stdout.println(`Dimensions: ${x} x ${y}`)

      // Compound words: ALLOWED
      inputValidator <- "regex"
      parameterCount <- 4
      stdout.println(`Validator: ${inputValidator}, Params: ${parameterCount}`)

Common mistakes

E11031 — The parameter name 'val' is a banned non-descriptive name; use a meaningful identifier like 'orderWeight' that tells the caller what to pass. See ek9 -h E11031 for details.

Incorrect:

        val as Float
        destinationZone as Integer
      <-
        shippingCost as Float: val * #^ destinationZone * 0.5

Correct:

        orderWeight as Float
        destinationZone as Integer
      <-
        shippingCost as Float: orderWeight * #^ destinationZone * 0.5
Other ways to ask this
  • What parameter names are allowed in EK9 functions?
  • How do I fix E11031 in function signatures?
  • What should I name my function arguments in EK9?

Keywords: argument, naming, function, E11031, banned, parameter