[erlang-questions] peculiar type spec

Richard Carlsson carlsson.richard@REDACTED
Wed Jan 25 09:57:11 CET 2017


If you refer to that whole line you quoted, then no, that's a "type
declaration". "Index" and "SecondaryKey" are just names that act as
placeholders, and since there is no other type information along with them,
those fields could have any type.

A "type variable" is a variable used as a parameter of the declared type,
as in this example (see section 7.3 in the link you included):

-type orddict(Key, Val) :: [{Key, Val}].

Here, Key and Val are both type variables. You could for exampe use this to
define another type, like so:

-type my_dict() :: orddict(atom(), integer()).


        /Richard

2017-01-24 23:02 GMT+01:00 Raghav Karol <raghav.karol@REDACTED>:

> I recently came across this type specification
>
> -type index_spec() :: {add, Index, SecondaryKey} | {remove, Index,
> SecondaryKey}.
>
> * Is this a `type variable', see [1] and how does one interpret it?
>
> Best,
> Raghav
>
> [1] http://erlang.org/doc/reference_manual/typespec.html
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170125/80987d34/attachment.htm>


More information about the erlang-questions mailing list