Skip to content

Commit cccdc63

Browse files
author
xenocons
committed
---
yaml --- r: 139000 b: refs/heads/try2 c: d8094f8 h: refs/heads/master v: v3
1 parent 8fbe7a9 commit cccdc63

File tree

724 files changed

+5347
-9340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

724 files changed

+5347
-9340
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: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b778ec92823636570836987403c3e012c71d95de
8+
refs/heads/try2: d8094f8602247927a39d33cbad13bdff3b2d467f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/RELEASES.txt

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,8 @@
1-
Version 0.6 (March 2013)
1+
Version 0.6 (?)
22
---------------------------
33

4-
* ~??? changes, numerous bugfixes
5-
6-
* TODO:
7-
* Ord/Cmp
8-
* Lifetime changes
9-
* Implicit self
10-
* Remove `static` keyword
11-
* Static method syntax
12-
* `as Trait`
13-
* `copy` removed, replaced with `Clone`?
14-
* `std::map` removed, replaced with `core::hashmap`
15-
16-
* Syntax changes
17-
* The self type parameter in traits is now spelled `Self`
18-
* Replaced the `Durable` trait with the `'static` lifetime
19-
* The old closure type syntax with the trailing sigil has been
20-
removed in favor of the more consistent leading sigil
21-
* `super` is a keyword, and may be prefixed to paths
22-
* Trait bounds are separated with `+` instead of whitespace
23-
* Traits are implemented with `impl Trait for Type`
24-
instead of `impl Type: Trait`
25-
* The `export` keyword has finally been removed
26-
* The `move` keyword has been removed (linear types move by default)
27-
* The interior mutability qualifier on vectors, `[mut T]`, has been
28-
removed. Use `&mut [T]`, etc.
29-
* `mut` is no longer valid in `~mut T`. Use inherited mutability
30-
* `fail` is no longer a keyword. Use `fail!()`
31-
* `assert` is no longer a keyword. Use `assert!()`
32-
* `log` is no longer a keyword. use `debug!`, etc.
33-
* 1-tuples may be represented as `(T,)`
34-
* Struct fields may no longer be `mut`. Use inherited mutability,
35-
`@mut T`, `core::mut` or `core::cell`
36-
* `extern mod { ... }` is no longer valid syntax for foreign
37-
function modules. Use extern blocks: `extern { ... }`
38-
* Newtype enums removed. Used tuple-structs.
39-
* Trait implementations no longer support visibility modifiers
40-
41-
* Semantic changes
42-
* Types with owned pointers or custom destructors move by default,
43-
eliminating the `move` keyword
44-
* All foreign functions are considered unsafe
45-
* &mut is now unaliasable
46-
* Writes to borrowed @mut pointers are prevented dynamically
47-
* () has size 0
48-
* The name of the main function can be customized using #[main]
49-
* The default type of an inferred closure is &fn instead of @fn
50-
* Name resolution continues to be tweaked
51-
* Method visibility is inherited from the implementation declaration
52-
53-
* Other language changes
54-
* Structural records have been removed
55-
* Many more types can be used in constants, including enums
56-
`static lifetime pointers and vectors
57-
* Pattern matching over vectors improved and expanded
58-
* Typechecking of closure types has been overhauled to
59-
improve inference and eliminate unsoundness
60-
614
* Libraries
62-
* Added big integers to `std::bigint`
63-
* Removed `core::oldcomm` module
64-
* Added pipe-based `core::comm` module
65-
* Numeric traits have been reorganized under `core::num`
66-
* `vec::slice` finally returns a slice
67-
* `debug!` and friends don't require a format string, e.g. `debug!(Foo)`
68-
* Containers reorganized around traits in `core::container`
69-
* `core::dvec` removed, `~[T]` is a drop-in replacement
70-
* `core::send_map` renamed to `core::hashmap`
71-
* `std::treemap` reimplemented as an owned balanced tree
72-
* `std::deque` and `std::smallintmap` reimplemented as owned containers
73-
* `core::trie` added as a fast ordered map for integer keys
74-
* Set types added to `core::hashmap`, `core::trie` and `std::treemap`
75-
76-
* Tools
77-
* Replaced the 'cargo' package manager with 'rustpkg'
78-
* Added all-purpose 'rust' tool
79-
* `rustc --test` now supports a benchmarks with the `#[bench]` attribute
80-
* rustc now attempts to offer spelling suggestions
81-
82-
* Misc
83-
* Improved support for ARM and Android
84-
* Preliminary MIPS backend
85-
* Improved foreign function ABI implementation for x86, x86_64
86-
* Various and memory usage improvements
87-
* Rust code may be embedded in foreign code under limited circumstances
5+
* `core::send_map` renamed to `core::hashmap`
886

897
Version 0.5 (December 2012)
908
---------------------------

branches/try2/doc/rust.md

Lines changed: 88 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ do drop
212212
else enum extern
213213
false fn for
214214
if impl
215-
let loop
215+
let log loop
216216
match mod mut
217217
priv pub pure
218218
ref return
@@ -805,20 +805,21 @@ Use declarations support a number of "convenience" notations:
805805
An example of `use` declarations:
806806

807807
~~~~
808+
use foo = core::info;
808809
use core::float::sin;
809810
use core::str::{slice, to_upper};
810811
use core::option::Some;
811812
812813
fn main() {
813-
// Equivalent to 'info!(core::float::sin(1.0));'
814-
info!(sin(1.0));
814+
// Equivalent to 'log(core::info, core::float::sin(1.0));'
815+
log(foo, sin(1.0));
815816
816-
// Equivalent to 'info!(core::option::Some(1.0));'
817-
info!(Some(1.0));
817+
// Equivalent to 'log(core::info, core::option::Some(1.0));'
818+
log(info, Some(1.0));
818819
819-
// Equivalent to
820-
// 'info!(core::str::to_upper(core::str::slice("foo", 0, 1)));'
821-
info!(to_upper(slice("foo", 0, 1)));
820+
// Equivalent to 'log(core::info,
821+
// core::str::to_upper(core::str::slice("foo", 0, 1)));'
822+
log(info, to_upper(slice("foo", 0, 1)));
822823
}
823824
~~~~
824825

@@ -888,10 +889,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following
888889
the function name.
889890

890891
~~~~ {.xfail-test}
891-
fn iter<T>(seq: &[T], f: &fn(T)) {
892+
fn iter<T>(seq: &[T], f: fn(T)) {
892893
for seq.each |elt| { f(elt); }
893894
}
894-
fn map<T, U>(seq: &[T], f: &fn(T) -> U) -> ~[U] {
895+
fn map<T, U>(seq: &[T], f: fn(T) -> U) -> ~[U] {
895896
let mut acc = ~[];
896897
for seq.each |elt| { acc.push(f(elt)); }
897898
acc
@@ -989,7 +990,7 @@ output slot type would normally be. For example:
989990

990991
~~~~
991992
fn my_err(s: &str) -> ! {
992-
info!(s);
993+
log(info, s);
993994
fail!();
994995
}
995996
~~~~
@@ -1181,8 +1182,8 @@ Traits are implemented for specific types through separate [implementations](#im
11811182
# type BoundingBox = int;
11821183
11831184
trait Shape {
1184-
fn draw(&self, Surface);
1185-
fn bounding_box(&self) -> BoundingBox;
1185+
fn draw(Surface);
1186+
fn bounding_box() -> BoundingBox;
11861187
}
11871188
~~~~
11881189

@@ -1195,9 +1196,9 @@ These appear after the trait name, using the same syntax used in [generic functi
11951196

11961197
~~~~
11971198
trait Seq<T> {
1198-
fn len(&self) -> uint;
1199-
fn elt_at(&self, n: uint) -> T;
1200-
fn iter(&self, &fn(T));
1199+
fn len() -> uint;
1200+
fn elt_at(n: uint) -> T;
1201+
fn iter(fn(T));
12011202
}
12021203
~~~~
12031204

@@ -1209,7 +1210,7 @@ For example:
12091210

12101211
~~~~
12111212
# type Surface = int;
1212-
# trait Shape { fn draw(&self, Surface); }
1213+
# trait Shape { fn draw(Surface); }
12131214
12141215
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
12151216
sh.draw(surface);
@@ -1227,7 +1228,7 @@ to pointers to the trait name, used as a type.
12271228
# impl Shape for int { }
12281229
# let mycircle = 0;
12291230
1230-
let myshape: @Shape = @mycircle as @Shape;
1231+
let myshape: Shape = @mycircle as @Shape;
12311232
~~~~
12321233

12331234
The resulting value is a managed box containing the value that was cast,
@@ -1271,8 +1272,8 @@ methods of the supertrait may be called on values of subtrait-bound type paramet
12711272
Refering to the previous example of `trait Circle : Shape`:
12721273

12731274
~~~
1274-
# trait Shape { fn area(&self) -> float; }
1275-
# trait Circle : Shape { fn radius(&self) -> float; }
1275+
# trait Shape { fn area() -> float; }
1276+
# trait Circle : Shape { fn radius() -> float; }
12761277
fn radius_times_area<T: Circle>(c: T) -> float {
12771278
// `c` is both a Circle and a Shape
12781279
c.radius() * c.area()
@@ -1282,10 +1283,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
12821283
Likewise, supertrait methods may also be called on trait objects.
12831284

12841285
~~~ {.xfail-test}
1285-
# trait Shape { fn area(&self) -> float; }
1286-
# trait Circle : Shape { fn radius(&self) -> float; }
1287-
# impl Shape for int { fn area(&self) -> float { 0.0 } }
1288-
# impl Circle for int { fn radius(&self) -> float { 0.0 } }
1286+
# trait Shape { fn area() -> float; }
1287+
# trait Circle : Shape { fn radius() -> float; }
1288+
# impl Shape for int { fn area() -> float { 0.0 } }
1289+
# impl Circle for int { fn radius() -> float { 0.0 } }
12891290
# let mycircle = 0;
12901291
12911292
let mycircle: Circle = @mycircle as @Circle;
@@ -1302,7 +1303,7 @@ Implementations are defined with the keyword `impl`.
13021303
# struct Point {x: float, y: float};
13031304
# type Surface = int;
13041305
# struct BoundingBox {x: float, y: float, width: float, height: float};
1305-
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
1306+
# trait Shape { fn draw(Surface); fn bounding_box() -> BoundingBox; }
13061307
# fn do_draw_circle(s: Surface, c: Circle) { }
13071308
13081309
struct Circle {
@@ -1311,8 +1312,8 @@ struct Circle {
13111312
}
13121313
13131314
impl Shape for Circle {
1314-
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
1315-
fn bounding_box(&self) -> BoundingBox {
1315+
fn draw(s: Surface) { do_draw_circle(s, self); }
1316+
fn bounding_box() -> BoundingBox {
13161317
let r = self.radius;
13171318
BoundingBox{x: self.center.x - r, y: self.center.y - r,
13181319
width: 2.0 * r, height: 2.0 * r}
@@ -2073,7 +2074,7 @@ and moving values from the environment into the lambda expression's captured env
20732074
An example of a lambda expression:
20742075

20752076
~~~~
2076-
fn ten_times(f: &fn(int)) {
2077+
fn ten_times(f: fn(int)) {
20772078
let mut i = 0;
20782079
while i < 10 {
20792080
f(i);
@@ -2176,7 +2177,7 @@ If the `expr` is a [field expression](#field-expressions), it is parsed as thoug
21762177
In this example, both calls to `f` are equivalent:
21772178

21782179
~~~~
2179-
# fn f(f: &fn(int)) { }
2180+
# fn f(f: fn(int)) { }
21802181
# fn g(i: int) { }
21812182
21822183
f(|j| g(j));
@@ -2396,6 +2397,58 @@ fn max(a: int, b: int) -> int {
23962397
}
23972398
~~~~
23982399

2400+
### Log expressions
2401+
2402+
~~~~~~~~{.ebnf .gram}
2403+
log_expr : "log" '(' level ',' expr ')' ;
2404+
~~~~~~~~
2405+
2406+
Evaluating a `log` expression may, depending on runtime configuration, cause a
2407+
value to be appended to an internal diagnostic logging buffer provided by the
2408+
runtime or emitted to a system console. Log expressions are enabled or
2409+
disabled dynamically at run-time on a per-task and per-item basis. See
2410+
[logging system](#logging-system).
2411+
2412+
Each `log` expression must be provided with a *level* argument in
2413+
addition to the value to log. The logging level is a `u32` value, where
2414+
lower levels indicate more-urgent levels of logging. By default, the lowest
2415+
four logging levels (`1_u32 ... 4_u32`) are predefined as the constants
2416+
`error`, `warn`, `info` and `debug` in the `core` library.
2417+
2418+
Additionally, the macros `error!`, `warn!`, `info!` and `debug!` are defined
2419+
in the default syntax-extension namespace. These expand into calls to the
2420+
logging facility composed with calls to the `fmt!` string formatting
2421+
syntax-extension.
2422+
2423+
The following examples all produce the same output, logged at the `error`
2424+
logging level:
2425+
2426+
~~~~
2427+
# let filename = "bulbasaur";
2428+
2429+
// Full version, logging a value.
2430+
log(core::error, ~"file not found: " + filename);
2431+
2432+
// Log-level abbreviated, since core::* is used by default.
2433+
log(error, ~"file not found: " + filename);
2434+
2435+
// Formatting the message using a format-string and fmt!
2436+
log(error, fmt!("file not found: %s", filename));
2437+
2438+
// Using the error! macro, that expands to the previous call.
2439+
error!("file not found: %s", filename);
2440+
~~~~
2441+
2442+
A `log` expression is *not evaluated* when logging at the specified logging-level, module or task is disabled at runtime.
2443+
This makes inactive `log` expressions very cheap;
2444+
they should be used extensively in Rust code, as diagnostic aids,
2445+
as they add little overhead beyond a single integer-compare and branch at runtime.
2446+
2447+
Logging is presently implemented as a language built-in feature,
2448+
as it makes use of compiler-provided, per-module data tables and flags.
2449+
In the future, logging will move into a library, and will no longer be a core expression type.
2450+
It is therefore recommended to use the macro forms of logging (`error!`, `debug!`, etc.) to minimize disruption in code that uses logging.
2451+
23992452

24002453
# Type system
24012454

@@ -2678,11 +2731,11 @@ An example of an object type:
26782731

26792732
~~~~~~~~
26802733
trait Printable {
2681-
fn to_str(&self) -> ~str;
2734+
fn to_str() -> ~str;
26822735
}
26832736
26842737
impl Printable for int {
2685-
fn to_str(&self) -> ~str { int::to_str(*self) }
2738+
fn to_str() -> ~str { int::to_str(self) }
26862739
}
26872740
26882741
fn print(a: @Printable) {
@@ -2702,7 +2755,7 @@ and the cast expression in `main`.
27022755
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
27032756

27042757
~~~~~~~
2705-
fn map<A: Copy, B: Copy>(f: &fn(A) -> B, xs: &[A]) -> ~[B] {
2758+
fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: &[A]) -> ~[B] {
27062759
if xs.len() == 0 { return ~[]; }
27072760
let first: B = f(xs[0]);
27082761
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
@@ -2721,11 +2774,11 @@ example, in:
27212774

27222775
~~~~~~~~
27232776
trait Printable {
2724-
fn make_string(&self) -> ~str;
2777+
fn make_string() -> ~str;
27252778
}
27262779
27272780
impl Printable for ~str {
2728-
fn make_string(&self) -> ~str { copy *self }
2781+
fn make_string() -> ~str { copy self }
27292782
}
27302783
~~~~~~~~
27312784

@@ -3096,7 +3149,7 @@ communication facilities.
30963149

30973150
The runtime contains a system for directing [logging
30983151
expressions](#log-expressions) to a logging console and/or internal logging
3099-
buffers. Logging can be enabled per module.
3152+
buffers. Logging expressions can be enabled per module.
31003153

31013154
Logging output is enabled by setting the `RUST_LOG` environment
31023155
variable. `RUST_LOG` accepts a logging specification made up of a

0 commit comments

Comments
 (0)