erlang的erl_eval

自己尝试使用erl_eval做一些联系,发掘改模块的功能:
[root@dev-emp-com work]# erl
Erlang R14B (erts-5.8.1) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.1  (abort with ^G)
1> Binding1 = erl_eval:new_bindings().
[]
2> Binding2 = erl_eval:add_binding('A', 1, Binding1).
[{'A',1}]
3> Binding3 = erl_eval:add_binding('C', 2, Binding2).
[{'A',1},{'C',2}]
4> rel_eval:binding('A', Binding3).
** exception error: undefined function rel_eval:binding/2
5> erl_eval:binding('A', Binding3).
{value,1}
6> erl_eval:binding('B', Binding3).
unbound
7> erl_eval:bindings(Binding3).     
[{'A',1},{'C',2}]
8> erl_eval:del_binding('A', Binding3).
[{'C',2}]
9> erl_eval:binding('C', Binding3).    
{value,2}
10> erl_eval:bindings(Binding3).        
[{'A',1},{'C',2}]
11> Binding4 = erl_eval:del_binding('A', Binding3).
[{'C',2}]
12> erl_eval:bindings(Binding4).                   
[{'C',2}]
13> {ok, Ts, _} = erl_scan:string("io:format(\"A is:~p~n\", [A]).").
{ok,[{atom,1,io},
     {':',1},
     {atom,1,format},
     {'(',1},
     {string,1,"A is:~p~n"},
     {',',1},
     {'[',1},
     {var,1,'A'},
     {']',1},
     {')',1},
     {dot,1}],
    1}
14> {ok, Expr} = erl_parse:parse(Ts).
** exception error: no match of right hand side value 
                    {error,{1,erl_parse,["syntax error before: ","':'"]}}
15> {ok, Expr} = erl_parse:parse_exprs(Ts).                         
{ok,[{call,1,
           {remote,1,{atom,1,io},{atom,1,format}},
           [{string,1,"A is:~p~n"},{cons,1,{var,1,'A'},{nil,1}}]}]}
16> erl_eval:exprs(Expr).
** exception error: undefined function erl_eval:exprs/1
17> erl_eval:exprs(Expr, Binding2).
A is:1
{value,ok,[{'A',1}]}
18> 

你可能感兴趣的:(erlang,erl_eval)