Parametric Identifier Component

The parametric identifier component is the part of an identifier used to abstract away part of the value or type of a member. It can be thought of as the value parameter list of a function.

It is represented by a listing of contract members each separated by a comma , and together surrounded by parentheses ( ). For instance, the following snippet:

id(a: '', b: '') = a b

represents a concrete member parametrically identified with two string parameters.

Important

It is in fact possible to refer to the parameters of a parametric identifier (only in the value assigned, and/or in the type ascribed, to this parametric identifier component) as if they were concrete members, despite their “contract member shape”. The actual value of the parameters depend on the parametric accessor used to access their parametric identifier.

Note

Two parametric identifiers a and b are identical when a has the same amount of parameters as b and when the types of all parameters of a are exactly the same as, and appear in exactly the same order as, the types of the parameters of b. For instance, the following snippet:

[
    id(a: []): ''
    id(b: []): Any
]

would abruptly halt the execution of the interpreter with the following informative message:

error: found duplicated definitions for id(: []):
at <row>:<col>:
    id(a: []): ''
    ^
at <row>:<col>:
    id(b: []): Any
    ^

Under the hood, the parametric identifier components are compared only using the type of their parameters and their declared order. The error is caused by both identifiers having the same types in the same order, independently of their names.

Note also that two identified types, where one is a subtype of the other (while the other is not), can coexist in the same structural value or type. Identified types can therefore be used to disambiguate parametric identifiers.