diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-11 08:15:16 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-11 08:15:16 -0400 |
| commit | 39353546bbd194cc7f21897b769e0900daee26d8 (patch) | |
| tree | 4800f2b67836b2602ac2147c1784a239da0e3868 /README.md | |
| parent | 34714bf35e57696ad37c654f2d6b654d692f6fdd (diff) | |
Describe namespace and symbol extension
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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. |
