blog.programfan.info
新网站即将启用

[摘]erlang spec 内置类型

Type :: any() %% The top type, the set of all Erlang terms.
| none() %% The bottom type, contains no terms.
| pid()
| port()
| ref()
| [] %% nil
| Atom
| Binary
| float()
| Fun
| Integer
| List
| Tuple
| Union
| UserDefined %% described in Section 2
Union :: Type1 | Type2 Atom :: atom()
| Erlang_Atom %% 'foo', 'bar', ...
Binary :: binary() %% <<_:_ * 8>>
| <<>>
| <<_:Erlang_Integer>> %% Base size
| <<_:_*Erlang_Integer>> %% Unit size
| <<_:Erlang_Integer, _:_*Erlang_Integer>>

Fun :: fun()
%% any function
| fun((...) -> Type) %% any arity, returning Type
| fun(() -> Type)
| fun((TList) -> Type)
Integer :: integer()
| Erlang_Integer %% ..., -1, 0, 1, ... 42 ...
| Erlang_Integer..Erlang_Integer %% specifies an integer range

List :: list(Type)
%% Proper list ([]-terminated)
| improper_list(Type1, Type2) %% Type1=contents, Type2=termination
| maybe_improper_list(Type1, Type2) %% Type1 and Type2 as above

Tuple :: tuple()
%% stands for a tuple of any size
| {}
| {TList}

TList :: Type
| Type, TList

========================== =====================================
Built
-in type Stands for
========================== =====================================
``term()`` ``any()``
``
bool()`` ``'false' | 'true'``
``
byte()`` ``0..255``
``
char()`` ``0..16#10ffff``
``non_neg_integer()`` ``
0..``
``pos_integer()`` ``
1..``
``neg_integer()`` ``..
-1``
``number()`` ``integer()
| float()``
``list()`` ``[any()]``
``maybe_improper_list()`` ``maybe_improper_list(any(), any())``
``maybe_improper_list(T)`` ``maybe_improper_list(T, any())``
``
string()`` ``[char()]``
``nonempty_string()`` ``[
char(),...]``
``iolist()`` ``maybe_improper_list(``
``
char() | binary() |``
``iolist(), binary()
| [])``
``module()`` ``atom()``
``mfa()`` ``{atom(),atom(),
byte()}``
``node()`` ``atom()``
``timeout()`` ``
'infinity' | non_neg_integer()``
``no_return()`` ``none()``
========================== =====================================

摘自:这儿


posted @ 2011-04-25 11:29  Gordon Chao  Views(2066)  Comments(0Edit  收藏  举报
www.programfan.info
新网站即将启用