[erlang-questions] Unlike behavior in -spec and type importing

Ivan Carmenates García co7eb@REDACTED
Sun Aug 11 17:14:16 CEST 2013

Hi all,


I was dealing with edoc and -spec attribute and I found a little not liked
behavior regards importing types from another modules.

For examples I was setting the specification of start/2 application start
point function like this:



%%% @doc

%%% Start point of the application.

%%% @end


-spec start(StartType, StartArgs) -> {'ok', Pid} | {'ok', Pid, State} when

                StartType :: application:start_type(), %% @see application
module for start_type() type specification.

                StartArgs :: term(),

                Pid :: pid(),

                State :: term().


start(StartType, StartArgs)->

                . . .

I check the source of application module to see if the start_type() type was
exported and it is not.

And my module compiles well, and even I changed to StartType ::
unknown_module: unknown_type() type and it still compiles,

It seems that there are no type checking outside of the module.


All this could seems a little nothing important thing but, I like to program
in Erlang a lot, even without using any IDE, I like notepad++ with Erlang
colors definition.

And I’m proud of my code and the language even more since I learned that I
can do thing like -spec, -type and documentation.


The same still happens with functions, I can do
non_declared_module:non_declared_fun() and it will compile. Only in runtime
it will fail.





NOTE: I apologies for any bad intention you could think I have with this, I
stand for Erlang and its Community.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130811/794eeb54/attachment.htm>

More information about the erlang-questions mailing list