compiler/utils/idioms

  Source   Edit

This module implements various helper routines for idioms used throughout the compiler. Dependencies on other modules should be kept as minimal as possible

Types

HOslice[T] = object
  a*, b*: T
A half-open slice, that is, a slice where the end is excluded. These are useful for use with unsigned integers, as, compared to Slice, no special handling is required for empty slices.   Source   Edit

Procs

func len[T](x: HOslice[T]): int {.inline.}
Returns the number of items in the slice   Source   Edit

Iterators

iterator items[T](s: HOslice[T]): T
Returns all items in the slice   Source   Edit

Templates

template unreachable()
Use unreachable to mark a point in the program as unreachable. That is, execution must never reach said point and if it does, the event is treated as an unrecoverable fatal error. As the intent is clearer, it's preferred to use unreachable is over doAssert false   Source   Edit
template unreachable(e: enum)
More efficient than using unreachable($e)   Source   Edit
template unreachable(msg: string)
Similar to #unreachable, but reports an additional msg when reached   Source   Edit