about summary refs log tree commit diff
path: root/doc/tutorial/syntax.md
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-11-01 14:38:55 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-11-01 14:38:55 +0100
commitaa01876c95a3f50ef6129f1501d97c7a6bb0e856 (patch)
tree2e2336aee2bf21a4ba72814eb04027a2fa6d2120 /doc/tutorial/syntax.md
parente8e2cd44f48a6edcdd4477ab66f0fc5935ecd1a1 (diff)
downloadrust-aa01876c95a3f50ef6129f1501d97c7a6bb0e856.tar.gz
rust-aa01876c95a3f50ef6129f1501d97c7a6bb0e856.zip
Flesh out the module section of the tutorial
Diffstat (limited to 'doc/tutorial/syntax.md')
-rw-r--r--doc/tutorial/syntax.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/tutorial/syntax.md b/doc/tutorial/syntax.md
index a40c9822152..8c6a54f50d4 100644
--- a/doc/tutorial/syntax.md
+++ b/doc/tutorial/syntax.md
@@ -86,6 +86,27 @@ The double-colon (`::`) is used as a module separator, so
 `std::io::println` means 'the thing named `println` in the module
 named `io` in the module named `std`'.
 
+Rust will normally emit warning about unused variables. These can be
+suppressed by using a variable name that starts with an underscore.
+
+    fn this_warns(x: int) {}
+    fn this_doesnt(_x: int) {}
+
+## Variable declaration
+
+The `let` keyword, as we've seen, introduces a local variable. Global
+constants can be defined with `const`:
+
+    import std;
+    const repeat: uint = 5u;
+    fn main() {
+        let count = 0u;
+        while count < repeat {
+            std::io::println("Hi!");
+            count += 1u;
+        }
+    }
+
 ## Types
 
 The `-> bool` in the last example is the way a function's return type
@@ -256,3 +277,7 @@ exists, convert the result of the expression to the given type.
     let x: float = 4.0;
     let y: uint = x as uint;
     assert y == 4u;
+
+## Attributes
+
+FIXME Briefly introduce attributes