The New and Improved edoc

Richard Carlsson richardc@REDACTED
Wed Feb 25 15:46:14 CET 2004


On Wed, 25 Feb 2004, Ulf Wiger wrote:

> Is there some profound reason why Variable '::' Type isn't allowed on
> the right-hand side of a function spec? I can write Variable or Type,
> but not Variable::Type.

Yes - the reason is that the whole of the right-hand side (after the
'->') is a single type expression, just like each separate Type in
'Variable::Type'. The signature says "the parameters of this function
have these names and these types, and the return value has that type".

> I'd like to be able to write
>
> %% @spec handle_call(Request::request(), From::from(), State::state()) ->
> %%            {reply, Reply::reply(), NewState::state()}
>
> so that I can refer to NewState in the following @doc, but this is not
> allowed. I can give it a name or a type, but not both. Vexing.

The way to do that today is of course:

%% @spec handle_call(Request::request(), From::from(), State::state()) ->
%%            {reply, Reply, NewState}
%%        Reply = reply()
%%        NewState = state()

but I know that this is something that has many people confused and/or
vexed. If one would regard 'Name::...' as metadata in a type expression,
without any further meaning, then I think it works. I'll see if it can
be added.

	/Richard


Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED	WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list