| 1 | = Spec-param entity = |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | == Selectors == |
| 6 | |
| 7 | ''The type of the result elements are indicated in parenthesis.'' |
| 8 | |
| 9 | * {{{type}}} (''type''): The type expression of the spec-parameter. |
| 10 | |
| 11 | == Properties == |
| 12 | |
| 13 | The following properties are defined for spec-param entities: |
| 14 | |
| 15 | * {{{name}}} (''atom''): Name of the spec-parameter. |
| 16 | * {{{index}}} (''int''): Index of the spec-parameter in the corresponding clause. |
| 17 | * {{{text}}} (''string''): String representation of the spec-parameter. |
| 18 | |
| 19 | == Textual output format == |
| 20 | |
| 21 | When using any of our interfaces, other than [ScriptableInterface 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.) |
| 22 | |
| 23 | {{{ |
| 24 | ri:q("mods.spec.params"). |
| 25 | -spec io:format(Format :: string(), list()) -> string(). |
| 26 | Format :: string() |
| 27 | list() |
| 28 | }}} |
| 29 | |
| 30 | == Review of non-trivial selectors == |
| 31 | 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: |
| 32 | |
| 33 | === Specparam.type: === |
| 34 | Returns the type or type expression of the given specparam. (Single-atom type expressions are filtered.) |
| 35 | {{{ |
| 36 | ri:q("mods.spec"). |
| 37 | a.erl |
| 38 | -spec io_lib:format(Format :: io:format(), list(term())) -> [char]. |
| 39 | ... |
| 40 | ok |
| 41 | ri:q("mods.spec.param.type"). |
| 42 | Format :: io:format() |
| 43 | Format :: io:format() |
| 44 | list(term()) |
| 45 | erlang:list/1 |
| 46 | ... |
| 47 | }}} |
| 48 | |
| 49 | === Specparam.name: === |
| 50 | Returns the name of the specparam as a string. If the name was omitted, returns "undefined". |
| 51 | {{{ |
| 52 | ri:q("mods.spec"). |
| 53 | a.erl |
| 54 | -spec io_lib:format(Format :: io:format(), list(term())) -> [char]. |
| 55 | ... |
| 56 | ok |
| 57 | ri:q("mods.spec.param.name"). |
| 58 | Format :: io:format() |
| 59 | name = "Format" |
| 60 | list(term()) |
| 61 | name = "undefined" |
| 62 | ... |
| 63 | }}} |