Move to short type parameter keywords

Issue #1076
This commit is contained in:
Marijn Haverbeke 2011-10-28 15:09:12 +02:00
parent 8e65dffc30
commit 7a0aee74bf
5 changed files with 24 additions and 24 deletions

View file

@ -26,9 +26,9 @@
*
* Since this forms a lattice, we denote the capabilites in terms of a
* worst-case requirement. That is, if your function needs to move-and-send (or
* copy) your T, you write fn<unique T>(...). If you need to move but not send,
* copy) your T, you write fn<uniq T>(...). If you need to move but not send,
* you write fn<T>(...). And if you need neither -- can work with any sort of
* pinned data at all -- then you write fn<pinned T>(...).
* pinned data at all -- then you write fn<pin T>(...).
*
* Most types are unique or shared. Other possible name combinations for these
* two: (tree, graph; pruned, pooled; message, local; owned, common) are

View file

@ -1735,11 +1735,11 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
}
fn parse_ty_param(p: parser) -> ast::ty_param {
let k = if eat_word(p, "pinned") || eat_word(p, "pin") {
ast::kind_pinned
} else if eat_word(p, "unique") || eat_word(p, "uniq") {
ast::kind_unique
} else { eat_word(p, "shar"); ast::kind_shared };
let k = if eat_word(p, "pin") { ast::kind_pinned }
else if eat_word(p, "uniq") { ast::kind_unique }
else if eat_word(p, "shar") { ast::kind_shared }
// FIXME distinguish implied shared from explicit
else { ast::kind_shared };
ret {ident: parse_ident(p), kind: k};
}

View file

@ -1193,8 +1193,8 @@ fn print_arg_mode(s: ps, m: ast::mode) {
fn print_kind(s: ps, kind: ast::kind) {
alt kind {
ast::kind_unique. { word_nbsp(s, "unique"); }
ast::kind_pinned. { word_nbsp(s, "pinned"); }
ast::kind_unique. { word_nbsp(s, "uniq"); }
ast::kind_pinned. { word_nbsp(s, "pin"); }
_ {/* fallthrough */ }
}
}

View file

@ -41,7 +41,7 @@ native "c-stack-cdecl" mod rustrt {
type void;
type rust_port;
fn chan_id_send<unique T>(t: *sys::type_desc,
fn chan_id_send<uniq T>(t: *sys::type_desc,
target_task: task::task, target_port: port_id,
-data: T);
@ -52,7 +52,7 @@ native "c-stack-cdecl" mod rustrt {
}
native "rust-intrinsic" mod rusti {
fn recv<unique T>(port: *rustrt::rust_port) -> T;
fn recv<uniq T>(port: *rustrt::rust_port) -> T;
}
type port_id = int;
@ -75,7 +75,7 @@ dropped.
Channels may be duplicated and themselves transmitted over other channels.
*/
tag chan<unique T> {
tag chan<uniq T> {
chan_t(task::task, port_id);
}
@ -95,7 +95,7 @@ transmitted. If a port value is copied, both copies refer to the same port.
Ports may be associated with multiple <chan>s.
*/
tag port<unique T> { port_t(@port_ptr); }
tag port<uniq T> { port_t(@port_ptr); }
/*
Function: send
@ -105,7 +105,7 @@ Sends data over a channel.
The sent data is moved into the channel, whereupon the caller loses access
to it.
*/
fn send<unique T>(ch: chan<T>, -data: T) {
fn send<uniq T>(ch: chan<T>, -data: T) {
let chan_t(t, p) = ch;
rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
task::yield();
@ -116,7 +116,7 @@ Function: port
Constructs a port.
*/
fn port<unique T>() -> port<T> {
fn port<uniq T>() -> port<T> {
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>())))
}
@ -128,7 +128,7 @@ Receive from a port.
If no data is available on the port then the task will block until data
becomes available.
*/
fn recv<unique T>(p: port<T>) -> T { ret rusti::recv(***p) }
fn recv<uniq T>(p: port<T>) -> T { ret rusti::recv(***p) }
/*
Function: chan
@ -137,6 +137,6 @@ Constructs a channel.
The channel is bound to the port used to construct it.
*/
fn chan<unique T>(p: port<T>) -> chan<T> {
fn chan<uniq T>(p: port<T>) -> chan<T> {
chan_t(task::get_task(), rustrt::get_port_id(***p))
}

View file

@ -228,7 +228,7 @@ Returns:
A handle to the new task
*/
fn spawn<unique T>(-data: T, f: fn(T)) -> task {
fn spawn<uniq T>(-data: T, f: fn(T)) -> task {
spawn_inner(data, f, none)
}
@ -241,7 +241,7 @@ termination
Immediately before termination, either on success or failure, the spawned
task will send a <task_notification> message on the provided channel.
*/
fn spawn_notify<unique T>(-data: T, f: fn(T),
fn spawn_notify<uniq T>(-data: T, f: fn(T),
notify: comm::chan<task_notification>) -> task {
spawn_inner(data, f, some(notify))
}
@ -255,7 +255,7 @@ This is a convenience wrapper around spawn_notify which, when paired
with <join> can be easily used to spawn a task then wait for it to
complete.
*/
fn spawn_joinable<unique T>(-data: T, f: fn(T)) -> joinable_task {
fn spawn_joinable<uniq T>(-data: T, f: fn(T)) -> joinable_task {
let p = comm::port::<task_notification>();
let id = spawn_notify(data, f, comm::chan::<task_notification>(p));
ret (id, p);
@ -271,11 +271,11 @@ fn spawn_joinable<unique T>(-data: T, f: fn(T)) -> joinable_task {
//
// After the transition this should all be rewritten.
fn spawn_inner<unique T>(-data: T, f: fn(T),
fn spawn_inner<uniq T>(-data: T, f: fn(T),
notify: option<comm::chan<task_notification>>)
-> task {
fn wrapper<unique T>(-data: *u8, f: fn(T)) {
fn wrapper<uniq T>(-data: *u8, f: fn(T)) {
let data: ~T = unsafe::reinterpret_cast(data);
f(*data);
}