anchor.diff:      [['when'|Ts]|Body].
   
   %% comp_let(VarBindings, Body, Env, L, State) -> {c_let()|c_case(),State}.
  -%%  Compile a let expr. We are a little cunning in that we specialise
  -%%  the the case where all the patterns are variables and there are no
  -%%  guards, the simple case.
  +%%  Compile a let expr. First evaluate all the value expressions in
  +%%  parallel so they don't inherit variables, then build nested cases
  +%%  to do matching optimising case where value bound to variable. Use
  +%%  nested cases so match fail only give one value. Probably not worth
  +%%  the effort as optimiser would do it.
   
   comp_let(Vbs, B, Env, L, St0) ->
  -    %% Test if this is a simple let, i.e. no matching.
  -    Simple = all(fun ([Pat,_]) -> is_atom(Pat);
  -                     (_) -> false               %Has guard
  -                 end, Vbs),
  -    case Simple of
  -        true ->
  -            %% This is not really necessary, but fun.
  -            {Cvs,Pvs,[],St1} = comp_lambda_args([ V || [V|_] <- Vbs ], L, St0),
  -            Efun = fun ([_,E], St) -> comp_expr(E, Env, L, St) end,
  -            {Ces,St2} = mapfoldl(Efun, St1, Vbs),
  -            {Cb,St3} = comp_body(B, add_vbindings(Pvs, Env), L, St2),
  -            {ann_c_let([L], Cvs, ann_c_values([L], Ces), Cb),St3};
  -        false ->
  -            %% This would be much easier to do by building a clause
  -            %% and compiling it directly, but then we would have to
  -            %% build a tuple to hold all values.
  -            Pfun = fun ([P|_], {Psvs,Vsts,Sta}) ->
  -                           {Cp,Pvs,Vts,Stb} = pattern(P, L, Sta),
  -                           {Cp,{union(Pvs, Psvs),Vsts ++ Vts,Stb}}
  -                   end,
  -            {Cps,{Pvs,Vts,St1}} = mapfoldl(Pfun, {[],[],St0}, Vbs),
  -            %% Build a sequence of guard tests.
  -            Gfun = fun ([_,['when'|G]|_], Cgs) -> G ++ Cgs;
  -                       (_, Cgs) -> Cgs
  -                   end,
  -            Gs = Vts ++ foldr(Gfun, [], Vbs),	%The variable tests
  -            Efun = fun ([_,_,E], St) -> comp_expr(E, Env, L, St);
  -                       ([_,E], St) -> comp_expr(E, Env, L, St)
  -                   end,
  -            {Ces,St2} = mapfoldl(Efun, St1, Vbs),
  -            Env1 = add_vbindings(Pvs, Env),
  -            {Cg,St3} = comp_guard(Gs, Env1, L, St2),
  -            {Cb,St4} = comp_body(B, Env1, L, St3),
  -            {Cvs,St5} = new_c_vars(length(Ces), L, St4),
  -            Cf = let_fail(Cvs, L, St5),
  -            {ann_c_case([L], ann_c_values([L], Ces),
  -                        [ann_c_clause([L], Cps, Cg, Cb),Cf]),
  -             St5}
  -    end.
  -
  -let_fail(Cvs, L, St) ->
  -    fail_clause(Cvs, c_tuple([c_atom(badmatch),c_tuple(Cvs)]), [], L, St).
  +    {Cvs,Ces,Cms,St1} = comp_let_vbs(Vbs, Env, L, St0),
  +    {Cb,St2} = comp_let_body(Cms, B, add_vbindings(Cvs, Env), L, St1),
  +    %% Build nesting let which evaluates expressions first.
  +    {ann_c_let([L], Cvs, ann_c_values([L], Ces), Cb),St2}.
  +
  +comp_let_vbs(Vbs, Env, L, St) ->
  +    Fun = fun ([V,E], {Cvs,Ces,Cms,St0}) when is_atom(V) ->
  +                  {Ce,St1} = comp_expr(E, Env, L, St0),
  +                  {[c_var(V)|Cvs],[Ce|Ces],Cms,St1};
  +              ([P,E], {Cvs,Ces,Cms,St0}) ->
  +                  {V,St1} = new_var(St0),
  +                  {Ce,St2} = comp_expr(E, Env, L, St1),
  +                  {[c_var(V)|Cvs],[Ce|Ces],[{P,[],V}|Cms],St2};
  +              ([P,['when'|G],E], {Cvs,Ces,Cms,St0}) ->
  +                  {V,St1} = new_var(St0),
  +                  {Ce,St2} = comp_expr(E, Env, L, St1),
  +                  {[c_var(V)|Cvs],[Ce|Ces],[{P,G,V}|Cms],St2}
  +          end,
  +    lists:foldr(Fun, {[],[],[],St}, Vbs).
  +
  +comp_let_body([{P,G,V}|Cms], B, Env0, L, St0) ->
  +    Cv = c_var(V),
  +    {Cp,Pvs,Vts,St1} = pattern(P, L, St0),
  +    Env1 = add_vbindings(Pvs, Env0),
  +    {Cg,St2} = comp_guard(Vts ++ G, Env1, L, St1),
  +    {Cb,St3} = comp_let_body(Cms, B, Env1, L, St2),
  +    Cf = let_fail(Cv, L, St3),
  +    {ann_c_case([L], Cv, [ann_c_clause([L], [Cp], Cg, Cb),Cf]),St3};
  +comp_let_body([], B, Env, L, St0) ->
  +    {Cb,St1} = comp_body(B, Env, L, St0),
  +    {Cb,St1}.
  +
  +let_fail(Cv, L, St) ->
  +    fail_clause([Cv], c_tuple([c_atom(badmatch),Cv]), [], L, St).
   
   %% comp_let_function(FuncBindngs, Body, Env, Line, State) ->
   %%      {c_letrec(),State}.
  
positive.code:                    Ar = length(Cas),
                     Ann = line_file_anno(Li, Sta),
                     case get_fbinding(Fun, Ar, En) of
                         {yes,M,F} ->             %Import
                             {ann_c_call(Ann, c_atom(M), c_atom(F), Cas),Sta};
                         {yes,Name} ->
                             %% Might have been renamed, use real function name.
  
negative.code:                 false ->
                      case lfe_internal:is_erl_bif(Name, Ar) of
                          true ->                 %Auto-imported Erlang BIF
                              {yes,erlang,Name};
                          false -> no
                      end
              end
  