diff options
author | Araq <rumpf_a@web.de> | 2018-11-05 18:22:27 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-11-06 13:55:03 +0100 |
commit | 25cb2e0c70963667838954cb7cb4785081e55da2 (patch) | |
tree | 689d094dc2324cac795552ee3624a5c093b0f04a /doc | |
parent | 1c7fbad378bc47b8d6d75f7e4a6fdde8085cf692 (diff) | |
download | Nim-25cb2e0c70963667838954cb7cb4785081e55da2.tar.gz |
document system.UncheckedArray
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.rst | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index 98943619d..e73806147 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -1231,6 +1231,37 @@ so that the builtin ``echo`` proc does what is expected: # prints "@[1, 2, 3]" and not "123" +Unchecked arrays +---------------- +The ``UncheckedArray[T]`` type is a special kind of ``array`` where its bounds +are not checked. This is often useful to implement customized flexibly sized +arrays. Additionally an unchecked array is translated into a C array of +undetermined size: + +.. code-block:: nim + type + MySeq = object + len, cap: int + data: UncheckedArray[int] + +Produces roughly this C code: + +.. code-block:: C + typedef struct { + NI len; + NI cap; + NI data[]; + } MySeq; + +The base type of the unchecked array may not contain any GC'ed memory but this +is currently not checked. + +**Future directions**: GC'ed memory should be allowed in unchecked arrays and +there should be an explicit annotation of how the GC is to determine the +runtime size of the array. + + + Tuples and object types ----------------------- A variable of a tuple or object type is a heterogeneous storage @@ -7897,36 +7928,6 @@ defined, and it should not be used with GC'ed memory (ref's). **Future directions**: Using GC'ed memory in packed pragma will result in compile-time error. Usage with inheritance should be defined and documented. -Unchecked pragma ----------------- -The ``unchecked`` pragma can be used to mark a named array as ``unchecked`` -meaning its bounds are not checked. This is often useful to -implement customized flexibly sized arrays. Additionally an unchecked array is -translated into a C array of undetermined size: - -.. code-block:: nim - type - ArrayPart{.unchecked.} = array[0, int] - MySeq = object - len, cap: int - data: ArrayPart - -Produces roughly this C code: - -.. code-block:: C - typedef struct { - NI len; - NI cap; - NI data[]; - } MySeq; - -The base type of the unchecked array may not contain any GC'ed memory but this -is currently not checked. - -**Future directions**: GC'ed memory should be allowed in unchecked arrays and -there should be an explicit annotation of how the GC is to determine the -runtime size of the array. - Dynlib pragma for import ------------------------ |