about summary refs log tree commit diff
path: root/doc/tutorial
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-11-01 15:41:14 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-11-01 15:41:14 +0100
commit4fec1798d0d7177c6d15b825d69f2db1a2e814ff (patch)
treeb587beea691317c4afdd0f6a8920fd403c825102 /doc/tutorial
parenta6d856c57c7b61106d08dcc3444b0f394ff2c73e (diff)
Tie up some ends in the tutorial
Diffstat (limited to 'doc/tutorial')
-rw-r--r--doc/tutorial/args.md2
-rw-r--r--doc/tutorial/control.md2
-rw-r--r--doc/tutorial/data.md15
-rw-r--r--doc/tutorial/generic.md3
-rw-r--r--doc/tutorial/mod.md7
-rw-r--r--doc/tutorial/order1
-rw-r--r--doc/tutorial/setup.md15
-rw-r--r--doc/tutorial/syntax.md26
-rw-r--r--doc/tutorial/test.md3
9 files changed, 63 insertions, 11 deletions
diff --git a/doc/tutorial/args.md b/doc/tutorial/args.md
index 77a221cdcf4..7c084687bb2 100644
--- a/doc/tutorial/args.md
+++ b/doc/tutorial/args.md
@@ -105,7 +105,7 @@ and `&&` for by(-immutable)-reference. It is sometimes necessary to
 override the defaults. We'll talk more about this when discussing
 [generics][gens].
 
-[gens]: FIXME
+[gens]: generic.html
 
 ## Other uses of safe references
 
diff --git a/doc/tutorial/control.md b/doc/tutorial/control.md
index 9d6dd358fc4..198d035accb 100644
--- a/doc/tutorial/control.md
+++ b/doc/tutorial/control.md
@@ -148,7 +148,7 @@ handle the failure, allowing the program to continue running.
 to access a vector out of bounds, or running a pattern match with no
 matching clauses, both result in the equivalent of a `fail`.
 
-[tasks]: FIXME
+[tasks]: task.html
 
 ## Logging
 
diff --git a/doc/tutorial/data.md b/doc/tutorial/data.md
index 638db23cb08..0ae474aa54c 100644
--- a/doc/tutorial/data.md
+++ b/doc/tutorial/data.md
@@ -292,4 +292,17 @@ strings. They are always immutable.
 
 ## Resources
 
-FIXME fill this in
+Resources are data types that have a destructor associated with them.
+
+    resource file_desc(fd: int) {
+        close_file_desc(fd);
+    }
+
+This defines a type `file_desc` and a constructor of the same name,
+which takes an integer. Values of such a type can not be copied, and
+when they are destroyed (by going out of scope, or, when boxed, when
+their box is cleaned up), their body runs. In the example above, this
+would cause the given file descriptor to be closed.
+
+NOTE: We're considering alternative approaches for data types with
+destructors. Resources might go away in the future.
diff --git a/doc/tutorial/generic.md b/doc/tutorial/generic.md
index 4ab121bd7b3..1c97e62f6a8 100644
--- a/doc/tutorial/generic.md
+++ b/doc/tutorial/generic.md
@@ -102,3 +102,6 @@ pass to a generic higher-order function as being passed by pointer:
 
 NOTE: This is inconvenient, and we are hoping to get rid of this
 restriction in the future.
+
+FIXME discuss kinds, when they have settled
+
diff --git a/doc/tutorial/mod.md b/doc/tutorial/mod.md
index 352b51c1db5..50f7afb765a 100644
--- a/doc/tutorial/mod.md
+++ b/doc/tutorial/mod.md
@@ -35,7 +35,7 @@ It is also possible to include multiple files in a crate. For this
 purpose, you create a `.rc` crate file, which references any number of
 `.rs` code files. A crate file could look like this:
 
-    #[link(name = "farm", vers = "2.5", author = "mjh")]
+    #[link(name = "farm", vers = "2.5", author = "mjh")];
     mod cow;
     mod chicken;
     mod horse;
@@ -90,7 +90,7 @@ local name `myfarm`.
 
 Our example crate declared this set of `link` attributes:
 
-    #[link(name = "farm", vers = "2.5", author = "mjh")]
+    #[link(name = "farm", vers = "2.5", author = "mjh")];
 
 The version does not match the one provided in the `use` directive, so
 unless the compiler can find another crate with the right version
@@ -102,14 +102,13 @@ Now for something that you can actually compile yourself. We have
 these two files:
 
     // mylib.rs
+    #[link(name = "mylib", vers = "1.0")];
     fn world() -> str { "world" }
 
     // main.rs
     use mylib;
     fn main() { log_err "hello " + mylib::world(); }
 
-FIXME the compiler currently complains about missing link metas when you compile this
-
 Now compile and run like this (adjust to your platform if necessary):
 
     > rustc --lib mylib.rs
diff --git a/doc/tutorial/order b/doc/tutorial/order
index d7ed3605db7..bf621816d47 100644
--- a/doc/tutorial/order
+++ b/doc/tutorial/order
@@ -9,3 +9,4 @@ generic
 mod
 ffi
 task
+test
diff --git a/doc/tutorial/setup.md b/doc/tutorial/setup.md
index ec1e27a0af9..44d99891f76 100644
--- a/doc/tutorial/setup.md
+++ b/doc/tutorial/setup.md
@@ -10,8 +10,8 @@ Rust program files are, by convention, given the extension `.rs`. Say
 we have a file `hello.rs` containing this program:
 
     use std;
-    fn main() {
-        std::io::println("hello world!");
+    fn main(args: [str]) {
+        std::io::println("hello world from " + args[0] + "!");
     }
 
 If the Rust compiler was installed successfully, running `rustc
@@ -30,7 +30,16 @@ into an error.
 
 ## Anatomy of a Rust program
 
-FIXME say something about libs, main, modules, use
+In its simplest form, a Rust program is simply a `.rs` file with some
+types and functions defined in it. If it has a `main` function, it can
+be compiled to an executable. Rust does not allow code that's not a
+declaration to appear at the top level of the file—all statements must
+live inside a function.
+
+Rust programs can also be compiled as libraries, and included in other
+programs. The `use std` directive that appears at the top of a lot of
+examples imports the standard library. This is described in more
+detail [later on](mod.html).
 
 ## Editing Rust code
 
diff --git a/doc/tutorial/syntax.md b/doc/tutorial/syntax.md
index 8c6a54f50d4..1ccd49760ec 100644
--- a/doc/tutorial/syntax.md
+++ b/doc/tutorial/syntax.md
@@ -280,4 +280,28 @@ exists, convert the result of the expression to the given type.
 
 ## Attributes
 
-FIXME Briefly introduce attributes
+Every definition can be annotated with attributes. Attributes are meta
+information that can serve a variety of purposes. One of those is
+conditional compilation:
+
+    #[cfg(target_os = "win32")]
+    fn register_win_service() { /* ... */ }
+
+This will cause the function to vanish without a trace during
+compilation on a non-Windows platform. Attributes always look like
+`#[attr]`, where `attr` can be simply a name (as in `#[test]`, which
+is used by the [built-in test framework](test.html)), a name followed
+by `=` and then a literal (as in `#[license = "BSD"]`, which is a
+valid way to annotate a Rust program as being released under a
+BSD-style license), or a name followed by a comma-separated list of
+nested attributes, as in the `cfg` example above.
+
+An attribute without a semicolon following it applies to the
+definition that follows it. When terminated with a semicolon, it
+applies to the current context. The above example could also be
+written like this:
+
+    fn register_win_service() {
+        #[cfg(target_os = "win32")];
+        /* ... */
+    }
diff --git a/doc/tutorial/test.md b/doc/tutorial/test.md
new file mode 100644
index 00000000000..636f65947a0
--- /dev/null
+++ b/doc/tutorial/test.md
@@ -0,0 +1,3 @@
+# Testing
+
+FIXME to be written