From 5268b0e1df434e267b365e931fead9caa151c54b Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 7 Feb 2021 09:53:14 -0800 Subject: [PATCH] 7691 --- README.md | 9 +++++---- mu.md | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ae6eb90a..b884505c 100644 --- a/README.md +++ b/README.md @@ -131,10 +131,11 @@ $ qemu-system-i386 disk.img The entire stack shares certain properties and conventions. Programs consist of functions and functions consist of statements, each performing a single operation. Operands to statements are always variables or constants. You can't -say `a + b*c`, you have to break it up into two operations. Variables can live -in memory or in registers. Registers must be explicitly specified. There are -some shared lexical rules; comments always start with '#', and numbers are -always written in hex. +perform `a + b*c` in a single statement; you have to break it up into two. +Variables can live in memory or in registers. Registers must be explicitly +specified. There are some shared lexical rules. Comments always start with +'#'. Numbers are always written in hex. Many terms can have context-dependent +_metadata_ attached after '/'. Here's an example program in Mu: diff --git a/mu.md b/mu.md index 0bc63d2b..9bd37b67 100644 --- a/mu.md +++ b/mu.md @@ -59,7 +59,8 @@ 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. Outputs can't take names. +and outputs _must_ be registers (specified using metadata after a `/`). +Outputs can't take names. 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) @@ -98,6 +99,20 @@ 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". +Mu currently has no way to name magic constants. Instead, document integer +literals using metadata after a `/`. For example: + +``` +var x/eax: int <- copy 3/margin-left +``` + +Here we use metadata in two ways: to specify a register for the variable `x` +(checked), and to give a name to the constant `3` (unchecked; purely for +documentation). + +Variables can't currently accept unchecked metadata for documentation. +(Perhaps this should change.) + ## Blocks Blocks are useful for grouping related statements. They're delimited by `{`