[erlang-questions] ets:file2tab/1 question

Sverker Eriksson <>
Thu Jun 12 10:29:13 CEST 2008


Per Melin wrote:
> 2008/6/11 DougEdmunds <>:
>   
>> In the docs for the ets module:
>>
>> file2tab(Filename) -> {ok,Tab} | {error,Reason}
>>
>> Types:
>>
>> Filename = string() | atom()
>> Tab = tid() | atom()
>> Reason = term()
>>
>> Can someone provide an example where
>> Tab returns an atom() and not a tid()?
>>     
>
> 1> ets:new(foo, [named_table]).
> foo
> 2> ets:tab2file(foo, "foo.ets").
> ok
> 3> ets:delete(foo).
> true
> 4> ets:file2tab("foo.ets").
> {ok,foo
Every ets table has a an opaque tid(). Named tables also have a name 
(atom()).

In current implementation however, the opaque tid() of a named table 
happens to be the same as the name. But this is not guaranteed by the 
interface.

So, the statement "Tab = tid() | atom()" would to imply that 
ets:file2tab returns the tid() for an unnamed table and the name for a 
named table.

/Sverker, Erlang OTP Ericsson




More information about the erlang-questions mailing list