about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--mu.md17
1 files changed, 12 insertions, 5 deletions
diff --git a/mu.md b/mu.md
index f940a6bd..4abb7610 100644
--- a/mu.md
+++ b/mu.md
@@ -42,6 +42,13 @@ a `var` statement has two forms:
 Variables in registers must be initialized. Variables on the stack are
 implicitly zeroed out.
 
+Variables exist only within the `{}` block they're defined in. Space allocated
+to them on the stack is reclaimed after execution leaves the block. Registers
+restore whatever variable was using them in the outer block.
+
+It is perfectly ok to reuse a register for a new variable. Even in a single
+block (though you permanently lose the old variable then).
+
 Variables can be in six 32-bit _general-purpose_ registers of the x86 processor.
   - eax
   - ebx
@@ -50,6 +57,9 @@ Variables can be in six 32-bit _general-purpose_ registers of the x86 processor.
   - esi ('s' often a mnemonic for 'source')
   - edi ('d' often a mnemonic for 'destination')
 
+Most functions return results in `eax` by convention. In practice, it ends up
+churning through variables pretty quickly.
+
 You can store several types in these registers:
   - int
   - boolean
@@ -381,7 +391,7 @@ Xor:
   xor-with var, n
 ```
 
-### Shifts
+### Bitwise shifts
 
 Shifts require variables of non-`addr`, non-`float` types.
 
@@ -415,6 +425,7 @@ You can compute the address of any variable in memory (never in registers):
 
 As mentioned up top, `addr` variables can never escape the function where
 they're computed. You can't store them on the heap, or in compound types.
+Think of them as short-lived things.
 
 To manage long-lived addresses, _allocate_ them on the heap.
 
@@ -430,10 +441,6 @@ have to first convert them into a short-lived `addr` using _lookup_.
   var y/eax: (addr T) <- lookup x: (handle T)
 ```
 
-The output of `lookup` is always returned in register `eax`. Many other
-function calls do the same thing. In practice, this means `eax` ends up being
-a temporary location used to store lots of variables in quick succession.
-
 Since handles are large compound types, there's a special helper for comparing
 them:
 
>099f0d5d ^
418ea7d3 ^
e97b446a ^
90538f23 ^
6488bfcf ^
90538f23 ^
6488bfcf ^
90538f23 ^
23fd294d ^

6488bfcf ^











90538f23 ^



531f14c9 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53