Ulf Wiger etxuwig@REDACTED
Sun Jun 9 21:51:48 CEST 2002

On 9 Jun 2002, Lyn A Headley wrote:

>The interpret request fails and says the module must be purged before
>loading.  Ok fine.  code:purge(cothink).  Try again.  Same error!

>(lyn@REDACTED)4> code:purge(cothink).
>(lyn@REDACTED)5> c(cothink, debug_info).
>(lyn@REDACTED)6> debugger:start().
>=ERROR REPORT==== 9-Jun-2002::11:32:27 ===
>Module cothink must be purged before loading

When you run c(cothink, debug_info), the module is automatically
loaded. The c() function compiles _and_ loads the file.
>From c.erl:

c(File, Opt) when atom(Opt) -> c(File, [Opt]);
c(File, Opts0) ->
    Opts = [report_errors,report_warnings|Opts0],
    case compile:file(File, Opts) of
        {ok,Mod} ->                             %Listing file.
            machine_load(Mod, File, Opts);
        {ok,Mod,Ws} ->                          %Warnings ...
            machine_load(Mod, File, Opts);
        Other ->                                %Errors go here

If you want to compile, but not load, a file, use
compile:file(File, Options) - in this case:

  compile:file(File, [debug_info]).

(I know that compile:file(File, debug_info) works, but I don't
like it, partly because compile.erl only recognizes singleton
options that are atoms -- so it's inconsistent -- and partly
because it is, as far as I can tell, an undocumented feature.)

Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson Telecom AB, ATM Multiservice Networks

More information about the erlang-questions mailing list