New Issue: tertiary initializers

17225, "mppf", "tertiary initializers", "2021-02-22T21:26:44Z"

(This issue is a spin-off from issue #16732).

Should Chapel allow one to create an init or init= in a different module from the one defining the type? If so, are there special constraints or features required for such initializers? Additionally, should it be possible to create custom init= functions for non-record non-class types (e.g. int) ?

One issue is that in a tertiary initializer, it will not necessarily be possible to initialize all of the fields because some of them might be private (private fields are discussed in #6067). This issue is also present when creating an init= for a built-in type such as int. How might we write a tertiary initializer without naming the fields?

For example, let's consider how one might be able to create an init= to support things like var x: int = mybigint;

// approach 1
proc int.init=(rhs: bigint) {
  var i = rhs.bigintToInt();
  this = i; // not yet legal under initializer rules
}
// approach 2
proc int.init=(rhs: bigint) {
  var i = rhs.bigintToInt();
  this.init(i); // requires `proc int.init(from: int)` which we wouldn't normally add
}
// approach 3
proc int.init=(rhs: bigint) {
  var i = rhs.bigintToInt();
  this.init=(i); // currently a syntax error
}