[erlang-questions] please never make spec required

Steve Davis steven.charles.davis@REDACTED
Wed Feb 18 15:03:40 CET 2009


Please, please *never* make spec a required part of Erlang.

How can a spec be justified when a spec can be both longer and harder
to read than the code. e.g.: from lists...
-spec(append/2 :: ([T],[T]) -> [T]).
append(L1, L2) -> L1 ++ L2.

...much like java generics which tried to make types compile-time
safe, this is well-meaning BS in my book. I confidently predict that
the cost(s) of spec will be far, far greater than the reward(s)...

Major concerns for me are:
- code bloat
- source file obfuscation (yes it's harder to read a module with specs
in it)
- having to find and look up a type() to understand something
- specs that include dynamic elements i.e. funs (yes, that's *code*,
people, and they will need debugging) e.g. again from lists:
       -spec(merge/3 :: (fun((X, Y) -> bool()), [X], [Y]) -> [_]).
- specs that are wrong or get out of sync with the code (which they
will)

Really, hold your hand on your heart, and tell me how...
-spec(foldl/3 :: (fun((T, _) -> _), _, [T]) -> _).
...helps anyone at all?

Well, that's my 2c -- do as you see fit, but please, please, never
make me do this!

/s




More information about the erlang-questions mailing list