Tag tracking

The exception tracking is part of Nim’s effect system. Raising an exception is an effect. Other effects can also be defined. A user defined effect is a means to tag a routine and to perform checks against this tag:

  1. type IO = object ## input/output effect
  2. proc readLine(): string {.tags: [IO].} = discard
  3. proc no_IO_please() {.tags: [].} =
  4. # the compiler prevents this:
  5. let x = readLine()

A tag has to be a type name. A tags list - like a raises list - can also be attached to a proc type. This affects type compatibility.

The inference for tag tracking is analogous to the inference for exception tracking.