I didn't find specific description in doc and only could learn from codes.
1. Or we Only need it when argument is a function as following?
#List.map (function n -> n * 2 + 1) [0;1;2;3;4];;
- : int list = [1; 3; 5; 7; 9]
2. Like in the complicated case, it's hard to read.
Or we don't need care about it?
let rec trans (env : vartype V.t) (node : ast_node) =
let rec trdec = function
A.FunctionDec functions ->
let mk_param fenv (name, typ, pos) =
let t = lookup_base_type env typ pos in
V.enter_param fenv name t (is_ptr t)
in
let mk_func_env (name, params, typ, _, pos) =
let ret_type = match typ with
Some x -> lookup_base_type env x pos
| None -> UNIT
and types = List.map (fun(_,t,p)-> lookup_base_type env t p)
params in
let fenv = V.enter_fun env name None types ret_type in
List.iter (mk_param fenv) params;
fenv
in
let trans_func fenv (_, _, _, body, _) =
let b = trans fenv (EXP body) in
add_function (V.frame fenv) b
in
let envs = (List.map mk_func_env functions) in
List.iter2 trans_func envs functions;
T.nil
| A.VarDec(name, typ, init, pos) ->
let e,t = trexp init in
......
[Non-text portions of this message have been removed]
.