[erlang-questions] Where is an ets guide?

Bob Ippolito <>
Fri Sep 22 19:58:50 CEST 2006


On 9/22/06, Jeff Crane <> wrote:
> > > ets:new(mytable,[]).
> > > 16 % that's a tid!
> >
> > Identifiers are supposed to be opaque.. just like
> > the internal
> > representation of dict, etc.
>
>  I dont know anything about dict. that doesnt help me
> understand what mytable is for.

It has nothing to do with dict specifically. Table identifiers are
opaque. You don't care what they look like, just like you shouldn't
care what the internal representation of a record is or the internal
representation of a dict or anything else. Just cause it happens to be
an integer doesn't mean anything.

> > > ets:insert(mytable,{1,"first"}).
> > > % Nope...wtf?
> >
> > mytable isn't the Tid, and you didn't ask for a
> > named table.
>
> What are you talking about? I made a table with a name
> atom of mytable, what is that other than the table
> name?

It doesn't have a name because you didn't use the named_table option.
Did you read the reply I sent?

> > > MyTable2 = ets:new(mytable2,[]).
> > > 19 % that's a tid!
> > >
> > > ets:insert(MyTable2,{2,"second"}).
> > > % true? Um, I'm lost.
> >
> > How lost could you be?
> > > What's the point of the name atom?
> What's the point of the name atom?
> You didn't answer the question, of course I'm lost.
>
> Why is MyTable2 the table reference, when mytable2
> should be the correct reference? What's the point of
> mytable2 if it's not the named reference? Sheesh.

I specifically pointed you to the named_table option, which gives
tables a name. If you don't specify the named_table option, the name
you give it is completely ignored and you have to use the tid.
MyTable2 is a reference to the tid.

> > It helps to read *all* of the docs for a function.
> > There's a
> > named_table option, which lets you specify the Tid
> > as an atom:
> >
> > * named_table  If this option is present, the name
> > Name is associated
> > with the table identifier. The name can then be used
> > instead of the
> > table identifier in subsequent operations.

Why didn't you read this part of the reply?

-bob



More information about the erlang-questions mailing list