[erlang-questions] Edoc optional function parameters

Matt Williamson dawsdesign@REDACTED
Mon Aug 18 20:06:05 CEST 2008


Thank you. That's good enough.

On Mon, Aug 18, 2008 at 1:18 PM, Richard Carlsson <richardc@REDACTED> wrote:

> Matt Williamson wrote:
> > Hello,
> >
> > In the docs for gen_server, there for example is call/2,3, two
> > signatures for the same base function. How do I use edoc to do something
> > similar? Basically I want one argument to be optional without writing a
> > @spec for each one. Here's what I have now:
> >
> > %%===================================================================
> > %% API
> > %%===================================================================
> > %%-------------------------------------------------------------------
> > %% @spec put(Node, Key, Value) -> Result
> > %%     Result = {ok, inserted, Key} | {error, notinserted}
> > %%     Key = term()
> > %%     Value = term()
> > %%     Node = node()
> > %% @doc Inserts a Key, Value pair into the server.
> > %%-------------------------------------------------------------------
> > put(Key, Value) ->
> >     put(node(), Key, Value).
> >
> > put(Node, Key, Value) ->
> >     gen_server:call({simpledb_svr, Node}, {insert, Key, Value}).
>
> You currently need to provide a spec for both, but for put/2, you
> can write "@equiv put(node(), Key, Value)" instead of the @doc.
>
>    /Richard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080818/6eeea04b/attachment.htm>


More information about the erlang-questions mailing list