[erlang-questions] Where is an ets guide?

Michael McDaniel erlangX@REDACTED
Fri Sep 22 01:33:10 CEST 2006


On Thu, Sep 21, 2006 at 04:21:26PM -0700, Bob Ippolito wrote:
> On 9/21/06, Jeff Crane <jefcrane@REDACTED> wrote:
> > I would like to find an ets usage guide?
> >
> >
> > I had to type in "ets:new erlang" to Google just to
> > come up with a half tutorial that just raises more
> > questions.
> >
> > http://schemecookbook.org/Erlang/HashChapter
> > ---
> > dict provides a simple dictionary implementation, in
> > which values (of any Erlang type) can be stored and
> > accessed by keys (Erlang terms). ets has a similar
> > interface, but is designed for dealing with vast
> > quantities of
> > data.
> > ---
> > What does that mean? They are the same, but not, and
> > one is designed for dealing with lots of data, and
> > dict is for something else entirely, like making
> > toast?
> 
> I'm new to Erlang, but I didn't have any problems figuring it out from
> the documentation. I don't know why you're looking at older docs from
> somewhere other than erlang.org though? From erlang.org, click
> "documentation" on the left, then the first link "Erlang/OTP R11B
> documentation".. which takes you to the current docs here:
> http://erlang.org/doc/doc-5.5.1/doc/
> 
> To find docs for a module it'll be under one of the Applications on
> the menu bar in the left. It's anyone's guess which application a
> given module will be in, but I would look in stdlib first, then
> kernel. ets is in stdlib.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  May be easier to click 'Modules' on the left (at top) and then
  find the module ...

~M

> 
> > look around and HOPE new/2 is the correct choice to
> > start...
> >
> > ets:new(Name,Options) -> tid()
> >
> > so I type
> >
> > ets:new(mytable,[]).
> > 16 % that's a tid!
> 
> Identifiers are supposed to be opaque.. just like the internal
> representation of dict, etc.
> 
> > ets:insert(mytable,{1,"first"}).
> > % Nope...wtf?
> 
> mytable isn't the Tid, and you didn't ask for a named table.
> 
> > MyTable2 = ets:new(mytable2,[]).
> > 19 % that's a tid!
> >
> > ets:insert(MyTable2,{2,"second"}).
> > % true? Um, I'm lost.
> 
> How lost could you be? It says very specifically that it always
> returns true. What else would you want it to return?
> 
> > What's the point of the name atom?
> 
> 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.
> 
> > Better yet, where's a halfway decent guide to ETS?
> 
> The docs are pretty sufficient, if you read them.
> 
> -bob
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Michael McDaniel
Portland, Oregon, USA
http://autosys.us
+1 503 283 5284



More information about the erlang-questions mailing list