about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-11 03:36:11 +0000
committerbors <bors@rust-lang.org>2014-08-11 03:36:11 +0000
commit4d27b4875e16ed6a4a0c9697432f1152b727e84a (patch)
tree14156aecfe8b49626fe840d0ed5c57055e07351c
parentc4a63fabe345967e7d6b4570752ea081cae21785 (diff)
parent14e245bd47d3ac1a981d50a6f752aa27cca7d85e (diff)
downloadrust-4d27b4875e16ed6a4a0c9697432f1152b727e84a.tar.gz
rust-4d27b4875e16ed6a4a0c9697432f1152b727e84a.zip
auto merge of #15410 : LemmingAvalanche/rust/patch-1, r=alexcrichton
People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names. 

This is just a proposed explanation of this convention, as I've interpreted it - I assumed that the convention came from a language like Haskell, so I tailored it according to that. So beware that I might have misjudged how it is used in the Rust language, or at least how it is used in the Rust tutorial.
-rw-r--r--src/doc/tutorial.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md
index 1a004e31c7d..1942ed54097 100644
--- a/src/doc/tutorial.md
+++ b/src/doc/tutorial.md
@@ -1133,6 +1133,16 @@ let xs = Cons(1, box Cons(2, box Cons(3, box Nil)));
 let ys = xs; // copies `Cons(u32, pointer)` shallowly
 ~~~
 
+> *Note:* Names like `xs` and `ys` are a naming
+> convention for collection-like data structures
+> (like our `List`). These collections are given 
+> names appended with 's' to signify plurality, 
+> i.e. that the data structure stores multiple 
+> elements.  For example, `xs` in this case can 
+> be read as "a list of ex-es", where "x" here 
+> are elements of type `u32`.
+
+
 Rust will consider a shallow copy of a type with a destructor like `List` to
 *move ownership* of the value. After a value has been moved, the source
 location cannot be used unless it is reinitialized.