3

In Nim, the noReturn pragma marks a proc that never returns.

How is that different than a function that returns void?

dgo.a
  • 2,634
  • 23
  • 35

1 Answers1

5

Returning void means the function returns nothing:

proc saySomething(): void =
  echo "something"

The empty brackets as well as the : void are optional:

proc saySomething =
  echo "something"

Annotating a function with noReturn means the function will not return at all:

proc killTheProgram {.noReturn.} =
  quit(0)

proc raiseSomething {.noReturn.} =
  raise newException(ValueError, "Something")
def-
  • 5,275
  • 20
  • 18