16731, “vasslitvinov”, “CG: visibility and applicability of ‘implements’ declarations”, “2020-11-17T20:03:22Z”
Main issue: #8629
Related: #16688
Split out from #16411
In summary, how does an ‘implements’ declaration behave?
-
(function-like) It is visible uniformly throughout the scope it is in; brought in by
use
statements; can be ambiguous. -
(var-like) It is visible only in the part of the scope that follows the declaration; can be brought in by
use
statements; shadows similar declarations in enclosing scopes. -
(something else) ?
Here are a couple of specific aspects, moved here from #16411:
Importability of implements
declarations
When a module contains implements
declarations, are they brought in with a use
or import
? For example:
module Impl {
implements X(int);
}
use Impl;
use Impl except X;
use Impl only Y;
import Impl;
// is `implements X(int)` visible here upon each of the above?
Under both (function-like) and (var-like), implements
declarations are use
-able and can be restricted with except
and only
.
What should happen upon import Impl;
?
Shadowing of implements
declarations
What happens with two implements X(int)
, in an outer scope and an inner scope? If my call to a CG function requires implements X(int)
, is this an ambiguity or the closer statement wins?
{
implements X(int);
{
implements X(int);
{
...querying implements X(int)... // OK or "ambiguous" ?
}
}
}
(var-like): the inner statement shadows the outer statement.
(function-like) the two statements are ambiguous.
If there are two implements X(int)
in the same scope, they are clearly ambiguous.
implements
applicability to textually-preceding code
(discussed further in #16688)
Should an implements
statement be visible:
(var-like) only in textually-following code, or
(function-like) anywhere in the scope where it occurs?
For example:
proc x(arg) where implements X(arg.type) {...}
x(5); // OK if "function-like", error if "var-like"
implements X(int);