erlangets

Why to assign a name for an ETS table that is not a named_table?


What is the point providing names to ETS tables created via ets:new/2 without named_table flag? Does it make any difference what I put there?


Solution

  • With ETS table created without the named_table flag:

    • You can use several times the same name for different tables.
    • You cannot use the name to access to those tables, you must use the table identifier (if you try, you get an exception error which may destroy the table if you do it in the ETS owner process).
    • In observer's Table Viewer, the name of not named_table is displayed, thus it can be interesting to give a meaningful name anyway.

    This feature is useful, for example, when a code spawns identical processes or a groups of processes, running in parallel and using each their own ETS table.