diff options
79 files changed, 152 insertions, 155 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 424d930e35c..ec527ab0173 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -349,7 +349,7 @@ fn configure() -> cargo { c } -fn for_each_package(c: cargo, b: block(source, package)) { +fn for_each_package(c: cargo, b: fn(source, package)) { c.sources.values({ |v| for p in copy v.packages { b(v, p); diff --git a/src/comp/metadata/cstore.rs b/src/comp/metadata/cstore.rs index 3c75df586be..e3201834a3d 100644 --- a/src/comp/metadata/cstore.rs +++ b/src/comp/metadata/cstore.rs @@ -93,7 +93,7 @@ fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool { ret p(cstore).metas.contains_key(cnum); } -fn iter_crate_data(cstore: cstore, i: block(ast::crate_num, crate_metadata)) { +fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { p(cstore).metas.items {|k,v| i(k, v);}; } diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs index 9855fa75d42..bdd4623bbea 100644 --- a/src/comp/metadata/decoder.rs +++ b/src/comp/metadata/decoder.rs @@ -460,7 +460,7 @@ fn list_crate_items(bytes: @[u8], md: ebml::doc, out: io::writer) { out.write_str("\n"); } -fn iter_crate_items(bytes: @[u8], proc: block(str, ast::def_id)) { +fn iter_crate_items(bytes: @[u8], proc: fn(str, ast::def_id)) { let md = ebml::new_doc(bytes); let paths = ebml::get_doc(md, tag_paths); let index = ebml::get_doc(paths, tag_index); diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index 279f761dfb2..cc79e6a2bf0 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -486,7 +486,7 @@ fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) -> } fn encode_index<T>(ebml_w: ebml::writer, buckets: [@[entry<T>]], - write_fn: block(io::writer, T)) { + write_fn: fn(io::writer, T)) { let writer = ebml_w.writer; ebml::start_tag(ebml_w, tag_index); let bucket_locs: [uint] = []; diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index 266b319fe29..2e4e5cdc66d 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -16,7 +16,7 @@ export parse_bounds_data; // data buffer. Whatever format you choose should not contain pipe characters. // Callback to translate defs to strs or back: -type conv_did = block(ast::def_id) -> ast::def_id; +type conv_did = fn(ast::def_id) -> ast::def_id; type pstate = {data: @[u8], crate: int, mutable pos: uint, tcx: ty::ctxt}; @@ -138,7 +138,7 @@ fn parse_ty_constr_arg(st: @pstate) -> ast::constr_arg_general_<@path> { } fn parse_constr<T: copy>(st: @pstate, conv: conv_did, - pser: block(@pstate) -> ast::constr_arg_general_<T>) + pser: fn(@pstate) -> ast::constr_arg_general_<T>) -> @ty::constr_general<T> { let sp = ast_util::dummy_sp(); // FIXME: use a real span let args: [@sp_constr_arg<T>] = []; diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index d2c75bc182e..ea301228db6 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -436,7 +436,7 @@ fn check_if(c: @ast::expr, then: ast::blk, els: option::t<@ast::expr>, *sc.invalid = append_invalid(*sc.invalid, then_invalid, orig_invalid); } -fn check_loop(cx: ctx, sc: scope, checker: block()) { +fn check_loop(cx: ctx, sc: scope, checker: fn()) { let orig_invalid = filter_invalid(*sc.invalid, sc.bs); checker(); let new_invalid = filter_invalid(*sc.invalid, sc.bs); diff --git a/src/comp/middle/debuginfo.rs b/src/comp/middle/debuginfo.rs index cfde53fa820..fdc1c51cbd6 100644 --- a/src/comp/middle/debuginfo.rs +++ b/src/comp/middle/debuginfo.rs @@ -140,7 +140,7 @@ fn md_from_metadata<T>(val: debug_metadata) -> T unsafe { } fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int, - eq: block(md: T) -> bool) -> option::t<T> unsafe { + eq: fn(md: T) -> bool) -> option::t<T> unsafe { if cache.contains_key(mdtag) { let items = cache.get(mdtag); for item in items { diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 600389b3058..db35362f3ea 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -58,7 +58,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map, // variables. `id` is the node_id for some expression that creates the // closure. fn with_appropriate_checker(cx: ctx, id: node_id, - b: block(fn@(ctx, ty::t, sp: span))) { + b: fn(fn@(ctx, ty::t, sp: span))) { let fty = ty::node_id_to_monotype(cx.tcx, id); alt ty::ty_fn_proto(cx.tcx, fty) { proto_uniq { b(check_send); } diff --git a/src/comp/middle/last_use.rs b/src/comp/middle/last_use.rs index 60b8bfd9879..af078afe53f 100644 --- a/src/comp/middle/last_use.rs +++ b/src/comp/middle/last_use.rs @@ -203,7 +203,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, } } -fn visit_block(tp: block_type, cx: ctx, visit: block()) { +fn visit_block(tp: block_type, cx: ctx, visit: fn()) { let local = @{type: tp, mutable second: false, mutable exits: []}; cx.blocks = cons(local, @cx.blocks); visit(); diff --git a/src/comp/middle/lint.rs b/src/comp/middle/lint.rs index 7cba82e80be..838764171f0 100644 --- a/src/comp/middle/lint.rs +++ b/src/comp/middle/lint.rs @@ -26,7 +26,7 @@ impl opt_ for option { } // FIXME: Copied from driver.rs, to work around a bug(#1566) -fn time(do_it: bool, what: str, thunk: block()) { +fn time(do_it: bool, what: str, thunk: fn()) { if !do_it{ ret thunk(); } let start = std::time::precise_time_s(); thunk(); diff --git a/src/comp/middle/pat_util.rs b/src/comp/middle/pat_util.rs index b949dce004d..9e50355f43e 100644 --- a/src/comp/middle/pat_util.rs +++ b/src/comp/middle/pat_util.rs @@ -91,7 +91,7 @@ fn pat_id_map(tcx: ty::ctxt, pat: @pat) -> pat_id_map { // This does *not* normalize. The pattern should be already normalized // if you want to get a normalized pattern out of it. // Could return a constrained type in order to express that (future work) -fn pat_bindings(pat: @pat, it: block(@pat)) { +fn pat_bindings(pat: @pat, it: fn(@pat)) { alt pat.node { pat_ident(_, option::none) { it(pat); } pat_ident(_, option::some(sub)) { it(pat); pat_bindings(sub, it); } diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 3b49f8c33ad..1d54ed27997 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -632,7 +632,7 @@ fn resolve_constr(e: @env, c: @ast::constr, sc: scopes, _v: vt<scopes>) { fn resolve_import(e: env, defid: ast::def_id, name: ast::ident, ids: [ast::ident], sp: codemap::span, sc: scopes) { fn register(e: env, id: node_id, cx: ctxt, sp: codemap::span, - name: ast::ident, lookup: block(namespace) -> option::t<def>, + name: ast::ident, lookup: fn(namespace) -> option::t<def>, impls: [@_impl]) { let val = lookup(ns_val(ns_any_value)), typ = lookup(ns_type), md = lookup(ns_module); @@ -1712,7 +1712,7 @@ fn add_name(ch: checker, sp: span, name: ident) { fn ident_id(&&i: ident) -> ident { ret i; } -fn ensure_unique<T>(e: env, sp: span, elts: [T], id: block(T) -> ident, +fn ensure_unique<T>(e: env, sp: span, elts: [T], id: fn(T) -> ident, kind: str) { let ch = checker(e, kind); for elt: T in elts { add_name(ch, sp, id(elt)); } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 8919237b688..8de5d7257e2 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3233,8 +3233,8 @@ fn invoke_full(bcx: @block_ctxt, llfn: ValueRef, llargs: [ValueRef], fn invoke_(bcx: @block_ctxt, llfn: ValueRef, llargs: [ValueRef], to_zero: [{v: ValueRef, t: ty::t}], to_revoke: [{v: ValueRef, t: ty::t}], - invoker: block(@block_ctxt, ValueRef, [ValueRef], - BasicBlockRef, BasicBlockRef)) -> @block_ctxt { + invoker: fn(@block_ctxt, ValueRef, [ValueRef], + BasicBlockRef, BasicBlockRef)) -> @block_ctxt { // FIXME: May be worth turning this into a plain call when there are no // cleanups to run if bcx.unreachable { ret bcx; } @@ -4106,7 +4106,7 @@ fn trans_fn_cleanups(fcx: @fn_ctxt, cx: @block_ctxt) { } } -fn block_locals(b: ast::blk, it: block(@ast::local)) { +fn block_locals(b: ast::blk, it: fn(@ast::local)) { for s: @ast::stmt in b.node.stmts { alt s.node { ast::stmt_decl(d, _) { @@ -4423,7 +4423,7 @@ enum self_arg { impl_self(ty::t), no_self, } fn trans_closure(cx: @local_ctxt, sp: span, decl: ast::fn_decl, body: ast::blk, llfndecl: ValueRef, ty_self: self_arg, ty_params: [ast::ty_param], - id: ast::node_id, maybe_load_env: block(@fn_ctxt)) { + id: ast::node_id, maybe_load_env: fn(@fn_ctxt)) { set_uwtable(llfndecl); // Set up arguments to the function. diff --git a/src/comp/middle/trans_closure.rs b/src/comp/middle/trans_closure.rs index 7fece0cefdf..3f7c8181ab5 100644 --- a/src/comp/middle/trans_closure.rs +++ b/src/comp/middle/trans_closure.rs @@ -57,7 +57,7 @@ import shape::{size_of}; // closure is allocated in the task heap and is reference counted. // For a block, the closure is allocated on the stack. Note that in // all cases we allocate space for a ref count just to make our lives -// easier when upcasting to block(T)->U, in the shape code, and so +// easier when upcasting to fn(T)->U, in the shape code, and so // forth. // // ## Opaque Closures ## @@ -637,7 +637,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t, fn make_null_test( in_bcx: @block_ctxt, ptr: ValueRef, - blk: block(@block_ctxt) -> @block_ctxt) + blk: fn(@block_ctxt) -> @block_ctxt) -> @block_ctxt { let not_null_bcx = new_sub_block_ctxt(in_bcx, "not null"); let next_bcx = new_sub_block_ctxt(in_bcx, "next"); diff --git a/src/comp/middle/trans_impl.rs b/src/comp/middle/trans_impl.rs index 2e2e245a1c1..ff4a8db24a7 100644 --- a/src/comp/middle/trans_impl.rs +++ b/src/comp/middle/trans_impl.rs @@ -157,7 +157,7 @@ fn trans_vtable(ccx: @crate_ctxt, id: ast::node_id, name: str, } fn trans_wrapper(ccx: @crate_ctxt, pt: [ast::ident], llfty: TypeRef, - fill: block(ValueRef, @block_ctxt) -> @block_ctxt) + fill: fn(ValueRef, @block_ctxt) -> @block_ctxt) -> ValueRef { let lcx = @{path: pt, module_path: [], ccx: ccx}; let name = link::mangle_internal_name_by_path(ccx, pt); diff --git a/src/comp/middle/trans_vec.rs b/src/comp/middle/trans_vec.rs index 68207867071..c31da3cfecd 100644 --- a/src/comp/middle/trans_vec.rs +++ b/src/comp/middle/trans_vec.rs @@ -258,7 +258,7 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef, type val_and_ty_fn = fn@(@block_ctxt, ValueRef, ty::t) -> result; -type iter_vec_block = block(@block_ctxt, ValueRef, ty::t) -> @block_ctxt; +type iter_vec_block = fn(@block_ctxt, ValueRef, ty::t) -> @block_ctxt; fn iter_vec_raw(bcx: @block_ctxt, vptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> @block_ctxt { diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index c6af04460ff..b367b5b6cb3 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -968,7 +968,7 @@ fn non_init_constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id) } fn args_mention<T>(args: [@constr_arg_use], - q: block([T], node_id) -> bool, + q: fn([T], node_id) -> bool, s: [T]) -> bool { /* FIXME diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index b7751fc235e..2af258d120a 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1083,7 +1083,7 @@ fn type_is_native(cx: ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_native(_) { ret true; } _ { ret false; } } } -fn type_structurally_contains(cx: ctxt, ty: t, test: block(sty) -> bool) -> +fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> bool { let sty = struct(cx, ty); if test(sty) { ret true; } @@ -1420,7 +1420,7 @@ fn hash_type_structure(st: sty) -> uint { fn hash_raw_ty(&&rt: @raw_t) -> uint { ret rt.hash; } -fn arg_eq<T>(eq: block(T, T) -> bool, +fn arg_eq<T>(eq: fn(T, T) -> bool, a: @sp_constr_arg<T>, b: @sp_constr_arg<T>) -> bool { @@ -1439,7 +1439,7 @@ fn arg_eq<T>(eq: block(T, T) -> bool, } } -fn args_eq<T>(eq: block(T, T) -> bool, +fn args_eq<T>(eq: fn(T, T) -> bool, a: [@sp_constr_arg<T>], b: [@sp_constr_arg<T>]) -> bool { let i: uint = 0u; @@ -1930,7 +1930,6 @@ mod unify { fn sub_proto(p_sub: ast::proto, p_sup: ast::proto) -> bool { ret alt (p_sub, p_sup) { (_, ast::proto_any) { true } - (_, ast::proto_block) { true } /* NDM temporary */ (ast::proto_bare, _) { true } // Equal prototypes are always subprotos: @@ -2083,7 +2082,7 @@ mod unify { } fn unify_tps(cx: @ctxt, expected_tps: [t], actual_tps: [t], - variance: variance, finish: block([t]) -> result) -> result { + variance: variance, finish: fn([t]) -> result) -> result { let result_tps = [], i = 0u; for exp in expected_tps { let act = actual_tps[i]; diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index dcaf16c973e..5477c495883 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -241,7 +241,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>, } /* helper for transcribe_exprs: what vars from `b` occur in `e`? */ -fn free_vars(b: bindings, e: @expr, it: block(ident)) { +fn free_vars(b: bindings, e: @expr, it: fn(ident)) { let idents: hashmap<ident, ()> = new_str_hash::<()>(); fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings, idents: hashmap<ident, ()>) -> ident { @@ -536,7 +536,7 @@ fn block_to_ident(blk: blk_) -> option::t<ident> { fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { fn select_pt_1(cx: ext_ctxt, m: matchable, - fn_m: block(ast::mac) -> match_result) -> match_result { + fn_m: fn(ast::mac) -> match_result) -> match_result { ret alt m { match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index cb7e1144334..5a4925486d9 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -149,7 +149,7 @@ fn bad_expr_word_table() -> hashmap<str, ()> { for word in ["mod", "if", "else", "while", "do", "alt", "for", "break", "cont", "ret", "be", "fail", "type", "resource", "check", "assert", "claim", "native", "fn", "pure", - "unsafe", "block", "import", "export", "let", "const", + "unsafe", "import", "export", "let", "const", "log", "copy", "sendfn", "impl", "iface", "enum"] { words.insert(word, ()); } @@ -366,7 +366,7 @@ fn parse_constr_in_type(p: parser) -> @ast::ty_constr { } -fn parse_constrs<T: copy>(pser: block(parser) -> @ast::constr_general<T>, +fn parse_constrs<T: copy>(pser: fn(parser) -> @ast::constr_general<T>, p: parser) -> [@ast::constr_general<T>] { let constrs: [@ast::constr_general<T>] = []; @@ -504,9 +504,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { _ { /* fallthrough */ } } t = parse_ty_fn(proto, p); - } else if eat_word(p, "block") { - //p.warn("block is deprecated, use fn& or fn"); - t = parse_ty_fn(ast::proto_block, p); } else if eat_word(p, "native") { expect_word(p, "fn"); t = parse_ty_fn(ast::proto_bare, p); @@ -545,7 +542,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg { } fn parse_seq_to_before_gt<T: copy>(sep: option::t<token::token>, - f: block(parser) -> T, + f: fn(parser) -> T, p: parser) -> [T] { let first = true; let v = []; @@ -562,7 +559,7 @@ fn parse_seq_to_before_gt<T: copy>(sep: option::t<token::token>, } fn parse_seq_to_gt<T: copy>(sep: option::t<token::token>, - f: block(parser) -> T, p: parser) -> [T] { + f: fn(parser) -> T, p: parser) -> [T] { let v = parse_seq_to_before_gt(sep, f, p); expect_gt(p); @@ -570,7 +567,7 @@ fn parse_seq_to_gt<T: copy>(sep: option::t<token::token>, } fn parse_seq_lt_gt<T: copy>(sep: option::t<token::token>, - f: block(parser) -> T, + f: fn(parser) -> T, p: parser) -> spanned<[T]> { let lo = p.span.lo; expect(p, token::LT); @@ -581,7 +578,7 @@ fn parse_seq_lt_gt<T: copy>(sep: option::t<token::token>, } fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep, - f: block(parser) -> T, p: parser) -> [T] { + f: fn(parser) -> T, p: parser) -> [T] { let val = parse_seq_to_before_end(ket, sep, f, p); p.bump(); ret val; @@ -604,7 +601,7 @@ fn seq_sep_none() -> seq_sep { fn parse_seq_to_before_end<T: copy>(ket: token::token, sep: seq_sep, - f: block(parser) -> T, p: parser) -> [T] { + f: fn(parser) -> T, p: parser) -> [T] { let first: bool = true; let v: [T] = []; while p.token != ket { @@ -620,7 +617,7 @@ fn parse_seq_to_before_end<T: copy>(ket: token::token, fn parse_seq<T: copy>(bra: token::token, ket: token::token, - sep: seq_sep, f: block(parser) -> T, + sep: seq_sep, f: fn(parser) -> T, p: parser) -> spanned<[T]> { let lo = p.span.lo; expect(p, bra); @@ -813,9 +810,6 @@ fn parse_bottom_expr(p: parser) -> pexpr { _ { /* fallthrough */ } } ret pexpr(parse_fn_expr(p, proto)); - } else if eat_word(p, "block") { - p.warn("block is deprecated, use fn& or fn"); - ret pexpr(parse_fn_expr(p, ast::proto_block)); } else if eat_word(p, "unchecked") { ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk)); } else if eat_word(p, "unsafe") { diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 2ebcaa055a7..4327ccf9ac0 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -210,7 +210,7 @@ fn synth_comment(s: ps, text: str) { word(s.s, "*/"); } -fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN)) { +fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) { box(s, 0u, b); let first = true; for elt: IN in elts { @@ -221,8 +221,8 @@ fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN)) { } -fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN), - get_span: block(IN) -> codemap::span) { +fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN), + get_span: fn(IN) -> codemap::span) { box(s, 0u, b); let len = vec::len::<IN>(elts); let i = 0u; diff --git a/src/comp/util/filesearch.rs b/src/comp/util/filesearch.rs index ece3f17e747..60df64a2a35 100644 --- a/src/comp/util/filesearch.rs +++ b/src/comp/util/filesearch.rs @@ -18,7 +18,7 @@ export relative_target_lib_path; export get_cargo_root; export libdir; -type pick<T> = block(path: fs::path) -> option::t<T>; +type pick<T> = fn(path: fs::path) -> option::t<T>; fn pick_file(file: fs::path, path: fs::path) -> option::t<fs::path> { if fs::basename(path) == file { option::some(path) } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index cccce3e5f1b..71968abdd6d 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -63,7 +63,7 @@ fn is_test_ignored(config: config, testfile: str) -> bool { } } -fn iter_header(testfile: str, it: block(str)) { +fn iter_header(testfile: str, it: fn(str)) { let rdr = result::get(io::file_reader(testfile)); while !rdr.eof() { let ln = rdr.read_line(); diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index b905bfdddde..c1b3ad5f341 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -215,7 +215,7 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::ty, tm: test_mode *crate2 } -fn under(n: uint, it: block(uint)) { +fn under(n: uint, it: fn(uint)) { let i: uint = 0u; while i < n { it(i); i += 1u; } } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 3b358011422..d027e3825e1 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -75,7 +75,7 @@ pure fn to_str(v: t) -> str { if v { "true" } else { "false" } } brief = "Iterates over all truth values by passing them to `blk` \ in an unspecified order" )] -fn all_values(blk: block(v: t)) { +fn all_values(blk: fn(v: t)) { blk(true); blk(false); } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d605b575901..e3dadaa7e38 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -29,7 +29,7 @@ If `value` is left(T) then `f_left` is applied to its contents, if the result is returned. */ fn either<T, U, - V>(f_left: block(T) -> V, f_right: block(U) -> V, value: t<T, U>) -> + V>(f_left: fn(T) -> V, f_right: fn(U) -> V, value: t<T, U>) -> V { alt value { left(l) { f_left(l) } right(r) { f_right(r) } } } diff --git a/src/libcore/int.rs b/src/libcore/int.rs index ca48e83011c..47a699b834e 100644 --- a/src/libcore/int.rs +++ b/src/libcore/int.rs @@ -84,7 +84,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: int, hi: int, it: block(int)) { +fn range(lo: int, hi: int, it: fn(int)) { let i = lo; while i < hi { it(i); i += 1; } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 8cba1c84dc0..c86127b4664 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -36,7 +36,7 @@ pure fn get<T: copy>(opt: t<T>) -> T { /* */ -fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> { +fn map<T, U: copy>(opt: t<T>, f: fn(T) -> U) -> t<U> { alt opt { some(x) { some(f(x)) } none { none } } } @@ -70,7 +70,7 @@ Function: maybe Applies a function to the contained value or returns a default */ -fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U { +fn maybe<T, U: copy>(def: U, opt: t<T>, f: fn(T) -> U) -> U { alt opt { none { def } some(t) { f(t) } } } @@ -80,7 +80,7 @@ Function: may Performs an operation on the contained value or does nothing */ -fn may<T>(opt: t<T>, f: block(T)) { +fn may<T>(opt: t<T>, f: fn(T)) { alt opt { none {/* nothing */ } some(t) { f(t); } } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 0b229110ec3..52c3ff95d23 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -110,7 +110,7 @@ Example: > }) */ -fn chain<T, U: copy, V: copy>(res: t<T, V>, op: block(T) -> t<U, V>) +fn chain<T, U: copy, V: copy>(res: t<T, V>, op: fn(T) -> t<U, V>) -> t<U, V> { alt res { ok(t) { op(t) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b24c2158d41..1cccaf0f641 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -347,7 +347,7 @@ Function: iter_chars Iterate over the characters in a string */ -fn iter_chars(s: str, it: block(char)) { +fn iter_chars(s: str, it: fn(char)) { let pos = 0u, len = byte_len(s); while (pos < len) { let {ch, next} = char_range_at(s, pos); @@ -371,7 +371,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop_chars(s: str, it: block(char) -> bool) -> bool{ +fn loop_chars(s: str, it: fn(char) -> bool) -> bool{ ret loop_chars_sub(s, 0u, byte_len(s), it); } @@ -398,7 +398,7 @@ Safety note: represent valid positions inside `s` */ fn loop_chars_sub(s: str, byte_offset: uint, byte_len: uint, - it: block(char) -> bool) -> bool { + it: fn(char) -> bool) -> bool { let i = byte_offset; let result = true; while i < byte_len { @@ -1061,7 +1061,7 @@ Example: > let s = str::as_buf("PATH", { |path_buf| libc::getenv(path_buf) }); */ -fn as_buf<T>(s: str, f: block(sbuf) -> T) -> T unsafe { +fn as_buf<T>(s: str, f: fn(sbuf) -> T) -> T unsafe { let buf = buf(s); f(buf) } diff --git a/src/libcore/u32.rs b/src/libcore/u32.rs index 569d59b981a..45e54bb5069 100644 --- a/src/libcore/u32.rs +++ b/src/libcore/u32.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u32, hi: u32, it: block(u32)) { +fn range(lo: u32, hi: u32, it: fn(u32)) { let i = lo; while i < hi { it(i); i += 1u32; } } diff --git a/src/libcore/u64.rs b/src/libcore/u64.rs index bce99f02b87..472702c8eac 100644 --- a/src/libcore/u64.rs +++ b/src/libcore/u64.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u64, hi: u64, it: block(u64)) { +fn range(lo: u64, hi: u64, it: fn(u64)) { let i = lo; while i < hi { it(i); i += 1u64; } } diff --git a/src/libcore/u8.rs b/src/libcore/u8.rs index eadfcadda4a..b025751020b 100644 --- a/src/libcore/u8.rs +++ b/src/libcore/u8.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u8, hi: u8, it: block(u8)) { +fn range(lo: u8, hi: u8, it: fn(u8)) { let i = lo; while i < hi { it(i); i += 1u8; } } diff --git a/src/libcore/uint.rs b/src/libcore/uint.rs index 598c6baffe4..8d032610e17 100644 --- a/src/libcore/uint.rs +++ b/src/libcore/uint.rs @@ -115,7 +115,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: uint, hi: uint, it: block(uint)) { +fn range(lo: uint, hi: uint, it: fn(uint)) { let i = lo; while i < hi { it(i); i += 1u; } } @@ -136,7 +136,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop(lo: uint, hi: uint, it: block(uint) -> bool) -> bool { +fn loop(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { let i = lo; while i < hi { if (!it(i)) { ret false; } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index f677af1efc7..0a1a4012422 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -26,7 +26,7 @@ Type: init_op A function used to initialize the elements of a vector. */ -type init_op<T> = block(uint) -> T; +type init_op<T> = fn(uint) -> T; /* @@ -402,7 +402,7 @@ Function: map Apply a function to each element of a vector and return the results */ -fn map<T, U>(v: [T], f: block(T) -> U) -> [U] { +fn map<T, U>(v: [T], f: fn(T) -> U) -> [U] { let result = []; reserve(result, len(v)); for elem: T in v { result += [f(elem)]; } @@ -414,7 +414,7 @@ Function: map_mut Apply a function to each element of a mutable vector and return the results */ -fn map_mut<T: copy, U>(v: [const T], f: block(T) -> U) -> [U] { +fn map_mut<T: copy, U>(v: [const T], f: fn(T) -> U) -> [U] { let result = []; reserve(result, len(v)); for elem: T in v { @@ -429,7 +429,7 @@ Function: map2 Apply a function to each pair of elements and return the results */ -fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] { +fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: fn(T, U) -> V) -> [V] { let v0_len = len(v0); if v0_len != len(v1) { fail; } let u: [V] = []; @@ -446,7 +446,7 @@ Apply a function to each element of a vector and return the results If function `f` returns `none` then that element is excluded from the resulting vector. */ -fn filter_map<T: copy, U: copy>(v: [const T], f: block(T) -> option::t<U>) +fn filter_map<T: copy, U: copy>(v: [const T], f: fn(T) -> option::t<U>) -> [U] { let result = []; for elem: T in v { @@ -467,7 +467,7 @@ holds. Apply function `f` to each element of `v` and return a vector containing only those elements for which `f` returned true. */ -fn filter<T: copy>(v: [T], f: block(T) -> bool) -> [T] { +fn filter<T: copy>(v: [T], f: fn(T) -> bool) -> [T] { let result = []; for elem: T in v { if f(elem) { result += [elem]; } @@ -492,7 +492,7 @@ Function: foldl Reduce a vector from left to right */ -fn foldl<T: copy, U>(z: T, v: [const U], p: block(T, U) -> T) -> T { +fn foldl<T: copy, U>(z: T, v: [const U], p: fn(T, U) -> T) -> T { let accum = z; iter(v) { |elt| accum = p(accum, elt); @@ -505,7 +505,7 @@ Function: foldr Reduce a vector from right to left */ -fn foldr<T, U: copy>(v: [const T], z: U, p: block(T, U) -> U) -> U { +fn foldr<T, U: copy>(v: [const T], z: U, p: fn(T, U) -> U) -> U { let accum = z; riter(v) { |elt| accum = p(elt, accum); @@ -520,7 +520,7 @@ Return true if a predicate matches any elements If the vector contains no elements then false is returned. */ -fn any<T>(v: [T], f: block(T) -> bool) -> bool { +fn any<T>(v: [T], f: fn(T) -> bool) -> bool { for elem: T in v { if f(elem) { ret true; } } ret false; } @@ -532,7 +532,7 @@ Return true if a predicate matches any elements in both vectors. If the vectors contains no elements then false is returned. */ -fn any2<T, U>(v0: [T], v1: [U], f: block(T, U) -> bool) -> bool { +fn any2<T, U>(v0: [T], v1: [U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); let v1_len = len(v1); let i = 0u; @@ -550,7 +550,7 @@ Return true if a predicate matches all elements If the vector contains no elements then true is returned. */ -fn all<T>(v: [T], f: block(T) -> bool) -> bool { +fn all<T>(v: [T], f: fn(T) -> bool) -> bool { for elem: T in v { if !f(elem) { ret false; } } ret true; } @@ -562,7 +562,7 @@ Return true if a predicate matches all elements in both vectors. If the vectors are not the same size then false is returned. */ -fn all2<T, U>(v0: [T], v1: [U], f: block(T, U) -> bool) -> bool { +fn all2<T, U>(v0: [T], v1: [U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); if v0_len != len(v1) { ret false; } let i = 0u; @@ -600,7 +600,7 @@ Apply function `f` to each element of `v`, starting from the first. When function `f` returns true then an option containing the element is returned. If `f` matches no elements then none is returned. */ -fn find<T: copy>(v: [T], f: block(T) -> bool) -> option::t<T> { +fn find<T: copy>(v: [T], f: fn(T) -> bool) -> option::t<T> { for elt: T in v { if f(elt) { ret some(elt); } } ret none; } @@ -626,7 +626,7 @@ Function: position_pred Find the first index for which the value matches some predicate */ -fn position_pred<T>(v: [T], f: block(T) -> bool) -> option::t<uint> { +fn position_pred<T>(v: [T], f: fn(T) -> bool) -> option::t<uint> { let i: uint = 0u; while i < len(v) { if f(v[i]) { ret some::<uint>(i); } i += 1u; } ret none; @@ -747,7 +747,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the element's value. */ -fn iter<T>(v: [const T], f: block(T)) { +fn iter<T>(v: [const T], f: fn(T)) { iteri(v) { |_i, v| f(v) } } @@ -757,7 +757,7 @@ Function: iter2 Iterates over two vectors in parallel */ -fn iter2<U, T>(v: [U], v2: [T], f: block(U, T)) { +fn iter2<U, T>(v: [U], v2: [T], f: fn(U, T)) { let i = 0; for elt in v { f(elt, v2[i]); i += 1; } } @@ -770,7 +770,7 @@ Iterates over a vector's elements and indexes Iterates over vector `v` and, for each element, calls function `f` with the element's value and index. */ -fn iteri<T>(v: [const T], f: block(uint, T)) { +fn iteri<T>(v: [const T], f: fn(uint, T)) { let i = 0u, l = len(v); while i < l { f(i, v[i]); i += 1u; } } @@ -784,7 +784,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the element's value. */ -fn riter<T>(v: [const T], f: block(T)) { +fn riter<T>(v: [const T], f: fn(T)) { riteri(v) { |_i, v| f(v) } } @@ -796,7 +796,7 @@ Iterates over a vector's elements and indexes in reverse Iterates over vector `v` and, for each element, calls function `f` with the element's value and index. */ -fn riteri<T>(v: [const T], f: block(uint, T)) { +fn riteri<T>(v: [const T], f: fn(uint, T)) { let i = len(v); while 0u < i { i -= 1u; @@ -814,7 +814,7 @@ is sorted then the permutations are lexicographically sorted). The total number of permutations produced is `len(v)!`. If `v` contains repeated elements, then some permutations are repeated. */ -fn permute<T: copy>(v: [const T], put: block([T])) { +fn permute<T: copy>(v: [const T], put: fn([T])) { let ln = len(v); if ln == 0u { put([]); diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 59e6263f82f..d02d78eaab8 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -53,7 +53,7 @@ fn create(nbits: uint, init: bool) -> t { ret @{storage: storage, nbits: nbits}; } -fn process(v0: t, v1: t, op: block(uint, uint) -> uint) -> bool { +fn process(v0: t, v1: t, op: fn(uint, uint) -> uint) -> bool { let len = vec::len(v1.storage); assert (vec::len(v0.storage) == len); assert (v0.nbits == v1.nbits); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 24e072692a9..b76ba4ad9b8 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -73,7 +73,7 @@ fn get_doc(d: doc, tg: uint) -> doc { } } -fn docs(d: doc, it: block(uint, doc)) { +fn docs(d: doc, it: fn(uint, doc)) { let pos = d.start; while pos < d.end { let elt_tag = vint_at(*d.data, pos); @@ -83,7 +83,7 @@ fn docs(d: doc, it: block(uint, doc)) { } } -fn tagged_docs(d: doc, tg: uint, it: block(doc)) { +fn tagged_docs(d: doc, tg: uint, it: fn(doc)) { let pos = d.start; while pos < d.end { let elt_tag = vint_at(*d.data, pos); diff --git a/src/libstd/four.rs b/src/libstd/four.rs index 48b3d919afb..ad44f225f25 100644 --- a/src/libstd/four.rs +++ b/src/libstd/four.rs @@ -195,7 +195,7 @@ Function: all_values Iterates over all truth values by passing them to `blk` in an unspecified order */ -fn all_values(blk: block(v: t)) { +fn all_values(blk: fn(v: t)) { blk(both); blk(four::true); blk(four::false); diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 8e9839a8901..a2f6b8c225f 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -84,7 +84,7 @@ Function: traverse Visit all pairs in the map in order. */ -fn traverse<K, V: copy>(m: treemap<K, V>, f: block(K, V)) { +fn traverse<K, V: copy>(m: treemap<K, V>, f: fn(K, V)) { alt *m { empty { } node(@k, @v, _, _) { diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 6331e57ea7d..1db355dd385 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -529,7 +529,7 @@ mod fsync { // fsync file after executing blk // FIXME find better way to create resources within lifetime of outer res fn FILE_res_sync(&&file: FILE_res, opt_level: option::t<level>, - blk: block(&&res<os::libc::FILE>)) { + blk: fn(&&res<os::libc::FILE>)) { blk(res({ val: *file, opt_level: opt_level, fsync_fn: fn@(&&file: os::libc::FILE, l: level) -> int { @@ -540,7 +540,7 @@ mod fsync { // fsync fd after executing blk fn fd_res_sync(&&fd: fd_res, opt_level: option::t<level>, - blk: block(&&res<fd_t>)) { + blk: fn(&&res<fd_t>)) { blk(res({ val: *fd, opt_level: opt_level, fsync_fn: fn@(&&fd: fd_t, l: level) -> int { @@ -553,7 +553,7 @@ mod fsync { iface t { fn fsync(l: level) -> int; } // Call o.fsync after executing blk - fn obj_sync(&&o: t, opt_level: option::t<level>, blk: block(&&res<t>)) { + fn obj_sync(&&o: t, opt_level: option::t<level>, blk: fn(&&res<t>)) { blk(res({ val: o, opt_level: opt_level, fsync_fn: fn@(&&o: t, l: level) -> int { ret o.fsync(l); } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index b05f895c327..2081a21de23 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -46,7 +46,7 @@ ls - The list to fold z - The initial value f - The function to apply */ -fn foldl<T: copy, U>(ls: list<U>, z: T, f: block(T, U) -> T) -> T { +fn foldl<T: copy, U>(ls: list<U>, z: T, f: fn(T, U) -> T) -> T { let accum: T = z; iter(ls) {|elt| accum = f(accum, elt);} accum @@ -61,7 +61,7 @@ Apply function `f` to each element of `v`, starting from the first. When function `f` returns true then an option containing the element is returned. If `f` matches no elements then none is returned. */ -fn find<T: copy, U: copy>(ls: list<T>, f: block(T) -> option::t<U>) +fn find<T: copy, U: copy>(ls: list<T>, f: fn(T) -> option::t<U>) -> option::t<U> { let ls = ls; while true { @@ -164,7 +164,7 @@ Function: iter Iterate over a list */ -fn iter<T>(l: list<T>, f: block(T)) { +fn iter<T>(l: list<T>, f: fn(T)) { alt l { cons(hd, tl) { f(hd); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index c3517d4d3f6..ed37318246b 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -88,17 +88,17 @@ iface map<K: copy, V: copy> { Iterate over all the key/value pairs in the map */ - fn items(block(K, V)); + fn items(fn(K, V)); /* Method: keys Iterate over all the keys in the map */ - fn keys(block(K)); + fn keys(fn(K)); /* Iterate over all the values in the map */ - fn values(block(V)); + fn values(fn(V)); } // FIXME: package this up and export it as a datatype usable for @@ -246,7 +246,7 @@ mod chained { } fn foreach_entry<K: copy, V: copy>(chain0: chain<K,V>, - blk: block(@entry<K,V>)) { + blk: fn(@entry<K,V>)) { let chain = chain0; while true { alt chain { @@ -261,7 +261,7 @@ mod chained { } fn foreach_chain<K: copy, V: copy>(chains: [const chain<K,V>], - blk: block(@entry<K,V>)) { + blk: fn(@entry<K,V>)) { let i = 0u, n = vec::len(chains); while i < n { foreach_entry(chains[i], blk); @@ -281,7 +281,7 @@ mod chained { } } - fn items<K: copy, V: copy>(tbl: t<K,V>, blk: block(K,V)) { + fn items<K: copy, V: copy>(tbl: t<K,V>, blk: fn(K,V)) { let tbl_chains = tbl.chains; // Satisfy alias checker. foreach_chain(tbl_chains) { |entry| let key = entry.key; @@ -310,11 +310,11 @@ mod chained { fn remove(k: K) -> option::t<V> { remove(self, k) } - fn items(blk: block(K, V)) { items(self, blk); } + fn items(blk: fn(K, V)) { items(self, blk); } - fn keys(blk: block(K)) { items(self) { |k, _v| blk(k) } } + fn keys(blk: fn(K)) { items(self) { |k, _v| blk(k) } } - fn values(blk: block(V)) { items(self) { |_k, v| blk(v) } } + fn values(blk: fn(V)) { items(self) { |_k, v| blk(v) } } } fn mk<K: copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> map<K,V> { diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 2d06c74f336..7b5320a5dfc 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -81,7 +81,7 @@ fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} { fn md4_str(msg: [u8]) -> str { let {a, b, c, d} = md4(msg); - fn app(a: u32, b: u32, c: u32, d: u32, f: block(u32)) { + fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); } let result = ""; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 9290bf8992e..5e856ff5e0e 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -419,7 +419,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop_chars(rope: rope, it: block(char) -> bool) -> bool { +fn loop_chars(rope: rope, it: fn(char) -> bool) -> bool { alt(rope) { node::empty { ret true } node::content(x) { ret node::loop_chars(x, it) } @@ -435,7 +435,7 @@ Parameters: rope - A rope to traverse. It may be empty it - A block to execute with each consecutive character of the rope. */ -fn iter_chars(rope: rope, it: block(char)) { +fn iter_chars(rope: rope, it: fn(char)) { loop_chars(rope) {|x| it(x); ret true @@ -466,7 +466,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop_leaves(rope: rope, it: block(node::leaf) -> bool) -> bool{ +fn loop_leaves(rope: rope, it: fn(node::leaf) -> bool) -> bool{ alt(rope) { node::empty { ret true } node::content(x) {ret node::loop_leaves(x, it)} @@ -1135,7 +1135,7 @@ mod node { ret result; } - fn loop_chars(node: @node, it: block(char) -> bool) -> bool { + fn loop_chars(node: @node, it: fn(char) -> bool) -> bool { ret loop_leaves(node, {|leaf| ret str::loop_chars_sub(*leaf.content, leaf.byte_offset, @@ -1159,7 +1159,7 @@ mod node { `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ - fn loop_leaves(node: @node, it: block(leaf) -> bool) -> bool{ + fn loop_leaves(node: @node, it: fn(leaf) -> bool) -> bool{ let current = node; while true { alt(*current) { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 36c9e1281c2..dada53f355b 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -110,7 +110,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn get(&&key: uint) -> V { get(self, key) } fn find(&&key: uint) -> option::t<V> { find(self, key) } fn rehash() { fail } - fn items(it: block(&&uint, V)) { + fn items(it: fn(&&uint, V)) { let idx = 0u; for item in self.v { alt item { @@ -122,14 +122,14 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { idx += 1u; } } - fn keys(it: block(&&uint)) { + fn keys(it: fn(&&uint)) { let idx = 0u; for item in self.v { if item != none { it(idx); } idx += 1u; } } - fn values(it: block(V)) { + fn values(it: fn(V)) { for item in self.v { alt item { some(elt) { it(elt); } _ {} } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 8739e8d81c5..f7f6812d7de 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -10,7 +10,7 @@ export quick_sort; export quick_sort3; /* Type: lteq */ -type lteq<T> = block(T, T) -> bool; +type lteq<T> = fn(T, T) -> bool; /* Function: merge_sort diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 7e181a80457..4771bc3196b 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -83,7 +83,7 @@ Function: traverse Visit all pairs in the map in order. */ -fn traverse<K, V>(m: treemap<K, V>, f: block(K, V)) { +fn traverse<K, V>(m: treemap<K, V>, f: fn(K, V)) { alt *m { empty { } node(k, v, _, _) { diff --git a/src/libstd/tri.rs b/src/libstd/tri.rs index 558a45f475a..7cc749429ce 100644 --- a/src/libstd/tri.rs +++ b/src/libstd/tri.rs @@ -164,7 +164,7 @@ Function: all_values Iterates over all truth values by passing them to `blk` in an unspecified order */ -fn all_values(blk: block(v: t)) { +fn all_values(blk: fn(v: t)) { blk(tri::false); blk(unknown); blk(tri::true); diff --git a/src/test/bench/99bob-iter.rs b/src/test/bench/99bob-iter.rs index eaab9d6b731..02d55cf64d3 100644 --- a/src/test/bench/99bob-iter.rs +++ b/src/test/bench/99bob-iter.rs @@ -40,7 +40,7 @@ fn sub(t: str, n: int) -> str { /* Using an interator */ -fn ninetynine(it: block(int)) { +fn ninetynine(it: fn(int)) { let n: int = 100; while n > 1 { n -= 1; it(n); } } diff --git a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs index a7348b26fa2..2abaabc3ef8 100644 --- a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs +++ b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs @@ -4,7 +4,7 @@ fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint { ret f; } -fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { +fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint { ret to_lambda1({|x| b(x)}); } diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 42c893a2064..95d1bdf0787 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -2,11 +2,11 @@ // other tycons. fn coerce(b: fn()) -> native fn() { - fn lol(f: native fn(block()) -> native fn(), + fn lol(f: native fn(fn()) -> native fn(), g: fn()) -> native fn() { ret f(g); } fn fn_id(f: native fn()) -> native fn() { ret f } ret lol(fn_id, b); - //!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()` + //!^ ERROR mismatched types: expected `native fn(fn()) -> native fn()` } fn main() { diff --git a/src/test/compile-fail/block-copy.rs b/src/test/compile-fail/block-copy.rs index 63a2e9bcb39..e986330ee0e 100644 --- a/src/test/compile-fail/block-copy.rs +++ b/src/test/compile-fail/block-copy.rs @@ -1,8 +1,8 @@ // error-pattern: block type can only appear -fn lol(f: block()) -> block() { ret f; } +fn lol(f: fn()) -> fn() { ret f; } fn main() { let i = 8; - let f = lol(block () { log(error, i); }); + let f = lol(fn&() { log(error, i); }); f(); } diff --git a/src/test/compile-fail/block-deinitializes-upvar.rs b/src/test/compile-fail/block-deinitializes-upvar.rs index 65367a01a7b..6de84a2a163 100644 --- a/src/test/compile-fail/block-deinitializes-upvar.rs +++ b/src/test/compile-fail/block-deinitializes-upvar.rs @@ -1,5 +1,5 @@ // error-pattern:Tried to deinitialize a variable declared in a different -fn force(f: block()) { f(); } +fn force(f: fn()) { f(); } fn main() { let x = @{x: 17, y: 2}; let y = @{x: 5, y: 5}; diff --git a/src/test/compile-fail/block-require-return.rs b/src/test/compile-fail/block-require-return.rs index dc14053084d..6a05ccf0605 100644 --- a/src/test/compile-fail/block-require-return.rs +++ b/src/test/compile-fail/block-require-return.rs @@ -1,3 +1,3 @@ // error-pattern: not all control paths return -fn force(f: block() -> int) -> int { f() } +fn force(f: fn() -> int) -> int { f() } fn main() { log(error, force({|| })); } diff --git a/src/test/compile-fail/block-uninit.rs b/src/test/compile-fail/block-uninit.rs index 4d7f73b341c..94df3392bbb 100644 --- a/src/test/compile-fail/block-uninit.rs +++ b/src/test/compile-fail/block-uninit.rs @@ -1,4 +1,4 @@ // error-pattern: Unsatisfied precondition constraint -fn force(f: block()) { f(); } -fn main() { let x: int; force(block () { log(error, x); }); } +fn force(f: fn()) { f(); } +fn main() { let x: int; force(fn&() { log(error, x); }); } diff --git a/src/test/compile-fail/cap-clause-illegal-cap.rs b/src/test/compile-fail/cap-clause-illegal-cap.rs index 6f4972fdf66..32b21797976 100644 --- a/src/test/compile-fail/cap-clause-illegal-cap.rs +++ b/src/test/compile-fail/cap-clause-illegal-cap.rs @@ -1,6 +1,6 @@ // error-pattern: copying a noncopyable value -fn to_lambda2(b: block(uint) -> uint) -> fn@(uint) -> uint { +fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint { // test case where copy clause specifies a value that is not used // in fn@ body, but value is illegal to copy: ret fn@[copy b](u: uint) -> uint { 22u }; diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs index 2117eeefe8b..1f052679065 100644 --- a/src/test/compile-fail/lambda-mutate-nested.rs +++ b/src/test/compile-fail/lambda-mutate-nested.rs @@ -1,7 +1,7 @@ // error-pattern:assigning to upvar // Make sure that nesting a block within a fn@ doesn't let us // mutate upvars from a fn@. -fn f2(x: block()) { x(); } +fn f2(x: fn()) { x(); } fn main() { let i = 0; diff --git a/src/test/pretty/block-arg-disambig.rs b/src/test/pretty/block-arg-disambig.rs index 0f249b99d19..e57c7be48a9 100644 --- a/src/test/pretty/block-arg-disambig.rs +++ b/src/test/pretty/block-arg-disambig.rs @@ -1,2 +1,2 @@ -fn blk1(b: block()) -> fn@() { ret fn@() { }; } +fn blk1(b: fn()) -> fn@() { ret fn@() { }; } fn test1() { (blk1 {|| #debug["hi"]; })(); } diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 5c346f672ec..bc272ab3b97 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -1,6 +1,6 @@ // error-pattern:fail -fn x(it: block(int)) { +fn x(it: fn(int)) { fail; it(0); } diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index 7b7cba966e9..e1e93ac94cd 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -1,6 +1,6 @@ // error-pattern:fail -fn x(it: block(int)) { +fn x(it: fn(int)) { let a = @0; it(1); } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index b2b1d4ed85d..72fd69ec675 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -4,7 +4,7 @@ fn main() { let cheese = "roquefort"; let carrots = @"crunchy"; - fn@(tasties: @str, macerate: block(str)) { + fn@(tasties: @str, macerate: fn(str)) { macerate(*tasties); } (carrots, { |food| let mush = food + cheese; diff --git a/src/test/run-pass/alt-phi.rs b/src/test/run-pass/alt-phi.rs index 11f0ff87a68..c63c622e2ef 100644 --- a/src/test/run-pass/alt-phi.rs +++ b/src/test/run-pass/alt-phi.rs @@ -2,7 +2,7 @@ enum thing { a, b, c, } -fn foo(it: block(int)) { it(10); } +fn foo(it: fn(int)) { it(10); } fn main() { let x = true; diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 9c301ae2ac2..24184cdc2d9 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -6,7 +6,7 @@ fn f1(a: {mutable x: int}, &b: int, -c: int) -> int { ret r; } -fn f2(a: int, f: block(int)) -> int { f(1); ret a; } +fn f2(a: int, f: fn(int)) -> int { f(1); ret a; } fn main() { let a = {mutable x: 1}, b = 2, c = 3; diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index 1e3c0a7e2af..bf65441e7fa 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -8,7 +8,11 @@ fn asLambda( f : fn@()->uint ) -> uint { ret f(); } -fn asBlock( f : block()->uint ) -> uint { +fn asBlock( f : fn&()->uint ) -> uint { + ret f(); +} + +fn asAny( f : fn()->uint ) -> uint { ret f(); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index 8fd79740512..71342eee6e8 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -1,5 +1,5 @@ fn main() { - fn f(i: block() -> uint) -> uint { i() } + fn f(i: fn() -> uint) -> uint { i() } let v = [-1f, 0f, 1f, 2f, 3f]; let z = vec::foldl(f, v) { |x, _y| x } { || 22u }; assert z == 22u; diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index 85bb68e7387..230df12e621 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -1,4 +1,4 @@ fn main() { - fn as_buf<T>(s: str, f: block(str) -> T) -> T { f(s) } + fn as_buf<T>(s: str, f: fn(str) -> T) -> T { f(s) } as_buf("foo", {|foo: str| -> () log(error, foo);}); } diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index a9a4ba557ed..0b6413fc3ec 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -1,4 +1,4 @@ -fn force(f: block() -> int) -> int { ret f(); } +fn force(f: fn() -> int) -> int { ret f(); } fn main() { fn f() -> int { ret 7; } assert (force(f) == 7); diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 0f09aae2409..8a01150e313 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -1,4 +1,4 @@ -fn iter_vec<T>(v: [T], f: block(T)) { for x: T in v { f(x); } } +fn iter_vec<T>(v: [T], f: fn(T)) { for x: T in v { f(x); } } fn main() { let v = [1, 2, 3, 4, 5, 6, 7]; diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index bec21791c90..085f468c60a 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -1,4 +1,4 @@ -fn iter_vec<T>(v: [T], f: block(T)) { for x: T in v { f(x); } } +fn iter_vec<T>(v: [T], f: fn(T)) { for x: T in v { f(x); } } fn main() { let v = [1, 2, 3, 4, 5]; diff --git a/src/test/run-pass/fn-bare-coerce-to-block.rs b/src/test/run-pass/fn-bare-coerce-to-block.rs index 9da242f572f..67662525a1d 100644 --- a/src/test/run-pass/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/fn-bare-coerce-to-block.rs @@ -1,6 +1,6 @@ fn bare() {} -fn likes_block(f: block()) { f() } +fn likes_block(f: fn()) { f() } fn main() { likes_block(bare); diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 08e7b843611..c77a37cf27c 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn two(it: block(int)) { it(0); it(1); } +fn two(it: fn(int)) { it(0); it(1); } fn main() { let a: [mutable int] = [mutable -1, -1, -1, -1]; diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 5919ee91b44..d5ceb820264 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -1,6 +1,6 @@ -fn pairs(it: block((int, int))) { +fn pairs(it: fn((int, int))) { let i: int = 0; let j: int = 0; while i < 10 { it((i, j)); i += 1; j += i; } diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index 90356d15b4b..047819bfb75 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -10,7 +10,7 @@ fn main() { assert (sum == 45); } -fn first_ten(it: block(int)) { +fn first_ten(it: fn(int)) { let i: int = 0; while i < 10 { #debug("first_ten"); it(i); i = i + 1; } } diff --git a/src/test/run-pass/iface-generic.rs b/src/test/run-pass/iface-generic.rs index 2286642cda1..c37dc989f38 100644 --- a/src/test/run-pass/iface-generic.rs +++ b/src/test/run-pass/iface-generic.rs @@ -12,10 +12,10 @@ impl of to_str for () { } iface map<T> { - fn map<U>(f: block(T) -> U) -> [U]; + fn map<U>(f: fn(T) -> U) -> [U]; } impl <T> of map<T> for [T] { - fn map<U>(f: block(T) -> U) -> [U] { + fn map<U>(f: fn(T) -> U) -> [U] { let r = []; for x in self { r += [f(x)]; } r diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index c02fc34ae8b..c82c1eb97e9 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -1,6 +1,6 @@ -fn range(a: int, b: int, it: block(int)) { +fn range(a: int, b: int, it: fn(int)) { assert (a < b); let i: int = a; while i < b { it(i); i += 1; } diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 71ac2fc0c62..1476a015828 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -1,4 +1,4 @@ -fn test(f: block(uint) -> uint) -> uint { +fn test(f: fn(uint) -> uint) -> uint { ret f(22u); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 8f9acab6128..fbc29c55a31 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -11,7 +11,7 @@ mod b { impl util for uint { fn str() -> str { uint::str(self) } - fn times(f: block(uint)) { + fn times(f: fn(uint)) { let c = 0u; while c < self { f(c); c += 1u; } } @@ -19,8 +19,8 @@ impl util for uint { impl util<T> for [T] { fn len() -> uint { vec::len(self) } - fn iter(f: block(T)) { for x in self { f(x); } } - fn map<U>(f: block(T) -> U) -> [U] { + fn iter(f: fn(T)) { for x in self { f(x); } } + fn map<U>(f: fn(T) -> U) -> [U] { let r = []; for elt in self { r += [f(elt)]; } r diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index 67b0f366acd..645f6407bfe 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -1,6 +1,6 @@ -fn range(lo: uint, hi: uint, it: block(uint)) { +fn range(lo: uint, hi: uint, it: fn(uint)) { let lo_ = lo; while lo_ < hi { it(lo_); lo_ += 1u; } } diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index b2069f3a265..d54a7f5a5e0 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -7,7 +7,7 @@ import std::list::*; // Can't easily be written as a "pure fn" because there's // no syntax for specifying that f is pure. -fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: block(T, U) -> U) -> U { +fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: fn(T, U) -> U) -> U { alt ls { nil { u } cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) } |
