Why must functions used with stream call/async return a value?

← Streams and Pipelines · Ref: Q843

Functions used with call/async must return a value — the return value becomes the next element downstream. A void function produces nothing.

See Q813 for call/async rules. See Q842 for function type requirement.

Example

defines module qa.streams.function.must.return

  defines function

    getFirstName()
      <- rtn <- "Steve"

    getLastName()
      <- rtn <- "Limb"

  defines class
    StreamSink
      received <- String()
      operator |
        -> item as String
        if item?
          received: String(item)
      override operator ? as pure
        <- rtn as Boolean: received?

  defines function

    StreamReturnDemo()
      collector <- StreamSink()
      cat [getFirstName] | call > collector
      require collector?

Common mistakes

E07490 — Functions used with stream call must return a value. Void functions produce nothing. See ek9 -h E07490 for details.

Incorrect:

    getFirstName()
      stdout <- Stdout()
      stdout.println("logged")

Correct:

    getFirstName()
      <- rtn <- "Steve"
Other ways to ask this
  • What triggers E07490 FUNCTION_MUST_RETURN_VALUE?
  • Why can't I use void functions with call in EK9 streams?
  • What function signature does stream call require?

Coming from another language?

Java: Supplier returns T, Runnable returns void. Python: map expects return values. EK9: call/async require supplier-style functions.

Keywords: void, pipeline, return, stream, E07490, call, supplier, function