Bycopy pragma

The bycopy pragma can be applied to an object or tuple type or a proc param. It instructs the compiler to pass the type by value to procs:

  1. type
  2. Vector {.bycopy.} = object
  3. x, y, z: float

The Nim compiler automatically determines whether a parameter is passed by value or by reference based on the parameter type’s size. If a parameter must be passed by value or by reference, (such as when interfacing with a C library) use the bycopy or byref pragmas. Notice params marked as byref takes precedence over types marked as bycopy.