Skip to content

Commit a5a677b

Browse files
author
Daniel Patterson
committed
---
yaml --- r: 35917 b: refs/heads/try2 c: c33bff9 h: refs/heads/master i: 35915: b5eb403 v: v3
1 parent 03d2e79 commit a5a677b

File tree

3 files changed

+64
-42
lines changed

3 files changed

+64
-42
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 91315c3c2f2b07cc090fa9d1a69aa389f3c605c2
8+
refs/heads/try2: c33bff955707d496d675126433627297487daa25
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/doc/rust.md

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,11 @@ Examples of floating-point literals of various forms:
388388
12E+99_f64; // type f64
389389
~~~~
390390

391-
##### Unit and boolean literals
391+
##### Nil and boolean literals
392392

393-
The _unit value_, the only value of the type that has the same name, is written as `()`.
394-
The two values of the boolean type are written `true` and `false`.
393+
The _nil value_, the only value of the type by the same name, is
394+
written as `()`. The two values of the boolean type are written `true`
395+
and `false`.
395396

396397
### Symbols
397398

@@ -500,13 +501,14 @@ only be invoked in expression position.
500501
any token other than a delimiter or `$`.)
501502

502503
Macro invocations are looked up by name, and each macro rule is tried in turn;
503-
the first successful match is transcribed. The matching and transcription
504+
the first successful match is transcribed. The matching and transcribing
504505
processes are closely related, and will be described together:
505506

506507
### Macro By Example
507508

508-
The macro expander matches and transcribes every token that does not begin with a `$` literally, including delimiters.
509-
For parsing reasons, delimiters must be balanced, but they are otherwise not special.
509+
Everything that does not begin with a `$` is matched and transcirbed
510+
literally, including delimiters. For parsing reasons, they must be matched,
511+
but they are otherwise not special.
510512

511513
In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the
512514
Rust syntax named by _designator_. Valid designators are `item`, `block`,
@@ -515,11 +517,11 @@ are the right-hand side and the left-hand side respectively of the `=>` in
515517
macro rules. In the transcriber, the designator is already known, and so only
516518
the name of a matched nonterminal comes after the dollar sign.
517519

518-
In both the matcher and transcriber, the Kleene star-like operator indicates repetition.
519-
The Kleene star operator consists of `$` and parens, optionally followed by a separator token, followed by `*` or `+`.
520-
`*` means zero or more repetitions, `+` means at least one repetition.
521-
The parens are not matched or transcribed.
522-
On the matcher side, a name is bound to _all_ of the names it
520+
In bothe the matcher and transcriber, the Kleene star-like operator,
521+
consisting of `$` and parens, optionally followed by a separator token,
522+
followed by `*` or `+`, indicates repetition. (`*` means zero or more
523+
repetitions, `+` means at least one repetition. The parens are not matched or
524+
transcribed). On the matcher side, a name is bound to _all_ of the names it
523525
matches, in a structure that mimics the structure of the repetition
524526
encountered on a successful match. The job of the transcriber is to sort that
525527
structure out.
@@ -548,34 +550,41 @@ Rust syntax is restricted in two ways:
548550
1. The parser will always parse as much as possible. If it attempts to match
549551
`$i:expr [ , ]` against `8 [ , ]`, it will attempt to parse `i` as an array
550552
index operation and fail. Adding a separator can solve this problem.
551-
2. The parser must have eliminated all ambiguity by the time it reaches a `$` _name_ `:` _designator_.
552-
This requirement most often affects name-designator pairs when they occur at the beginning of, or immediately after, a `$(...)*`; requiring a distinctive token in front can solve the problem.
553+
2. The parser must have eliminated all ambiguity by the time it reaches a
554+
`$` _name_ `:` _designator_. This most often affects them when they occur in
555+
the beginning of, or immediately after, a `$(...)*`; requiring a distinctive
556+
token in front can solve the problem.
553557

554558

555559
## Syntax extensions useful for the macro author
556560

557561
* `log_syntax!` : print out the arguments at compile time
558-
* `trace_macros!` : supply `true` or `false` to enable or disable printing of the macro expansion process.
559-
* `ident_to_str!` : turn the identifier argument into a string literal
560-
* `concat_idents!` : create a new identifier by concatenating the arguments
562+
* `trace_macros!` : supply `true` or `false` to enable or disable printing
563+
of the macro expansion process.
564+
* `ident_to_str!` : turns the identifier argument into a string literal
565+
* `concat_idents!` : creates a new identifier by concatenating its arguments
561566

562567

563568

564569
# Crates and source files
565570

566-
Rust is a *compiled* language.
567-
Its semantics obey a *phase distinction* between compile-time and run-time.
568-
Those semantic rules that have a *static interpretation* govern the success or failure of compilation.
569-
We refer to these rules as "static semantics".
570-
Semantic rules called "dynamic semantics" govern the behavior of programs at run-time.
571-
A program that fails to compile due to violation of a compile-time rule has no defined dynamic semantics; the compiler should halt with an error report, and produce no executable artifact.
571+
Rust is a *compiled* language. Its semantics are divided along a
572+
*phase distinction* between compile-time and run-time. Those semantic
573+
rules that have a *static interpretation* govern the success or failure
574+
of compilation. A program that fails to compile due to violation of a
575+
compile-time rule has no defined semantics at run-time; the compiler should
576+
halt with an error report, and produce no executable artifact.
572577

573-
The compilation model centres on artifacts called _crates_.
574-
Each compilation processes a single crate in source form, and if successful, produces a single crate in binary form: either an executable or a library.
578+
The compilation model centres on artifacts called _crates_. Each compilation
579+
is directed towards a single crate in source form, and if successful,
580+
produces a single crate in binary form: either an executable or a library.
575581

576-
A _crate_ is a unit of compilation and linking, as well as versioning, distribution and runtime loading.
577-
A crate contains a _tree_ of nested [module](#modules) scopes.
578-
The top level of this tree is a module that is anonymous (from the point of view of paths within the module) and any item within a crate has a canonical [module path](#paths) denoting its location within the crate's module tree.
582+
A _crate_ is a unit of compilation and linking, as well as versioning,
583+
distribution and runtime loading. A crate contains a _tree_ of nested
584+
[module](#modules) scopes. The top level of this tree is a module that is
585+
anonymous -- from the point of view of paths within the module -- and any item
586+
within a crate has a canonical [module path](#paths) denoting its location
587+
within the crate's module tree.
579588

580589
Crates are provided to the Rust compiler through two kinds of file:
581590

@@ -585,15 +594,18 @@ Crates are provided to the Rust compiler through two kinds of file:
585594
> **Note:** The functionality of crate files will be merged into source files in future versions of Rust.
586595
> The separate processing of crate files, both their grammar and file extension, will be removed.
587596
588-
The Rust compiler is always invoked with a single crate file as input, and always produces a single output crate.
597+
The Rust compiler is always invoked with a single input file, and always
598+
produces a single output crate.
589599

590600
When the Rust compiler is invoked with a crate file, it reads the _explicit_
591601
definition of the crate it's compiling from that file, and populates the
592602
crate with modules derived from all the source files referenced by the
593603
crate, reading and processing all the referenced modules at once.
594604

595-
When the Rust compiler is invoked with a source file, it creates an _implicit_ crate and treats the source file as if it is the sole module populating this explicit crate.
596-
The module name is derived from the source file name, with the `.rs` extension removed.
605+
When the Rust compiler is invoked with a source file, it creates an
606+
_implicit_ crate and treats the source file as though it was referenced as
607+
the sole module populating this implicit crate. The module name is derived
608+
from the source file name, with the `.rs` extension removed.
597609

598610
## Crate files
599611

@@ -650,8 +662,10 @@ containing source files and/or further subdirectories. The filesystem
650662
directory associated with a `dir_directive` module can either be explicit,
651663
or if omitted, is implicitly the same name as the module.
652664

653-
A `source_directive` references a source file, either explicitly or implicitly, by combining the module name with the file extension `.rs`.
654-
The module contained in that source file is bound to the module path formed by the `dir_directive` modules containing the `source_directive`.
665+
A `source_directive` references a source file, either explicitly or
666+
implicitly by combining the module name with the file extension `.rs`. The
667+
module contained in that source file is bound to the module path formed by
668+
the `dir_directive` modules containing the `source_directive`.
655669

656670
## Source files
657671

@@ -661,8 +675,9 @@ location of which -- in the module tree of the current crate -- is defined
661675
from outside the source file: either by an explicit `source_directive` in
662676
a referencing crate file, or by the filename of the source file itself.
663677

664-
A source file that contains a `main` function can be compiled to an executable.
665-
If a `main` function is present, its return type must be [`unit`](#primitive-types) and it must take no arguments.
678+
A source file that contains a `main` function can be compiled to an
679+
executable. If a `main` function is present,
680+
its return type must be [`nil`](#primitive-types) and it must take no arguments.
666681

667682
# Items and attributes
668683

@@ -1483,10 +1498,10 @@ A temporary's lifetime equals the largest lifetime of any borrowed pointer that
14831498

14841499
A _literal expression_ consists of one of the [literal](#literals)
14851500
forms described earlier. It directly describes a number, character,
1486-
string, boolean value, or the unit value.
1501+
string, boolean value, or the nil value.
14871502

14881503
~~~~~~~~ {.literals}
1489-
(); // unit type
1504+
(); // nil type
14901505
"hello"; // string type
14911506
'5'; // character type
14921507
5; // integer type
@@ -1851,7 +1866,7 @@ operators may be composed with the `=` operator. The expression `lval
18511866
OP= val` is equivalent to `lval = lval OP val`. For example, `x = x +
18521867
1` may be written as `x += 1`.
18531868

1854-
Any such expression always has the [`unit`](#primitive-types) type.
1869+
Any such expression always has the [`nil`](#primitive-types) type.
18551870

18561871
#### Operator precedence
18571872

@@ -2403,8 +2418,11 @@ types. User-defined types have limited capabilities.
24032418

24042419
The primitive types are the following:
24052420

2406-
* The "unit" type `()`, having the single "unit" value `()` (occasionally called "nil").
2407-
^[The "unit" value `()` is *not* a sentinel "null pointer" value for reference slots; the "unit" type is the implicit return type from functions otherwise lacking a return type, and can be used in other contexts (such as message-sending or type-parametric code) as a zero-size type.]
2421+
* The "nil" type `()`, having the single "nil" value `()`.^[The "nil" value
2422+
`()` is *not* a sentinel "null pointer" value for reference slots; the "nil"
2423+
type is the implicit return type from functions otherwise lacking a return
2424+
type, and can be used in other contexts (such as message-sending or
2425+
type-parametric code) as a zero-size type.]
24082426
* The boolean type `bool` with values `true` and `false`.
24092427
* The machine types.
24102428
* The machine-dependent integer and floating-point types.

branches/try2/doc/tutorial.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ while count < 10 {
216216

217217
Although Rust can almost always infer the types of local variables, you
218218
can specify a variable's type by following it with a colon, then the type
219-
name.
219+
name.
220220

221221
~~~~
222222
let monster_size: float = 57.8;
@@ -381,6 +381,10 @@ of:
381381
`[mut T]` Mutable vector with unknown size
382382
------------------------- -----------------------------------------------
383383

384+
> ***Note***: In the future, mutability for vectors may be defined by
385+
> the slot that contains the vector, not the type of the vector itself,
386+
> deprecating [mut T] syntax.
387+
384388
In function types, the return type is specified with an arrow, as in
385389
the type `fn() -> bool` or the function declaration `fn foo() -> bool
386390
{ }`. For functions that do not return a meaningful value, you can
@@ -1951,7 +1955,7 @@ trait Printable {
19511955
~~~~
19521956

19531957
Traits may be implemented for specific types with [impls]. An impl
1954-
that implements a trait includes the name of the trait at the start of
1958+
that implements a trait includes the name of the trait at the start of
19551959
the definition, as in the following impls of `Printable` for `int`
19561960
and `~str`.
19571961

0 commit comments

Comments
 (0)