New Issue: How to deprecate a paren-ful function in favor of its parenless variant?

18945, "vasslitvinov", "How to deprecate a paren-ful function in favor of its parenless variant?", "2022-01-07T22:07:54Z"

This issue is concerned with choosing an implementation approach for issuing a deprecation warning in the situations when we transition from a parenful function to its parenless variant.

One approach is implemented in #18930, for the change X.targetLocales() --> X.targetLocales, where X is a Chapel array, domain, or distribution. In this case our goal is to detect calls X.targetLocales(), issue a warning, and replace them with calls to X.targetLocales.

Is this approach OK, can it be applied in other cases, or should we replace it with something else?

The approach in #18930 is this:

  • Switch the methods targetLocales on arrays, domains, distributions to paren-less.
    This way when the user writes code that is correct in the new world, it works.
  • When the user invokes myArr.targetLocales() with parentheses:
    • the compiler resolves myArr.targetLocales to the paren-less method, returning an int
    • the parens cause the compiler to take the returned int and invoke .this() on it
    • so far, no changes to the compiler are involved;
      the compiler representation looks like this:
            temp1: int <-- myArr.targetLocales
            temp2: ??? <-- temp1.this()
  • In order to do something special when there are parentheses in myArr.targetLocales(), #18930 modifies the compiler to:
    • look at each call to this() in preFoldNamed
    • check if:
      • the caller's receiver is the result of a call to "targetLocales"
      • the receiver of that call to "targetLocales" is an array or domain or distribution
    • if so:
      • issue a deprecation warning
      • remove the call to this() to enable the compilation to proceed as if there were no parentheses