From e2b07a5fd0bbaad232c717fb90a31d6c61d72bd4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Jul 2022 20:06:50 -0400 Subject: Try to include previous variable definitions in REPL links --- docs/doc/match.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/doc/match.html') diff --git a/docs/doc/match.html b/docs/doc/match.html index 767a4bb5..13568805 100644 --- a/docs/doc/match.html +++ b/docs/doc/match.html @@ -67,7 +67,7 @@ 13

(A side note is that BQN restricts what can cause these side effects: they can only happen by calling a block function or modifier, and never a primitive or purely tacit operation). Now suppose we share the value of F with another variable like F1 below. When we apply G, the result of F might change, but so does F1! This effect is called aliasing.

-↗️
    F1  F
+↗️
    F1  F
     {𝕏 6}¨ FF1
 ⟨ 14 14 ⟩
 
@@ -77,7 +77,7 @@
 ⟨ 9 9 ⟩
 

In some cases you might not be able to demonstrate aliasing so cleanly. A function such as a random number generator changes its own state, so calling one function will change the other. But comparison tells you directly whether two blocks are the same.

-↗️
    f = f1
+↗️
    f = f1
 1
 

As with other kinds of functions, just because two blocks always behave the same doesn't mean they are equal. Any function that's written as {𝕩} will always work the same as other functions spelled that way, but the two functions below are different instances because they come from two different places in the source code.

@@ -92,7 +92,7 @@ ⟨ 8 12 ⟩

These functions both have the definition {a×𝕩}, but give different results! They are different instances of the same block, and have different environments: for T2, a is 2, and for T3, it's 3.

-↗️
    t2 = t3
+↗️
    t2 = t3
 0
 

Some definitions should help to make things clearer. A "block" is not actually a BQN value, but a region of source code enclosed in {} brackets. When the program encounters a block function or modifier, it creates an instance of this block, and then uses this instance in the rest of the expression (actually, an immediate block also creates an instance, but this instance is immediately run, and discarded when it finishes, so it can't be accessed as a value). Every time the function Gen is run, it evaluates the statements it contains, and the second statement {a×𝕩} creates a block instance. So Gen creates a new block instance each time. This is necessary for Gen to work correctly: each time it runs, it creates a new scope, so it needs to create a new function that will be tied to that scope.

-- cgit v1.2.3