[erlang-questions] Spec is diabolical IMHO

Steve Davis steven.charles.davis@REDACTED
Wed Sep 26 02:38:04 CEST 2012

Can someone who knows better explain how this evil child of -spec:

%% @doc The gen_server code_change/3 callback, called when performing
%% a hot code upgrade on the server. Currently unused.
-spec code_change(OldVsn, State, Extra) -> {ok, State} | {error, Reason}
      OldVsn :: Vsn | {down, Vsn},
      Vsn :: term(),
      State :: #state{},
      Extra :: term(),
      Reason :: term().
code_change(_OldVsn, State, _Extra) -> {ok, State}.

...is not a total waste of too many talented people's time over the more transparent:

code_change(_OldVsn, State = #state{}, _Extra) -> {ok, State}.

...or is spec just a diabolical case of over-engineering that is at once both incredibly onerous and bug-prone justified in the cause of the weaknesses of some ill-designed test tool?

My gut reaction is that if you feel that you NEED TO DO TDD style testing, you should take the time parse the source and not bloat it beyond readability by inflicting conventions on the development of the source that will simply distract and so *cause* the bugs you think that you are testing for.

A better use of developer time would be to enforce documentation of the intention of the function.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120925/3c9a8be6/attachment.htm>

More information about the erlang-questions mailing list