[erlang-questions] Built In Types
Mon Apr 16 23:01:59 CEST 2012
On 04/16/2012 10:16 PM, maxim minin wrote:
> Hi Erlangers,
> i try to define a type "product" like:
> -type product :: 'A'|'B'|'C'.
> But the compiler complains"type product() already defined".
> At http://www.erlang.org/doc/reference_manual/typespec.html is "product" not in the list of built-in types.
> So i have two quetions:
> Is "product" really a built-in type?
Hmmm... Nice discrepancy detected! This was actually news to me.
Turns out that there are four atom names, which are not built-in types,
but are instead used internally by the type system and are in principle
defined for all arities. These are listed in lib/stdlib/src/erl_lint.erl
is_var_arity_type(tuple) -> true;
is_var_arity_type(product) -> true;
is_var_arity_type(union) -> true;
is_var_arity_type(record) -> true;
is_var_arity_type(_) -> false.
So, for the time being, you cannot use the atoms 'tuple', 'product',
'union' or 'record' as names of types. These should be a note of that in
the reference_manual (or perhaps revise the representation to use less
common atoms for some of these, e.g. '$$product').
Sorry for the inconvenience...
> Is it possible to show all built-in types in erlang shell?
More information about the erlang-questions