ETS function not working properly in Erlang

129 views Asked by At

New function of ets gives back a integer instead of atom

    1> A=ets:new(hello,[set]).
       126999
2

There are 2 answers

0
Emil Vikström On BEST ANSWER

ets:new/2 is supposed to return a table identifier of typ tid(). That identifier should be sent to other ets functions to tell what table you are working on.

The identifier now happens to be an integer, but you should not count on that (you cannot add two identifiers together, for example). Only ever use it as an ETS table identifier.

0
rvirding On

It returns an identifier whose type is not defined, currently an integer. If you create a named table then the identifier will be an atom which is its name. So for example:

1> A = ets:new(hello, [set,named_table]).
hello.
2> A.
hello

The table name can now be used as its identifier. This is similar to "naming" processes by registering them.