about summary refs log tree commit diff
path: root/doc/tutorial/syntax.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tutorial/syntax.md')
-rw-r--r--doc/tutorial/syntax.md25
1 files changed, 23 insertions, 2 deletions
diff --git a/doc/tutorial/syntax.md b/doc/tutorial/syntax.md
index 8182cc11932..aa53932c382 100644
--- a/doc/tutorial/syntax.md
+++ b/doc/tutorial/syntax.md
@@ -1,7 +1,5 @@
 # Syntax Basics
 
-FIXME: briefly mention syntax extentions, #fmt
-
 ## Braces
 
 Assuming you've programmed in any C-family language (C++, Java,
@@ -307,3 +305,26 @@ written like this:
         #[cfg(target_os = "win32")];
         /* ... */
     }
+
+## Syntax extensions
+
+There are plans to support user-defined syntax (macros) in Rust. This
+currently only exists in very limited form.
+
+The compiler defines a few built-in syntax extensions. The most useful
+one is `#fmt`, a printf-style text formatting macro that is expanded
+at compile time.
+
+    std::io::writeln(#fmt("%s is %d", "the answer", 42));
+
+`#fmt` supports most of the directives that [printf][pf] supports, but
+will give you a compile-time error when the types of the directives
+don't match the types of the arguments.
+
+[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf
+
+All syntax extensions look like `#word`. Another built-in one is
+`#env`, which will look up its argument as an environment variable at
+compile-time.
+
+    std::io::writeln(#env("PATH"));