From 5f73037b8a556d393d2960bb7986131726ddd78c Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 07:50:44 +0200 Subject: [PATCH 1/6] reference: not sure this is the right place to discuss design --- src/doc/reference.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 83849574260..1aad12c08b9 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -4036,10 +4036,6 @@ In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for all compilation needs, and the other options are just available if more fine-grained control is desired over the output format of a Rust crate. -# Appendix: Rationales and design trade-offs - -*TODO*. - # Appendix: Influences Rust is not a particularly original language, with design elements coming from From e0f35da9c1839aced4b0db840486b6da0742f444 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 07:55:59 +0200 Subject: [PATCH 2/6] reference: fix anchor link --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 83849574260..5d2bb1e1904 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3897,7 +3897,7 @@ references to boxes are dropped. ### Variables A _variable_ is a component of a stack frame, either a named function parameter, -an anonymous [temporary](#lvalues,-rvalues-and-temporaries), or a named local +an anonymous [temporary](#lvalues-rvalues-and-temporaries), or a named local variable. A _local variable_ (or *stack-local* allocation) holds a value directly, From 70770753722fc302d7db634f8215362c1079d217 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 08:04:55 +0200 Subject: [PATCH 3/6] doc: "familiarity" does not need to be repeated here --- src/doc/grammar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index 3ae93b8f279..7bfe8b62e8a 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -9,7 +9,7 @@ provides only one kind of material: This document does not serve as an introduction to the language. Background familiarity with the language is assumed. A separate [guide] is available to -help acquire such background familiarity. +help acquire such background. This document also does not serve as a reference to the [standard] library included in the language distribution. Those libraries are documented From 996bd9d0d6b7887e4720d5a595ce9fd2c6a82c80 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 08:18:00 +0200 Subject: [PATCH 4/6] reference: 3 of the 4 things mentioned here are optional --- src/doc/reference.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 83849574260..7cae6a515cb 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -900,9 +900,10 @@ fn main() {} ### Functions -A _function item_ defines a sequence of [statements](#statements) and an -optional final [expression](#expressions), along with a name and a set of -parameters. Functions are declared with the keyword `fn`. Functions declare a +A _function item_ defines a sequence of [statements](#statements) and a +final [expression](#expressions), along with a name and a set of +parameters. Other than a name, all these are optional. +Functions are declared with the keyword `fn`. Functions may declare a set of *input* [*variables*](#variables) as parameters, through which the caller passes arguments into the function, and the *output* [*type*](#types) of the value the function will return to its caller on completion. From f34eafdcf9486189f594dc1e38a5b490bcba67ec Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 08:25:29 +0200 Subject: [PATCH 5/6] reference: follow idiom in code snippet --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 83849574260..e8ac474b07e 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -921,7 +921,7 @@ An example of a function: ``` fn add(x: i32, y: i32) -> i32 { - return x + y; + x + y } ``` From 0b13ee0ced39db0acaf1bb966e57417bd42b0423 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 24 Sep 2015 08:42:39 +0200 Subject: [PATCH 6/6] reference: rename "structure" to the more familiar "struct" --- src/doc/reference.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 83849574260..336c25744ca 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -674,7 +674,7 @@ There are several kinds of item: * [modules](#modules) * [functions](#functions) * [type definitions](grammar.html#type-definitions) -* [structures](#structures) +* [structs](#structs) * [enumerations](#enumerations) * [constant items](#constant-items) * [static items](#static-items) @@ -1155,7 +1155,7 @@ type Point = (u8, u8); let p: Point = (41, 68); ``` -### Structures +### Structs A _structure_ is a nominal [structure type](#structure-types) defined with the keyword `struct`. @@ -2614,7 +2614,7 @@ comma: ### Structure expressions There are several forms of structure expressions. A _structure expression_ -consists of the [path](#paths) of a [structure item](#structures), followed by +consists of the [path](#paths) of a [structure item](#structs), followed by a brace-enclosed list of one or more comma-separated name-value pairs, providing the field values of a new instance of the structure. A field name can be any identifier, and is separated from its value expression by a colon. @@ -2622,13 +2622,13 @@ The location denoted by a structure field is mutable if and only if the enclosing structure is mutable. A _tuple structure expression_ consists of the [path](#paths) of a [structure -item](#structures), followed by a parenthesized list of one or more +item](#structs), followed by a parenthesized list of one or more comma-separated expressions (in other words, the path of a structure item followed by a tuple expression). The structure item must be a tuple structure item. A _unit-like structure expression_ consists only of the [path](#paths) of a -[structure item](#structures). +[structure item](#structs). The following are examples of structure expressions: @@ -3145,7 +3145,7 @@ if` condition is evaluated. If all `if` and `else if` conditions evaluate to A `match` expression branches on a *pattern*. The exact form of matching that occurs depends on the pattern. Patterns consist of some combination of -literals, destructured arrays or enum constructors, structures and tuples, +literals, destructured arrays or enum constructors, structs and tuples, variable binding specifications, wildcards (`..`), and placeholders (`_`). A `match` expression has a *head expression*, which is the value to compare to the patterns. The type of the patterns must equal the type of the head @@ -3469,7 +3469,7 @@ named reference to an [`enum` item](#enumerations). ### Recursive types Nominal types — [enumerations](#enumerated-types) and -[structures](#structure-types) — may be recursive. That is, each `enum` +[structs](#structure-types) — may be recursive. That is, each `enum` constructor or `struct` field may refer, directly or indirectly, to the enclosing `enum` or `struct` type itself. Such recursion has restrictions: @@ -3497,7 +3497,7 @@ let a: List = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil)))); ### Pointer types All pointers in Rust are explicit first-class values. They can be copied, -stored into data structures, and returned from functions. There are two +stored into data structs, and returned from functions. There are two varieties of pointer in Rust: * References (`&`)