anchor.diff:      end.
   
   handle_call(get_used, _From, #st{used=Used}=St) ->
  -    {stop,normal,gb_sets:to_list(Used),St}.
  +    {stop,normal,gb_sets:to_list(Used),St};
  +handle_call(get_gen, _From, #st{gen=G0}=St) ->
  +    {L,G} = do_get_gen(gb_trees:to_list(G0), [], []),
  +    {reply,L,St#st{gen=gb_trees:from_orddict(G)}};
  +handle_call({gen_func,Prefix,Key,GenFun}, _From, #st{gen=G0,gc=Gc0}=St) ->
  +    case gb_trees:lookup(Key, G0) of
  +	none ->
  +	    Name = list_to_atom(Prefix ++ integer_to_list(Gc0)),
  +	    Gc = Gc0 + 1,
  +	    G = gb_trees:insert(Key, {Name,GenFun}, G0),
  +	    {reply,Name,St#st{gen=G,gc=Gc}};
  +	{value,{Name,_}} ->
  +	    {reply,Name,St}
  +    end.
   
   terminate(_, _) ->
       ok.
  
positive.code: 
  %%% Internal functions.
  
  -record(st, {used}).
  
  init([]) ->
      St = #st{used=gb_sets:empty()},
      {ok,St}.
  
  handle_cast({need,MFA}, #st{used=Used0}=St) ->
  
negative.code:     asn1ct_rtt:assert_defined(MFA),
      cast({need,MFA}).
  
  call_gen(Prefix, Key, Gen, Args) when is_function(Gen, 2) ->
      F = req({gen_func,Prefix,Key,Gen}),
      asn1ct_gen:emit([F,"(",call_args(Args, ""),")"]).
  
  call_gen(Prefix, Key, Gen) when is_function(Gen, 2) ->
      req({gen_func,Prefix,Key,Gen}).
  
  generate(Fd) ->
      do_generate(Fd),
      Used0 = req(get_used),
      erase(?MODULE),
      Used = sofs:set(Used0, [mfa]),
  