diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-03-26 22:32:22 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-03-26 22:32:22 -0700 |
commit | 9f71d7248c908900e987c08b2ab4642dfd88eacb (patch) | |
tree | 4a66cc6cdd3e41eb0f1a4cb83c421addaf9f4cc2 | |
parent | 4d0df592acdc345d1728a68e7194cc25fced4c09 (diff) | |
download | mu-9f71d7248c908900e987c08b2ab4642dfd88eacb.tar.gz |
.
-rw-r--r-- | mu.md | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/mu.md b/mu.md index 9bd37b67..34149a29 100644 --- a/mu.md +++ b/mu.md @@ -43,7 +43,9 @@ and [vocabulary.md](vocabulary.md). ## Functions and calls -Zooming out from single statements, here's a complete sample program in Mu: +Zooming out from single statements, here's a complete sample program in Mu +that runs in Linux (Mu programs without an OS need `main` to have a different +signature): <img alt='ex2.mu' src='html/ex2.mu.png' width='400px'> @@ -82,17 +84,6 @@ You can exit a function at any time with the `return` instruction. Give it the right number of arguments, and it'll assign them respectively to the function's outputs before jumping back to the caller. -The function `main` is special; it is where the program starts running. It -must always return a single int in register `ebx` (as the exit status of the -process). It can also optionally accept an array of strings as input (from the -shell command-line). To be precise, `main` must have one of the following -two signatures: - -- `fn main -> _/ebx: int` -- `fn main args: (addr array (addr array byte)) -> _/ebx: int` - -(The name of the inout is 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 |