.. default-domain:: chpl .. module:: Reflection :synopsis: Support for reflecting about properties of a Chapel program's code. Reflection ========== **Usage** .. code-block:: chapel use Reflection; or .. code-block:: chapel import Reflection; Support for reflecting about properties of a Chapel program's code. Functions for reflecting about language elements, such as fields, functions, and methods. For reflecting about aspects of the compilation process, see :mod:`ChplConfig`. .. function:: proc getNumFields(type t) param: int Return the number of fields in a class or record as a param. The count of fields includes types and param fields. .. function:: proc numFields(type t) param: int .. warning:: 'numFields' is deprecated - please use 'getNumFields' instead Return the number of fields in a class or record as a param. The count of fields includes types and param fields. .. function:: proc getFieldName(type t, param idx: int) param: string Get the name of the field at `idx` in a class or record. Causes a compilation error if `idx` is not in 0..= 0 && idx < getNumFields(t) && isParam(__primitive("field by num", obj, idx + 1)) Get the field at `idx` in a class or record. When the field at `idx` is a `param`, this overload will be chosen to return a `param`. Causes a compilation error if `idx` is not in 0..= 0 && idx < getNumFields(t) && isType(__primitive("field by num", obj, idx + 1)) Get the field at `idx` in a class or record. When the field at `idx` is a `type` variable, this overload will be chosen to return a type. Causes a compilation error if `idx` is not in 0..