From 15908ba604c2a27b84a30d7ce91ceb7a8c1064aa Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 17 Jul 2020 21:25:22 -0400 Subject: Mirror repository tree in docs/ and add html spec documents --- docs/spec/README.html | 14 +++++ docs/spec/evaluate.html | 94 +++++++++++++++++++++++++++++++++ docs/spec/grammar.html | 138 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/spec/literal.html | 14 +++++ docs/spec/token.html | 40 ++++++++++++++ docs/spec/types.html | 20 +++++++ 6 files changed, 320 insertions(+) create mode 100644 docs/spec/README.html create mode 100644 docs/spec/evaluate.html create mode 100644 docs/spec/grammar.html create mode 100644 docs/spec/literal.html create mode 100644 docs/spec/token.html create mode 100644 docs/spec/types.html (limited to 'docs/spec') diff --git a/docs/spec/README.html b/docs/spec/README.html new file mode 100644 index 00000000..6a4ba53f --- /dev/null +++ b/docs/spec/README.html @@ -0,0 +1,14 @@ + +

BQN specification

+

This directory gives a (currently incomplete) specification for BQN. The specification differs from the documentation in doc/ in that its purpose is only to describe the exact details of BQN's operation in the most quickly accessible way, rather than to explain the core ideas of BQN functionality and how it might be used. Since it is easier to specify than to document, the specification is currently more complete than the documentation; for example, it includes nearly all primitives.

+

The following aspects define BQN and are or will be specified:

+ + diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html new file mode 100644 index 00000000..6552f80e --- /dev/null +++ b/docs/spec/evaluate.html @@ -0,0 +1,94 @@ + +

This page describes the semantics of the code constructs whose grammar is given in grammar.md. The formation rules there are not named, and here they are identified by either the name of the term or by copying the rule entirely if there are several alternative productions.

+

Here we assume that the referent of each identifier, or equivalently the connections between identifiers, have been identified according to the scoping rules.

+

Programs and blocks

+

The result of parsing a valid BQN program is a PROGRAM, and the program is run by evaluating this term.

+

A PROGRAM or BODY is a list of STMTs (for BODY, the last must be an EXPR, a particular kind of STMT), which are evaluated in program order. The statement nothing does nothing when evaluated, while EXPR evaluates some APL code and possibly assigns the results, as described below.

+

A block consists of several BODY terms, some of which may have an accompanying header describing accepted inputs and how they are processed. A value block brVal can only have one BODY, and is evaluated by evaluating the code in it. Other types of blocks do not evaluate any BODY immediately, but instead return a function, modifier, or operator that obtains its result by evaluating a particular BODY. The BODY is identified and evaluated once the block has received enough inputs (operands or arguments), which for modifiers and compositions can take one or two calls: if two calls are required, then on the first call the operands are simply stored and no code is evaluated yet. Two calls are required if there is more than one BODY term, if the BODY contains the special names π•¨π•©π•€π•Žπ•π•Š, or if its header specifies arguments (the header-body is a _mCase or _cCase_). Otherwise only one is required.

+

To evaluate a block when enough inputs have been received, first the correct case must be identified. To do this, first each special case (FCase, _mCase, or _cCase_) is checked in order to see if its arguments are strucurally compatible with the given arguments. That is, is headW is a value, there must be a left argument matching that structure, and if headX is a value, the right argument must match that structure. This means that 𝕨 not only matches any left argument but also no argument. The test for compatibility is the same as for multiple assignment described below, except that the header may contain constants, which must match the corresponding part of the given argument.If no special case matches, then an appropriate general case (FMain, _mMain, or _cMain_) is used: if there are two, the first is used with no left argument and the second with a left argument; if there are one, it is always used, and if there are none, an error results.

+

The only remaining step before evaluating the BODY is to bind the inputs and other names. Special names are always bound when applicable: 𝕨𝕩𝕀 if arguments are used, 𝕨 if there is a left argument, π•—π•˜ if operands are used, and _𝕣 and _𝕣_ for modifiers and combinators, respectively. Any names in the header are also bound, allowing multiple assignment for arguments.

+

If there is no left argument, but the BODY contains 𝕨 at the top level, then it is conceptually re-parsed with 𝕨 replaced by Β· to give a monadic version before application. As the only effect when this re-parsed form is valid is to change some instances of arg to nothing, this can be achieved efficiently by annotating parts of the AST that depend on 𝕨 as conditionally-nothing. However, it also causes an error if 𝕨 is used as an operand or list element, where nothing is not allowed by the grammar.

+

Assignment

+

An assignment is one of the four rules containing ASGN. It is evaluated by first evaluating the right-hand-side valExpr, FuncExpr, _modExpr, or _cmpExp_ expression, and then storing the result in the left-hand-side identifier or identifiers. The result of the assignment expression is the result of its right-hand side. Except for values, only a lone identifier is allowed on the left-hand side and storage is obvious. For values, multiple assignment with a list left-hand side is also allowed. Multiple assignment is performed recursively by assigning right-hand-side values to the left-hand-side targets, with single-identifier (v) assignment as the base case. When matching the right-hand side to a list left-hand side, the left hand side is treated as a list of lhs targets. The evaluated right-hand side must be a list (rank-1 array) of the same length, and is matched to these targets element-wise.

+

Modified assignment is the value assignment rule lhs Derv "↩" valExpr. In this case, lhs should be evaluated as if it were a valExpr (the syntax is a subset of valExpr), and the result of the function application lhs Derv valExpr should be assigned to lhs, and is also the result of the modified assignment expression.

+

Expressions

+

We now give rules for evaluating an atom, Func, _mod or _comp_ expression (the possible options for ANY). A literal vl, Fl, _ml, or _cl_ has a fixed value defined by the specification (value literals and built-ins). An identifier v, F, _m, or _c_ is evaluated by returning its value; because of the scoping rules it must have one when evaluated. A parenthesized expression such as "(" _modExpr ")" simply returns the result of the interior expression. A braced construct such as BraceFunc is defined by the evaluation of the statements it contains after all parameters are accepted. Finally, a list "⟨" β‹„? ( ( EXPR β‹„ )* EXPR β‹„? )? "⟩" or ANY ( "β€Ώ" ANY )+ consists grammatically of a list of expressions. To evaluate it, each expression is evaluated in source order and their results are placed as elements of a rank-1 array. The two forms have identical semantics but different punctuation.

+

Rules in the table below are function and operator evaluation.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLeftCalledRightRTypes
𝕨( value | nothing )?Dervarg𝕩Function, value
𝕗Operand_modModifier
𝕗Operand_comp_( value | Func )π•˜Composition
+

In each case the constituent expressions are evaluated in reverse source order: Right, then Called, then Left. Then the expression's result is obtained by calling the Called value on its parameters. A left argument of nothing is not used as a parameter, leaving only a right argument in that case. The data type of the Called value must be appropriate to the expression type, as indicated in the "Types" column. For function application, a value type (number, character, or array) is allowed. It is called simply by returning itself. Although the arguments are ignored in this case, they are still evaluated. A braced construct is evaluated by binding the parameter names given in columns L and R to the corresponding values. Then if all parameter levels present have been bound, its body is evaluated to give the result of application.

+

The following rules derive new functions or operators from existing ones.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LeftCenterRightResult
_comp_( value | Func ){𝔽 _C_ R}
Operand_comp_{L _C_ 𝔽}
OperandDervFork{(𝕨L𝕩)C(𝕨R𝕩)}
nothing?DervFork{ C(𝕨R𝕩)}
+

As with applications, all expressions are evaluated in reverse source order before doing anything else. Then a result is formed without calling the center value. Its value in BQN is given in the rightmost column, using L, C, and R for the results of the expressions in the left, center, and right columns, respectively. For the first two rules (partial application), the given operand is bound to the composition: the result is a modifier that, when called, calls the center composition with the bound operand on the same side it appeared on and the new operand on the remaining side. A train is a function that, when called, calls the right-hand function on all arguments, then the left-hand function, and calls the center function with these results as arguments. In a composition partial application, the result will fail when applied if the center value does not have the composition type, and in a fork, it will fail if any component has a modifier or composition type (that is, cannot be applied as a function). BQN implementations are not required to check for these types when forming the result of these expressions, but may give an error on formation even if the result will never be applied.

+ diff --git a/docs/spec/grammar.html b/docs/spec/grammar.html new file mode 100644 index 00000000..56803787 --- /dev/null +++ b/docs/spec/grammar.html @@ -0,0 +1,138 @@ + +

BQN's grammar is given below. Terms are defined in a BNF variant. However, handling special names properly is possible but difficult in BNF, so they are explained in text along with the braced block grammar.

+

The symbols v, F, _m, and _c_ are identifier tokens with value, function, modifier, and composition classes respectively. Similarly, vl, Fl, _ml, and _cl_ refer to value literals (numeric and character literals, or primitives) of those classes. While names in the BNF here follow the identifier naming scheme, this is informative only: syntactic classes are no longer used after parsing and cannot be inspected in a running program.

+

A program is a list of statements. Almost all statements are expressions. However, explicit definitions and valueless results stemming from Β·, or 𝕨 in a monadic brace function, can be used as statements but not expressions.

+
PROGRAM  = β‹„? ( ( STMT β‹„ )* STMT β‹„? )?
+STMT     = EXPR | DEF | nothing
+β‹„        = ( "β‹„" | "," | \n )+
+EXPR     = valExpr | FuncExpr | _modExpr | _cmpExp_
+
+

Here we define the "atomic" forms of functions and operators, which are either single tokens or enclosed in paired symbols. Stranded vectors with β€Ώ, which binds more tightly than any form of execution, are also included.

+
ANY      = atom    | Func     | _mod     | _comp_
+_comp_   = _c_ | _cl_ | "(" _cmpExp_ ")" | _brComp_
+_mod     = _m  | _ml  | "(" _modExpr ")" | _brMod  
+Func     =  F  |  Fl  | "(" FuncExpr ")" |  BrFunc 
+atom     =  v  |  vl  | "(" valExpr  ")" |  brVal | list
+list     = "⟨" β‹„? ( ( EXPR β‹„ )* EXPR β‹„? )? "⟩"
+value    = atom | ANY ( "β€Ώ" ANY )+
+
+

Starting at the highest-order objects, modifiers and compositions have fairly simple syntax. In most cases the syntax for ← and ↩ is the same, but only ↩ can be used for modified assignment.

+
ASGN     = "←" | "↩"
+_cmpExp_ = _comp_
+         | _c_ ASGN _cmpExp_
+_modExpr = _mod
+         | _comp_ ( value | Func )    # Right partial application
+         | Operand _comp_             # Left partial application
+         | _m  ASGN _modExpr
+
+

Functions can be formed by fully applying operators or as trains. Operators are left-associative, so that the left operand (Operand) can include operators but the right operand (value | Func) cannot. Trains are right-associative, but bind less tightly than operators. Assignment is not allowed in the top level of a train: it must be parenthesized.

+
Derv     = Func
+         | Operand _mod
+         | Operand _comp_ ( value | Func )
+Operand  = value
+         | Derv
+Fork     = Derv
+         | Operand Derv Fork          # 3-train
+         | nothing Derv Fork          # 2-train
+Train    = Fork
+         | Derv Fork                  # 2-train
+FuncExpr = Train
+         | F ASGN FuncExpr
+
+

Value expressions are complicated by the possibility of list assignment. We also define nothing-statements, which have very similar syntax to value expressions but do not permit assignment.

+
arg      = valExpr
+         | ( value | nothing )? Derv arg
+nothing  = "Β·"
+         | ( value | nothing )? Derv nothing
+LHS_ANY  = lhsValue | F | _m | _c_
+LHS_ATOM = LHS_ANY | "(" lhsStr ")"
+LHS_ELT  = LHS_ANY | lhsStr
+lhsValue = v
+         | "⟨" β‹„? ( ( LHS_ELT β‹„ )* LHS_ELT β‹„? )? "⟩"
+lhsStr   = LHS_ATOM ( "β€Ώ" LHS_ATOM )+
+lhs      = lhsValue | lhsStr
+valExpr  = arg
+         | lhs ASGN valExpr
+         | lhs Derv "↩" valExpr       # Modified assignment
+
+

A header looks like a name for the thing being headed, or its application to inputs (possibly twice in the case of modifiers and compositions). As with assignment, it is restricted to a simple form with no extra parentheses. The full list syntax is allowed for arguments. As a special rule, a monadic function header specifically can omit the function when the argument is not just a name (as this would conflict with a value label). The following cases define only headers with arguments, which are assumed to be special cases; there can be any number of these. Headers without arguments can only refer to the general caseβ€”note that operands are not pattern matchedβ€”so there can be at most two of these kinds of headers, indicating the monadic and dyadic cases.

+
headW    = value | "𝕨"
+headX    = value | "𝕩"
+HeadF    = F | "𝕗" | "𝔽"
+HeadG    = F | "π•˜" | "𝔾"
+ModH1    = HeadF ( _m  | "_𝕣"  )
+CmpH1    = HeadF ( _c_ | "_𝕣_" ) HeadG
+FuncHead = headW? ( F | "π•Š" ) headX
+         | vl | "(" valExpr ")" | brVal | list   # value,
+         | ANY ( "β€Ώ" ANY )+                      # but not v
+_modHead = headW? ModH1 headX
+_cmpHed_ = headW? CmpH1 headX
+
+

A braced block contains bodies, which are lists of statements, separated by semicolons and possibly preceded by headers, which are separated from the body with a colon. Multiple bodies allow different handling for various cases, which are pattern-matched by headers. For a value block there are no inputs, so there can only be one possible case and one body. Functions and operators allow any number of "matched" bodies, with headers that have arguments, followed by at most two "main" bodies with either no headers or headers without arguments. If there is one main body, it is ambivalent, but two main bodies refer to the monadic and dyadic cases.

+
BODY     = β‹„? ( STMT β‹„ )* EXPR β‹„?
+FCase    = β‹„? FuncHead ":" BODY
+_mCase   = β‹„? _modHead ":" BODY
+_cCase_  = β‹„? _cmpHed_ ":" BODY
+FMain    = ( β‹„?    F            ":" )? BODY
+_mMain   = ( β‹„? ( _m  | ModH1 ) ":" )? BODY
+_cMain_  = ( β‹„? ( _c_ | CmpH1 ) ":" )? BODY
+brVal    = "{" ( β‹„? v ":" )? BODY "}"
+BrFunc   = "{" (  FCase  ";" )* (  FCase  |  FMain ( ";"  FMain )? ) "}"
+_brMod   = "{" ( _mCase  ";" )* ( _mCase  | _mMain ( ";" _mMain )? ) "}"
+_brComp_ = "{" ( _cCase_ ";" )* ( _cCase_ | _cMan_ ( ";" _cMan_ )? ) "}"
+
+

Two additional rules apply to blocks, based on the special name associations in the table below. First, each block allows the special names in its column to be used as the given token types within BODY terms (not headers). Except for the spaces labelled "None", each column is cumulative and a given entry also includes all the entries above it. Second, for BrFunc, _brMod, and _brComp_ terms, if no header is given, then at least one BODY term in it must contain one of the names on, and not above, the corresponding row. Otherwise the syntax would be ambiguous, since for example a simple "{" BODY "}" sequence could have any type.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TermvF_m_c_other
brVal, PROGRAMNoneNoneNoneNone
BrFuncπ•¨π•©π•€π•Žπ•π•Š";"
_brMod𝕗𝕣𝔽_𝕣
_brComp_π•˜π”ΎNone_𝕣_
+

The rules for special name can be expressed in BNF by making many copies of all expression rules above. For each "level", or row in the table, a new version of every rule should be made that allows that level but not higher ones, and another version should be made that requires exactly that level. The values themselves should be included in v, F, _m, and _c_ for these copies. Then the "allowed" rules are made simply by replacing the terms they contain (excluding brVal and so on) with the same "allowed" versions, and "required" rules are constructed using both "allowed" and "required" rules. For every part of a production rule, an alternative should be created that requires the relevant name in that part while allowing it in the others. For example, ( value | nothing )? Derv arg would be transformed to

+
arg_req1 = valExpr_req1
+         | ( value_req1 | nothing_req1 ) Derv_allow1 arg_allow1
+         | ( value_allow1 | nothing_allow1 )? Derv_req1 arg_allow1
+         | ( value_allow1 | nothing_allow1 )? Derv_allow1 arg_req1
+
+

Quite tedious. The explosion of rules is partly due to the fact that the brace-typing rule falls into a weaker class of grammars than the other rules. Most of BQN is deterministic context-free but brace-typing is not, only context-free. Fortunately brace typing does not introduce the parsing difficulties that can be present in a general context-free grammar, and it can easily be performed in linear time: after scanning but before parsing, move through the source code maintaining a stack of the current top-level set of braces. Whenever a colon or special name is encountered, annotate that set of braces to indicate that it is present. When a closing brace is encountered and the top brace is popped off the stack, the type is needed if there was no colon, and can be found based on which names were present. One way to present this information to the parser is to replace the brace tokens with new tokens that indicate the type.

+ diff --git a/docs/spec/literal.html b/docs/spec/literal.html new file mode 100644 index 00000000..c4914753 --- /dev/null +++ b/docs/spec/literal.html @@ -0,0 +1,14 @@ + +

A literal is a single token that indicates a fixed character, number, or array. While literals indicate data of a value type, primitives indicate data of a function type: function, modifier, or composition.

+

Two types of literal deal with text. As the source code is considered to be a sequence of unicode code points ("characters"), and these code points are also used for BQN's character data type, the representation of a text literal is very similar to its value. In a text literal, the newline character is always represented using the ASCII line feed character, code point 10. A character literal is enclosed with single quotes ' and its value is identical to the single character between them. A string literal is enclosed in double quotes ", and any double quotes between them must come in pairs, as a lone double quote marks the end of the literal. The value of a string literal is a rank-1 array whose elements are the characters in between the enclosing quotes, after replacing each pair of double quotes with only one such quote.

+

The format of a numeric literal is more complicated. From the tokenization rules, a numeric literal consists of a numeric character (one of Β―βˆžΟ€.0123456789) followed by any number of numeric or alphabetic characters. Some numeric literals are valid and indicate a number, while others are invalid and cause an error. The grammar for valid numbers is given below in a BNF variant. Only four alphabetic characters are allowed: "i", which separates the real and imaginary components of a complex number, "e", which functions as in scientific notation, and the uppercase versions of these letters.

+
number    = component ( ( "i" | "I" ) component )?
+component = mantissa ( ( "e" | "E" ) exponent )?
+exponent  = "Β―"? digit+
+mantissa  = "Β―"? ( "∞" | "Ο€" | digit+ ( "." digit+ )? )
+digit     = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+
+

The digits or arabic numerals correspond to the numbers from 0 to 9 in the conventional way (also, each corresponds to its code point value minus 48). A sequence of digits gives a natural number by evaluating it in base 10: the number is 0 for an empty sequence, and otherwise the last digit's numerical value plus ten times the number obtained from the remaining digits. The symbol ∞ indicates infinity and Ο€ indicates the ratio pi) of a circle's circumference to its diameter (or, for modern mathematicians, the smallest positive real number at which the function {⋆0j1×𝕩} attains a real part of 0). The high minus symbol Β― indicates that the number containing it is to be negated.

+

When an exponent is provided (with e or E), the corresponding mantissa is multiplied by ten to that power, giving the value mantissaΓ—10⋆exponent. If a second component is present (using i or I), that component's value is multiplied by the imaginary unit i and added to the first component; otherwise the value is the first component's value without modification. If complex numbers are not supported, then i should not be allowed in numeric literals, even when followed by 0.

+

The above specification describes exactly a complex number with extended real components. To obtain a BQN number, each component is rounded to its nearest representative by the rules of the number system used: for IEEE 754, smallest distance, with ties rounding to the option with even mantissa.

+ diff --git a/docs/spec/token.html b/docs/spec/token.html new file mode 100644 index 00000000..531cfd6e --- /dev/null +++ b/docs/spec/token.html @@ -0,0 +1,40 @@ + +

This page describes BQN's token formation rules (token formation is also called scanning). Most tokens in BQN are a single character long, but quoted characters and strings, identifiers, and numbers can consist of multiple characters, and comments, spaces, and tabs are discarded during token formation.

+

BQN source code should be considered as a series of unicode code points, which we refer to as "characters". The separator between lines in a file is considered to be a single character, newline, even though some operating systems such as Windows typically represent it with a two-character CRLF sequence. Implementers should note that not all languages treat unicode code points as atomic, as exposing the UTF-8 or UTF-16 representation instead is common. For a language such as JavaScript that uses UTF-16, the double-struck characters π•¨π•Žπ•©π•π•—π”½π•˜π”Ύ are represented as two 16-bit surrogate characters, but BQN treats them as a single unit.

+

A BQN character literal consists of a single character between single quotes, such as 'a', and a string literal consists of any number of characters between double quotes, such as "" or "abc". Character and string literals take precedence with comments over other tokenization rules, so that # between quotes does not start a comment and whitespace between quotes is not removed, but a quote within a comment does not start a character literal. Almost any character can be included directly in a character or string literal without escaping. The only exception is the double quote character ", which must be written twice to include it in a string, as otherwise it would end the string instead. Character literals require no escaping at all, as the length is fixed. In particular, literals for the double and single quote characters are written ''' and '"', while length-1 strings containing these characters are "'" and """".

+

A comment consists of the hash character # and any following text until (not including) the next newline character. The initial # must not be part of a string literal started earlier. Comments are ignored entirely and do not form tokens.

+

Identifiers and numeric literals share the same token formation rule. These tokens are formed from the numeric characters Β―βˆžΟ€.0123456789 and alphabetic characters _abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ and the oddball 𝕣. Any sequence of these characters adjacent to each other forms a single token, which is a numeric literal if it begins with a numeric character and an identifier if it begins with an alphabetic character. Numeric literals are also subject to numeric literal rules, which specify which numeric literals are valid and which numbers they represent. If the token contains 𝕣 it must be either 𝕣, _𝕣, or _𝕣_ and is considered a special name (see below). As the value taken by this identifier can only be a modifier or composition, the uppercase character ℝ is not allowed.

+

Following this step, the whitespace characters space and tab are ignored, and do not form tokens. Only these whitespace characters, and the newline character, which does form a token, are allowed.

+

Otherwise, a single character forms a token. Only the specified set of characters can be used; others result in an error. The classes of characters are given below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassCharacters
Primitive Function+-Γ—Γ·β‹†βˆšβŒŠβŒˆ|¬∧∨<>β‰ =≀β‰₯β‰‘β‰’βŠ£βŠ’β₯ŠβˆΎβ‰β†‘β†“β†•βŒ½β‰/β‹β’βŠβŠ‘βŠβŠ’βˆŠβ·βŠ”
Primitive Modifier˜˘¨⌜⁼´`
Primitive Compositionβˆ˜β—‹βŠΈβŸœβŒΎβŠ˜β—ΆβŽ‰βš‡βŸ
Special nameπ•¨π•©π•—π•˜π•€π•Žπ•π”½π”Ύπ•Š
Punctuation←↩→(){}βŸ¨βŸ©β€Ώβ‹„, and newline
+

In the BQN grammar specification, the three primitive classes are grouped into terminals Fl, _ml, and _cl, while the punctuation characters are identified separately as keywords such as "←". The special names are handled specially. The uppercase versions π•Žπ•π”½π”Ύπ•Š and lowercase versions π•¨π•©π•—π•˜π•€ are two spellings of the five underlying inputs and function.

+ diff --git a/docs/spec/types.html b/docs/spec/types.html new file mode 100644 index 00000000..81ed35ee --- /dev/null +++ b/docs/spec/types.html @@ -0,0 +1,20 @@ + +

BQN programs manipulate data of six types:

+ +

Of these, the first three are considered value types and the remaining three function types. We first describe the much simpler function types; the remainder of this page will be dedicated to the value types. A member of any function type accepts some number of inputs and either returns a result or causes an error; inputs and the result are data of any type. When a function is given inputs (called), it may produce side effects before returning, such as manipulating variables and calling other functions within its scope, or performing I/O.

+ +

To begin the value types, a character is a Unicode code point, that is, its value is a non-negative integer within the ranges defined by Unicode (however, it is distinct from this number as a BQN value). Characters are ordered by this numeric value. BQN deals with code points as abstract entities and does not use encodings such as UTF-8 or UTF-16.

+

The precise type of a number may vary across BQN implementations or instances. A real number is a member of some supported subset of the extended real numbers, that is, the real numbers and positive or negative infinity. Some system must be defined for rounding an arbitrary real number to a member of this subset, and the basic arithmetic operations add, subtract, multiply, divide, and natural exponent (base e) are defined by performing these operations on exact real values and rounding the result. The Power function (dyadic ⋆) is also used but need not be exactly rounded. A complex number is a value with two real number components, a real part and an imaginary part. A BQN implementation can either support real numbers only, or complex numbers.

+

An array is a rectangular collection of data. It is defined by a shape, which is a list of non-negative integer lengths, and a ravel, which is a list of elements whose length (the array's bound) is the product of all lengths in the shape. Arrays are defined inductively: any value (of a value or function type) can be used as an element of an array, but it is not possible for an array to contain itself as an element, or an array that contains itself, and so on.

+ -- cgit v1.2.3