diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-29 10:18:56 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-29 10:18:56 -0500 |
| commit | 1e557aef7de584cd471630adb13aeae549e0c3e1 (patch) | |
| tree | 09baf81b3b9ff075ae1a60cd16353f07ca7c8483 /docs | |
| parent | 476d8529bafe74c68ac34f567b2c81e9f168875a (diff) | |
Rewrite array section in types.md
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/doc/types.html | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/doc/types.html b/docs/doc/types.html index c2ae74e5..c1786660 100644 --- a/docs/doc/types.html +++ b/docs/doc/types.html @@ -53,8 +53,10 @@ </ul> <p>Other linear combinations such as adding two characters or negating a character are not allowed. You can check whether an application of <code><span class='Function'>+</span></code> or <code><span class='Function'>-</span></code> on numbers and characters is allowed by applying the same function to the "characterness" of each value: <code><span class='Number'>0</span></code> for a number and <code><span class='Number'>1</span></code> for a character. The result will be a number if this application gives <code><span class='Number'>0</span></code> and a character if this gives <code><span class='Number'>1</span></code>, and otherwise the operation is not allowed.</p> <h3 id="arrays">Arrays</h3> -<p>A BQN array is a multidimensional arrangement of data.</p> -<p>Currently, the intention is that arrays will not have prototypes, so that all empty arrays of the same shape behave identically. Different elements of an array should not influence each other. While some APLs force numbers placed in the same array to a common representation, which may have different precision properties, BQN will enforce 64-bit floating-point precision, and only use representations or methods compatible with it (for example, integers up to 32 bits).</p> +<p>A BQN array is a multidimensional arrangement of data. This means it has a certain <em>shape</em>, which is a finite list of natural numbers giving the length along each axis, and it contains an <em>element</em> for each possible <em>index</em>, which is a choice of one natural number that's less than each axis length in the shape. The total number of elements, or <em>bound</em>, is then the product of all the lengths in the shape. The shape may have any length including zero, and this shape is known as the array's <em>rank</em>. An array of rank 0, which always contains exactly one element, is called a <em>unit</em>, while an array of rank 1 is called a <em>list</em> and an array of rank 2 is called a <em>table</em>.</p> +<p>Each array—empty or nonempty—has an inferred property called a <em>fill</em>. The fill either indicates what element should be used to pad an array, or that such an element is not known and an error should result. Fills are used by Take (<code><span class='Function'>↑</span></code>) and the two Nudge functions (<code><span class='Function'>»«</span></code>).</p> +<p>Arrays are value types (or immutable), so that there is no way to "change" the shape or elements of an array. An array with different properties is a different array. As a consequence, arrays are an inductive type, and it's not possible for an array to contain itself, or contain an array that contains itself, and so on. However, it is possible for an array to contain a function or other operation that has access to the array through a variable, and in this sense an array can "know about" itself.</p> +<p>Different elements of an array should not influence each other. While some APLs force numbers placed in the same array to a common representation, which may have different precision properties, BQN values must not change behavior when placed in an array. However, this doesn't preclude changing the storage type of an array for better performance: for example, in a BQN implementation using 64-bit floats, an array whose elements are all integers that fit in 32-bit int range might be represented as an array of 32-bit ints.</p> <h2 id="operation-types">Operation types</h2> <p>An operation is either a function or modifier, and can be applied to <em>inputs</em>—which are called <em>arguments</em> for functions and <em>operands</em> for modifiers—to obtain a result. During this application an operation might also change variables within its scope and call other operations, or cause an error, in which case it doesn't return a result. There is one type of call for each of the three operation types, and an operation will give an error if it is called in a way that doesn't match its type.</p> <p>In BQN syntax the result of a function has a subject role and the result of a modifier has a function role. However, the result can be any value at all: roles take place at the syntactic level, which has no bearing on types and values in the semantic level. This distinction is discussed further in <a href="context.html#mixing-roles">Mixing roles</a>.</p> |
