[erlang-questions] Where to find a full list of OTP built-in types specifications?

Gary Hai <>
Fri Oct 28 08:03:19 CEST 2011


It seems erl_types.erl contains the mystery of types definitions and internal checks. And the dict() type declaration is hard-coded, so we can use the dict() type. But I still can't find single document to list dict() and other  hidden types declarations.

On Oct 27, 2011, at 6:18 PM, Michael Richter wrote:

> From http://www.erlang.org/doc/man/dict.html:
> 
> The representation of a dictionary is not defined.
> 
> That being said, cracking open the code for lib/stdlib/dict.erl I find:
> 
> -record(dict,
> 	{size=0		      :: non_neg_integer(),   	% Number of elements
> 	 n=?seg_size	      :: non_neg_integer(),   	% Number of active slots
> 	 maxn=?seg_size	      :: non_neg_integer(),	% Maximum slots
> 	 bso=?seg_size div 2  :: non_neg_integer(),   	% Buddy slot offset
> 	 exp_size=?exp_size   :: non_neg_integer(),   	% Size to expand at
> 	 con_size=?con_size   :: non_neg_integer(),   	% Size to contract at
> 	 empty		      :: tuple(),		% Empty segment
> 	 segs		      :: tuple()	      	% Segments
> 	}).
> %% A declaration equivalent to the following one is hard-coded in erl_types.
> %% That declaration contains hard-coded information about the #dict{}
> %% structure and the types of its fields.  So, please make sure that any
> %% changes to its structure are also propagated to erl_types.erl.
> %%
> %% -opaque dict() :: #dict{}.
> 
> On 26 October 2011 15:03, Gary Hai <> wrote:
> Thanks a lot. I want to get the full list of built-in types spec, while as dict() is missed in official document but is used anywhere. So another question is where is the built-in types specs declared, specially, the dict() type.
>> ./lib/compiler/src/rec_env.erl:-type mapping()     :: {'map', dict()} | {'rec', dict(), dict()}.
> 
> On Oct 26, 2011, at 12:30 PM, Michael Richter wrote:
> 
>> :~/Development/Erlang/otp_src_R14B04$ for a in type spec ; do grep "^-$a" $(find . -name *.erl -or -name *.hrl) ; done
>> ./bootstrap/lib/parsetools/include/yeccpre.hrl:-type yecc_ret() :: {'error', _} | {'ok', _}.
>> ./bootstrap/lib/stdlib/include/erl_bits.hrl:-type bt_endian():: 'big' | 'little' | 'native'.
>> ./bootstrap/lib/stdlib/include/erl_bits.hrl:-type bt_sign()  :: 'signed' | 'unsigned'.
>> ./bootstrap/lib/stdlib/include/erl_bits.hrl:-type bt_type()  :: 'integer' | 'float' | 'binary' | 'utf8' | 'utf16' | 'utf32'.
>> ./bootstrap/lib/stdlib/include/erl_bits.hrl:-type bt_unit()  :: 1..256.
>> ./lib/compiler/test/compile_SUITE.erl:-type all_return_type() :: [atom()].
>> ./lib/compiler/src/rec_env.erl:-type mapping()     :: {'map', dict()} | {'rec', dict(), dict()}.
>> ./lib/compiler/src/rec_env.erl:-type environment() :: [mapping(),...].
>> ./lib/compiler/src/v3_core.erl:-type iapply()    :: #iapply{}.
>> ./lib/compiler/src/v3_core.erl:-type ibinary()   :: #ibinary{}.
>> ./lib/compiler/src/v3_core.erl:-type icall()     :: #icall{}.
>> ./lib/compiler/src/v3_core.erl:-type icase()     :: #icase{}.
>> ./lib/compiler/src/v3_core.erl:-type icatch()    :: #icatch{}.
>> ./lib/compiler/src/v3_core.erl:-type iclause()   :: #iclause{}.
>> ./lib/compiler/src/v3_core.erl:-type ifun()      :: #ifun{}.
>> ./lib/compiler/src/v3_core.erl:-type iletrec()   :: #iletrec{}.
>> ./lib/compiler/src/v3_core.erl:-type imatch()    :: #imatch{}.
>>>> 
>> From there redirect to a file or run it for further processing through an awk script and you've got a list of all types and function specifications in the entire distribution arranged however you like it.
>> 
>> On 26 October 2011 10:31, Gary Hai <> wrote:
>> Hi all,
>> 
>> I am eager for a full list of all built-in types and function specifications as reference manual for erlang coding. The erlang reference manual ( http://www.erlang.org/doc/reference_manual/typespec.html) of type specs page does not include OTP module, so I think it is not a full list.
>> 
>> Thanks,
>> 
>> Gary
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>> 
>> 
>> 
>> 
>> -- 
>> "Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot."
>> --Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
> 
> 
> 
> 
> -- 
> "Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot."
> --Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111028/0b79dece/attachment.html>


More information about the erlang-questions mailing list