Make fn denote a bare function. Convert fn to fn@ as needed

This commit is contained in:
Brian Anderson 2011-10-18 15:07:40 -07:00
parent f324704c0a
commit 29ad3bdb10
64 changed files with 263 additions and 248 deletions

View file

@ -88,7 +88,7 @@ fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str)
ret {crate: crate, src: src};
}
fn time<@T>(do_it: bool, what: str, thunk: fn() -> T) -> T {
fn time<@T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
if !do_it { ret thunk(); }
let start = std::time::precise_time_s();
let rv = thunk();

View file

@ -12,7 +12,7 @@ import front::attr;
export modify_for_testing;
type node_id_gen = fn() -> ast::node_id;
type node_id_gen = fn@() -> ast::node_id;
type test = {span: span, path: [ast::ident], ignore: bool};
@ -369,7 +369,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
il: ast::il_normal,
cf: ast::return_val,
constraints: []};
let proto = ast::proto_fn;
let proto = ast::proto_bare;
let test_main_call_expr = mk_test_main_call(cx);

View file

@ -28,9 +28,9 @@ export external_resolver;
// def_id for an item defined in another crate, somebody needs to figure out
// what crate that's in and give us a def_id that makes sense for the current
// build.
type external_resolver = fn(ast::def_id) -> ast::def_id;
type external_resolver = fn@(ast::def_id) -> ast::def_id;
fn lookup_hash(d: ebml::doc, eq_fn: fn([u8]) -> bool, hash: uint) ->
fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]) -> bool, hash: uint) ->
[ebml::doc] {
let index = ebml::get_doc(d, tag_index);
let table = ebml::get_doc(index, tag_index_table);

View file

@ -16,7 +16,7 @@ export parse_ty_data;
// data buffer. Whatever format you choose should not contain pipe characters.
// Callback to translate defs to strs or back:
type str_def = fn(str) -> ast::def_id;
type str_def = fn@(str) -> ast::def_id;
type pstate =
{data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
@ -34,7 +34,7 @@ fn parse_ident(st: @pstate, sd: str_def, last: char) -> ast::ident {
ret parse_ident_(st, sd, bind is_last(last, _));
}
fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn(char) -> bool) ->
fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn@(char) -> bool) ->
ast::ident {
let rslt = "";
while !is_last(peek(st) as char) {

View file

@ -24,7 +24,7 @@ type freevar_map = hashmap<ast::node_id, freevar_info>;
// Since we want to be able to collect upvars in some arbitrary piece
// of the AST, we take a walker function that we invoke with a visitor
// in order to start the search.
fn collect_freevars(def_map: resolve::def_map, walker: fn(visit::vt<int>)) ->
fn collect_freevars(def_map: resolve::def_map, walker: fn@(visit::vt<int>)) ->
freevar_info {
let seen = new_int_hash();
let refs = @mutable [];

View file

@ -595,6 +595,7 @@ fn lookup_in_scope_strict(e: env, sc: scopes, sp: span, name: ident,
fn scope_is_fn(sc: scope) -> bool {
ret alt sc {
scope_fn(_, ast::proto_iter., _) | scope_fn(_, ast::proto_fn., _) |
scope_fn(_, ast::proto_bare., _) |
scope_native_item(_) {
true
}

View file

@ -109,7 +109,7 @@ fn matches_always(p: @ast::pat) -> bool {
};
}
type enter_pat = fn(@ast::pat) -> option::t<[@ast::pat]>;
type enter_pat = fn@(@ast::pat) -> option::t<[@ast::pat]>;
fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match {
let result = [];
@ -314,7 +314,7 @@ fn any_tup_pat(m: match, col: uint) -> bool {
}
type exit_node = {bound: bind_map, from: BasicBlockRef, to: BasicBlockRef};
type mk_fail = fn() -> BasicBlockRef;
type mk_fail = fn@() -> BasicBlockRef;
fn pick_col(m: match) -> uint {
let scores = vec::init_elt_mut(0u, vec::len(m[0].pats));

View file

@ -259,8 +259,8 @@ type fn_ctxt =
lcx: @local_ctxt};
tag cleanup {
clean(fn(@block_ctxt) -> @block_ctxt);
clean_temp(ValueRef, fn(@block_ctxt) -> @block_ctxt);
clean(fn@(@block_ctxt) -> @block_ctxt);
clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt);
}
fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) {

View file

@ -151,7 +151,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) {
visit_stmt: relax_precond_stmt,
visit_item:
fn (_i: @item, _cx: relax_ctxt, _vt: visit::vt<relax_ctxt>) { },
visit_fn: do_nothing
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
with *visitor};
let v1 = visit::mk_vt(visitor);
v1.visit_block(b, cx, v1);

View file

@ -111,7 +111,8 @@ fn check_states_against_conditions(fcx: fn_ctxt, f: _fn, tps: [ast::ty_param],
visitor =
@{visit_stmt: check_states_stmt,
visit_expr: check_states_expr,
visit_fn: do_nothing with *visitor};
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
with *visitor};
visit::visit_fn(f, tps, sp, i, id, fcx, visit::mk_vt(visitor));
/* Check that the return value is initialized */

View file

@ -54,7 +54,8 @@ fn find_locals(tcx: ty::ctxt, f: _fn, tps: [ty_param], sp: span, i: fn_ident,
visitor =
@{visit_local: collect_local,
visit_expr: collect_pred,
visit_fn: do_nothing with *visitor};
visit_fn: bind do_nothing(_, _, _, _, _, _, _)
with *visitor};
visit::visit_fn(f, tps, sp, i, id, cx, visit::mk_vt(visitor));
ret cx;
}

View file

@ -603,7 +603,7 @@ fn cname(cx: ctxt, typ: t) -> option::t<str> {
// Type folds
type ty_walk = fn(t);
type ty_walk = fn@(t);
fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
alt struct(cx, ty) {
@ -655,9 +655,9 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
}
tag fold_mode {
fm_var(fn(int) -> t);
fm_param(fn(uint, ast::kind) -> t);
fm_general(fn(t) -> t);
fm_var(fn@(int) -> t);
fm_param(fn@(uint, ast::kind) -> t);
fm_general(fn@(t) -> t);
}
fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
@ -2712,13 +2712,14 @@ fn type_err_to_str(err: ty::type_err) -> str {
// Converts type parameters in a type to type variables and returns the
// resulting type along with a list of type variable IDs.
fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn() -> int, typ: t,
fn bind_params_in_type(sp: span, cx: ctxt, next_ty_var: fn@() -> int, typ: t,
ty_param_count: uint) -> {ids: [int], ty: t} {
let param_var_ids: @mutable [int] = @mutable [];
let i = 0u;
while i < ty_param_count { *param_var_ids += [next_ty_var()]; i += 1u; }
fn binder(sp: span, cx: ctxt, param_var_ids: @mutable [int],
_next_ty_var: fn() -> int, index: uint, _kind: ast::kind) -> t {
_next_ty_var: fn@() -> int, index: uint,
_kind: ast::kind) -> t {
if index < vec::len(*param_var_ids) {
ret mk_var(cx, param_var_ids[index]);
} else {

View file

@ -53,7 +53,7 @@ type fn_ctxt =
// Used for ast_ty_to_ty() below.
type ty_getter = fn(ast::def_id) -> ty::ty_param_kinds_and_ty;
type ty_getter = fn@(ast::def_id) -> ty::ty_param_kinds_and_ty;
fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> int {
alt fcx.locals.find(id) {
@ -516,8 +516,8 @@ mod collect {
ret k;
}
fn ty_of_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t,
ty_of_arg: fn(ast::arg) -> arg, decl: ast::fn_decl,
fn ty_of_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t,
ty_of_arg: fn@(ast::arg) -> arg, decl: ast::fn_decl,
proto: ast::proto, ty_params: [ast::ty_param],
def_id: option::t<ast::def_id>) ->
ty::ty_param_kinds_and_ty {
@ -536,8 +536,8 @@ mod collect {
alt def_id { some(did) { cx.tcx.tcache.insert(did, tpt); } _ { } }
ret tpt;
}
fn ty_of_native_fn_decl(cx: @ctxt, convert: fn(&&@ast::ty) -> ty::t,
ty_of_arg: fn(ast::arg) -> arg,
fn ty_of_native_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t,
ty_of_arg: fn@(ast::arg) -> arg,
decl: ast::fn_decl, abi: ast::native_abi,
ty_params: [ast::ty_param], def_id: ast::def_id)
-> ty::ty_param_kinds_and_ty {
@ -1227,8 +1227,10 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
let visit =
@{visit_local: visit_local,
visit_pat: visit_pat,
visit_fn: visit_fn,
visit_item: visit_item with *visit::default_visitor()};
visit_fn: bind visit_fn(_, _, _, _, _, _, _),
visit_item: bind visit_item(_, _, _)
with *visit::default_visitor()};
visit::visit_block(f.body, (), visit::mk_vt(visit));
ret {var_bindings: vb,
locals: locals,
@ -2787,7 +2789,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
let main_t = ty::node_id_to_monotype(tcx, main_id);
alt ty::struct(tcx, main_t) {
ty::ty_fn(ast::proto_fn., args, rs, ast::return_val., constrs) {
ty::ty_fn(ast::proto_bare., args, rs, ast::return_val., constrs) {
let ok = vec::len(constrs) == 0u;
ok &= ty::type_is_nil(tcx, rs);
let num_args = vec::len(args);

View file

@ -6,10 +6,10 @@ import std::map::new_str_hash;
import codemap;
type syntax_expander =
fn(ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
type macro_def = {ident: str, ext: syntax_extension};
type macro_definer =
fn(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
tag syntax_extension {
normal(syntax_expander);

View file

@ -11,7 +11,7 @@ import syntax::ext::base::*;
fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, e: expr_,
fld: ast_fold, orig: fn(expr_, ast_fold) -> expr_) -> expr_ {
fld: ast_fold, orig: fn@(expr_, ast_fold) -> expr_) -> expr_ {
ret alt e {
expr_mac(mac) {
alt mac.node {

View file

@ -72,7 +72,7 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! {
// we'll want to return something indicating amount of progress and location
// of failure instead of `none`.
type match_result = option::t<arb_depth<matchable>>;
type selector = fn(matchable) -> match_result;
type selector = fn@(matchable) -> match_result;
fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
{pre: [@expr], rep: option::t<@expr>, post: [@expr]} {
@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
}
}
fn option_flatten_map<T, @U>(f: fn(T) -> option::t<U>, v: [T]) ->
fn option_flatten_map<T, @U>(f: fn@(T) -> option::t<U>, v: [T]) ->
option::t<[U]> {
let res = [];
for elem: T in v {
@ -263,7 +263,7 @@ iter free_vars(b: bindings, e: @expr) -> ident {
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
recur: fn(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
alt elts_to_ell(cx, exprs) {
{pre: pre, rep: repeat_me_maybe, post: post} {
let res = vec::map(recur, pre);
@ -351,7 +351,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
e: ast::expr_, fld: ast_fold,
orig: fn(ast::expr_, ast_fold) -> ast::expr_) ->
orig: fn@(ast::expr_, ast_fold) -> ast::expr_) ->
ast::expr_ {
ret alt e {
expr_path(p) {
@ -378,7 +378,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
t: ast::ty_, fld: ast_fold,
orig: fn(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
orig: fn@(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
ret alt t {
ast::ty_path(pth, _) {
alt path_to_ident(pth) {
@ -402,7 +402,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
blk: blk_, fld: ast_fold,
orig: fn(blk_, ast_fold) -> blk_) -> blk_ {
orig: fn@(blk_, ast_fold) -> blk_) -> blk_ {
ret alt block_to_ident(blk) {
some(id) {
alt follow_for_trans(cx, b.find(id), idx_path) {

View file

@ -20,58 +20,59 @@ type ast_fold = @mutable a_f;
type ast_fold_precursor =
//unlike the others, item_ is non-trivial
{fold_crate: fn(crate_, ast_fold) -> crate_,
fold_crate_directive: fn(crate_directive_, ast_fold) -> crate_directive_,
fold_view_item: fn(view_item_, ast_fold) -> view_item_,
fold_native_item: fn(&&@native_item, ast_fold) -> @native_item,
fold_item: fn(&&@item, ast_fold) -> @item,
fold_item_underscore: fn(item_, ast_fold) -> item_,
fold_method: fn(method_, ast_fold) -> method_,
fold_block: fn(blk_, ast_fold) -> blk_,
fold_stmt: fn(stmt_, ast_fold) -> stmt_,
fold_arm: fn(arm, ast_fold) -> arm,
fold_pat: fn(pat_, ast_fold) -> pat_,
fold_decl: fn(decl_, ast_fold) -> decl_,
fold_expr: fn(expr_, ast_fold) -> expr_,
fold_ty: fn(ty_, ast_fold) -> ty_,
fold_constr: fn(ast::constr_, ast_fold) -> constr_,
fold_fn: fn(_fn, ast_fold) -> _fn,
fold_mod: fn(_mod, ast_fold) -> _mod,
fold_native_mod: fn(native_mod, ast_fold) -> native_mod,
fold_variant: fn(variant_, ast_fold) -> variant_,
fold_ident: fn(&&ident, ast_fold) -> ident,
fold_path: fn(path_, ast_fold) -> path_,
fold_local: fn(local_, ast_fold) -> local_,
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
new_id: fn(node_id) -> node_id,
new_span: fn(span) -> span};
{fold_crate: fn@(crate_, ast_fold) -> crate_,
fold_crate_directive: fn@(crate_directive_,
ast_fold) -> crate_directive_,
fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
fold_native_item: fn@(&&@native_item, ast_fold) -> @native_item,
fold_item: fn@(&&@item, ast_fold) -> @item,
fold_item_underscore: fn@(item_, ast_fold) -> item_,
fold_method: fn@(method_, ast_fold) -> method_,
fold_block: fn@(blk_, ast_fold) -> blk_,
fold_stmt: fn@(stmt_, ast_fold) -> stmt_,
fold_arm: fn@(arm, ast_fold) -> arm,
fold_pat: fn@(pat_, ast_fold) -> pat_,
fold_decl: fn@(decl_, ast_fold) -> decl_,
fold_expr: fn@(expr_, ast_fold) -> expr_,
fold_ty: fn@(ty_, ast_fold) -> ty_,
fold_constr: fn@(ast::constr_, ast_fold) -> constr_,
fold_fn: fn@(_fn, ast_fold) -> _fn,
fold_mod: fn@(_mod, ast_fold) -> _mod,
fold_native_mod: fn@(native_mod, ast_fold) -> native_mod,
fold_variant: fn@(variant_, ast_fold) -> variant_,
fold_ident: fn@(&&ident, ast_fold) -> ident,
fold_path: fn@(path_, ast_fold) -> path_,
fold_local: fn@(local_, ast_fold) -> local_,
map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr],
new_id: fn@(node_id) -> node_id,
new_span: fn@(span) -> span};
type a_f =
{fold_crate: fn(crate) -> crate,
fold_crate_directive: fn(&&@crate_directive) -> @crate_directive,
fold_view_item: fn(&&@view_item) -> @view_item,
fold_native_item: fn(&&@native_item) -> @native_item,
fold_item: fn(&&@item) -> @item,
fold_item_underscore: fn(item_) -> item_,
fold_method: fn(&&@method) -> @method,
fold_block: fn(blk) -> blk,
fold_stmt: fn(&&@stmt) -> @stmt,
fold_arm: fn(arm) -> arm,
fold_pat: fn(&&@pat) -> @pat,
fold_decl: fn(&&@decl) -> @decl,
fold_expr: fn(&&@expr) -> @expr,
fold_ty: fn(&&@ty) -> @ty,
fold_constr: fn(&&@constr) -> @constr,
fold_fn: fn(_fn) -> _fn,
fold_mod: fn(_mod) -> _mod,
fold_native_mod: fn(native_mod) -> native_mod,
fold_variant: fn(variant) -> variant,
fold_ident: fn(&&ident) -> ident,
fold_path: fn(path) -> path,
fold_local: fn(&&@local) -> @local,
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
new_id: fn(node_id) -> node_id,
new_span: fn(span) -> span};
{fold_crate: fn@(crate) -> crate,
fold_crate_directive: fn@(&&@crate_directive) -> @crate_directive,
fold_view_item: fn@(&&@view_item) -> @view_item,
fold_native_item: fn@(&&@native_item) -> @native_item,
fold_item: fn@(&&@item) -> @item,
fold_item_underscore: fn@(item_) -> item_,
fold_method: fn@(&&@method) -> @method,
fold_block: fn@(blk) -> blk,
fold_stmt: fn@(&&@stmt) -> @stmt,
fold_arm: fn@(arm) -> arm,
fold_pat: fn@(&&@pat) -> @pat,
fold_decl: fn@(&&@decl) -> @decl,
fold_expr: fn@(&&@expr) -> @expr,
fold_ty: fn@(&&@ty) -> @ty,
fold_constr: fn@(&&@constr) -> @constr,
fold_fn: fn@(_fn) -> _fn,
fold_mod: fn@(_mod) -> _mod,
fold_native_mod: fn@(native_mod) -> native_mod,
fold_variant: fn@(variant) -> variant,
fold_ident: fn@(&&ident) -> ident,
fold_path: fn@(path) -> path,
fold_local: fn@(&&@local) -> @local,
map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr],
new_id: fn@(node_id) -> node_id,
new_span: fn@(span) -> span};
//fn nf_dummy<T>(&T node) -> T { fail; }
@ -119,7 +120,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
span: mi.span};
}
//used in noop_fold_item and noop_fold_crate
fn fold_attribute_(at: attribute, fmi: fn(&&@meta_item) -> @meta_item) ->
fn fold_attribute_(at: attribute, fmi: fn@(&&@meta_item) -> @meta_item) ->
attribute {
ret {node: {style: at.node.style, value: *fmi(@at.node.value)},
span: at.span};
@ -495,7 +496,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
value */
fn noop_map_exprs(f: fn(&&@expr) -> @expr, es: [@expr]) -> [@expr] {
fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: [@expr]) -> [@expr] {
ret vec::map(f, es);
}
@ -568,32 +569,34 @@ resource foldres(f: ast_fold) {
}
fn make_fold(afp: ast_fold_precursor) -> @foldres {
// FIXME: Have to bind all the bare functions into shared functions
// because @mutable is invariant with respect to its contents
let result: ast_fold =
@mutable {fold_crate: nf_crate_dummy,
fold_crate_directive: nf_crate_directive_dummy,
fold_view_item: nf_view_item_dummy,
fold_native_item: nf_native_item_dummy,
fold_item: nf_item_dummy,
fold_item_underscore: nf_item_underscore_dummy,
fold_method: nf_method_dummy,
fold_block: nf_blk_dummy,
fold_stmt: nf_stmt_dummy,
fold_arm: nf_arm_dummy,
fold_pat: nf_pat_dummy,
fold_decl: nf_decl_dummy,
fold_expr: nf_expr_dummy,
fold_ty: nf_ty_dummy,
fold_constr: nf_constr_dummy,
fold_fn: nf_fn_dummy,
fold_mod: nf_mod_dummy,
fold_native_mod: nf_native_mod_dummy,
fold_variant: nf_variant_dummy,
fold_ident: nf_ident_dummy,
fold_path: nf_path_dummy,
fold_local: nf_local_dummy,
map_exprs: noop_map_exprs,
new_id: noop_id,
new_span: noop_span};
@mutable {fold_crate: bind nf_crate_dummy(_),
fold_crate_directive: bind nf_crate_directive_dummy(_),
fold_view_item: bind nf_view_item_dummy(_),
fold_native_item: bind nf_native_item_dummy(_),
fold_item: bind nf_item_dummy(_),
fold_item_underscore: bind nf_item_underscore_dummy(_),
fold_method: bind nf_method_dummy(_),
fold_block: bind nf_blk_dummy(_),
fold_stmt: bind nf_stmt_dummy(_),
fold_arm: bind nf_arm_dummy(_),
fold_pat: bind nf_pat_dummy(_),
fold_decl: bind nf_decl_dummy(_),
fold_expr: bind nf_expr_dummy(_),
fold_ty: bind nf_ty_dummy(_),
fold_constr: bind nf_constr_dummy(_),
fold_fn: bind nf_fn_dummy(_),
fold_mod: bind nf_mod_dummy(_),
fold_native_mod: bind nf_native_mod_dummy(_),
fold_variant: bind nf_variant_dummy(_),
fold_ident: bind nf_ident_dummy(_),
fold_path: bind nf_path_dummy(_),
fold_local: bind nf_local_dummy(_),
map_exprs: bind noop_map_exprs(_, _),
new_id: bind noop_id(_),
new_span: bind noop_span(_)};
/* naturally, a macro to write these would be nice */
fn f_crate(afp: ast_fold_precursor, f: ast_fold, c: crate) -> crate {

View file

@ -390,7 +390,8 @@ fn parse_constr_in_type(p: parser) -> @ast::ty_constr {
}
fn parse_constrs<T>(pser: fn(parser) -> @ast::constr_general<T>, p: parser) ->
fn parse_constrs<T>(pser: fn@(parser) -> @ast::constr_general<T>,
p: parser) ->
[@ast::constr_general<T>] {
let constrs: [@ast::constr_general<T>] = [];
while true {
@ -602,7 +603,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
}
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
f: fn(parser) -> T,
f: fn@(parser) -> T,
p: parser) -> [T] {
let first = true;
let v = [];
@ -618,7 +619,7 @@ fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
ret v;
}
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
p: parser) -> [T] {
let v = parse_seq_to_before_gt(sep, f, p);
expect_gt(p);
@ -626,7 +627,7 @@ fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
ret v;
}
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn(parser) -> T,
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
p: parser) -> spanned<[T]> {
let lo = p.get_lo_pos();
expect(p, token::LT);
@ -645,7 +646,7 @@ fn parse_seq_to_end<@T>(ket: token::token, sep: option::t<token::token>,
fn parse_seq_to_before_end<@T>(ket: token::token,
sep: option::t<token::token>,
f: fn(parser) -> T, p: parser) -> [T] {
f: fn@(parser) -> T, p: parser) -> [T] {
let first: bool = true;
let v: [T] = [];
while p.peek() != ket {
@ -660,7 +661,7 @@ fn parse_seq_to_before_end<@T>(ket: token::token,
fn parse_seq<@T>(bra: token::token, ket: token::token,
sep: option::t<token::token>, f: fn(parser) -> T, p: parser)
sep: option::t<token::token>, f: fn@(parser) -> T, p: parser)
-> spanned<[T]> {
let lo = p.get_lo_pos();
expect(p, bra);
@ -2141,7 +2142,7 @@ fn parse_fn_item_proto(p: parser) -> ast::proto {
p.bump();
ast::proto_fn
} else {
ast::proto_fn
ast::proto_bare
}
}
@ -2153,7 +2154,7 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
p.bump();
ast::proto_fn
} else {
ast::proto_fn
ast::proto_bare
}
}
@ -2165,7 +2166,7 @@ fn parse_fn_anon_proto(p: parser) -> ast::proto {
p.bump();
ast::proto_fn
} else {
ast::proto_fn
ast::proto_bare
}
}
@ -2198,7 +2199,8 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
} else if is_word(p, "unsafe") && p.look_ahead(1u) != token::LBRACE {
p.bump();
expect_word(p, "fn");
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, ast::proto_fn,
let proto = parse_fn_item_proto(p);
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, proto,
attrs, ast::il_normal));
} else if eat_word(p, "iter") {
ret some(parse_item_fn_or_iter(p, ast::impure_fn, ast::proto_iter,

View file

@ -18,7 +18,7 @@ tag ann_node {
node_expr(ps, @ast::expr);
node_pat(ps, @ast::pat);
}
type pp_ann = {pre: fn(ann_node), post: fn(ann_node)};
type pp_ann = {pre: fn@(ann_node), post: fn@(ann_node)};
fn no_ann() -> pp_ann {
fn ignore(_node: ann_node) { }
@ -352,7 +352,7 @@ fn print_native_item(s: ps, item: @ast::native_item) {
ast::native_item_fn(lname, decl, typarams) {
print_fn(s, decl, ast::proto_fn, item.ident, typarams,
print_fn(s, decl, ast::proto_bare, item.ident, typarams,
decl.constraints);
alt lname {
none. { }
@ -1557,7 +1557,7 @@ fn escape_str(st: str, to_escape: char) -> str {
ret out;
}
fn to_str<T>(t: T, f: fn(ps, T)) -> str {
fn to_str<T>(t: T, f: fn@(ps, T)) -> str {
let writer = io::string_writer();
let s = rust_printer(writer.get_writer());
f(s, t);
@ -1578,7 +1578,7 @@ fn next_comment(s: ps) -> option::t<lexer::cmnt> {
// Removing the aliases from the type of f in the next two functions
// triggers memory corruption, but I haven't isolated the bug yet. FIXME
fn constr_args_to_str<T>(f: fn(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
fn constr_args_to_str<T>(f: fn@(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
str {
let comma = false;
let s = "(";
@ -1590,7 +1590,7 @@ fn constr_args_to_str<T>(f: fn(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
ret s;
}
fn constr_arg_to_str<T>(f: fn(T) -> str, c: ast::constr_arg_general_<T>) ->
fn constr_arg_to_str<T>(f: fn@(T) -> str, c: ast::constr_arg_general_<T>) ->
str {
alt c {
ast::carg_base. { ret "*"; }
@ -1643,11 +1643,11 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
fn proto_to_str(p: ast::proto) -> str {
ret alt p {
ast::proto_fn. { "fn" }
ast::proto_fn. { "fn@" }
ast::proto_iter. { "iter" }
ast::proto_block. { "block" }
ast::proto_closure. { "lambda" }
ast::proto_bare. { "fn#" }
ast::proto_bare. { "fn" }
};
}

View file

@ -18,20 +18,20 @@ tag vt<E> { mk_vt(visitor<E>); }
type visitor<E> =
// takes the components so that one function can be
// generic over constr and ty_constr
@{visit_mod: fn(_mod, span, E, vt<E>),
visit_view_item: fn(@view_item, E, vt<E>),
visit_native_item: fn(@native_item, E, vt<E>),
visit_item: fn(@item, E, vt<E>),
visit_local: fn(@local, E, vt<E>),
visit_block: fn(ast::blk, E, vt<E>),
visit_stmt: fn(@stmt, E, vt<E>),
visit_arm: fn(arm, E, vt<E>),
visit_pat: fn(@pat, E, vt<E>),
visit_decl: fn(@decl, E, vt<E>),
visit_expr: fn(@expr, E, vt<E>),
visit_ty: fn(@ty, E, vt<E>),
visit_constr: fn(path, span, node_id, E, vt<E>),
visit_fn: fn(_fn, [ty_param], span, fn_ident, node_id, E, vt<E>)};
@{visit_mod: fn@(_mod, span, E, vt<E>),
visit_view_item: fn@(@view_item, E, vt<E>),
visit_native_item: fn@(@native_item, E, vt<E>),
visit_item: fn@(@item, E, vt<E>),
visit_local: fn@(@local, E, vt<E>),
visit_block: fn@(ast::blk, E, vt<E>),
visit_stmt: fn@(@stmt, E, vt<E>),
visit_arm: fn@(arm, E, vt<E>),
visit_pat: fn@(@pat, E, vt<E>),
visit_decl: fn@(@decl, E, vt<E>),
visit_expr: fn@(@expr, E, vt<E>),
visit_ty: fn@(@ty, E, vt<E>),
visit_constr: fn@(path, span, node_id, E, vt<E>),
visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id, E, vt<E>)};
fn default_visitor<E>() -> visitor<E> {
ret @{visit_mod: bind visit_mod::<E>(_, _, _, _),
@ -341,97 +341,97 @@ fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
type simple_visitor =
// takes the components so that one function can be
// generic over constr and ty_constr
@{visit_mod: fn(_mod, span),
visit_view_item: fn(@view_item),
visit_native_item: fn(@native_item),
visit_item: fn(@item),
visit_local: fn(@local),
visit_block: fn(ast::blk),
visit_stmt: fn(@stmt),
visit_arm: fn(arm),
visit_pat: fn(@pat),
visit_decl: fn(@decl),
visit_expr: fn(@expr),
visit_ty: fn(@ty),
visit_constr: fn(path, span, node_id),
visit_fn: fn(_fn, [ty_param], span, fn_ident, node_id)};
@{visit_mod: fn@(_mod, span),
visit_view_item: fn@(@view_item),
visit_native_item: fn@(@native_item),
visit_item: fn@(@item),
visit_local: fn@(@local),
visit_block: fn@(ast::blk),
visit_stmt: fn@(@stmt),
visit_arm: fn@(arm),
visit_pat: fn@(@pat),
visit_decl: fn@(@decl),
visit_expr: fn@(@expr),
visit_ty: fn@(@ty),
visit_constr: fn@(path, span, node_id),
visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id)};
fn default_simple_visitor() -> simple_visitor {
ret @{visit_mod: fn (_m: _mod, _sp: span) { },
visit_view_item: fn (_vi: @view_item) { },
visit_native_item: fn (_ni: @native_item) { },
visit_item: fn (_i: @item) { },
visit_local: fn (_l: @local) { },
visit_block: fn (_b: ast::blk) { },
visit_stmt: fn (_s: @stmt) { },
visit_arm: fn (_a: arm) { },
visit_pat: fn (_p: @pat) { },
visit_decl: fn (_d: @decl) { },
visit_expr: fn (_e: @expr) { },
visit_ty: fn (_t: @ty) { },
visit_constr: fn (_p: path, _sp: span, _id: node_id) { },
ret @{visit_mod: fn(_m: _mod, _sp: span) { },
visit_view_item: fn(_vi: @view_item) { },
visit_native_item: fn(_ni: @native_item) { },
visit_item: fn(_i: @item) { },
visit_local: fn(_l: @local) { },
visit_block: fn(_b: ast::blk) { },
visit_stmt: fn(_s: @stmt) { },
visit_arm: fn(_a: arm) { },
visit_pat: fn(_p: @pat) { },
visit_decl: fn(_d: @decl) { },
visit_expr: fn(_e: @expr) { },
visit_ty: fn(_t: @ty) { },
visit_constr: fn(_p: path, _sp: span, _id: node_id) { },
visit_fn:
fn (_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident,
fn(_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident,
_id: node_id) {
}};
}
fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
fn v_mod(f: fn(_mod, span), m: _mod, sp: span, &&e: (), v: vt<()>) {
fn v_mod(f: fn@(_mod, span), m: _mod, sp: span, &&e: (), v: vt<()>) {
f(m, sp);
visit_mod(m, sp, e, v);
}
fn v_view_item(f: fn(@view_item), vi: @view_item, &&e: (), v: vt<()>) {
fn v_view_item(f: fn@(@view_item), vi: @view_item, &&e: (), v: vt<()>) {
f(vi);
visit_view_item(vi, e, v);
}
fn v_native_item(f: fn(@native_item), ni: @native_item, &&e: (),
fn v_native_item(f: fn@(@native_item), ni: @native_item, &&e: (),
v: vt<()>) {
f(ni);
visit_native_item(ni, e, v);
}
fn v_item(f: fn(@item), i: @item, &&e: (), v: vt<()>) {
fn v_item(f: fn@(@item), i: @item, &&e: (), v: vt<()>) {
f(i);
visit_item(i, e, v);
}
fn v_local(f: fn(@local), l: @local, &&e: (), v: vt<()>) {
fn v_local(f: fn@(@local), l: @local, &&e: (), v: vt<()>) {
f(l);
visit_local(l, e, v);
}
fn v_block(f: fn(ast::blk), bl: ast::blk, &&e: (), v: vt<()>) {
fn v_block(f: fn@(ast::blk), bl: ast::blk, &&e: (), v: vt<()>) {
f(bl);
visit_block(bl, e, v);
}
fn v_stmt(f: fn(@stmt), st: @stmt, &&e: (), v: vt<()>) {
fn v_stmt(f: fn@(@stmt), st: @stmt, &&e: (), v: vt<()>) {
f(st);
visit_stmt(st, e, v);
}
fn v_arm(f: fn(arm), a: arm, &&e: (), v: vt<()>) {
fn v_arm(f: fn@(arm), a: arm, &&e: (), v: vt<()>) {
f(a);
visit_arm(a, e, v);
}
fn v_pat(f: fn(@pat), p: @pat, &&e: (), v: vt<()>) {
fn v_pat(f: fn@(@pat), p: @pat, &&e: (), v: vt<()>) {
f(p);
visit_pat(p, e, v);
}
fn v_decl(f: fn(@decl), d: @decl, &&e: (), v: vt<()>) {
fn v_decl(f: fn@(@decl), d: @decl, &&e: (), v: vt<()>) {
f(d);
visit_decl(d, e, v);
}
fn v_expr(f: fn(@expr), ex: @expr, &&e: (), v: vt<()>) {
fn v_expr(f: fn@(@expr), ex: @expr, &&e: (), v: vt<()>) {
f(ex);
visit_expr(ex, e, v);
}
fn v_ty(f: fn(@ty), ty: @ty, &&e: (), v: vt<()>) {
fn v_ty(f: fn@(@ty), ty: @ty, &&e: (), v: vt<()>) {
f(ty);
visit_ty(ty, e, v);
}
fn v_constr(f: fn(path, span, node_id), pt: path, sp: span, id: node_id,
fn v_constr(f: fn@(path, span, node_id), pt: path, sp: span, id: node_id,
&&e: (), v: vt<()>) {
f(pt, sp, id);
visit_constr(pt, sp, id, e, v);
}
fn v_fn(f: fn(_fn, [ty_param], span, fn_ident, node_id), ff: _fn,
fn v_fn(f: fn@(_fn, [ty_param], span, fn_ident, node_id), ff: _fn,
tps: [ty_param], sp: span, ident: fn_ident, id: node_id, &&e: (),
v: vt<()>) {
f(ff, tps, sp, ident, id);

View file

@ -128,8 +128,8 @@ fn test_opts(config: config) -> test::test_opts {
}
type tests_and_conv_fn = {
tests: [test::test_desc<fn()>],
to_task: fn(fn()) -> test::joinable
tests: [test::test_desc<fn@()>],
to_task: fn@(fn@()) -> test::joinable
};
fn make_tests(cx: cx) -> tests_and_conv_fn {
@ -167,7 +167,7 @@ fn is_test(config: config, testfile: str) -> bool {
}
fn make_test(cx: cx, testfile: str, configport: port<[u8]>) ->
test::test_desc<fn()> {
test::test_desc<fn@()> {
{name: make_test_name(cx.config, testfile),
fn: make_test_closure(testfile, chan(configport)),
ignore: header::is_test_ignored(cx.config, testfile)}
@ -178,7 +178,7 @@ fn make_test_name(config: config, testfile: str) -> str {
}
fn make_test_closure(testfile: str,
configchan: chan<[u8]>) -> test::test_fn<fn()> {
configchan: chan<[u8]>) -> test::test_fn<fn@()> {
bind send_config(testfile, configchan)
}
@ -186,7 +186,7 @@ fn send_config(testfile: str, configchan: chan<[u8]>) {
send(configchan, str::bytes(testfile));
}
fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn()) ->
fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn@()) ->
test::joinable {
testfn();
let testfile = recv(configport);

View file

@ -154,13 +154,13 @@ fn worker(p: port<request>) {
// Only windows needs to set the library path
#[cfg(target_os = "win32")]
fn maybe_with_lib_path<@T>(path: str, f: fn() -> T) -> T {
fn maybe_with_lib_path<@T>(path: str, f: fn@() -> T) -> T {
with_lib_path(path, f)
}
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
fn maybe_with_lib_path<@T>(_path: str, f: fn() -> T) -> T {
fn maybe_with_lib_path<@T>(_path: str, f: fn@() -> T) -> T {
f()
}

View file

@ -232,7 +232,7 @@ fn exec_compiled_test(cx: cx, props: test_props, testfile: str) -> procres {
}
fn compose_and_run(cx: cx, testfile: str,
make_args: fn(config, str) -> procargs, lib_path: str,
make_args: fn@(config, str) -> procargs, lib_path: str,
input: option::t<str>) -> procres {
let procargs = make_args(cx.config, testfile);
ret program_output(cx, testfile, lib_path, procargs.prog, procargs.args,

View file

@ -216,7 +216,7 @@ iter under(n: uint) -> uint {
fn devnull() -> io::writer { std::io::string_writer().get_writer() }
fn as_str(f: fn(io::writer)) -> str {
fn as_str(f: fn@(io::writer)) -> str {
let w = std::io::string_writer();
f(w.get_writer());
ret w.get_str();

View file

@ -67,7 +67,7 @@ mod ct {
// A fragment of the output sequence
tag piece { piece_string(str); piece_conv(conv); }
type error_fn = fn(str) -> ! ;
type error_fn = fn@(str) -> ! ;
fn parse_fmt_string(s: str, error: error_fn) -> [piece] {
let pieces: [piece] = [];

View file

@ -50,7 +50,7 @@ fn has<@T>(ls_: list<T>, elt: T) -> bool {
fn length<@T>(ls: list<T>) -> uint {
fn count<T>(_t: T, &&u: uint) -> uint { ret u + 1u; }
ret foldl(ls, 0u, count);
ret foldl(ls, 0u, bind count(_, _));
}
fn cdr<@T>(ls: list<T>) -> list<T> {

View file

@ -1,9 +1,9 @@
/**
* Hashmap implementation.
*/
type hashfn<K> = fn(K) -> uint;
type hashfn<K> = fn@(K) -> uint;
type eqfn<K> = fn(K, K) -> bool;
type eqfn<K> = fn@(K, K) -> bool;
type hashmap<K, V> =
obj {

View file

@ -136,7 +136,7 @@ fn spawn_inner2<~T>(-data: T, f: fn#(T),
// FIXME: This is the old spawn function that spawns a shared closure.
// It is a hack and needs to be rewritten.
fn unsafe_spawn_inner(-thunk: fn(),
fn unsafe_spawn_inner(-thunk: fn@(),
notify: option<comm::chan<task_notification>>) ->
task_id unsafe {
let id = rustrt::new_task();

View file

@ -100,7 +100,7 @@ type joinable = (task, comm::port<task::task_notification>);
// In cases where test functions are closures it is not ok to just dump them
// into a task and run them, so this transformation gives the caller a chance
// to create the test task.
type test_to_task<@T> = fn(test_fn<T>) -> joinable;
type test_to_task<@T> = fn@(test_fn<T>) -> joinable;
// A simple console test runner
fn run_tests_console(opts: test_opts,
@ -215,7 +215,7 @@ tag testevent<@T> {
fn run_tests<@T>(opts: test_opts, tests: [test_desc<T>],
to_task: test_to_task<T>,
callback: fn(testevent<T>)) {
callback: fn@(testevent<T>)) {
let filtered_tests = filter_tests(opts, tests);
@ -286,7 +286,7 @@ fn filter_tests<@T>(opts: test_opts,
} else { ret option::none; }
};
vec::filter_map(filter, filtered)
vec::filter_map(bind filter(_), filtered)
};
// Sort the tests alphabetically
@ -295,13 +295,13 @@ fn filter_tests<@T>(opts: test_opts,
fn lteq<@T>(t1: test_desc<T>, t2: test_desc<T>) -> bool {
str::lteq(t1.name, t2.name)
}
sort::merge_sort(lteq, filtered)
sort::merge_sort(bind lteq(_, _), filtered)
};
ret filtered;
}
type test_future<@T> = {test: test_desc<T>, wait: fn() -> test_result};
type test_future<@T> = {test: test_desc<T>, wait: fn@() -> test_result};
fn run_test<@T>(test: test_desc<T>,
to_task: test_to_task<T>) -> test_future<T> {

View file

@ -52,7 +52,7 @@ fn find<@K, @V>(m: treemap<K, V>, k: K) -> option<V> {
}
// Performs an in-order traversal
fn traverse<@K, @V>(m: treemap<K, V>, f: fn(K, V)) {
fn traverse<@K, @V>(m: treemap<K, V>, f: fn@(K, V)) {
alt *m {
empty. { }
node(k, v, _, _) {

View file

@ -20,7 +20,7 @@ fn reserve<@T>(&v: [mutable? T], n: uint) {
pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
type init_op<T> = fn(uint) -> T;
type init_op<T> = fn@(uint) -> T;
fn init_fn<@T>(op: init_op<T>, n_elts: uint) -> [T] {
let v = [];

View file

@ -51,11 +51,11 @@ mod map_reduce {
export reducer;
export map_reduce;
type putter = fn(str, int);
type putter = fn@(str, int);
type mapper = fn(str, putter);
type getter = fn() -> option<int>;
type getter = fn@() -> option<int>;
type reducer = fn(str, getter);

View file

@ -1,4 +1,4 @@
// error-pattern:mismatched types: expected fn#() but found fn()
// error-pattern:mismatched types: expected fn() but found fn@()
fn# f() {
}

View file

@ -1,6 +1,6 @@
// error-pattern:may alias with argument
fn foo(x: {mutable x: int}, f: fn()) { log x; }
fn foo(x: {mutable x: int}, f: fn@()) { log x; }
fn whoknows(x: @mutable {mutable x: int}) { *x = {mutable x: 10}; }

View file

@ -1,3 +1,7 @@
// FIXME: Autobind doesn't work for bare functions currently
// because it would have to convert them to shared closures
// xfail-test
fn f<@T>(x: [T]) -> T { ret x[0]; }
fn g(act: fn([int]) -> int) -> int { ret act([1, 2, 3]); }

View file

@ -5,7 +5,7 @@
fn f(n: int) -> int { ret n; }
fn main() {
let g: fn() -> int = bind f(10);
let g: fn@() -> int = bind f(10);
let i: int = g();
assert (i == 10);
}

View file

@ -1,7 +1,7 @@
fn main() {
fn echo<T>(c: int, x: [T]) { }
let y: fn([int]) = bind echo(42, _);
let y: fn@([int]) = bind echo(42, _);
y([1]);
}

View file

@ -5,7 +5,7 @@
fn f() -> int { ret 42; }
fn main() {
let g: fn() -> int = bind f();
let g: fn@() -> int = bind f();
let i: int = g();
assert (i == 42);
}

View file

@ -5,7 +5,7 @@
fn f(n: int) -> int { ret n; }
fn main() {
let g: fn(int) -> int = bind f(_);
let g: fn@(int) -> int = bind f(_);
let i: int = g(42);
assert (i == 42);
}

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(@T, @T) -> bool;
type compare<T> = fn@(@T, @T) -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = alt true { true { expected } };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = alt true { true { expected } };

View file

@ -1,7 +1,7 @@
// -*- rust -*-
type compare<T> = fn(~T, ~T) -> bool;
type compare<T> = fn@(~T, ~T) -> bool;
fn test_generic<@T>(expected: ~T, eq: compare<T>) {
let actual: ~T = alt true { true { expected } };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = alt true { true { expected } };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = alt true { true { expected } };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(@T, @T) -> bool;
type compare<T> = fn@(@T, @T) -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = { expected };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = { expected };

View file

@ -1,7 +1,7 @@
// -*- rust -*-
type compare<T> = fn(~T, ~T) -> bool;
type compare<T> = fn@(~T, ~T) -> bool;
fn test_generic<@T>(expected: ~T, eq: compare<T>) {
let actual: ~T = { expected };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = { expected };

View file

@ -4,7 +4,7 @@
// -*- rust -*-
// Tests for standalone blocks as expressions with dynamic type sizes
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, eq: compare<T>) {
let actual: T = { expected };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(@T, @T) -> bool;
type compare<T> = fn@(@T, @T) -> bool;
fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
let actual: @T = if true { expected } else { not_expected };

View file

@ -2,7 +2,7 @@
// -*- rust -*-
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected } else { not_expected };

View file

@ -4,7 +4,7 @@
// -*- rust -*-
// Tests for if as expressions with dynamic type sizes
type compare<T> = fn(T, T) -> bool;
type compare<T> = fn@(T, T) -> bool;
fn test_generic<@T>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected } else { not_expected };

View file

@ -1,12 +1,12 @@
fn fix_help<A, @B>(f: fn(fn(A) -> B, A) -> B, x: A) -> B {
fn fix_help<A, @B>(f: fn(fn@(A) -> B, A) -> B, x: A) -> B {
ret f(bind fix_help(f, _), x);
}
fn fix<A, @B>(f: fn(fn(A) -> B, A) -> B) -> fn(A) -> B {
fn fix<A, @B>(f: fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
ret bind fix_help(f, _);
}
fn fact_(f: fn(&&int) -> int, &&n: int) -> int {
fn fact_(f: fn@(&&int) -> int, &&n: int) -> int {
// fun fact 0 = 1
ret if n == 0 { 1 } else { n * f(n - 1) };
}

View file

@ -1,12 +1,12 @@
fn fix_help<A, ~B>(f: fn(fn(A) -> B, A) -> B, x: A) -> B {
fn fix_help<A, ~B>(f: fn(fn@(A) -> B, A) -> B, x: A) -> B {
ret f(bind fix_help(f, _), x);
}
fn fix<A, ~B>(f: fn(fn(A) -> B, A) -> B) -> fn(A) -> B {
fn fix<A, ~B>(f: fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
ret bind fix_help(f, _);
}
fn fact_(f: fn(&&int) -> int, &&n: int) -> int {
fn fact_(f: fn@(&&int) -> int, &&n: int) -> int {
// fun fact 0 = 1
ret if n == 0 { 1 } else { n * f(n - 1) };
}

View file

@ -5,6 +5,6 @@ fn# f<T>(i: T, j: T, k: T) {
fn main() {
// Binding a bare function turns it into a shared closure
let g: fn() = bind f(10, 10, 20);
let g: fn@() = bind f(10, 10, 20);
g();
}

View file

@ -4,6 +4,6 @@ fn# f(i: int) {
fn main() {
// Binding a bare function turns it into a shared closure
let g: fn() = bind f(10);
let g: fn@() = bind f(10);
g();
}

View file

@ -1,5 +1,5 @@
// -*- rust -*-
fn ho(f: fn(int) -> int) -> int { let n: int = f(3); ret n; }
fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); ret n; }
fn direct(x: int) -> int { ret x + 1; }

View file

@ -26,7 +26,7 @@ mod map_reduce {
export mapper;
export map_reduce;
type putter = fn(str, str);
type putter = fn@(str, str);
type mapper = fn(str, putter);

View file

@ -1,4 +1,4 @@
fn quux<@T>(x: T) -> T { let f = id::<T>; ret f(x); }
fn quux<@T>(x: T) -> T { let f = bind id::<T>(_); ret f(x); }
fn id<@T>(x: T) -> T { ret x; }

View file

@ -1,5 +1,5 @@
// Make sure we don't leak lambdas in silly ways.
fn force(f: fn()) { f() }
fn force(f: fn@()) { f() }
fn main() {
let x = 7;
lambda () { log_err x; };

View file

@ -1,5 +1,5 @@
fn add(i: int, j: int) -> int { ret i + j; }
fn binder(n: int) -> fn() -> int { let f = bind add(n, _); ret bind f(2); }
fn binder(n: int) -> fn@() -> int { let f = bind add(n, _); ret bind f(2); }
fn main() {
binder(5);
let f = binder(1);

View file

@ -13,7 +13,7 @@ fn pure_foldl<@T, @U>(ls: list<T>, u: U, f: block(T, U) -> U) -> U {
// fn from a pure fn
pure fn pure_length<@T>(ls: list<T>) -> uint {
fn count<T>(_t: T, &&u: uint) -> uint { u + 1u }
unchecked{ pure_foldl(ls, 0u, count) }
unchecked{ pure_foldl(ls, 0u, bind count(_, _)) }
}
pure fn nonempty_list<@T>(ls: list<T>) -> bool { pure_length(ls) > 0u }

View file

@ -79,7 +79,7 @@ fn test_boxes(a: @int, b: @int, c: @int, d: @int) {
assert (deq.get(3) == d);
}
type eqfn<T> = fn(T, T) -> bool;
type eqfn<T> = fn@(T, T) -> bool;
fn test_parameterized<@T>(e: eqfn<T>, a: T, b: T, c: T, d: T) {
let deq: deque::t<T> = deque::create::<T>();
@ -178,7 +178,7 @@ fn test() {
two(17, 42));
log "*** test parameterized: taggypar<int>";
let eq4: eqfn<taggypar<int>> = taggypareq::<int>;
let eq4: eqfn<taggypar<int>> = bind taggypareq::<int>(_, _);
test_parameterized::<taggypar<int>>(eq4, onepar::<int>(1),
twopar::<int>(1, 2),
threepar::<int>(1, 2, 3),

View file

@ -12,7 +12,7 @@ import std::option;
fn test_simple() {
log "*** starting test_simple";
fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; }
let hasher_uint: map::hashfn<uint> = util::id;
let hasher_uint: map::hashfn<uint> = bind util::id(_);
let eqer_uint: map::eqfn<uint> = eq_uint;
let hasher_str: map::hashfn<str> = str::hash;
let eqer_str: map::eqfn<str> = str::eq;
@ -85,7 +85,7 @@ fn test_growth() {
let num_to_insert: uint = 64u;
fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; }
log "uint -> uint";
let hasher_uint: map::hashfn<uint> = util::id;
let hasher_uint: map::hashfn<uint> = bind util::id(_);
let eqer_uint: map::eqfn<uint> = eq_uint;
let hm_uu: map::hashmap<uint, uint> =
map::mk_hashmap::<uint, uint>(hasher_uint, eqer_uint);