loading a table from file doesn't work unless inside erl shell

Claes Wikstrom klacke@REDACTED
Sun Apr 30 11:17:59 CEST 2006


Matthias Lang wrote:

> Can you run 'hello world' from bash? If you can do that, then you can
> do anything, i.e. there's nothing special about ets. Here's an
> example:
> 
> Here's hello world:
> 
>    -module(hw).
>    -export([go/1]).
> 
>    go(X) ->
>       io:fwrite("Hello world. My arguments are ~p\n", [X]).

Except that the process owning the ets table must
continue to live. When an ets-owning process dies, all ets
tables created by the process dies.

Thus:

go(File) ->
    spawn(fun() ->
            ets:file2tab(File),
            timer:sleep(infinity)
          end).


/klacke


-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control
cellphone: +46 70 2097763



More information about the erlang-questions mailing list