From 7a0a9374f888fddb0073c96a4532947ffd0b684b Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 1 Dec 2020 14:43:27 -0500 Subject: Add a few system functions to the spec --- docs/spec/index.html | 1 + docs/spec/system.html | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 docs/spec/system.html (limited to 'docs') diff --git a/docs/spec/index.html b/docs/spec/index.html index 017ab106..6d85d9bb 100644 --- a/docs/spec/index.html +++ b/docs/spec/index.html @@ -16,4 +16,5 @@
  • Evaluation semantics
  • Primitives (reference implementations)
  • Inferred properties (type, Undo, and Under)
  • +
  • System-provided values ()
  • diff --git a/docs/spec/system.html b/docs/spec/system.html new file mode 100644 index 00000000..e8caea8e --- /dev/null +++ b/docs/spec/system.html @@ -0,0 +1,187 @@ + + + + Specification: BQN system-provided values + + +

    Specification: BQN system-provided values

    +

    This portion of the spec is definitely still a draft.

    +

    The symbol is used to access values other than primitives provided by BQN.

    +

    File access

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameSummary
    •pathCurrent file's path
    •ImportLoad a script file
    •FCharsRead from or write to an entire file, as characters
    •FLinesRead from or write to an entire file, as lines
    •FBytesRead from or write to an entire file, as bytes
    +

    File paths for any of the commands in this section may be relative or absolute. Relative paths are taken relative to the source file that loads that instance of the system command.

    +

    •path simply gives the path of the file in which it appears. It includes a trailing slash but not the name of the file itself.

    +

    •Import loads another BQN script. The script is evaluated in its own scope, and its result is either the result of the last line, or a module if it exports with at the top level. If it is a module, then it must be destructured immediately unless first-class namespaces are possible.

    +

    Functions •FChars, •FLines, and •FBytes are all ambivalent. If only one argument is given, then it must be the name of a file, and the result is the contents of the file in the appropriate format. If there are two arguments, then the left argument is the filename and the right is the desired contents. These are written to the file, overwriting its contents. The three formats are:

    + +

    Input and output

    + + + + + + + + + + + + + +
    NameSummary
    •OutPrint argument string
    +

    Operation properties

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameSummary
    •TypeReturn a number indicating type
    •GlyphReturn the glyph for a primitive
    •SourceReturn the source of a block, as a string
    •DecomposeShow the parts of a compound function
    +

    Each function in this section is monadic.

    +

    •Type gives its argument's type, as a number from the table below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NumberType
    0Array
    1Number
    2Character
    3Function
    41-modifier
    52-modifier
    +

    •Glyph gives the glyph corresponding to a primitive as a single character, for example returning '+' given an argument matching +. It causes an error if the argument is not a primitive.

    +

    •Source gives a string containing a block's source, including the enclosing braces {}. It causes an error if the argument is not a primitive.

    +

    •Decompose breaks down one level of a compound function or modifier, returning a list with a code giving what kind of structure it has (as listed in the table below) followed by each of its components. Non-operations do not cause an error, but return code -1, then the argument as a single component. The result is thus a list of length 2 to 4, and •Decompose cannot cause an error.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KindCodeComponents
    Non-operation-1𝕩
    Primitive0𝕩
    Block1𝕩
    2-train2 g,h
    3-train3f,g,h
    1-mod4𝕗,𝕣
    2-mod5𝕗,𝕣,𝕘
    Left partial6𝕗,𝕣
    Right partial7 𝕣,𝕘
    +

    Timing

    -- cgit v1.2.3