Spec-param entity
Spec-param entities correspond to parameters of a -spec attribute. Typically these only contain type expressions related to the expected types of parameters in the referenced function's applications, however names can also be specified for parameters in a -spec attribute. Please note that "-spec" definitions can have multiple clauses, and the index property refers to the parameter's index in the containing clause, so there will be multiple spec-param entities with the same index for any such spec-entity.
Selectors
The type of the result elements are indicated in parenthesis.
- type (type): The type expression of the spec-parameter.
Properties
The following properties are defined for spec-param entities:
- name (atom): Name of the spec-parameter.
- index (int): Index of the spec-parameter in the corresponding clause.
- text (string): String representation of the spec-parameter.
Textual output format
When using any of our interfaces, other than ris, this entity will be represented in the output as a string with the same format as it was described in the -spec form. (Including whitespaces.)
ri:q("mods.spec.params"). -spec io:format(Format :: string(), list()) -> string(). Format :: string() list()
Review of non-trivial selectors
For some of the selectors it may not be initially clear how and what would they return. A description of these can be found here:
Specparam.type:
Returns the type or type expression of the given specparam. (Single-atom type expressions are filtered.)
ri:q("mods.spec"). a.erl -spec io_lib:format(Format :: io:format(), list(term())) -> [char]. ... ok ri:q("mods.spec.param.type"). Format :: io:format() Format :: io:format() list(term()) erlang:list/1 ...
Specparam.name:
Returns the name of the specparam as a string. If the name was omitted, returns "undefined".
ri:q("mods.spec"). a.erl -spec io_lib:format(Format :: io:format(), list(term())) -> [char]. ... ok ri:q("mods.spec.param.name"). Format :: io:format() name = "Format" list(term()) name = "undefined" ...