Skip to content

Commit 3de1a97

Browse files
committed
---
yaml --- r: 4536 b: refs/heads/master c: 1dd9240 h: refs/heads/master v: v3
1 parent e51d033 commit 3de1a97

File tree

2 files changed

+43
-69
lines changed

2 files changed

+43
-69
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2f35f645c3a0231be7100318c459e450350124d1
2+
refs/heads/master: 1dd9240e56a4059684805b71580cbcc59e59fa64

trunk/doc/rust.texi

+42-68
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ Additional specific influences can be seen from the following languages:
550550

551551
@menu
552552
* Ref.Lex:: Lexical structure.
553-
* Ref.Path:: References to slots and items.
553+
* Ref.Path:: References to items.
554554
* Ref.Gram:: Grammar.
555555
* Ref.Comp:: Compilation and component model.
556556
* Ref.Mem:: Semantic model of memory.
@@ -977,69 +977,43 @@ The special symbols are:
977977
@page
978978
@node Ref.Path
979979
@section Ref.Path
980-
@c * Ref.Path:: References to slots and items.
980+
@c * Ref.Path:: References to items.
981981
@cindex Names of items or slots
982982
@cindex Path name
983983
@cindex Type parameters
984984

985-
A @dfn{path} is a ubiquitous syntactic form in Rust that deserves special
986-
attention. A path denotes a slot or an
987-
item. @xref{Ref.Mem.Slot}. @xref{Ref.Item}. Every slot and item in a Rust
988-
crate has a @emph{canonical path} that refers to it from the crate top-level,
989-
as well as a number of shorter @emph{relative paths} that may also denote it
990-
in inner scopes of the crate. There is no way to define a slot or item without
991-
a canonical path within its crate (with the exception of the crate's implicit
992-
top-level module). Paths have meaning only within a specific
993-
crate. @xref{Ref.Comp.Crate}.
985+
A @dfn{path} is a sequence of one or more path components separated by a
986+
namespace qualifier (@code{::}). If a path consists of only one component, it
987+
may refer to either an item or a slot in a local control
988+
scope. @xref{Ref.Mem.Slot}. @xref{Ref.Item}. If a path has multiple
989+
components, it refers to an item.
994990

995-
Paths consist of period-separated components. In the simplest form, path
996-
components are identifiers. @xref{Ref.Lex.Ident}.
991+
Every item has a @emph{canonical path} within its crate, but the path naming
992+
an item is only meaningful within a given crate. There is no global namespace
993+
across crates; an item's canonical path merely identifies it within the
994+
crate. @xref{Ref.Comp.Crate}
995+
996+
Path components are usually identifiers. @xref{Ref.Lex.Ident}. The last
997+
component of a path may also have trailing explicit type arguments.
997998

998999
Two examples of simple paths consisting of only identifier components:
9991000
@example
10001001
x;
1001-
x.y.z;
1002-
@end example
1003-
1004-
Paths fall into two important categories: @emph{names} and
1005-
@emph{lvals}.
1006-
1007-
A @dfn{name} denotes an item, and is statically resolved to its
1008-
referent at compile time.
1009-
1010-
An @dfn{lval} denotes a slot or some component of a value held within a slot,
1011-
and is statically resolved at compile time to a sequence of memory operations
1012-
and primitive (arithmetic) expressions that will be executed to load or store
1013-
the associated value, starting from the task stack frame, at run time.
1014-
1015-
In some contexts, the Rust grammar accepts a general @emph{path}, but a
1016-
subsequent syntactic restriction requires the path to be an lval or a name. In
1017-
other words: in some contexts an lval is required (for example, on the left
1018-
hand side of the copy operator, @pxref{Ref.Expr.Copy}) and in other contexts a
1019-
name is required (for example, as a type parameter, @pxref{Ref.Item}). In no
1020-
case is the grammar made ambiguous by accepting a general path and restricting
1021-
allowed paths to names or lvals after parsing. These restrictions are noted in
1022-
the grammar. @xref{Ref.Gram}.
1023-
1024-
A name component may include type parameters. Type parameters are denoted by
1025-
square brackets. Square brackets are used @emph{only} to denote type
1026-
parameters in Rust. If a name component includes a type parameter, the type
1027-
parameter must also resolve statically to a type in the environment of the
1028-
name. Type parameters are only part of the names of items. @xref{Ref.Item}.
1029-
1030-
An example of a name with type parameters:
1031-
@example
1032-
m.map[int,str];
1002+
x::y::z;
10331003
@end example
10341004

1035-
An lval component may include an indexing operator. Index operators are
1036-
enclosed in parentheses and can include any integral expression. Indexing
1037-
operators can only be applied to vectors or strings, and imply a run-time
1038-
bounds-check. @xref{Ref.Type.Vec}.
1005+
In most contexts, the Rust grammar accepts a general @emph{path}, but
1006+
subsequent passes pay restrict paths occurring in various contexts to refer to
1007+
slots or items, depending on the semantics of the occurrence. In other words:
1008+
in some contexts a slot is required (for example, on the left hand side of the
1009+
copy operator, @pxref{Ref.Expr.Copy}) and in other contexts an item is
1010+
required (for example, as a type parameter, @pxref{Ref.Item}). In no case is
1011+
the grammar made ambiguous by accepting a general path and interpreting the
1012+
reference in later passes. @xref{Ref.Gram}.
10391013

1040-
An example of an lval with a dynamic indexing operator:
1014+
An example of a path with type parameters:
10411015
@example
1042-
x.y.(1 + v).z;
1016+
m::map[int,str];
10431017
@end example
10441018

10451019
@page
@@ -1110,8 +1084,8 @@ all members of the crate have canonical path names. @xref{Ref.Path}. The
11101084
the crate: these are either directory modules, corresponding to directories in
11111085
the filesystem of the compilation environment, or file modules, corresponding
11121086
to Rust source files. The names given to such modules in @code{mod} directives
1113-
become prefixes of the paths of items and slots defined within any included
1114-
Rust source files.
1087+
become prefixes of the paths of items defined within any included Rust source
1088+
files.
11151089

11161090
The @code{use} directives within the crate specify @emph{other crates} to scan
11171091
for, locate, import into the crate's module namespace during compilation, and
@@ -1381,7 +1355,7 @@ Some operations implicitly dereference boxes. Examples of such @dfn{implicit
13811355
dereference} operations are:
13821356
@itemize
13831357
@item arithmetic operators (@code{x + y - z})
1384-
@item name-component selection (@code{x.y.z})
1358+
@item field selection (@code{x.y.z})
13851359
@end itemize
13861360

13871361
An example of an implicit-dereference operation performed on box values:
@@ -1731,9 +1705,9 @@ declarations. @xref{Ref.Comp.Crate}.
17311705

17321706
An example of an import:
17331707
@example
1734-
import std.math.sin;
1708+
import std::math::sin;
17351709
fn main() @{
1736-
// Equivalent to 'log std.math.sin(1.0);'
1710+
// Equivalent to 'log std::math::sin(1.0);'
17371711
log sin(1.0);
17381712
@}
17391713
@end example
@@ -1767,8 +1741,8 @@ mod foo @{
17671741
@}
17681742
17691743
fn main() @{
1770-
foo.primary(); // Will compile.
1771-
foo.helper(2,3) // ERROR: will not compile.
1744+
foo::primary(); // Will compile.
1745+
foo::helper(2,3) // ERROR: will not compile.
17721746
@}
17731747
@end example
17741748

@@ -3268,7 +3242,7 @@ fn read_file_lines(&str path) -> vec[str] @{
32683242
vec[str] r;
32693243
file f = open_read(path);
32703244
for each (str s in lines(f)) @{
3271-
vec.append(r,s);
3245+
vec::append(r,s);
32723246
@}
32733247
ret r;
32743248
@}
@@ -3368,7 +3342,7 @@ Example of 4 for loops, all identical:
33683342
@example
33693343
let v: vec[foo] = [a, b, c];
33703344
3371-
for (foo e in v.(0, _vec.len(v))) @{
3345+
for (foo e in v.(0, vec::len(v))) @{
33723346
bar(e);
33733347
@}
33743348
@@ -3400,8 +3374,8 @@ Example of a foreach loop:
34003374
@example
34013375
let txt: str;
34023376
let lines: vec[str];
3403-
for each (str s in _str.split(txt, "\n")) @{
3404-
vec.push(lines, s);
3377+
for each (str s in str::split(txt, "\n")) @{
3378+
vec::push(lines, s);
34053379
@}
34063380
@end example
34073381

@@ -3477,7 +3451,7 @@ let strs: vec[str];
34773451
34783452
alt @{
34793453
case (str s <- p) @{
3480-
vec.append(strs, s);
3454+
vec::append(strs, s);
34813455
@}
34823456
case (c <| x) @{
34833457
x++;
@@ -3762,16 +3736,16 @@ expressions can be enabled or disabled via a two-dimensional filtering process:
37623736
By Item
37633737

37643738
Each @emph{item} (module, function, iterator, object, type) in Rust has a
3765-
static name-path within its crate module, and can have logging enabled or
3766-
disabled on a name-path-prefix basis.
3739+
static path within its crate module, and can have logging enabled or
3740+
disabled on a path-prefix basis.
37673741

37683742
@sp 1
37693743
@item
37703744
By Task
37713745

3772-
Each @emph{task} in a running Rust program has a unique ownership-path through
3773-
the task ownership tree, and can have logging enabled or disabled on an
3774-
ownership-path-prefix basis.
3746+
Each @emph{task} in a running Rust program has a unique ownership relation
3747+
through the task ownership tree, and can have logging enabled or disabled on
3748+
an ownership-ancestry basis.
37753749
@end itemize
37763750

37773751
Logging is integrated into the language for efficiency reasons, as well as the

0 commit comments

Comments
 (0)