about summary refs log tree commit diff stats
path: root/mu.md
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-14 11:06:25 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-14 11:06:25 -0700
commit48a056b6da03758bfb365c3a8bac7b849793f013 (patch)
treea57a3e8e3f5733d9d56fa53ecddd42588c30a4b8 /mu.md
parent9c810588a1512be88782f86f57eda34d05fe9b00 (diff)
downloadmu-48a056b6da03758bfb365c3a8bac7b849793f013.tar.gz
7028
Diffstat (limited to 'mu.md')
-rw-r--r--mu.md15
1 files changed, 11 insertions, 4 deletions
diff --git a/mu.md b/mu.md
index 84560377..81c057df 100644
--- a/mu.md
+++ b/mu.md
@@ -65,7 +65,9 @@ fn _name_ _inout_ ... -> _output_ ... {
 
 Each function has a header line, and some number of statements, each on a
 separate line. Headers describe inouts and outputs. Inouts can't be registers,
-and outputs _must_ be registers.
+and outputs _must_ be registers. In the above example, the outputs of both
+`do-add` and `main` have type `int` and are available in register `ebx` at the
+end of the respective calls.
 
 The above program also demonstrates a function call (to the function `do-add`).
 Function calls look the same as primitive statements: they can return (multiple)
@@ -79,7 +81,7 @@ fn f -> x/eax: int {
 }
 fn g {
   a/eax <- f  # ok
-  a/ebx <- f  # wrong
+  a/ebx <- f  # wrong; `a` must be in register `eax`
 }
 ```
 
@@ -92,8 +94,13 @@ two signatures:
 - `fn main -> x/ebx: int`
 - `fn main args: (addr array (addr array byte)) -> x/ebx: int`
 
-(The names of the inout and output are flexible. Strings are addresses to
-arrays of bytes, or `(addr array byte)` in Mu.)
+(The names of the inout and output are flexible.)
+
+Mu encloses multi-word types in parentheses, and types can get quite expressive.
+For example, you read `main`'s inout type as "an address to an array of
+addresses to arrays of bytes." Since addresses to arrays of bytes are almost
+always strings in Mu, you'll quickly learn to mentally shorten this type to
+"an address to an array of strings".
 
 ## Blocks