From 422c3727c47d92cbbd358991665a9b46f20688f4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 16 Aug 2020 17:02:28 -0400 Subject: Move discussion of extensions to its own documentation file --- docs/doc/extensions.html | 35 +++++++++++++++++++++++++++++++++++ docs/doc/index.html | 4 ++++ docs/index.html | 32 +------------------------------- 3 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 docs/doc/extensions.html (limited to 'docs') diff --git a/docs/doc/extensions.html b/docs/doc/extensions.html new file mode 100644 index 00000000..69406354 --- /dev/null +++ b/docs/doc/extensions.html @@ -0,0 +1,35 @@ + + +

BQN extensions

+

This page describes features that are not part of the core BQN specification, but may be specified in the future. If specified, these features would be optional, so that an implementation could choose to support them or not.

+

Complex numbers

+

These are fairly common in APL dialects and could be useful in BQN as well.

+

Sets and dictionaries

+

Sets are unordered collections of distinct values. Dictionaries have a set of keys and associate each key with a corresponding value. These types are a natural fit for the data in some cases; while they can be represented using arrays of keys and values, using the right type can lead to cleaner and faster algorithms.

+

The following glyphs are added for the dictionary and set literal notation.

+ + + + + + + + + + + + + + + + + +
Glyph(s)Meaning
:Key/value separator for dictionaries
⦃⦄Set
+

Set notation matches the bracketed list notation with the angle brackets changed to double-struck curly brackets ⦃⦄, but there is no ligature notation for sets.

+

Dictionaries use angle brackets ⟨⟩ like lists, but instead of expressions there are pairs of expressions separated by :. The first expression evaluates to the key and the second to the corresponding value. The empty dictionary is written :.

+

Dictionaries and sets should be supported their own set of primitive operations like arrays are. The glyphs ∪⊂⊃⊆⊇ from mathematics are unused for this reason: they could be wanted for set operations.

+

Namespaces and symbols

+

Sometimes it is useful to have a mutable type, particularly if a part of the program should maintain its own state over the course of execution. The closures required as part of a complete lexical scoping implementation actually allow something like this. If a function defines and returns an explicit function, then that function can read and change variables in its environment. As the environment includes the scope created to execute the outer function, calling the outer function creates a mutable environment that can be indirectly accessed through the returned function.

+

A namespace would allow such an environment to be directly accessed and manipulated. While it's possible there would be facilities to create a namespace, a simpler mechanism is simply to add a primitive that returns the current scope as a variable. This scope would then behave the same way as a returned function's environment, and would allow member access by a dot-like syntax.

+

A symbol is a variable representing a name in the program. Symbols would make it easier to interact with namespaces dynamically.

+ diff --git a/docs/doc/index.html b/docs/doc/index.html index 72ee937f..2ad426ba 100644 --- a/docs/doc/index.html +++ b/docs/doc/index.html @@ -23,4 +23,8 @@ +

Speculation:

+ diff --git a/docs/index.html b/docs/index.html index 2f5f3edb..4a9fd7a0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -457,7 +457,7 @@

The characters and , and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a function. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.

List notation

Lists (1-dimensional arrays) are enclosed in angle brackets ⟨⟩, with the results of the expressions in between being the list's elements. Lists of two elements or more can also be written with the ligature character . This character has higher binding strength than any part of an expression. If one of the elements is a compound expression, then it will need to be enclosed in parentheses.

-

If added, sets and dictionaries would also use a list-like notation.

+

If added, sets and dictionaries would also use a list-like notation.

Blocks

Blocks are written with curly braces {} and can be used to group expressions or define functions and modifiers. The contents are simply a sequence of expressions, where each is evaluated and the result of the last is returned in order to evaluate the block. This result can have any value, and its syntactic role in the calling context is determined by the normal rules: functions return subjects and modifiers return functions. Blocks have lexical scope.

The special names 𝕨 and 𝕩, which stand for arguments, and 𝕗 and 𝕘, which stand for operands, are available inside curly braces. Like ordinary names, the lowercase forms indicate subjects and the uppercase forms 𝕎𝕏𝔽𝔾 indicate functions. The type and syntactic role of the block is determined by its contents: a 2-modifier contains 𝕘, a 1-modifier contains 𝕗 but not 𝕘, and a function contains neither but does have one of 𝕨𝕩𝕤𝕎𝕏𝕊. If no special names are present the block is an immediate block and is evaluated as soon as it appears, with the result having a subject role.

@@ -473,34 +473,4 @@
  • 2-Modifier
  • All of these types are immutable, and immutable types should be the default for BQN. The only mutable type likely to be added is the namespace or scope.

    -

    BQN extensions

    -

    The above text describes the initial implementation target. The language will probably be extended after this target is reached. This section describes features which are not fully defined but could be added to the language.

    -

    Sets and dictionaries

    -

    Sets are unordered collections of distinct values. Dictionaries have a set of keys and associate each key with a corresponding value. These types are a natural fit for the data in some cases; while they can be represented using arrays of keys and values, using the right type can lead to cleaner and faster algorithms.

    -

    The following glyphs are added for the dictionary and set literal notation.

    - - - - - - - - - - - - - - - - - -
    Glyph(s)Meaning
    :Key/value separator for dictionaries
    ⦃⦄Set
    -

    Set notation matches the bracketed list notation with the angle brackets changed to double-struck curly brackets ⦃⦄, but there is no ligature notation for sets.

    -

    Dictionaries use angle brackets ⟨⟩ like lists, but instead of expressions there are pairs of expressions separated by :. The first expression evaluates to the key and the second to the corresponding value. The empty dictionary is written :.

    -

    Dictionaries and sets should be supported their own set of primitive operations like arrays are. The glyphs ∪⊂⊃⊆⊇ from mathematics are unused for this reason: they could be wanted for set operations.

    -

    Namespaces and symbols

    -

    Sometimes it is useful to have a mutable type, particularly if a part of the program should maintain its own state over the course of execution. The closures required as part of a complete lexical scoping implementation actually allow something like this. If a function defines and returns an explicit function, then that function can read and change variables in its environment. As the environment includes the scope created to execute the outer function, calling the outer function creates a mutable environment that can be indirectly accessed through the returned function.

    -

    A namespace would allow such an environment to be directly accessed and manipulated. While it's possible there would be facilities to create a namespace, a simpler mechanism is simply to add a primitive that returns the current scope as a variable. This scope would then behave the same way as a returned function's environment, and would allow member access by a dot-like syntax.

    -

    A symbol is a variable representing a name in the program. Symbols would make it easier to interact with namespaces dynamically.

    -- cgit v1.2.3