Module objutils

Search:
Group by:

Macros

macro genConstructor*(`type`: typed; args: varargs[untyped]): untyped

Generates constructor for the type. The second optional parameter is the name of the constructor. By default it's newType for the ref objects and initType for the objects. The third optional parameter is the word exported and means that the constructor must be exported.

Example:

type Obj* = ref object
  x: int
  y: string
genConstructor Obj, exported

let x = newObj(1, "a")
  Source Edit