experimental pragma

The experimental pragma enables experimental language features. Depending on the concrete feature this means that the feature is either considered too unstable for an otherwise stable release or that the future of the feature is uncertain (it may be removed any time).

Example:

  1. import threadpool
  2. {.experimental: "parallel".}
  3. proc threadedEcho(s: string, i: int) =
  4. echo(s, " ", $i)
  5. proc useParallel() =
  6. parallel:
  7. for i in 0..4:
  8. spawn threadedEcho("echo in parallel", i)
  9. useParallel()

As a top level statement, the experimental pragma enables a feature for the rest of the module it’s enabled in. This is problematic for macro and generic instantiations that cross a module scope. Currently these usages have to be put into a .push/pop environment:

  1. # client.nim
  2. proc useParallel*[T](unused: T) =
  3. # use a generic T here to show the problem.
  4. {.push experimental: "parallel".}
  5. parallel:
  6. for i in 0..4:
  7. echo "echo in parallel"
  8. {.pop.}
  1. import client
  2. useParallel(1)