New Issue: CG: allow implicit/inferred 'implements' declarations?

16952, “vasslitvinov”, “CG: allow implicit/inferred ‘implements’ declarations?”, “2021-01-15T00:35:04Z”

main issue: #8629

Should interfaces be “structural” or “nominative”?

An interface constraint is always satisfied when there is a visible declaration for that. (visibility: #16731)
In addition:

Structural : It is satisfied also when we can “infer” it, i.e. when all required interface functions are available at the point where the constraint is checked.

Nominative: An implements declaration must be present. Having all functions available is not sufficient.

There will likely be compelling use cases for both approaches. For example:

  • When converting existing unconstrained-generics (UG) code to CG, we will need to define interfaces for the formerly-UG functions that are being invoked. It will be convenient to let the implements declarations be inferred implicitly at callsites of those functions, so to reduce the amount of changes in the existing code. See also problem with point-of-instantiation · Issue #6252 · chapel-lang/chapel · GitHub

  • When expressing a semantic property that does not correlate with a presence or absence of a function, such as commutativity, we want to require implements declarations to be provided explicitly by the user.