From 7e0e38bd155fab76fa3b6776f9184611d044903d Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 18 Jul 2021 17:53:37 -0400 Subject: Finish lexical scope documentation --- docs/doc/block.html | 2 +- docs/doc/control.html | 2 +- docs/doc/embed.html | 2 +- docs/doc/fromJ.html | 2 +- docs/doc/functional.html | 4 +-- docs/doc/lexical.html | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/doc/namespace.html | 2 +- docs/doc/oop.html | 2 +- docs/doc/paradigms.html | 2 +- docs/doc/syntax.html | 2 +- 10 files changed, 75 insertions(+), 10 deletions(-) (limited to 'docs/doc') diff --git a/docs/doc/block.html b/docs/doc/block.html index eb57da8d..cd124aa9 100644 --- a/docs/doc/block.html +++ b/docs/doc/block.html @@ -12,7 +12,7 @@ Γ—{𝕩𝔽𝕩} 4 16 -

Because they use lexical scoping, blocks can also be used to encapsulate code. If a block uses only variables that it initializes, then it has no dependence on its environment and would work the same way if defined anywhere. But it can also use external variables, defined in a containing block.

+

Because they use lexical scoping, blocks can also be used to encapsulate code. If a block uses only variables that it initializes, then it has no dependence on its environment and would work the same way if defined anywhere. But it can also use external variables, defined in a containing block.

↗️
    a←b←"outer"
     { a←"inner" β‹„ aβ€Ώb }
 ⟨ "inner" "outer" ⟩
diff --git a/docs/doc/control.html b/docs/doc/control.html
index c00ce6e5..bf8f65de 100644
--- a/docs/doc/control.html
+++ b/docs/doc/control.html
@@ -22,7 +22,7 @@
 Test    ← {fn←{Cβ€ΏAπ•Še:Cβ—ΆAβ€ΏE}´𝕩⋄Fn@}
 

Blocks and functions

-

Control structures are generally defined to work with blocks of code, which they might skip, or execute one or more times. This might sound like a BQN immediate block, which also consists of a sequence of code to execute, but immediate blocks are always executed as soon as they are encountered and can't be manipulated the way that blocks in imperative languages can. They're intended to be used with lexical scoping as a tool for encapsulation. Instead, the main tool we will use to get control structures is the block function.

+

Control structures are generally defined to work with blocks of code, which they might skip, or execute one or more times. This might sound like a BQN immediate block, which also consists of a sequence of code to execute, but immediate blocks are always executed as soon as they are encountered and can't be manipulated the way that blocks in imperative languages can. They're intended to be used with lexical scoping as a tool for encapsulation. Instead, the main tool we will use to get control structures is the block function.

Using functions as blocks is a little outside their intended purpose, and the fact that they have to be passed an argument and are expected to use it will be a minor annoyance. The following conventions signal a function that ignores its argument and is called purely for the side effects: