From 39353546bbd194cc7f21897b769e0900daee26d8 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 11 Jun 2020 08:15:16 -0400 Subject: Describe namespace and symbol extension --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index f5507c20..2b310a35 100644 --- a/README.md +++ b/README.md @@ -216,3 +216,11 @@ Set notation matches the bracketed list notation with the angle brackets changed 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](https://en.wikipedia.org/wiki/Closure_(computer_programming)) 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